/* ════════════════════════════════════
   CSS変数・リセット
════════════════════════════════════ */
:root {
  --wood-dark:  #2C1A0E;
  --wood-mid:   #5C3317;
  --wood-light: #8B5E3C;
  --text-gold:  #F5D78A;
  --text-dim:   #C89850;
  --accent:     #F0A820;
  --bg:         #120A04;
  --bead-cream: #F5E6C8;
  --bead-edge:  #C8A96E;
  --bead-transition-ms: 240ms;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); width: 375px; min-height: 812px; margin: 0 auto; font-family: 'Georgia', serif; position: relative; overflow: hidden; touch-action: none; }
#appContainer { position: relative; width: 375px; min-height: 812px; overflow: hidden; }
.screen { overflow: hidden; touch-action: pan-y; }
.screen { width: 375px; min-height: 812px; display: flex; flex-direction: column; align-items: center; padding-bottom: 24px; }

/* ════════════════════════════════════
   ヘッダー
════════════════════════════════════ */
.header { width: 100%; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(232,168,50,0.2); min-height: 44px; }
.app-title { font-size: 16px; font-weight: bold; color: var(--text-gold); letter-spacing: 0.06em; white-space: nowrap; }
.app-title span { color: var(--accent); }

/* ════════════════════════════════════
   メトロノーム・BPM
════════════════════════════════════ */
.mini-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(232,168,50,0.2); border: 1px solid rgba(232,168,50,0.3); transition: background 0.06s; }
.mini-dot.active { background: var(--accent); box-shadow: 0 0 6px rgba(232,160,32,0.9); }
.beat-indicator-row { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 12px; margin-bottom: 14px; }
.beat-dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(232,168,50,0.2); border: 1px solid rgba(232,168,50,0.3); transition: background 0.06s; }
.beat-dot.active { background: var(--accent); box-shadow: 0 0 10px rgba(232,160,32,0.9); }
.bpm-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 12px; }
.bpm-btn { width: 36px; height: 36px; border-radius: 50%; background: rgba(232,168,50,0.12); border: 1px solid rgba(232,168,50,0.4); color: var(--text-gold); font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; user-select: none; transition: background 0.15s; }
.bpm-btn:hover { background: rgba(232,168,50,0.22); }
.bpm-display { text-align: center; min-width: 90px; }
.bpm-value { font-size: 38px; font-weight: bold; color: var(--text-gold); line-height: 1; }
.bpm-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.12em; margin-top: 2px; }
.bpm-slider-wrap { padding: 0 4px; margin-bottom: 14px; }
.bpm-slider { width: 100%; height: 4px; -webkit-appearance: none; appearance: none; background: rgba(232,168,50,0.2); border-radius: 2px; outline: none; cursor: pointer; }
.bpm-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; }
.bpm-range-labels { display: flex; justify-content: space-between; font-size: 9px; color: var(--text-dim); margin-top: 4px; }
.start-btn { width: 100%; padding: 12px; border-radius: 8px; font-size: 14px; font-weight: bold; letter-spacing: 0.1em; cursor: pointer; font-family: 'Georgia', serif; border: none; transition: all 0.15s; }
.start-btn.stopped { background: linear-gradient(135deg, #E8A020, #C87010); color: #1C1008; }
.start-btn.playing { background: rgba(92,51,23,0.6); border: 1px solid var(--wood-light); color: var(--text-dim); }

/* ════════════════════════════════════
   出題エリア
════════════════════════════════════ */
.quiz-message { font-size: 14px; color: var(--text-dim); letter-spacing: 0.1em; text-align: center; }
.quiz-start-btn { padding: 10px 28px; border-radius: 8px; font-size: 13px; font-weight: bold; letter-spacing: 0.1em; cursor: pointer; font-family: 'Georgia', serif; background: linear-gradient(135deg, #E8A020, #C87010); border: none; color: #1C1008; transition: all 0.15s; }

/* ════════════════════════════════════
   ノーツゾーン
════════════════════════════════════ */
.notes-zone { width: 340px; margin: 6px auto 0; position: relative; height: 240px; background: rgba(0,0,0,0.25); border-radius: 12px; overflow: hidden; border: 1px solid rgba(232,168,50,0.15); }
.notes-zone::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0px, transparent 67px, rgba(232,168,50,0.06) 67px, rgba(232,168,50,0.06) 68px); pointer-events: none; }
.judge-line { position: absolute; bottom: 28px; left: 12px; right: 12px; height: 2px; background: linear-gradient(90deg, transparent, rgba(255,215,0,0.7) 20%, #FFD700 50%, rgba(255,215,0,0.7) 80%, transparent); border-radius: 1px; transition: background 0.1s; }
.judge-line.flash { background: linear-gradient(90deg, transparent, rgba(255,230,0,1) 20%, #FFE000 50%, rgba(255,230,0,1) 80%, transparent); box-shadow: 0 0 16px rgba(255,215,0,1); }
.note { position: absolute; display: flex; flex-direction: row; align-items: center; justify-content: center; width: 72px; height: 58px; border-radius: 12px; left: 50%; transform: translateX(-50%); pointer-events: none; z-index: 5; gap: 1px; }
.note-op  { font-size: 22px; font-weight: bold; line-height: 1; }
.note-num { font-size: 32px; font-weight: bold; line-height: 1; }
.note.add { background: #1565C0; border: 1.5px solid #42A5F5; }
.note.add .note-op  { color: #BBDEFB; }
.note.add .note-num { color: #FFFFFF; }
.note.sub { background: #C62828; border: 1.5px solid #EF9A9A; }
.note.sub .note-op  { color: #FFCDD2; }
.note.sub .note-num { color: #FFFFFF; }
.note.placement { background: #757575; border: 1.5px solid #BDBDBD; }
.note.placement .note-num { color: #FFFFFF; }
.note-hit { position: absolute; width: 60px; height: 60px; border-radius: 50%; left: 50%; bottom: 8px; transform: translateX(-50%) scale(0); pointer-events: none; z-index: 4; animation: noteHit 0.35s ease-out forwards; }
.note-hit.perfect { background: radial-gradient(circle, rgba(255,215,0,0.7), transparent); }
.note-hit.good    { background: radial-gradient(circle, rgba(136,238,255,0.5), transparent); }
@keyframes noteHit { 0%{transform:translateX(-50%) scale(0);opacity:1} 100%{transform:translateX(-50%) scale(2.5);opacity:0} }
.notes-overlay { position: absolute; top: 6px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; z-index: 6; pointer-events: none; }
.notes-hint { font-size: 10px; color: rgba(200,160,80,1); letter-spacing: 0.04em; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-progress { font-size: 10px; color: rgba(200,160,80,1); letter-spacing: 0.06em; }
.next-preview { position: absolute; top: 28px; right: 12px; z-index: 7; min-width: 72px; padding: 5px 8px; border-radius: 8px; background: rgba(20,12,6,0.72); border: 1px solid rgba(232,168,50,0.28); color: var(--text-gold); font-size: 12px; line-height: 1.2; letter-spacing: 0.04em; text-align: center; pointer-events: none; box-shadow: 0 0 10px rgba(0,0,0,0.35); }
.next-preview .next-label { display: block; font-size: 8px; color: var(--text-dim); letter-spacing: 0.12em; margin-bottom: 2px; }
.next-preview .next-num { display: block; font-size: 14px; font-weight: bold; color: var(--text-gold); }
.next-preview.add .next-num { color: #BBDEFB; }
.next-preview.sub .next-num { color: #FFCDD2; }
.next-preview.placement .next-num { color: #FFFFFF; }
.notes-ready { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: bold; color: var(--text-gold); letter-spacing: 0.15em; z-index: 7; }

/* ════════════════════════════════════
   スコア表示
════════════════════════════════════ */
.score-display { width: 340px; margin: 6px auto 0; text-align: center; font-size: 14px; color: var(--text-gold); letter-spacing: 0.12em; min-height: 20px; }

/* ════════════════════════════════════
   判定エフェクト・クラッカー
════════════════════════════════════ */
.judge-effect { position: fixed; top: 38%; left: 50%; transform: translate(-50%,-50%) scale(0.5); font-size: 28px; font-weight: bold; pointer-events: none; opacity: 0; z-index: 150; }
.judge-effect.show { animation: judgeAnim 0.7s cubic-bezier(0.34,1.56,0.64,1) forwards; }
.judge-effect.perfect { color: #FFD700; text-shadow: 0 0 20px rgba(255,215,0,0.9); }
.judge-effect.good    { color: #88EEFF; text-shadow: 0 0 14px rgba(136,238,255,0.8); }
.judge-effect.miss    { color: #FF4444; text-shadow: 0 0 14px rgba(255,68,68,0.8); }
.judge-effect.try     { color: #FFA040; text-shadow: 0 0 14px rgba(255,160,64,0.8); }
@keyframes judgeAnim { 0%{opacity:0;transform:translate(-50%,-50%) scale(0.5)} 30%{opacity:1;transform:translate(-50%,-50%) scale(1.1)} 70%{opacity:1;transform:translate(-50%,-50%) scale(1)} 100%{opacity:0;transform:translate(-50%,-60%) scale(0.9)} }
#crackerWrap { position: fixed; top: 30%; left: 0; width: 100%; pointer-events: none; z-index: 200; }
.confetti { position: absolute; border-radius: 2px; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0%{transform:translateY(0) rotate(0deg);opacity:1} 100%{transform:translateY(80px) rotate(360deg);opacity:0} }

/* ════════════════════════════════════
   数値表示
════════════════════════════════════ */
.value-display { width: 100%; padding: 4px 20px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.digits-row { display: flex; gap: 4px; align-items: flex-end; }
.digit-box { width: 52px; text-align: center; }
.digit-label { font-size: 9px; color: var(--text-dim); margin-bottom: 2px; }
.digit-value { font-size: 20px; font-weight: bold; color: var(--text-gold); line-height: 1; transition: color 0.15s, transform 0.15s; }
.digit-value.pop { color: #FFD700; transform: scale(1.2); }
.total-row { display: flex; align-items: baseline; gap: 6px; }
.total-label { font-size: 10px; color: var(--text-dim); }
.total-value { font-size: 24px; font-weight: bold; color: var(--accent); line-height: 1; min-width: 70px; text-align: center; }

/* ════════════════════════════════════
   そろばん
════════════════════════════════════ */
.abacus-wrap { width: 340px; margin: 6px auto 0; }
.abacus-frame { width: 100%; background: linear-gradient(160deg, var(--wood-mid), var(--wood-dark)); border-radius: 12px; padding: 8px 6px; border: 2px solid var(--wood-light); box-shadow: inset 0 2px 6px rgba(255,255,255,0.08), 0 8px 30px rgba(0,0,0,0.6); }
.abacus-bar { width: 100%; height: 12px; background: linear-gradient(180deg, var(--wood-light), var(--wood-mid)); border-radius: 4px; }
.abacus-columns { display: flex; justify-content: space-around; padding: 0 2px; position: relative; }
.beam { position: absolute; left: 0; right: 0; z-index: 10; pointer-events: none; background: linear-gradient(180deg, var(--wood-light), var(--wood-mid), var(--wood-dark)); border-top: 1px solid rgba(255,255,255,0.15); border-bottom: 1px solid rgba(0,0,0,0.4); }
.col-wrap { width: 52px; position: relative; }
.col-wrap::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); width: 5px; background: linear-gradient(90deg, #0A0604, #2A1A0E, #0A0604); border-radius: 2px; z-index: 1; }
.bead { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 14px; background: linear-gradient(160deg, #FFF8E8 0%, var(--bead-cream) 45%, #D4B07A 100%); border: 1px solid var(--bead-edge); box-shadow: 0 2px 4px rgba(0,0,0,0.35), inset 0 1px 3px rgba(255,255,255,0.55); cursor: pointer; z-index: 3; user-select: none; -webkit-user-select: none; transition: top var(--bead-transition-ms) cubic-bezier(0.25,0.46,0.45,0.94), background 0.15s; }
.bead::after { content: ''; position: absolute; top: 5px; left: 8px; right: 8px; height: 6px; background: rgba(255,255,255,0.38); border-radius: 3px; pointer-events: none; }
.bead:active { opacity: 0.8; }
.bead.hl-add { background: linear-gradient(160deg, #80CFFF 0%, #2196F3 45%, #0D6EBD 100%); border-color: #2196F3; animation: hl-add 0.75s ease-in-out infinite alternate; }
.bead.hl-sub { background: linear-gradient(160deg, #FF9080 0%, #FF4444 45%, #CC1100 100%); border-color: #FF4444; animation: hl-sub 0.75s ease-in-out infinite alternate; }
@keyframes hl-add { from{box-shadow:0 0 8px rgba(33,150,243,0.5)} to{box-shadow:0 0 22px rgba(33,150,243,1)} }
@keyframes hl-sub { from{box-shadow:0 0 8px rgba(255,68,68,0.5)} to{box-shadow:0 0 22px rgba(255,68,68,1)} }

/* ════════════════════════════════════
   音選択・フラッシュ
════════════════════════════════════ */
.sound-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.sound-btn { padding: 6px 12px; border-radius: 6px; font-size: 11px; cursor: pointer; font-family: 'Georgia', serif; background: rgba(232,168,50,0.08); border: 1px solid rgba(232,168,50,0.25); color: var(--text-dim); transition: all 0.15s; }
.sound-btn.active { background: rgba(232,168,50,0.25); border-color: var(--accent); color: var(--text-gold); }
.sound-btn:hover { background: rgba(232,168,50,0.18); }
.tap-flash { position: fixed; inset: 0; background: rgba(232,160,32,0.06); pointer-events: none; opacity: 0; z-index: 100; }
.tap-flash.flash { animation: tapFlash 0.1s forwards; }
@keyframes tapFlash { 0%{opacity:1} 100%{opacity:0} }

/* ════════════════════════════════════
   画面遷移
════════════════════════════════════ */
.page {
  display: none;
  width: 375px;
  min-height: 812px;
  flex-direction: column;
  align-items: center;
  position: absolute;
  top: 0; left: 0;
  background: var(--bg);
  overflow-y: auto;
}
.page.active { display: flex; position: relative; overflow: hidden; max-height: 812px; }

/* ════════════════════════════════════
   タイトル画面
════════════════════════════════════ */
.title-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 40px 20px; }
.title-logo { font-size: 42px; font-weight: bold; color: var(--text-gold); letter-spacing: 0.06em; text-shadow: 0 0 30px rgba(232,200,120,0.5); }
.title-logo span { color: var(--accent); }
.title-sub { font-size: 13px; color: var(--text-dim); letter-spacing: 0.15em; margin-top: 8px; margin-bottom: 40px; }
.title-abacus-deco {
  width: 300px; height: 60px;
  background: linear-gradient(160deg, var(--wood-mid), var(--wood-dark));
  border-radius: 10px; border: 2px solid var(--wood-light);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 12px; margin-bottom: 48px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.deco-bead { width: 36px; height: 22px; border-radius: 11px; background: linear-gradient(160deg, #FFF8E8, var(--bead-cream), #D4B07A); border: 1px solid var(--bead-edge); box-shadow: 0 2px 4px rgba(0,0,0,0.3); animation: decoFloat 2s ease-in-out infinite alternate; }
.deco-bead:nth-child(2) { animation-delay: 0.3s; }
.deco-bead:nth-child(3) { animation-delay: 0.6s; }
.deco-bead:nth-child(4) { animation-delay: 0.9s; }
.deco-bead:nth-child(5) { animation-delay: 1.2s; }
@keyframes decoFloat { from{transform:translateY(0)} to{transform:translateY(-6px)} }
.title-btn { width: 280px; padding: 16px; border-radius: 10px; font-size: 16px; font-weight: bold; letter-spacing: 0.12em; cursor: pointer; font-family: 'Georgia', serif; background: linear-gradient(135deg, #E8A020, #C87010); border: none; color: #1C1008; box-shadow: 0 6px 20px rgba(232,160,32,0.4); transition: all 0.2s; margin-bottom: 14px; }
.title-btn:hover { box-shadow: 0 6px 28px rgba(232,160,32,0.65); transform: translateY(-2px); }
.title-btn.secondary { background: rgba(92,51,23,0.5); border: 1px solid var(--wood-light); color: var(--text-dim); box-shadow: none; font-size: 14px; }
.title-btn.secondary:hover { background: rgba(92,51,23,0.8); color: var(--text-gold); }
.title-version { font-size: 10px; color: rgba(160,120,64,0.5); margin-top: 24px; letter-spacing: 0.1em; }

/* ════════════════════════════════════
   レベル選択画面
════════════════════════════════════ */
.level-header { width: 100%; padding: 16px 20px 12px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(232,168,50,0.2); }
.level-back-btn { font-size: 18px; color: var(--text-dim); cursor: pointer; background: none; border: none; padding: 4px 8px; transition: color 0.15s; }
.level-back-btn:hover { color: var(--text-gold); }
.level-title { font-size: 16px; font-weight: bold; color: var(--text-gold); letter-spacing: 0.08em; }
.level-list { width: 340px; margin: 16px auto 0; display: flex; flex-direction: column; gap: 8px; }
.level-group { width: 100%; }
.level-group-header { width: 100%; padding: 12px 16px; border-radius: 10px; background: rgba(232,168,50,0.08); border: 1px solid rgba(232,168,50,0.3); cursor: pointer; display: flex; align-items: center; justify-content: space-between; transition: all 0.15s; user-select: none; }
.level-group-header:hover { background: rgba(232,168,50,0.15); }
.level-group-title { font-size: 15px; font-weight: bold; color: var(--text-gold); letter-spacing: 0.06em; display: flex; align-items: center; gap: 8px; }
.level-group-icon { font-size: 18px; }
.level-group-arrow { font-size: 12px; color: var(--text-dim); transition: transform 0.25s; }
.level-group-arrow.open { transform: rotate(180deg); }
.level-group-body { overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.level-group-body.open { max-height: 600px; }
.level-group-items { display: flex; flex-direction: column; gap: 6px; padding: 6px 0 2px 16px; }
.level-card { width: 100%; padding: 12px 16px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid rgba(232,168,50,0.15); cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: space-between; }
.level-card:hover { background: rgba(232,168,50,0.08); border-color: rgba(232,168,50,0.35); }
.level-card.locked { opacity: 0.4; cursor: not-allowed; }
.level-card-left { display: flex; flex-direction: column; gap: 3px; }
.level-card-name { font-size: 14px; font-weight: bold; color: var(--text-gold); }
.level-card-desc { font-size: 11px; color: var(--text-dim); }
.level-card-right { font-size: 20px; }
.level-best { font-size: 10px; color: var(--text-dim); }

/* ════════════════════════════════════
   リザルト画面
════════════════════════════════════ */
.result-wrap { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); gap: 0; }
.result-medal { font-size: 72px; margin-bottom: 8px; animation: medalPop 0.5s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes medalPop { from{transform:scale(0);opacity:0} to{transform:scale(1);opacity:1} }
.result-rank { font-size: 28px; font-weight: bold; letter-spacing: 0.1em; margin-bottom: 4px; }
.result-rank.gold   { color: #FFD700; text-shadow: 0 0 20px rgba(255,215,0,0.7); }
.result-rank.silver { color: #C0C0C0; text-shadow: 0 0 16px rgba(192,192,192,0.6); }
.result-rank.bronze { color: #CD7F32; text-shadow: 0 0 16px rgba(205,127,50,0.6); }
.result-rank.retry  { color: var(--text-dim); }
.result-level { font-size: 12px; color: var(--text-dim); letter-spacing: 0.1em; margin-bottom: 28px; }
.result-stats { width: min(340px, calc(100% - 32px)); background: rgba(255,255,255,0.04); border: 1px solid rgba(232,168,50,0.2); border-radius: 16px; padding: 18px 22px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.result-stat-row { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 16px; font-size: 15px; min-height: 28px; }
.result-stat-label { color: var(--text-dim); letter-spacing: 0.05em; white-space: nowrap; overflow: visible; }
.result-stat-value { font-weight: bold; color: var(--text-gold); font-size: 18px; text-align: right; white-space: nowrap; min-width: 72px; }
.result-stat-value.gold   { color: #FFD700; }
.result-stat-value.cyan   { color: #88EEFF; }
.result-stat-value.red    { color: #FF6666; }
.result-divider { border-top: 1px solid rgba(232,168,50,0.18); padding-top: 10px; margin-top: 4px; }
.result-score-row { border-top: 1px solid rgba(232,168,50,0.18); padding-top: 10px; margin-top: 2px; }
.result-score-row .result-stat-value { font-size: 22px; color: #FFD700; text-shadow: 0 0 10px rgba(255,215,0,0.35); }
.result-stat-value.combo { color: #FF8C00; }
.result-btns { display: flex; flex-direction: column; gap: 10px; width: min(340px, calc(100% - 32px)); }
.result-btn { width: 100%; padding: 14px; border-radius: 10px; font-size: 14px; font-weight: bold; letter-spacing: 0.1em; cursor: pointer; font-family: 'Georgia', serif; transition: all 0.15s; border: none; }
.result-btn.primary { background: linear-gradient(135deg, #E8A020, #C87010); color: #1C1008; }
.result-btn.secondary { background: rgba(92,51,23,0.5); border: 1px solid var(--wood-light); color: var(--text-dim); }
.result-btn.secondary:hover { background: rgba(92,51,23,0.8); color: var(--text-gold); }

/* ════════════════════════════════════
   テスト設定画面
════════════════════════════════════ */
.test-config-group { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: rgba(255,255,255,0.04); border: 1px solid rgba(232,168,50,0.2); border-radius: 10px; }
.test-config-label { font-size: 14px; font-weight: bold; color: var(--text-gold); letter-spacing: 0.06em; }
.test-config-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); }
.test-option-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.test-option-grid .sound-btn { flex: 1 1 calc(33.333% - 8px); min-width: 88px; }
.digit-options .sound-btn { flex-basis: calc(50% - 8px); }
.trace-options .sound-btn { flex-basis: calc(50% - 8px); }

/* Mobile course selection layout */
html {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  overflow: hidden;
}

body {
  width: 100%;
  max-width: 375px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: hidden;
  touch-action: manipulation;
}

#appContainer {
  width: 100%;
  max-width: 375px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.page {
  width: 100%;
  max-width: 375px;
  min-height: 100vh;
  min-height: 100dvh;
  position: absolute;
  overflow: hidden;
}

.page.active {
  display: flex;
  position: absolute;
  max-height: none;
}

#pageLevel.active,
#pageCourseGroup.active,
#pageTestConfig.active {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  touch-action: pan-y;
}

#pageGame.active {
  overflow: hidden;
  touch-action: none;
}

#pageGame .screen,
#pageGame .notes-zone,
#pageGame .abacus-wrap,
#pageGame .bead {
  touch-action: none;
}

.screen {
  width: 100%;
  max-width: 375px;
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: none;
}

.level-list,
.course-group-list,
.notes-zone,
.abacus-wrap,
.result-stats,
.result-btns {
  width: min(340px, calc(100% - 32px));
}

#quizIdle,
#pageTestConfig > div[style*="width:340px"] {
  width: min(340px, calc(100% - 32px)) !important;
}

.category-card {
  width: 100%;
  padding: 18px 20px;
  border-radius: 14px;
  background: rgba(232,168,50,0.08);
  border: 1px solid rgba(232,168,50,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s;
}

.course-group-list {
  margin: 16px auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-card:hover {
  background: rgba(232,168,50,0.15);
}

.category-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.category-card-icon {
  font-size: 24px;
  flex: 0 0 auto;
}

.category-card-name {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-gold);
  letter-spacing: 0.06em;
}

.category-card-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.category-card-arrow {
  font-size: 18px;
  color: var(--text-dim);
}
