:root {
  --ink: #2b2f44;
  --muted: #6f7480;
  --paper: #fffdf9;
  --canvas: #eef1f7;
  --blue: #345995;
  --blue-dark: #24406b;
  --blue-soft: #dfe7f3;
  --orange: #d97f2e;
  --red: #b94a48;
  --red-soft: #f8e1df;
  --line: #dcdfe6;
  --shadow: 0 14px 40px rgba(43, 47, 68, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(217, 127, 46, .12), transparent 30rem),
    linear-gradient(145deg, #e9edf5, #faf9f5 65%);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

button { font: inherit; }
button:focus-visible { outline: 4px solid rgba(217, 127, 46, .4); outline-offset: 3px; }

.app-shell {
  width: min(100%, 680px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark {
  display: grid; place-items: center; width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 14px; color: #fff; background: var(--blue); font: 700 22px/1 system-ui;
  box-shadow: 0 7px 18px rgba(52, 89, 149, .24);
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(19px, 5vw, 26px); letter-spacing: .02em; }
.eyebrow { margin: 0; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.icon-button { margin-left: auto; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--paper); font-size: 24px; cursor: pointer; }

.screen[hidden] { display: none !important; }
.feedback[hidden], .next-button[hidden] { display: none !important; }
.hero-card, .question-card, .complete-screen {
  position: relative; overflow: hidden; border: 1px solid rgba(220, 223, 230, .8);
  border-radius: 26px; background: var(--paper); box-shadow: var(--shadow);
}
.hero-card { padding: 30px 25px; }
.hero-card::after { content: ""; position: absolute; inset: auto -55px -75px auto; width: 190px; height: 190px; border-radius: 50%; background: var(--blue-soft); }
.hero-note { position: absolute; right: 25px; top: 17px; color: rgba(52, 89, 149, .16); font: 700 60px/1 system-ui; transform: rotate(7deg); }
.hero-card h2 { position: relative; z-index: 1; margin: 10px 0; max-width: 470px; font-size: clamp(25px, 7vw, 38px); line-height: 1.3; letter-spacing: .01em; }
.hero-card > p:last-child { position: relative; z-index: 1; max-width: 460px; margin: 0; color: var(--muted); line-height: 1.75; }

.mode-grid { display: grid; gap: 11px; margin: 16px 0; }
.mode-card {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 13px;
  width: 100%; min-height: 78px; padding: 13px 17px; border: 1px solid var(--line); border-radius: 19px;
  color: var(--ink); background: rgba(255, 253, 249, .82); text-align: left; cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.mode-card:hover { transform: translateY(-2px); border-color: var(--blue); box-shadow: 0 9px 24px rgba(43, 47, 68, .08); }
.mode-card.primary { color: #fff; border-color: var(--blue); background: var(--blue); }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { font-size: 17px; }
.mode-card small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.mode-card.primary small { color: rgba(255,255,255,.76); }
.mode-icon { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 13px; background: var(--blue-soft); color: var(--blue-dark); font: 700 22px/1 system-ui; }
.primary .mode-icon { background: rgba(255,255,255,.15); color: #fff; }

.summary-card, .result-grid { display: grid; grid-template-columns: repeat(3, 1fr); padding: 17px; border: 1px solid var(--line); border-radius: 19px; background: rgba(255,253,249,.7); }
.summary-card div, .result-grid div { display: grid; place-items: center; gap: 3px; }
.summary-card div + div, .result-grid div + div { border-left: 1px solid var(--line); }
.summary-card strong, .result-grid strong { font-size: 23px; font-variant-numeric: tabular-nums; }
.summary-card span, .result-grid span { color: var(--muted); font-size: 11px; }
.text-button { display: block; margin: 15px auto 0; padding: 10px; border: 0; color: var(--muted); background: transparent; text-decoration: underline; cursor: pointer; }

.quiz-status { display: flex; justify-content: space-between; margin: 0 3px 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.progress-track { height: 8px; margin-bottom: 19px; overflow: hidden; border-radius: 999px; background: #e2e5ec; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #6d8fc4); transition: width .35s ease; }
.question-card { display: grid; min-height: 200px; padding: 25px 20px; place-items: center; align-content: center; text-align: center; }
.question-kind { margin: 0 0 14px; color: var(--blue); font-size: 13px; font-weight: 800; letter-spacing: .09em; }
.question-prompt { font-size: clamp(17px, 4.6vw, 23px); font-weight: 700; line-height: 1.6; }
.question-prompt.meaning { font-size: clamp(16px, 4.2vw, 21px); }
.question-hint { min-height: 1.5em; margin: 15px 0 0; color: var(--muted); font-size: 13px; }
.question-visual { display: flex; justify-content: center; margin-top: 6px; }
.question-visual img { max-width: min(420px, 88vw); max-height: 46vh; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.question-visual svg { max-width: min(420px, 88vw); height: auto; }
.figure-caption { margin: 6px 0 0; color: var(--muted); font-size: 11px; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 16px; }
.answer-button {
  position: relative; display: grid; min-height: 76px; padding: 14px 13px 14px 38px; place-items: center;
  border: 2px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--paper);
  font-weight: 700; line-height: 1.5; cursor: pointer; transition: transform .13s ease, border-color .13s ease;
}
.answer-button:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--blue); }
.answer-button .number { position: absolute; top: 10px; left: 10px; display: grid; width: 23px; height: 23px; place-items: center; border-radius: 7px; color: var(--muted); background: #e8e6df; font-size: 11px; }
.answer-button.correct { border-color: var(--blue); background: var(--blue-soft); }
.answer-button.wrong { border-color: var(--red); background: var(--red-soft); }
.answer-button:disabled { cursor: default; opacity: .78; }
.answer-button.correct:disabled { opacity: 1; }

.feedback { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; margin-top: 14px; padding: 15px; border-radius: 17px; background: var(--blue-soft); }
.feedback.wrong { background: var(--red-soft); }
.feedback-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-weight: 900; }
.feedback.wrong .feedback-icon { background: var(--red); }
.feedback strong { display: block; margin-top: 1px; }
.feedback p { margin: 4px 0 0; color: #4d5455; font-size: 13px; line-height: 1.6; }
.next-button, .secondary-button { width: 100%; min-height: 56px; margin-top: 12px; border-radius: 16px; font-weight: 800; cursor: pointer; }
.next-button { border: 0; color: #fff; background: var(--blue); box-shadow: 0 9px 22px rgba(52,89,149,.22); }
.secondary-button { border: 2px solid var(--line); color: var(--ink); background: var(--paper); }
.key-help { margin: 12px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

.complete-screen { padding: 34px 22px; text-align: center; }
.complete-badge { display: grid; width: 78px; height: 78px; margin: 0 auto 18px; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-size: 38px; box-shadow: 0 11px 25px rgba(52,89,149,.24); }
.complete-screen h2 { margin: 8px 0; font-size: 34px; }
.complete-screen > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; }
.result-grid { margin: 22px 0; }

@media (max-width: 440px) {
  .app-shell { padding-inline: 13px; }
  .answer-grid { grid-template-columns: 1fr; gap: 9px; }
  .answer-button { min-height: 62px; }
  .question-card { min-height: 178px; }
  .hero-card { padding: 25px 20px; }
  .hero-note { right: 15px; font-size: 48px; }
  .hero-card::after { opacity: .42; }
  .question-visual img { max-height: 38vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
