:root {
  --ink: #17322e;
  --muted: #657873;
  --paper: #fffdf7;
  --cream: #f5f0e5;
  --green: #12352f;
  --mint: #bfe7d5;
  --mint-dark: #397865;
  --yellow: #f8ca56;
  --orange: #e7783f;
  --red: #bd4c46;
  --white: #fff;
  --shadow: 0 12px 30px rgba(18, 53, 47, .10);
  --radius: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 4%, rgba(248, 202, 86, .24), transparent 23rem),
    radial-gradient(circle at 96% 42%, rgba(191, 231, 213, .5), transparent 28rem),
    var(--paper);
  font-family: "DM Sans", system-ui, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.site-header {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand, .header-action {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Fredoka", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--green);
  background: var(--yellow);
  transform: rotate(-5deg);
}

.header-action {
  padding: 10px 15px;
  border: 1px solid rgba(18, 53, 47, .18);
  border-radius: 999px;
  font-weight: 700;
}

.app-shell {
  width: min(960px, calc(100% - 32px));
  min-height: calc(100vh - 150px);
  margin: 26px auto 40px;
}

.hero { max-width: 760px; padding: 40px 0 28px; }
.eyebrow { margin: 0 0 12px; color: var(--mint-dark); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: .8rem; }
h1, h2, h3 { font-family: "Fredoka", sans-serif; line-height: 1.06; }
h1 { max-width: 700px; margin: 0; font-size: clamp(3rem, 9vw, 6.4rem); letter-spacing: -.04em; }
h2 { margin: 0; font-size: clamp(2rem, 6vw, 3.6rem); letter-spacing: -.025em; }
h3 { margin: 0; font-size: 1.35rem; }
.lead { max-width: 580px; margin: 22px 0 0; color: var(--muted); font-size: clamp(1.05rem, 2.5vw, 1.25rem); line-height: 1.65; }
.accent { color: var(--orange); }

.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; }
.section-head p { margin: 8px 0 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.card {
  min-height: 180px;
  padding: 24px;
  border: 1px solid rgba(18, 53, 47, .1);
  border-radius: var(--radius);
  background: rgba(255,255,255,.76);
  box-shadow: var(--shadow);
}

button.card { text-align: left; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
button.card:hover { transform: translateY(-4px); box-shadow: 0 16px 38px rgba(18,53,47,.16); }
button.card:focus-visible, .answer:focus-visible, .primary:focus-visible, .secondary:focus-visible { outline: 4px solid rgba(231,120,63,.35); outline-offset: 3px; }
.card-icon { width: 50px; height: 50px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 16px; background: var(--cream); font-size: 1.6rem; }
.card p { margin: 9px 0 0; color: var(--muted); line-height: 1.45; }
.card.disabled { opacity: .55; box-shadow: none; cursor: default; }
.tag { display: inline-block; margin-top: 16px; padding: 5px 10px; border-radius: 999px; background: var(--mint); font-size: .78rem; font-weight: 800; }

.back { display: inline-flex; margin-bottom: 28px; padding: 0; border: 0; background: transparent; color: var(--mint-dark); font-weight: 800; cursor: pointer; }
.panel { max-width: 660px; margin: 32px auto; padding: clamp(24px, 6vw, 48px); border-radius: 30px; background: rgba(255,255,255,.88); box-shadow: var(--shadow); }
.panel.center { text-align: center; }
.topic-summary { margin: 12px 0 28px; color: var(--muted); }
label { display: block; margin-bottom: 9px; font-weight: 800; }
input { width: 100%; min-height: 56px; padding: 14px 16px; border: 2px solid #cad6d2; border-radius: 14px; color: var(--ink); background: white; font-size: 1.05rem; }
input:focus { border-color: var(--mint-dark); outline: 3px solid rgba(57,120,101,.15); }
.hint { margin: 9px 0 24px; color: var(--muted); font-size: .9rem; }
.primary, .secondary { min-height: 52px; padding: 13px 22px; border-radius: 14px; border: 0; font-weight: 800; cursor: pointer; }
.primary { color: white; background: var(--green); box-shadow: 0 8px 18px rgba(18,53,47,.2); }
.primary:hover { background: #1d4a41; }
.secondary { background: var(--cream); }
.button-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }

.quiz-wrap { max-width: 760px; margin: 0 auto; }
.quiz-top { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 14px; margin-bottom: 22px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 99px; background: #e3e8e5; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--orange); transition: width .3s ease; }
.stat-pill { padding: 8px 11px; border-radius: 99px; background: white; font-size: .9rem; font-weight: 800; box-shadow: 0 4px 12px rgba(18,53,47,.08); white-space: nowrap; }
.question-card { padding: clamp(24px, 6vw, 44px); border-radius: 30px; background: var(--green); color: white; box-shadow: var(--shadow); }
.question-count { margin: 0 0 14px; color: var(--mint); font-weight: 800; }
.question-card h2 { max-width: 650px; font-size: clamp(1.8rem, 5vw, 2.8rem); line-height: 1.18; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.answer { min-height: 76px; padding: 16px; border: 2px solid rgba(18,53,47,.1); border-radius: 18px; background: white; text-align: left; font-weight: 700; cursor: pointer; transition: transform .12s ease, border-color .15s ease; }
.answer:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--mint-dark); }
.answer:disabled { cursor: default; }
.answer.correct { color: #155f43; border-color: #55a982; background: #e1f5ea; }
.answer.wrong { color: #87322e; border-color: #d57a74; background: #fae8e6; }
.answer-letter { display: inline-grid; width: 31px; height: 31px; place-items: center; margin-right: 8px; border-radius: 9px; background: var(--cream); }
.feedback { min-height: 90px; margin-top: 18px; padding: 18px 20px; border-radius: 18px; background: white; box-shadow: var(--shadow); }
.feedback[hidden] { display: none; }
.feedback strong { display: block; margin-bottom: 5px; }
.feedback p { margin: 5px 0 0; color: var(--muted); line-height: 1.5; }
.feedback-head { display: flex; justify-content: space-between; gap: 10px; }
.bonus-note { color: var(--orange); font-weight: 800; }
.next-row { display: flex; justify-content: flex-end; margin-top: 14px; }

.score-big { margin: 16px 0 4px; font-family: "Fredoka", sans-serif; font-size: clamp(3.2rem, 12vw, 6rem); line-height: 1; }
.result-line { margin: 7px 0; color: var(--muted); font-size: 1.15rem; }
.record { display: inline-block; margin: 17px 0 4px; padding: 8px 13px; border-radius: 99px; background: var(--yellow); font-weight: 800; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 26px; }
.result-stat { padding: 16px 8px; border-radius: 16px; background: var(--cream); }
.result-stat strong { display: block; font-size: 1.4rem; }
.result-stat span { color: var(--muted); font-size: .82rem; }

.leaderboard { max-width: 760px; margin: 0 auto; }
.score-table { margin-top: 22px; overflow: hidden; border-radius: 22px; background: white; box-shadow: var(--shadow); }
.score-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; min-height: 66px; padding: 10px 18px; border-bottom: 1px solid #edf0ee; }
.score-row:last-child { border-bottom: 0; }
.rank { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--cream); font-weight: 800; }
.score-row:nth-child(1) .rank { background: var(--yellow); }
.score-meta { color: var(--muted); font-size: .84rem; }
.score-points { font-weight: 800; }
.empty { padding: 38px 20px; text-align: center; color: var(--muted); }

footer { min-height: 68px; display: flex; justify-content: center; align-items: center; gap: 9px; color: var(--muted); font-size: .85rem; }

@media (max-width: 720px) {
  .app-shell { margin-top: 8px; }
  .hero { padding-top: 25px; }
  .grid { grid-template-columns: 1fr; }
  .card { min-height: 130px; }
  .card-icon { margin-bottom: 14px; }
  .answers { grid-template-columns: 1fr; }
  .quiz-top { grid-template-columns: 1fr auto; }
  .quiz-top .stat-pill:last-child { grid-column: 2; }
  .progress-track { grid-row: 1 / 3; align-self: stretch; width: 10px; height: auto; }
  .progress-fill { width: 100% !important; height: var(--progress); }
  .result-stats { grid-template-columns: 1fr 1fr; }
  .panel { margin-top: 8px; }
}

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