:root {
  --paper: #fbf7f0;
  --paper-deep: #f1eade;
  --card: #fffdf9;
  --ink: #303631;
  --muted: #677069;
  --line: #ded8ce;
  --sage: #597968;
  --sage-dark: #3e5b4d;
  --sage-soft: #e2ebe3;
  --rose: #637d8e;
  --rose-soft: #e1e9ed;
  --violet: #707a76;
  --violet-soft: #e7eae6;
  --terra: #9a7059;
  --terra-soft: #eee5de;
  --shadow: 0 14px 35px rgba(75, 65, 52, .09);
  --shadow-small: 0 5px 14px rgba(75, 65, 52, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.aurora { position: fixed; z-index: -1; border-radius: 50%; pointer-events: none; filter: blur(4px); opacity: .6; }
.aurora-one { width: 43vw; height: 43vw; left: -20vw; top: -18vw; background: #e6efe7; }
.aurora-two { width: 40vw; height: 40vw; right: -18vw; bottom: -20vw; background: #ece4d7; }
.shell { width: min(100% - 32px, 900px); margin: 0 auto; position: relative; }

.topbar { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { color: var(--ink); text-decoration: none; letter-spacing: .1em; font-size: 1.08rem; font-weight: 800; }
.brand span { color: var(--terra); margin-left: 3px; }
.top-actions { display: flex; align-items: center; gap: 18px; }
.text-button { border: 0; color: var(--muted); background: transparent; padding: 8px 0; font: 600 .88rem/1 inherit; cursor: pointer; text-decoration: none; }
.text-button:hover { color: var(--sage-dark); }

.screen { display: none; min-height: calc(100vh - 84px); padding: 48px 0 70px; }
.screen.active { display: block; }
.hero { padding-top: clamp(42px, 9vh, 100px); }
.eyebrow { margin: 0 0 15px; color: var(--sage-dark); font-size: .82rem; font-weight: 800; letter-spacing: .09em; }
.hero h1, .studio h1 { max-width: 780px; margin: 0; letter-spacing: -.055em; font-size: clamp(3rem, 8vw, 6rem); line-height: .95; }
.hero h1 em, .studio h1 em { color: var(--rose); font-style: normal; }
.hero-copy { max-width: 560px; margin: 24px 0 35px; color: var(--muted); font-size: 1.06rem; line-height: 1.6; }

.start-card, .question-card, .leaderboard {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.start-card { border-radius: 22px; padding: clamp(20px, 4vw, 30px); }
.start-card label, .field > label { display: block; margin-bottom: 9px; color: var(--ink); font-size: .94rem; font-weight: 750; }
.start-row { display: flex; gap: 11px; }
input, textarea, select {
  width: 100%; min-width: 0; border: 1px solid #d2ccc2; border-radius: 12px; outline: 0; background: #fffefa; color: var(--ink);
  padding: 14px 15px; font: 500 1rem/1.35 inherit; transition: border-color .16s, box-shadow .16s;
}
input { min-height: 52px; flex: 1; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(111, 137, 120, .16); }
button { font-family: inherit; }
.primary, .secondary { min-height: 52px; border-radius: 12px; padding: 12px 19px; font-size: .96rem; font-weight: 800; cursor: pointer; transition: transform .16s, background .16s, border-color .16s; }
.primary { border: 1px solid var(--sage-dark); background: var(--sage); color: #fff; white-space: nowrap; }
.primary:hover { background: var(--sage-dark); transform: translateY(-1px); }
.primary:disabled { opacity: .65; cursor: wait; transform: none; }
.secondary { border: 1px solid #cfc7bd; background: var(--card); color: var(--ink); }
.secondary:hover { border-color: var(--sage); background: var(--sage-soft); }

.mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-top: 22px; }
.mode-row.levels { grid-template-columns: repeat(4, 1fr); }
.mode { min-height: 118px; border: 1px solid var(--line); border-radius: 15px; background: #fffefa; color: var(--muted); padding: 16px 13px; text-align: left; cursor: pointer; transition: border-color .16s, transform .16s, background .16s; }
.mode span { display: block; margin-bottom: 12px; color: var(--violet); font-size: 1.05rem; font-weight: 800; letter-spacing: .04em; }
.mode b, .mode small { display: block; }
.mode b { color: var(--ink); font-size: .95rem; }
.mode small { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.mode:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--sage); }
.mode.selected { border: 2px solid var(--sage); background: var(--sage-soft); padding: 15px 12px; }
.mode.selected span { color: var(--sage-dark); }
.mode.locked, .mode:disabled { cursor: not-allowed; opacity: .55; background: #f4f0e9; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 20px; margin: 25px 3px; color: var(--muted); font-size: .94rem; }

.game-screen { max-width: 720px; margin: 0 auto; padding-top: 54px; }
.game-meta, .streak-line { display: flex; align-items: center; gap: 11px; font-size: .9rem; font-weight: 750; }
.game-meta { justify-content: space-between; }
.badge { padding: 6px 10px; border-radius: 999px; background: var(--violet-soft); color: #5f566e; font-size: .83rem; }
.level-badge { padding: 6px 10px; border-radius: 999px; background: var(--terra-soft); color: #745140; font-size: .83rem; font-weight: 800; }
.score-label { margin-left: auto; color: var(--muted); font-size: .78rem; letter-spacing: .05em; }
.score-label b { margin-left: 6px; color: var(--sage-dark); font-size: 1rem; }
.timer { height: 9px; overflow: hidden; margin: 20px 0; border-radius: 999px; background: #dfdad1; }
.timer div { height: 100%; width: 100%; border-radius: inherit; background: var(--sage); transition: width .1s linear, background .2s; }
.streak-line { margin-bottom: 18px; color: var(--muted); font-size: .8rem; letter-spacing: .06em; }
.streak-pips { display: flex; gap: 5px; }
.streak-pips i { width: 20px; height: 8px; border-radius: 999px; background: #ddd7ce; }
.streak-pips i.on { background: var(--rose); }
#streakText { color: var(--rose); }

.question-card { min-height: 425px; border-radius: 24px; padding: clamp(25px, 5vw, 48px); }
.difficulty { margin: 0 0 18px; color: var(--terra); font-size: .86rem; letter-spacing: 4px; }
.question-card h2 { max-width: 660px; margin: 0 0 32px; font-size: clamp(1.65rem, 4vw, 2.45rem); line-height: 1.14; letter-spacing: -.035em; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer { min-height: 72px; border: 1px solid #d9d3ca; border-radius: 14px; background: #fffefa; color: var(--ink); padding: 13px 14px; display: flex; align-items: center; gap: 13px; text-align: left; font-size: 1rem; font-weight: 600; line-height: 1.35; cursor: pointer; transition: background .16s, border-color .16s, transform .16s; }
.answer:hover:not(:disabled) { border-color: var(--sage); background: var(--sage-soft); transform: translateY(-1px); }
.answer:disabled { cursor: default; }
.answer .letter { width: 31px; height: 31px; flex: none; display: grid; place-items: center; border-radius: 9px; background: #eee9e1; color: var(--muted); font-size: .8rem; font-weight: 800; }
.answer.correct { border-color: #8faa96; background: var(--sage-soft); }
.answer.correct .letter { background: var(--sage); color: white; }
.answer.wrong { border-color: #a5bbc7; background: var(--rose-soft); }
.answer.wrong .letter { background: var(--rose); color: white; }
.answer.removed { visibility: hidden; }
.fact { min-height: 26px; margin: 23px 0 0; color: #536259; font-size: .98rem; line-height: 1.55; }
.fact.show { animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.power-row { display: flex; gap: 10px; margin-top: 16px; }
.power { min-height: 48px; flex: 1; border: 1px solid #d9d3ca; border-radius: 12px; background: var(--card); color: var(--ink); padding: 10px; font-size: .88rem; font-weight: 700; cursor: pointer; }
.power:hover:not(:disabled) { background: var(--violet-soft); border-color: var(--violet); }
.power span { color: var(--violet); font-weight: 850; }
.power b { color: var(--muted); }
.power:disabled { opacity: .42; cursor: not-allowed; }

.result-screen { max-width: 620px; margin: 0 auto; padding-top: 40px; text-align: center; }
.result-orb { display: grid; place-items: center; width: 105px; height: 105px; margin: 8px auto 21px; border-radius: 50%; background: var(--terra-soft); color: var(--terra); font-size: 3.2rem; }
.result-screen h2 { margin: 0; font-size: clamp(2.25rem, 7vw, 4.2rem); letter-spacing: -.06em; line-height: .96; }
.result-message { max-width: 420px; margin: 15px auto; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.result-score { margin: 27px 0 14px; }
.result-score span, .result-score small { display: block; color: var(--muted); font-size: .82rem; font-weight: 750; letter-spacing: .09em; }
.result-score strong { display: block; margin: 7px; color: var(--sage-dark); font-size: 4.5rem; line-height: 1; letter-spacing: -.08em; }
.achievement { display: inline-block; border-radius: 999px; background: var(--violet-soft); color: #5d546a; padding: 9px 15px; font-size: .9rem; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin: 27px 0; }
.leaderboard { margin-top: 36px; border-radius: 19px; padding: 19px 23px; text-align: left; }
.board-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--sage-dark); font-size: .8rem; font-weight: 850; letter-spacing: .08em; }
.leaderboard ol { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.leaderboard li { counter-increment: rank; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; border-top: 1px solid var(--line); padding: 11px 0; color: var(--ink); font-size: .96rem; }
.leaderboard li::before { content: counter(rank, decimal-leading-zero); color: var(--muted); font-size: .79rem; font-weight: 750; }
.board-score { color: var(--sage-dark); font-size: .9rem; }
.toast { position: fixed; z-index: 3; left: 50%; bottom: 24px; translate: -50% 140px; border: 1px solid #d6cfc4; border-radius: 999px; background: var(--card); color: var(--ink); box-shadow: var(--shadow-small); padding: 12px 18px; font-size: .92rem; font-weight: 700; transition: translate .26s; }
.toast.show { translate: -50% 0; }

.studio { max-width: 760px; margin: 0 auto; padding: 42px 0 70px; }
.studio > p:not(.eyebrow):not(.studio-note) { max-width: 610px; color: var(--muted); font-size: 1.02rem; line-height: 1.6; }
.studio form { margin-top: 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 150px; gap: 12px; }
.field { margin: 17px 0; }
.answer-line { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 9px; margin: 9px 0; }
.answer-line > span { display: flex; align-items: center; justify-content: center; gap: 4px; color: var(--sage-dark); font-size: .84rem; font-weight: 800; }
.answer-line input[type="radio"] { width: auto; min-height: auto; accent-color: var(--sage); }
.studio-note { margin-top: 22px; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.status { min-height: 25px; margin-top: 13px; color: var(--sage-dark); font-weight: 700; }

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 900px); }
  .topbar { min-height: 67px; }
  .top-actions { gap: 12px; }
  .screen { min-height: calc(100vh - 67px); padding: 32px 0 54px; }
  .hero { padding-top: 48px; }
  .hero h1, .studio h1 { font-size: clamp(2.8rem, 15vw, 4rem); }
  .start-card { padding: 19px; }
  .start-row { display: block; }
  .start-row .primary { width: 100%; margin-top: 11px; }
  .mode-row.levels { grid-template-columns: 1fr 1fr; }
  .mode { min-height: 104px; }
  .hero-stats { gap: 11px; font-size: .88rem; }
  .game-screen { padding-top: 28px; }
  .question-card { min-height: 430px; border-radius: 20px; padding: 25px 19px; }
  .answers { grid-template-columns: 1fr; }
  .answer { min-height: 65px; }
  .power { padding: 9px 5px; font-size: .82rem; }
  .result-screen { padding-top: 24px; }
  .result-score strong { font-size: 4rem; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}
