/* moji trace */
@media (max-width:480px){.game-header{padding:56px 10px 8px}.home-btn{width:40px;height:40px;font-size:1.2rem;top:10px;left:10px}}
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{width:100%;height:100%;overflow:hidden;font-family:'Zen Maru Gothic',sans-serif;user-select:none}
body{background:linear-gradient(180deg,#FFF3E0 0%,#FFE0B2 45%,#FFCC80 100%);touch-action:manipulation}
.home-btn{position:fixed;top:12px;left:12px;width:48px;height:48px;background:#fff;border-radius:50%;display:flex;justify-content:center;align-items:center;font-size:1.4rem;text-decoration:none;box-shadow:0 4px 12px rgba(0,0,0,.15);z-index:9999;border:3px solid #FF9800}
#game-container{width:100%;height:100%;display:flex;flex-direction:column;position:relative;overflow:hidden}
.game-header{flex-shrink:0;padding:10px 16px;display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.title-badge{background:#fff;padding:8px 14px;border-radius:20px;font-weight:700;font-size:.95rem;box-shadow:0 3px 0 #E0E0E0;max-width:42vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.header-actions{display:flex;gap:8px}
.header-btn{font-family:inherit;font-weight:700;padding:8px 14px;border-radius:16px;border:none;background:#FF9800;color:#fff;box-shadow:0 3px 0 #E65100;cursor:pointer;font-size:.85rem}
.header-btn:active{transform:translateY(2px);box-shadow:0 1px 0 #E65100}
.progress-display{background:#fff;padding:8px 14px;border-radius:16px;font-weight:700;box-shadow:0 3px 0 #E0E0E0;font-size:.9rem}
.hidden{display:none!important}
.screen{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;padding:12px 16px 16px;overflow-y:auto;-webkit-overflow-scrolling:touch}
.screen-title{font-size:1.15rem;color:#E65100;margin-bottom:14px;text-align:center}
.mode-grid{display:grid;gap:12px;width:100%;max-width:520px}
.mode-grid-main{grid-template-columns:repeat(2,1fr)}
.mode-grid-sub{grid-template-columns:repeat(3,1fr)}
.mode-tile{font-family:inherit;background:#fff;border:4px solid #FFB74D;border-radius:18px;padding:14px 10px;display:flex;flex-direction:column;align-items:center;gap:6px;cursor:pointer;box-shadow:0 5px 14px rgba(0,0,0,.08);min-height:100px}
.mode-tile:active{transform:scale(.98);border-color:#FF9800}
.mode-emoji{font-size:2rem;font-weight:900;line-height:1}
.mode-name{font-weight:700;font-size:1rem;color:#333}
.mode-desc{font-size:.72rem;color:#666;text-align:center}
.back-btn{margin-top:18px;font-family:inherit;font-weight:700;padding:10px 28px;border-radius:20px;border:3px solid #999;background:#fff;cursor:pointer}
.screen-play{padding:8px 12px 12px;justify-content:center}
.play-main{display:flex;flex-direction:row;align-items:stretch;justify-content:center;gap:16px;width:100%;max-width:900px;flex:1;min-height:0}
.panel{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px}
.panel-left{background:rgba(255,255,255,.75);border-radius:20px;padding:12px;box-shadow:0 4px 16px rgba(0,0,0,.06);text-align:center}
.panel-right{justify-content:center}
.word-preview{font-size:clamp(1rem,3.5vw,1.35rem);font-weight:600;color:rgba(0,0,0,.22);letter-spacing:.12em;text-align:center;line-height:1.5;min-height:1.5em;font-family:'Klee One',serif}
.word-preview .done{color:#FF9800}
.word-preview .current{color:#E65100;text-decoration:underline;text-underline-offset:4px}
.emoji-hint{font-size:clamp(2.5rem,10vw,3.5rem);line-height:1}
.emoji-hint:empty{display:none}
.current-label{font-size:.8rem;color:#666}
.current-char{font-size:clamp(3rem,14vw,5rem);font-weight:600;color:#E65100;line-height:1.1;font-family:'Klee One',serif}
.hint-text{font-size:.85rem;color:#888;margin-top:4px}
.trace-frame{background:#fff;border-radius:20px;padding:4px;box-shadow:inset 0 2px 8px rgba(0,0,0,.06),0 6px 20px rgba(0,0,0,.1);border:4px solid #FFB74D;display:flex;align-items:center;justify-content:center;min-width:min(100%,calc(56vmin + 16px));min-height:min(100%,calc(56vmin + 16px));box-sizing:border-box}
#trace-canvas{display:block;width:min(65vmin,520px);height:min(65vmin,520px);max-width:100%;flex-shrink:0;touch-action:none;border-radius:12px;cursor:crosshair}
.trace-buttons{display:flex;gap:10px;margin-top:10px;align-items:center;justify-content:center}
.next-char-btn{font-family:inherit;font-weight:700;font-size:.95rem;padding:10px 24px;border-radius:16px;border:none;background:#43A047;color:#fff;box-shadow:0 3px 0 #2E7D32;cursor:pointer;white-space:nowrap}
.next-char-btn:active{transform:translateY(2px);box-shadow:0 1px 0 #2E7D32}
.clear-stroke-btn{font-family:inherit;font-weight:700;font-size:.85rem;padding:8px 20px;border-radius:16px;border:none;background:#78909C;color:#fff;box-shadow:0 3px 0 #546E7A;cursor:pointer}
.clear-stroke-btn:active{transform:translateY(2px)}
@media (orientation:portrait){.play-main{flex-direction:column;align-items:center}.panel-left{width:100%;max-width:440px}#trace-canvas{width:min(78vmin,480px);height:min(78vmin,480px)}}
@media screen and (max-height: 500px) {
  #game-container {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .game-header { padding: 4px 16px !important; }
  .title-badge { font-size: 0.8rem; padding: 4px 12px; }
  .progress-display { font-size: 0.8rem; padding: 4px 12px; }
  .header-btn { font-size: 0.75rem; padding: 6px 12px; }
  .screen { padding: 5px 15px; }
  .screen-title { font-size: 1rem; margin-bottom: 8px; }
  .mode-grid-main { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .mode-grid-sub { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .mode-tile { min-height: 80px; padding: 8px; }
  .mode-emoji { font-size: 1.5rem; }
  .mode-name { font-size: 0.85rem; }
  .screen-play{padding:4px 8px}
  .play-main{gap:15px;align-items:center}
  .emoji-hint{font-size:2.5rem;margin-bottom:5px}
  .current-char{font-size:clamp(3rem,28vh,5rem)}
  #trace-canvas{width:min(75vh,480px);height:min(75vh,480px)}
  .trace-frame{min-width:0;min-height:0;padding:6px}
}

.overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;z-index:10000;padding:16px}
.overlay-card{background:#fff;border-radius:24px;padding:24px 20px;max-width:320px;width:100%;text-align:center;box-shadow:0 12px 40px rgba(0,0,0,.2)}
.overlay-title{font-size:1.35rem;font-weight:900;color:#E65100;margin-bottom:10px}
.overlay-msg{font-size:.95rem;color:#555;margin-bottom:18px;line-height:1.5}
.overlay-btn{display:block;width:100%;font-family:inherit;font-weight:700;padding:14px;border-radius:18px;border:none;background:#FF9800;color:#fff;font-size:1.05rem;margin-bottom:10px;cursor:pointer;box-shadow:0 4px 0 #E65100}
.overlay-btn.secondary{background:#B0BEC5;box-shadow:0 4px 0 #78909C;color:#333}
.overlay-btn:active{transform:translateY(2px)}