/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:        #0f1117;
  --bg-2:      #161a24;
  --surface:   #1b2030;
  --surface-2: #232a3d;
  --line:      #2c3348;
  --line-2:    #3a4361;

  --text:      #eef1f8;
  --muted:     #9aa4bf;
  --faint:     #6b7492;

  --brand:     #7c5cff;
  --brand-2:   #a084ff;
  --good:      #35d07f;
  --good-dk:   #23a862;
  --bad:       #ff5c72;
  --bad-dk:    #d13a50;
  --gold:      #ffc53d;
  --flame:     #ff8a3d;
  --cyan:      #35c8e8;

  --r-sm: 8px; --r: 14px; --r-lg: 20px; --r-xl: 28px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);

  --jp: "Yu Gothic UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
        "MS Gothic", "Meiryo", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(124,92,255,.16), transparent 60%),
    radial-gradient(800px 500px at 95% 0%, rgba(53,200,232,.10), transparent 55%);
  background-attachment: fixed;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.jp { font-family: var(--jp); }

/* ── App shell ─────────────────────────────────────────────────────────── */
#app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: rgba(15,17,23,.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 17px; letter-spacing: -.3px;
  cursor: pointer; user-select: none;
}
.logo .mark, .logo .mark-img, .auth-brand .mark-img {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #1a2744, #0d1526);
  font-family: var(--jp); font-size: 19px;
  box-shadow: 0 4px 14px rgba(232,57,46,.35);
}
.logo .mark-img, .auth-brand .mark-img {
  background: none; object-fit: cover; flex: none;
}

.hud { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.stat {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat .ico { font-size: 15px; line-height: 1; }
.stat.streak { color: var(--flame); }
.stat.gems   { color: var(--gold); }
.stat.hearts { color: var(--bad); }
.stat.due    { color: var(--cyan); }
.stat.dim    { opacity: .45; }
.stat button { color: inherit; font-weight: 700; }

.nav {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.nav button {
  padding: 8px 15px; border-radius: 999px;
  color: var(--muted); font-weight: 650; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on {
  background: linear-gradient(145deg, #e8392e, #8b1a2b);
  color: #fff;
}

.nav-more { position: relative; display: none; }
.nav-more-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 80; min-width: 168px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-more-menu[hidden] { display: none !important; }
.nav-more-menu button {
  width: 100%; text-align: left; border-radius: 10px; padding: 10px 12px;
}
.hud { position: relative; flex-wrap: nowrap; }
.hud-more { position: relative; display: none; }
.hud-more-btn { gap: 5px; }
.hud-caret { font-size: 11px; opacity: .7; margin-left: 2px; }
.hud-more-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 80; min-width: 176px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 8px 0;
}
.hud-more-menu[hidden] { display: none !important; }
.hud-more-row {
  display: flex; justify-content: space-between; gap: 18px;
  padding: 8px 14px; font-size: 13.5px; color: var(--muted);
}
.hud-more-row b { color: var(--text); font-variant-numeric: tabular-nums; }

main { flex: 1; width: 100%; max-width: 940px; margin: 0 auto; padding: 30px 22px 90px; }

/* ── Generic bits ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
}

h1 { font-size: 30px; letter-spacing: -.8px; margin-bottom: 6px; }
h2 { font-size: 20px; letter-spacing: -.4px; margin-bottom: 4px; }
h3 { font-size: 15px; letter-spacing: -.2px; }
.sub { color: var(--muted); font-size: 15px; line-height: 1.55; }
.tiny { font-size: 12.5px; color: var(--faint); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }

/* Chunky pressable button, Duolingo-style */
.btn {
  --c: var(--brand); --cd: #4b31c9;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px 26px; border-radius: var(--r);
  background: var(--c); color: #fff;
  font-weight: 800; font-size: 15px; letter-spacing: .2px;
  box-shadow: 0 4px 0 var(--cd);
  transition: transform .07s, box-shadow .07s, filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--cd); }
.btn.good { --c: var(--good); --cd: var(--good-dk); color: #06301a; }
.btn.bad  { --c: var(--bad);  --cd: var(--bad-dk); }
.btn.ghost {
  background: transparent; color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--line-2);
}
.btn.ghost:active { transform: none; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: var(--muted);
}

.bar { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .45s cubic-bezier(.2,.9,.3,1); }
.bar.good > i { background: linear-gradient(90deg, var(--good-dk), var(--good)); }
.bar.gold > i { background: linear-gradient(90deg, #e5a400, var(--gold)); }

/* ── Home: daily banner ────────────────────────────────────────────────── */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  background: linear-gradient(135deg, rgba(124,92,255,.20), rgba(53,200,232,.10));
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  padding: 26px 28px; margin-bottom: 26px;
}
.hero .goal { margin-top: 14px; max-width: 420px; }
.hero .goal .bar { height: 14px; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; min-width: 210px; }

.countdown { font-variant-numeric: tabular-nums; }

/* ── Unit / lesson tree ────────────────────────────────────────────────── */
.unit { margin-bottom: 34px; }
.unit-head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, hsl(var(--h) 70% 22% / .85), hsl(var(--h) 60% 14% / .6));
  border: 1px solid hsl(var(--h) 55% 34% / .5);
  margin-bottom: 16px;
}
.unit-head .badge {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 24px;
  background: hsl(var(--h) 65% 45% / .28);
  border: 1px solid hsl(var(--h) 60% 55% / .4);
  font-family: var(--jp);
}
.unit-head .u-prog { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); font-weight: 700; }

.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 12px; }

