:root {
  --bg: #fbfaf7; --card: #ffffff; --fg: #1f2328; --muted: #5d636c; --line: #e2e0d9;
  --m: #1d4ed8; --f: #d42020; --n: #15803d; --pl: #7c3aed; --exc: #a16207; --ok: #15803d;
  --serif: Georgia, 'Times New Roman', serif; --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171b; --card: #1d2025; --fg: #e7e6e1; --muted: #a0a5ad; --line: #2f333a;
    --m: #7eaaff; --f: #ff7d7d; --n: #5fd18a; --pl: #bc9fff; --exc: #e2b552; --ok: #5fd18a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; display: flex; flex-direction: column; }
header { border-bottom: 1px solid var(--line); padding: 10px 16px; }
nav { display: flex; gap: 16px; align-items: center; max-width: 640px; margin: 0 auto; }
nav a { color: var(--muted); text-decoration: none; }
.nav-user { margin-left: auto; color: var(--muted); font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user:empty { display: none; }
.nav-user + .lang-switcher, .nav-user:empty ~ .lang-switcher { margin-left: 0; }
.lang-switcher { margin-left: auto; display: flex; gap: 4px; }
nav .link { font-size: 13px; }
.lang-switcher button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px;
  padding: 2px 8px; cursor: pointer; font: inherit; }
.lang-switcher button.active { color: var(--fg); border-color: var(--fg); }
main { flex: 1; display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 640px;
  margin: 0 auto; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; color: var(--muted); font-size: 14px; }
.controls label { display: inline-flex; align-items: center; gap: 4px; }
.controls .auto { margin-left: 8px; }
.stats { margin-left: auto; }
.card { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 240px; }
.message { color: var(--muted); font-size: 15px; min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center; }
.result { display: inline-flex; width: 44px; height: 44px; border-radius: 50%; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff; animation: pop .25s ease-out; }
.result.ok { background: var(--ok); } .result.wrong { background: var(--f); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.word { font-size: clamp(34px, 9vw, 52px); font-weight: 500; text-align: center; line-height: 1.15; transition: color .2s; }
.word .hl { font-weight: 800; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.word.g-m, .g-m { color: var(--m); } .word.g-f, .g-f { color: var(--f); } .word.g-n, .g-n { color: var(--n); }
.word .article { font-weight: 400; margin-right: .25em; }
.detail { text-align: center; display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.plural { color: var(--pl); font-size: 16px; display: flex; align-items: center; gap: 6px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 2px 6px; border-radius: 5px;
  border: 1px solid currentColor; line-height: 1.2; opacity: .85; }
.translation { font-family: var(--serif); font-size: 22px; display: flex; flex-direction: column; gap: 4px; align-items: center;
  padding-top: 10px; border-top: 1px dashed var(--line); width: 100%; }
.tr-line { display: inline-flex; align-items: center; gap: 8px; }
.tr-line.en { color: var(--muted); font-size: 16px; }
.translation .conf { color: var(--exc); font-size: 14px; font-family: system-ui, sans-serif; }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--line); width: 100%; }
.chip { display: inline-flex; align-items: center; border-radius: 999px; border: 1.5px solid currentColor; overflow: hidden; font-size: 14px; }
.chip-key { font-family: var(--mono); font-weight: 700; padding: 4px 10px; background: currentColor; }
.chip-key, .chip-name { line-height: 1.3; }
.chip .chip-key { color: var(--card); background: currentColor; }
.chip.g-m .chip-key { background: var(--m); } .chip.g-f .chip-key { background: var(--f); } .chip.g-n .chip-key { background: var(--n); }
.chip.exc { color: var(--exc); } .chip.exc .chip-key { background: var(--exc); }
.chip-name { padding: 4px 10px 4px 8px; font-variant: small-caps; letter-spacing: .02em; }
.hidden { display: none !important; }
.modes { display: flex; gap: 8px; }
.mode { flex: 1; font: inherit; font-size: 14px; padding: 8px 4px; border-radius: 10px; cursor: pointer;
  background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.mode.active { color: var(--fg); border-color: var(--fg); font-weight: 600; }
.word .question-fi { font-family: var(--serif); font-size: .9em; display: inline-flex; align-items: center; gap: 12px; }
.word .question-fi .badge { font-family: system-ui, sans-serif; font-size: 12px; }
.answers { display: grid; gap: 10px; }
.answers.cols-3 { grid-template-columns: repeat(3, 1fr); }
.answers.cols-2 { grid-template-columns: repeat(2, 1fr); }
.answer.choice { font-size: 19px; font-weight: 500; color: var(--fg); border-color: var(--line); padding: 14px 10px;
  display: flex; align-items: center; gap: 10px; text-align: left; }
.answer.choice .fi { font-family: var(--serif); font-size: 21px; }
.answer.choice .num { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.answer.choice.is-right { border-color: currentColor; opacity: 1; font-weight: 700; }
.answer.choice.is-right.g-m { color: var(--m); } .answer.choice.is-right.g-f { color: var(--f); } .answer.choice.is-right.g-n { color: var(--n); }
.answer.choice.chosen-wrong { color: var(--f); border-color: currentColor; opacity: 1; }
.answer { font: inherit; font-size: 26px; font-weight: 600; padding: 18px 0; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 2px solid currentColor; }
.answer:disabled { opacity: .45; cursor: default; }
.answer.chosen-wrong { background: color-mix(in srgb, currentColor 15%, var(--card)); }
.next-row { min-height: 52px; }
.next { width: 100%; font: inherit; font-size: 18px; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--fg); color: var(--bg); border: none; }
.signin { justify-content: center; }
.signin-card { flex: 0; gap: 16px; padding: 28px 20px; }
.signin-card h1 { margin: 0; }
.signin-card .muted { color: var(--muted); margin: 0; text-align: center; }
.signin-status { margin: 0; min-height: 1.2em; color: var(--exc); text-align: center; font-size: 14px; }
.signin-card .next { width: auto; padding: 12px 24px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin: 0; }
.link { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
