:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1f2330;
  --ink: #e7ebf3;
  --muted: #9aa3b5;
  --line: #2a2f3d;
  --blue: #2f81f7;
  --green: #2ea043;
  --amber: #d29922;
  --red: #da3633;
  --pink: #db4b78;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2030 0%, var(--bg) 55%);
  color: var(--ink);
  min-height: 100vh;
}

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.logo { font-size: 26px; font-weight: 700; letter-spacing: 2px; }
.tag { color: var(--muted); font-size: 13px; }
.progress { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.bar { width: 110px; height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; display: flex; }
.bar span { height: 100%; display: block; width: 0; transition: width .35s ease; }
#barMastered { background: var(--green); }
#barLearning { background: var(--amber); }

/* controls bar */
.controls {
  max-width: 980px; margin: 14px auto 0; padding: 0 18px;
  display: flex; flex-wrap: wrap; gap: 10px 22px;
}
.seg { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.seg-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-right: 2px; }
.seg button {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.seg button.active { background: var(--blue); border-color: var(--blue); }
.seg.disabled { opacity: .35; pointer-events: none; }
.ghostbtn { background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }

/* layout */
.game {
  max-width: 980px; margin: 26px auto; padding: 0 18px;
  display: grid; grid-template-columns: 400px 1fr; gap: 20px;
}
@media (max-width: 820px) { .game { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* cue */
.cue-label { color: var(--muted); font-size: 13px; }
.cue-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.cue-romaji { font-size: 40px; font-weight: 700; text-transform: lowercase; letter-spacing: 1px; }
.cue-glyph { font-size: 56px; font-weight: 600; line-height: 1; }
.cue-sub { color: var(--muted); font-size: 18px; }
.iconbtn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  font-size: 18px; width: 42px; height: 42px; cursor: pointer; margin-left: auto; }

/* type-the-sound answer area */
.type-wrap { margin: 14px 0; }
#answerInput {
  width: 100%; box-sizing: border-box; background: #11141c; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: 22px 18px;
  font-size: 30px; text-align: center; letter-spacing: 1px;
}
#answerInput:focus { outline: none; border-color: var(--blue); }
.read-result { margin-top: 14px; text-align: center; font-size: 16px; min-height: 28px; }
.read-result .big { font-size: 30px; }
.read-result.good { color: #6fdc8c; }
.read-result.bad { color: #ff8a85; }

/* canvas */
.pad-wrap { position: relative; margin: 14px 0; aspect-ratio: 1; }
#pad { width: 100%; height: 100%; background: #11141c; border: 1px solid var(--line);
  border-radius: 12px; touch-action: none; cursor: crosshair; display: block; }
.reveal {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 230px; color: rgba(231,235,243,0.10); pointer-events: none;
  opacity: 0; transition: opacity .25s; line-height: 1;
}
.reveal.show { opacity: 1; }

/* tools */
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbtn {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; flex: 1;
}
.toolbtn.primary { background: var(--blue); border-color: var(--blue); }
.toolbtn:disabled { opacity: .4; cursor: default; }
.hidden { display: none !important; }

/* feedback */
.feedback { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 16px; }
.score-row { display: flex; gap: 16px; align-items: center; }
.score {
  flex: 0 0 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  font-size: 26px; font-weight: 700; border: 4px solid var(--muted);
}
.score.great { border-color: var(--green); color: var(--green); }
.score.ok { border-color: var(--amber); color: var(--amber); }
.score.bad { border-color: var(--red); color: var(--red); }
.msgs { margin: 0; padding-left: 18px; color: var(--ink); font-size: 14px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); }
.chip.good { background: rgba(46,160,67,.15); border-color: var(--green); color: #6fdc8c; }
.chip.warn { background: rgba(218,54,51,.15); border-color: var(--red); color: #ff8a85; }
.chip.soft { background: rgba(210,153,34,.12); border-color: var(--amber); color: #e3b341; }

/* sensei */
.sensei-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sensei-head > div { display: flex; gap: 8px; }
.sensei-head .toolbtn { flex: 0 0 auto; }
.sensei-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-top: 12px; }
.sensei-card.offline { border-color: var(--amber); }
.mnemonic { margin: 0 0 8px; font-size: 15px; line-height: 1.55; }
.example { margin: 0; color: var(--muted); font-size: 14px; }
.example .jp, .jp { font-size: 20px; color: var(--ink); }
.example .rd { color: var(--blue); }
.hint-text { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 12px 0 0; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* attribution footer (KanjiVG CC BY-SA 3.0) */
.credit {
  max-width: 980px; margin: 8px auto 28px; padding: 0 18px;
  color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center;
}
.credit a { color: var(--blue); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* study chart — gojūon table (5 vowel columns), like a textbook kana chart */
.study { max-width: 980px; margin: 22px auto; padding: 0 18px; }
.study-hint { color: var(--muted); font-size: 13px; text-align: center; margin: 0 0 16px; }
.gojuon {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; max-width: 520px; margin: 0 auto;
}
.gcell {
  position: relative; background: var(--panel); border: none; color: var(--ink);
  cursor: pointer; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 0;
}
.gcell.empty { cursor: default; background: var(--panel-2); }
.gcell .kcell-glyph { font-size: 32px; line-height: 1; }
.gcell-romaji {
  position: absolute; right: 6px; bottom: 4px; font-size: 11px;
  color: var(--muted); text-transform: lowercase;
}
.gcell:hover:not(.empty) { background: var(--panel-2); }
.gcell.drawing .kcell-glyph { visibility: hidden; }
.gcell .kcell-canvas {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; display: none;
}
.gcell.drawing .kcell-canvas { display: block; }
.kana-sec { text-align: center; margin: 10px 0 12px; font-size: 16px; }
.kana-extra-label { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 8px; }

/* session leaderboard (Review session card) */
#bestSession { color: var(--green); }
.kana-lb { margin-top: 12px; }
.kana-lb-title { font-size: 14px; margin: 0 0 10px; color: var(--muted); }
.kana-lb-title b { color: var(--ink); }
.kana-hist { display: flex; align-items: flex-end; gap: 4px; height: 92px; padding-top: 14px; }
.kana-col {
  position: relative; flex: 1 1 0; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.kana-bar { width: 100%; max-width: 18px; min-height: 2px; background: var(--line); border-radius: 3px 3px 0 0; }
.kana-col.you .kana-bar { background: var(--blue); }
.kana-lbl { margin-top: 4px; font-size: 9px; color: var(--muted); }
.kana-col.you .kana-lbl { color: var(--blue); font-weight: 600; }
.kana-you { position: absolute; top: 0; font-size: 9px; font-weight: 600; color: var(--blue); }
.kana-lb-cap { font-size: 11px; color: var(--muted); margin: 8px 0 0; }
.kana-lb-note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

/* Sensei's recommended study path (always-visible banner under the menu) */
.path-note {
  max-width: 980px; margin: 14px auto 0; padding: 9px 18px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--blue); border-radius: 10px;
  font-size: 13px; color: var(--ink);
}
.path-note .path-title { color: var(--muted); font-weight: 600; margin-right: 4px; }
.path-note b { color: var(--blue); }