.lesson {
  position: relative; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 16px;
  display: flex; flex-direction: column; gap: 8px; min-height: 108px;
  transition: transform .12s, border-color .15s, background .15s;
}
.lesson:hover:not(.locked) { transform: translateY(-3px); border-color: var(--line-2); background: var(--surface-2); }
.lesson.locked { opacity: .42; cursor: not-allowed; }
.lesson.done { border-color: hsl(var(--h) 55% 40% / .6); }
.lesson .l-title { font-weight: 750; font-size: 14.5px; letter-spacing: -.2px; }
.lesson .l-sub { font-family: var(--jp); font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson .l-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.stars { letter-spacing: 1px; font-size: 13px; color: var(--gold); }
.stars .off { color: var(--line-2); }
.ring { width: 34px; height: 34px; flex: none; margin-left: auto; }
.ring circle { fill: none; stroke-width: 4; }
.ring .bgc { stroke: var(--surface-2); }
.ring .fgc { stroke: var(--good); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .5s; }

/* ── Lesson player ─────────────────────────────────────────────────────── */
.player { max-width: 720px; margin: 0 auto; }
.player-top { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.player-top .bar { flex: 1; }
.quit { font-size: 22px; color: var(--faint); padding: 4px 8px; border-radius: 8px; }
.quit:hover { color: var(--text); background: var(--surface); }
.combo { font-weight: 800; color: var(--flame); font-size: 14px; min-width: 42px; }

.q-head { font-size: 19px; font-weight: 750; letter-spacing: -.3px; margin-bottom: 24px; }

.prompt {
  display: grid; place-items: center; gap: 10px;
  padding: 34px 20px; margin-bottom: 26px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-height: 168px;
}
.prompt .big { font-family: var(--jp); font-size: 68px; line-height: 1.15; text-align: center; }
.prompt .big.long { font-size: 40px; }
.prompt .big.romaji-prompt, .prompt .big.en-prompt {
  font-family: inherit; font-size: 34px; font-weight: 700; letter-spacing: -.5px;
}
.prompt .reading { font-family: var(--jp); font-size: 17px; color: var(--muted); }
.prompt .romaji { font-size: 14px; color: var(--faint); letter-spacing: .4px; }

.speaker {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; font-size: 40px;
  background: linear-gradient(145deg, var(--brand), #4b31c9);
  box-shadow: 0 6px 0 #3a24a3;
  transition: transform .08s, box-shadow .08s;
}
.speaker:active { transform: translateY(6px); box-shadow: 0 0 0 #3a24a3; }
.speaker.small { width: 46px; height: 46px; font-size: 20px; box-shadow: 0 4px 0 #3a24a3; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choices.one-col { grid-template-columns: 1fr; }

.choice {
  padding: 18px 20px; border-radius: var(--r);
  background: var(--surface); border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
  font-weight: 650; font-size: 16px; text-align: center;
  transition: transform .07s, box-shadow .07s, border-color .15s, background .15s;
}
.choice:hover:not(:disabled) { border-color: var(--line-2); background: var(--surface-2); }
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.choice.jp { font-family: var(--jp); font-size: 30px; }
.choice.right { border-color: var(--good); background: rgba(53,208,127,.14); box-shadow: 0 4px 0 var(--good-dk); }
.choice.wrong { border-color: var(--bad); background: rgba(255,92,114,.13); box-shadow: 0 4px 0 var(--bad-dk); }
.choice:disabled { cursor: default; }

.typebox {
  width: 100%; padding: 18px 20px; border-radius: var(--r);
  background: var(--surface); border: 2px solid var(--line);
  font-size: 22px; text-align: center; letter-spacing: 1px;
}
.typebox:focus { border-color: var(--brand); outline: none; }
.typebox.right { border-color: var(--good); }
.typebox.wrong { border-color: var(--bad); }

/* Sentence builder */
.build-slots {
  min-height: 74px; display: flex; flex-wrap: wrap; gap: 9px; align-content: flex-start;
  padding: 14px; border-radius: var(--r);
  background: var(--bg-2); border: 2px dashed var(--line-2);
  margin-bottom: 16px;
}
.build-bank { display: flex; flex-wrap: wrap; gap: 9px; min-height: 50px; }
.tile {
  font-family: var(--jp); font-size: 21px;
  padding: 10px 16px; border-radius: 10px;
  background: var(--surface); border: 2px solid var(--line);
  box-shadow: 0 3px 0 var(--line);
  transition: transform .07s, box-shadow .07s;
}
.tile:hover { border-color: var(--line-2); }
.tile:active { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.tile.used { visibility: hidden; }

/* Verdict bar */
.verdict {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  animation: slideUp .22s cubic-bezier(.2,.9,.3,1);
}
.verdict.right { background: #0e2a1c; border-top-color: rgba(53,208,127,.4); }
.verdict.wrong { background: #2c1119; border-top-color: rgba(255,92,114,.4); }
.verdict-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 18px; }
.verdict .v-title { font-size: 19px; font-weight: 800; }
.verdict.right .v-title { color: var(--good); }
.verdict.wrong .v-title { color: var(--bad); }
.verdict .v-body { font-size: 14px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.verdict .v-body .jp { font-size: 17px; color: var(--text); }
.verdict .v-note { font-size: 13px; color: var(--muted); margin-top: 7px; font-style: italic; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0);} 25% { transform: translateX(-7px);} 75% { transform: translateX(7px);} }
.shake { animation: shake .3s; }
.pop { animation: pop .25s cubic-bezier(.2,1.3,.4,1); }

/* ── Results ───────────────────────────────────────────────────────────── */
.results { max-width: 560px; margin: 40px auto; text-align: center; }
.results .trophy { font-size: 76px; margin-bottom: 12px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 26px 0; }
.result-grid .cell { padding: 16px 10px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.result-grid .cell .v { font-size: 25px; font-weight: 800; letter-spacing: -.5px; }
.result-grid .cell .k { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .9px; margin-top: 3px; }
.big-stars { font-size: 40px; letter-spacing: 6px; color: var(--gold); margin: 8px 0 4px; }
.big-stars .off { color: var(--line-2); }

/* ── Kana drill ────────────────────────────────────────────────────────── */
.drill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }

.row-chip {
  display: flex; flex-direction: column; gap: 5px; text-align: left;
  padding: 13px 15px; border-radius: var(--r);
  background: var(--surface); border: 2px solid var(--line);
  transition: transform .1s, border-color .15s, background .15s;
}
.row-chip:hover { transform: translateY(-2px); border-color: var(--line-2); }
.row-chip.on { border-color: var(--brand); background: rgba(124,92,255,.14); }
.row-chip.on .rc-name::before { content: '✓ '; color: var(--brand-2); }
.row-chip.tall { min-height: 96px; }
.rc-name { font-weight: 750; font-size: 14.5px; }
.rc-kana { font-size: 17px; color: var(--muted); letter-spacing: 1px; }
.rc-desc { font-size: 12.5px; color: var(--faint); line-height: 1.45; }
.rc-count { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

.char-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.char-res {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto;
  gap: 2px 8px; align-items: center;
  padding: 8px 11px; border-radius: var(--r-sm);
  background: var(--bg-2); border: 1px solid var(--line);
}
.cr-k { font-size: 22px; grid-row: span 2; }
.cr-r { font-size: 12px; color: var(--faint); }
.cr-n { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.cr-bar { grid-column: 2 / 4; height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.cr-bar i { display: block; height: 100%; border-radius: 999px; }

/* ── Charts / reference tables ─────────────────────────────────────────── */
.chart-tabs { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.kana-group { margin-bottom: 22px; }
.kana-group h3 { color: var(--muted); margin-bottom: 10px; font-weight: 700; }
.kana-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.kana-cell {
  aspect-ratio: 1; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; gap: 1px;
  position: relative; overflow: hidden;
  transition: transform .12s, border-color .15s;
}
.kana-cell:hover { transform: translateY(-2px); border-color: var(--brand); }
.kana-cell .k { font-family: var(--jp); font-size: 27px; line-height: 1; }
.kana-cell .r { font-size: 11px; color: var(--faint); letter-spacing: .5px; }
.kana-cell .lvl { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--good); transition: width .4s; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; padding: 10px 12px; color: var(--faint); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .9px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .j { font-family: var(--jp); font-size: 19px; }
.tbl .strength { width: 64px; }
.tbl .strength .bar { height: 6px; }

/* ── Stats ─────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.heat { display: grid; grid-template-columns: repeat(26, 1fr); gap: 4px; margin-top: 12px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.heat i[data-l="1"] { background: rgba(124,92,255,.35); }
.heat i[data-l="2"] { background: rgba(124,92,255,.6); }
.heat i[data-l="3"] { background: rgba(124,92,255,.85); }
.heat i[data-l="4"] { background: var(--brand-2); }

.ach {
  display: flex; align-items: center; gap: 13px; padding: 13px 15px;
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--line);
}
.ach.locked { opacity: .38; }
.ach .a-ico { font-size: 27px; width: 42px; text-align: center; }
.ach .a-name { font-weight: 700; font-size: 14.5px; }
.ach .a-desc { font-size: 12.5px; color: var(--faint); margin-top: 2px; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed; top: 74px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 19px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line-2);
  box-shadow: var(--shadow); font-weight: 700; font-size: 14px;
  animation: pop .25s cubic-bezier(.2,1.3,.4,1);
}
.toast .t-ico { font-size: 21px; }
.toast.gold { border-color: rgba(255,197,61,.5); background: #2a2411; color: var(--gold); }

/* ── Boot / auth ───────────────────────────────────────────────────────── */
.boot {
  min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 12px;
}
.boot .jp { font-size: 54px; opacity: .5; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .25; } 50% { opacity: .7; } }

.auth-wrap { min-height: 84vh; display: grid; place-items: center; padding: 30px 18px; }
.auth-card {
  width: 100%; max-width: 430px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 30px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .mark, .auth-brand .mark-img {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, #e8392e, #8b1a2b); font-size: 24px;
  box-shadow: 0 4px 14px rgba(196,30,58,.45); flex: none;
}
.auth-brand .mark-img { background: none; object-fit: cover;
}
.auth-title { font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: 12px; margin-bottom: 22px; }
.auth-tabs button {
  flex: 1; padding: 10px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted);
}
.auth-tabs button.on { background: var(--surface-2); color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; }
.auth-form label > span { font-size: 13px; font-weight: 650; color: var(--muted); }
.auth-form label > span i { font-style: normal; font-weight: 500; }
.auth-form input[type=text], .auth-form input[type=password] {
  padding: 13px 15px; border-radius: var(--r);
  background: var(--bg-2); border: 2px solid var(--line); font-size: 15px;
}
.auth-form input:focus { border-color: var(--brand); outline: none; }
.auth-form input.bad { border-color: var(--bad); }
.auth-check { flex-direction: row !important; align-items: center; gap: 10px !important; cursor: pointer; }
.auth-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.auth-check span { font-size: 13.5px; color: var(--muted); }
.auth-error {
  padding: 11px 14px; border-radius: var(--r-sm); font-size: 13.5px;
  background: rgba(255,92,114,.12); border: 1px solid rgba(255,92,114,.4); color: #ffb3bd;
}
.auth-foot { margin-top: 18px; text-align: center; line-height: 1.5; }

.auth-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font-weight: 700; text-decoration: none; margin-bottom: 4px;
}
.auth-google:hover { border-color: var(--brand); }
.auth-google-icon { width: 18px; height: 18px; flex: none; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 16px 0 4px;
  color: var(--muted); font-size: 12px; font-weight: 650;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

/* ── Onboarding ────────────────────────────────────────────────────────── */
.ob-wrap { max-width: 620px; margin: 0 auto; padding: 26px 18px 60px; }
.ob-progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 26px; }
.ob-progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s; }
.ob-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 28px; }
.ob-card.center { text-align: center; }
.ob-card h1 { margin: 8px 0 6px; font-size: 26px; }
.ob-options { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.ob-option {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 15px 17px; border-radius: var(--r);
  background: var(--bg-2); border: 2px solid var(--line);
  transition: transform .1s, border-color .15s, background .15s;
}
.ob-option:hover { transform: translateY(-2px); border-color: var(--line-2); }
.ob-option.on { border-color: var(--brand); background: rgba(124,92,255,.14); }
.ob-ico { font-size: 26px; flex: none; }
.ob-body { display: flex; flex-direction: column; gap: 2px; }
.ob-body b { font-size: 15px; font-weight: 750; }
.ob-body i { font-style: normal; font-size: 12.5px; color: var(--faint); }
.ob-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }
.ob-nav.center-nav { flex-direction: column; }
.ob-date {
  width: 100%; margin-top: 20px; padding: 14px 16px; border-radius: var(--r);
  background: var(--bg-2); border: 2px solid var(--line); color: var(--text); font-size: 16px;
}
.ob-scores { display: flex; flex-direction: column; gap: 9px; margin-top: 22px; text-align: left; }
.ob-score { display: grid; grid-template-columns: 130px 1fr 42px; gap: 10px; align-items: center; font-size: 13px; }
.ob-score-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.ob-score-bar i { display: block; height: 100%; border-radius: 999px; transition: width .5s; }

/* ── Speaking ──────────────────────────────────────────────────────────── */
.mic-row { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 26px 0 18px; }
.mic {
  width: 108px; height: 108px; border-radius: 50%; font-size: 44px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), #4b31c9);
  box-shadow: 0 6px 0 #3a24a3; transition: transform .08s, box-shadow .08s;
}
.mic:active { transform: translateY(6px); box-shadow: 0 0 0 #3a24a3; }
.mic.live {
  background: linear-gradient(145deg, var(--bad), var(--bad-dk));
  box-shadow: 0 6px 0 #8f2233; animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%,100% { box-shadow: 0 6px 0 #8f2233, 0 0 0 0 rgba(255,92,114,.5); }
  50%     { box-shadow: 0 6px 0 #8f2233, 0 0 0 18px rgba(255,92,114,0); }
}
.mic-hint { font-size: 13.5px; color: var(--muted); text-align: center; }
.mic-hint kbd {
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 5px;
  padding: 1px 6px; font-size: 12px; font-family: inherit;
}
.speech-result { padding: 18px 20px; border-radius: var(--r); border: 2px solid var(--line); background: var(--surface); }
.speech-result.right { border-color: var(--good); background: rgba(53,208,127,.10); }
.speech-result.wrong { border-color: var(--bad); background: rgba(255,92,114,.09); }
.sr-head { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 12px; }
.sr-ico { font-size: 22px; }
.sr-pct { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; }
.sr-line { display: flex; align-items: baseline; gap: 12px; padding: 5px 0; }
.sr-line .tiny { width: 62px; flex: none; }
.sr-line .jp { font-size: 19px; }

/* ── Social ────────────────────────────────────────────────────────────── */
.league { display: flex; flex-direction: column; gap: 8px; }
.league-row {
  display: grid; grid-template-columns: 40px minmax(120px, 1.4fr) 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 13px 15px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
}
.league-row.you { border-color: var(--brand); background: rgba(124,92,255,.12); }
.lg-rank { font-size: 19px; text-align: center; font-weight: 800; color: var(--muted); }
.lg-who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lg-who b { font-size: 14.5px; }
.lg-who i { font-style: normal; color: var(--brand-2); }
.lg-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.lg-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.lg-xp { font-weight: 800; font-variant-numeric: tabular-nums; }
.lg-xp i { font-style: normal; font-size: 10px; color: var(--faint); margin-left: 3px; }
.lg-streak { color: var(--flame); font-weight: 700; font-size: 13px; min-width: 34px; text-align: right; }

.friend-list { display: flex; flex-direction: column; gap: 8px; }
.friend-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
}
.fr-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: linear-gradient(145deg, var(--brand), #4b31c9);
}
.fr-avatar.big { width: 54px; height: 54px; font-size: 22px; }
.fr-who { display: flex; flex-direction: column; gap: 1px; }
.fr-who b { font-size: 14.5px; }
.invite-code { font-family: ui-monospace, "Cascadia Mono", monospace; letter-spacing: 1px; color: var(--gold); }
.ach-strip { display: flex; flex-wrap: wrap; gap: 8px; font-size: 26px; }

/* ── Account menu / modals ─────────────────────────────────────────────── */
.stat.account { padding: 4px; border: none; background: none; }
.stat.account .avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), #4b31c9); font-weight: 800; font-size: 14px; color: #fff;
}
.stat.trial { color: var(--gold); }

.acct-menu {
  position: fixed; top: 62px; right: 18px; z-index: 300; width: 232px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
  animation: pop .16s cubic-bezier(.2,1.3,.4,1);
}
.acct-head { padding: 14px 16px 6px; display: flex; flex-direction: column; gap: 2px; }
.acct-plan { padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
.acct-menu button {
  display: block; width: 100%; text-align: left; padding: 11px 16px;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.acct-menu button:hover { background: var(--surface); color: var(--text); }
.acct-menu button.danger { color: var(--bad); border-top: 1px solid var(--line); }
.pill.gold { color: var(--gold); border-color: rgba(255,197,61,.4); background: #2a2411; }
.bill-featured { border-color: rgba(124,92,255,.45); }
.unit-gated { opacity: .92; }

.modal-back {
  position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 20px;
  background: rgba(6,8,13,.72); backdrop-filter: blur(4px);
  animation: pop .16s ease;
}
.modal {
  position: relative; width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-xl); padding: 26px; box-shadow: var(--shadow);
}
.modal-x {
  position: absolute; top: 14px; right: 16px; font-size: 18px; color: var(--faint);
  width: 30px; height: 30px; border-radius: 8px;
}
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.plan-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.plan-list li { font-size: 14px; color: var(--muted); padding-left: 22px; position: relative; }
.plan-list li::before { content: '✓'; position: absolute; left: 0; color: var(--good); font-weight: 800; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .nav-desk { display: none !important; }
  .nav-more { display: block; }
  .hud-desk { display: none !important; }
  .hud-more { display: block; }
  .topbar { gap: 10px; }
  .nav button { padding: 8px 12px; font-size: 13.5px; }
}

@media (max-width: 720px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .logo span:not(.mark) { display: none; }
  .hud { gap: 4px; }
  .stat { padding: 6px 10px; font-size: 13px; }
  .hud-pri { display: none !important; }
  main { padding: 20px 14px 90px; }
  .hero { grid-template-columns: 1fr; }
  .hero-actions { min-width: 0; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .prompt .big { font-size: 54px; }
  .prompt .big.long { font-size: 30px; }
  .choices { grid-template-columns: 1fr; }
  .heat { grid-template-columns: repeat(14, 1fr); }
  .auth-card, .ob-card { padding: 22px; }
  .league-row { grid-template-columns: 30px 1fr auto; row-gap: 8px; }
  .lg-bar { grid-column: 1 / -1; }
  .acct-menu { right: 10px; left: auto; width: min(232px, calc(100vw - 20px)); }
  .ob-score { grid-template-columns: 96px 1fr 38px; }
}
