:root {
  --ink: #22352f;
  --muted: #6d7772;
  --paper: #fffdf8;
  --canvas: #f7f1e7;
  --green: #24745b;
  --green-dark: #185642;
  --green-soft: #dcece4;
  --gold: #d99a33;
  --red: #b94a48;
  --red-soft: #f8e1df;
  --line: #ded8cd;
  --shadow: 0 14px 40px rgba(45, 57, 50, .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, 154, 51, .14), transparent 30rem),
    linear-gradient(145deg, #f4ecdf, #faf7f0 65%);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

button { font: inherit; }
button:focus-visible { outline: 4px solid rgba(217, 154, 51, .42); 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(--green); font: 700 26px/1 Georgia, serif;
  box-shadow: 0 7px 18px rgba(36, 116, 91, .24);
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(20px, 5vw, 27px); letter-spacing: .02em; }
.eyebrow { margin: 0; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.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(222, 216, 205, .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(--green-soft); }
.hero-note { position: absolute; right: 25px; top: 17px; color: rgba(36, 116, 91, .14); font: 92px/1 Georgia, serif; transform: rotate(7deg); }
.hero-card h2 { position: relative; z-index: 1; margin: 10px 0; max-width: 470px; font-size: clamp(27px, 8vw, 42px); line-height: 1.25; 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, 248, .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(--green); box-shadow: 0 9px 24px rgba(45, 57, 50, .08); }
.mode-card.primary { color: #fff; border-color: var(--green); background: var(--green); }
.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(--green-soft); color: var(--green-dark); font: 25px/1 Georgia, serif; }
.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,248,.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: #e6e0d6; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), #54a378); transition: width .35s ease; }
.question-card { display: grid; min-height: 245px; padding: 27px 22px; place-items: center; align-content: center; text-align: center; }
.question-kind { margin: 0 0 20px; color: var(--green); font-size: 13px; font-weight: 800; letter-spacing: .09em; }
.question-prompt { font-family: Georgia, "Yu Mincho", serif; font-size: clamp(29px, 9vw, 48px); font-weight: 700; line-height: 1.3; }
.question-prompt.meaning { font-family: inherit; font-size: clamp(23px, 6.5vw, 34px); }
.question-hint { min-height: 1.5em; margin: 17px 0 0; color: var(--muted); font-size: 13px; }
.music-symbol { display: inline-grid; min-width: 160px; min-height: 92px; place-items: center; color: var(--ink); }
.music-symbol svg { display: block; width: min(230px, 70vw); height: 100px; }
.music-text { font: italic 700 clamp(30px, 9vw, 48px)/1.2 Georgia, serif; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 16px; }
.answer-button {
  position: relative; display: grid; min-height: 88px; padding: 15px 13px 15px 38px; place-items: center;
  border: 2px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--paper);
  font-weight: 700; line-height: 1.45; cursor: pointer; transition: transform .13s ease, border-color .13s ease;
}
.answer-button:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--green); }
.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: #eee9df; font-size: 11px; }
.answer-button.symbol-answer { min-height: 116px; padding-left: 13px; }
.answer-button.symbol-answer .music-symbol { min-width: 90px; min-height: 70px; }
.answer-button.symbol-answer svg { width: min(145px, 35vw); height: 76px; }
.answer-button.correct { border-color: var(--green); background: var(--green-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(--green-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(--green); font-weight: 900; }
.feedback.wrong .feedback-icon { background: var(--red); }
.feedback strong { display: block; margin-top: 1px; }
.feedback p { margin: 4px 0 0; color: #4d5b55; 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(--green); box-shadow: 0 9px 22px rgba(36,116,91,.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(--green); font-size: 38px; box-shadow: 0 11px 25px rgba(36,116,91,.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: 68px; }
  .answer-button.symbol-answer { min-height: 94px; }
  .question-card { min-height: 218px; }
  .hero-card { padding: 25px 20px; }
  .hero-note { right: 15px; font-size: 76px; }
  .hero-card::after { opacity: .42; }
}

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