:root {
  --ink: #192722;
  --muted: #69736e;
  --paper: #f2ead5;
  --paper-light: #fcf8ed;
  --red: #a42c25;
  --red-dark: #711d19;
  --gold: #c29a3d;
  --gold-light: #e5cf8e;
  --green: #285747;
  --green-dark: #173b31;
  --line: rgba(25, 39, 34, .16);
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", "Arial Narrow", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Baskerville, Georgia, serif;
  --sans: Inter, Avenir, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent calc(50% - 560px), rgba(164, 44, 37, .12) calc(50% - 560px), rgba(164, 44, 37, .12) calc(50% - 559px), transparent calc(50% - 559px), transparent calc(50% + 559px), rgba(164, 44, 37, .12) calc(50% + 559px), rgba(164, 44, 37, .12) calc(50% + 560px), transparent calc(50% + 560px)),
    radial-gradient(circle at 8% 13%, rgba(194, 154, 61, .16), transparent 25rem),
    radial-gradient(circle at 94% 78%, rgba(40, 87, 71, .11), transparent 30rem),
    repeating-linear-gradient(0deg, rgba(25, 39, 34, .014) 0 1px, transparent 1px 4px),
    var(--paper);
  font-family: var(--sans);
}

body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 140px;
  height: 140px;
  border: 1px solid rgba(194, 154, 61, .22);
  transform: rotate(45deg);
}
body::before { top: -95px; left: -70px; }
body::after { right: -72px; bottom: -95px; }

button, select, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  width: min(1120px, calc(100% - 40px));
  height: 94px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-shield { position: relative; width: 46px; height: 50px; display: block; filter: drop-shadow(3px 4px 0 rgba(40, 87, 71, .14)); }
.brand-shield::after { content: ""; position: absolute; z-index: -1; inset: 7px -3px -2px 7px; border-right: 2px solid rgba(164, 44, 37, .35); border-bottom: 2px solid rgba(164, 44, 37, .35); }
.brand-shield img { width: 100%; height: 100%; object-fit: contain; }
.brand-copy { display: grid; gap: 4px; }
.brand-copy strong { display: flex; gap: .2em; font-family: var(--display); font-size: 22px; font-weight: 900; line-height: .78; letter-spacing: .015em; text-transform: uppercase; }
.brand-copy strong span:last-child { color: var(--red); }
.brand-copy small { color: var(--green); font-size: 8px; font-weight: 800; letter-spacing: .21em; }

.scoreboard { display: flex; gap: 25px; color: var(--muted); font-size: 10px; letter-spacing: .15em; }
.scoreboard span { display: flex; align-items: baseline; gap: 7px; }
.scoreboard strong { color: var(--ink); font-family: var(--serif); font-size: 20px; font-weight: 400; letter-spacing: 0; }

main { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.welcome { min-height: calc(100vh - 176px); padding: 72px 0 78px; display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(55px, 8vw, 110px); align-items: center; }
.hero-copy { position: relative; padding-left: 22px; }
.hero-copy::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: linear-gradient(transparent, var(--gold), transparent); }
.hero-emblem { position: absolute; top: -52px; right: 10px; width: 122px; height: 145px; color: var(--green); opacity: .085; transform: rotate(5deg); }
.hero-emblem img { width: 100%; height: 100%; object-fit: contain; }
.hero-emblem span { position: absolute; z-index: 1; top: 48px; left: 50%; translate: -50% 0; color: var(--gold); font-size: 23px; }

.eyebrow { margin: 0; color: var(--red); font-size: 10px; font-weight: 700; letter-spacing: .23em; }
h2 { font-family: var(--serif); font-weight: 400; }
h1 { margin: 20px 0 27px; font-family: var(--display); font-size: clamp(68px, 8vw, 108px); font-weight: 900; line-height: .72; letter-spacing: .005em; text-transform: uppercase; }
h1 em { display: inline-block; margin-left: 32px; color: var(--red); font-style: normal; font-weight: 900; letter-spacing: -.005em; text-shadow: 4px 4px 0 rgba(194, 154, 61, .2); }
.intro { max-width: 540px; margin: 0; color: var(--muted); font-family: var(--serif); font-size: 20px; line-height: 1.6; }
.hero-stats { margin-top: 37px; display: flex; flex-wrap: wrap; gap: 0; }
.hero-stats span { min-width: 116px; padding: 0 21px; color: var(--muted); border-left: 1px solid var(--line); font-size: 9px; letter-spacing: .11em; text-transform: uppercase; }
.hero-stats span:first-child { padding-left: 0; border-left: 0; }
.hero-stats strong { display: block; margin-bottom: 3px; color: var(--green); font-family: var(--serif); font-size: 24px; font-weight: 400; letter-spacing: 0; }
.leaderboard { max-width: 540px; margin-top: 34px; padding: 19px 21px 16px; background: rgba(252, 248, 237, .55); border: 1px solid rgba(40, 87, 71, .28); }
.leaderboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.leaderboard-heading > span { color: var(--muted); font-size: 8px; letter-spacing: .14em; }
.leaderboard-list { margin: 0; padding: 8px 0 0; list-style: none; counter-reset: leaderboard; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
.leaderboard-list li { min-width: 0; min-height: 34px; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 7px; border-bottom: 1px solid rgba(25, 39, 34, .08); color: var(--muted); font-size: 10px; counter-increment: leaderboard; }
.leaderboard-list li::before { content: counter(leaderboard, decimal-leading-zero); color: var(--gold); font-family: var(--serif); }
.leaderboard-name { overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-score { color: var(--red); font-family: var(--serif); font-size: 14px; }
.leaderboard-metrics { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; white-space: nowrap; }
.leaderboard-metrics small { color: var(--muted); font-size: 8px; font-weight: 600; letter-spacing: .03em; }
.leaderboard-list .leaderboard-empty { grid-column: 1 / -1; display: block; padding: 10px 0 3px; border: 0; text-align: center; }
.leaderboard-list .leaderboard-empty::before { content: none; }

.setup-wrap { position: relative; padding: 14px; }
.setup-wrap::before { content: ""; position: absolute; inset: 0; border: 1px solid rgba(194, 154, 61, .55); transform: rotate(1.2deg); }
.setup-kicker { position: relative; z-index: 2; width: max-content; margin: 0 auto -10px; padding: 0 13px; color: var(--red); background: var(--paper); font-size: 9px; font-weight: 700; letter-spacing: .2em; }
.setup-kicker span { margin: 0 8px; color: var(--gold); }
.settings { position: relative; z-index: 1; padding: 40px 37px 26px; background: rgba(252, 248, 237, .9); border: 1px solid var(--green); box-shadow: 12px 14px 0 rgba(40, 87, 71, .1); }
.settings::before, .settings::after { content: "◆"; position: absolute; color: var(--gold); background: var(--paper-light); font-size: 8px; }
.settings::before { top: -6px; left: -5px; }
.settings::after { right: -5px; bottom: -6px; }

.setup-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 15px; }
.setup-number { width: 31px; height: 31px; display: grid; place-items: center; color: var(--red); border: 1px solid rgba(164, 44, 37, .35); border-radius: 50%; font-family: var(--serif); font-size: 13px; }
.setup-heading p { margin: 0 0 2px; font-family: var(--serif); font-size: 18px; }
.setup-heading small { color: var(--muted); font-size: 10px; }
.setup-divider { height: 1px; margin: 25px 0; background: linear-gradient(90deg, transparent, var(--line) 15%, var(--line) 85%, transparent); }
fieldset { margin: 0; padding: 0; border: 0; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; background: #ede4cf; border: 1px solid rgba(25, 39, 34, .11); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 11px 5px; text-align: center; color: var(--muted); font-size: 11px; font-weight: 600; transition: color .15s, background .15s; }
.segmented input:checked + span { color: #fff; background: var(--green); box-shadow: 0 3px 8px rgba(23, 59, 49, .18); }
.segmented input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.difficulty-options { grid-template-columns: repeat(2, 1fr); }
.difficulty-help { min-height: 28px; margin: 9px 2px 0; color: var(--muted); font-size: 9px; line-height: 1.45; }

.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 14px; top: 50%; translate: 0 -58%; color: var(--red); pointer-events: none; }
select { width: 100%; padding: 13px 38px 13px 14px; color: var(--ink); background: #f7f0df; border: 1px solid var(--line); border-radius: 0; appearance: none; font-size: 12px; }
select:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.nickname-input { width: 100%; padding: 13px 14px; color: var(--ink); background: #f7f0df; border: 1px solid var(--line); border-radius: 0; font-size: 12px; }
.nickname-input::placeholder { color: #929993; }
.nickname-input:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.nickname-input[aria-invalid="true"] { border-color: var(--red); }
.field-error { min-height: 15px; margin: 6px 2px 0; color: var(--red); font-size: 9px; line-height: 1.4; }

.primary { min-width: 260px; padding: 17px 23px; color: #fff; background: var(--red); border: 1px solid var(--red); font-size: 10px; font-weight: 700; letter-spacing: .16em; box-shadow: 5px 5px 0 var(--red-dark); transition: transform .15s, box-shadow .15s, background .15s; }
.settings .primary { width: 100%; margin-top: 23px; }
.primary:hover { background: var(--red-dark); transform: translate(2px, 2px); box-shadow: 3px 3px 0 #511411; }
.primary:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.primary:disabled { opacity: .5; cursor: wait; }
.primary span { margin-left: 14px; }
.catalog-status { margin: 17px 0 0; color: var(--muted); text-align: center; font-size: 9px; line-height: 1.4; }

.game { position: relative; width: min(780px, 100%); margin: 0 auto; padding: 32px 0 60px; }
.game.transitioning > :not(.round-transition) { pointer-events: none; }
.round-meta { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: var(--muted); font-size: 11px; letter-spacing: .1em; }
.text-button { justify-self: start; padding: 8px 0; color: var(--muted); background: transparent; border: 0; }
.text-button:hover { color: var(--red); }
.round-side { justify-self: end; display: flex; align-items: center; gap: 10px; }
.pill { justify-self: end; padding: 6px 10px; color: var(--green); border: 1px solid rgba(40, 87, 71, .3); font-size: 8px; font-weight: 700; }
.question-timer {
  --timer-progress: 1;
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green-dark);
  background: conic-gradient(var(--red) calc(var(--timer-progress) * 1turn), rgba(25, 39, 34, .12) 0);
  transition: color .2s, filter .2s;
}
.timer-face { width: 35px; height: 35px; display: flex; align-items: baseline; justify-content: center; border-radius: 50%; background: var(--paper); }
.timer-face strong { align-self: center; font-family: var(--display); font-size: 20px; line-height: 1; letter-spacing: 0; }
.timer-face small { margin-left: 1px; font-size: 7px; font-weight: 800; letter-spacing: 0; }
.question-timer.waiting { opacity: .5; }
.question-timer.urgent { color: var(--red); filter: drop-shadow(0 0 5px rgba(164, 44, 37, .28)); animation: timer-pulse .8s ease-in-out infinite alternate; }
.question-timer.expired { color: #fff; background: var(--red); animation: none; }
.question-timer.expired .timer-face { background: var(--red); }
.progress { height: 3px; margin: 12px 0 28px; background: var(--line); }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .35s; }

.crest-card { padding: 25px 20px 5px; text-align: center; background: rgba(252, 248, 237, .35); border: 1px solid rgba(194, 154, 61, .28); }
.crest-stage { height: 280px; display: flex; align-items: center; justify-content: center; gap: 48px; }
.crest-stage img { max-width: 245px; max-height: 250px; filter: drop-shadow(0 12px 10px rgba(25, 39, 34, .17)); }
.crest-stage img.loading { opacity: .18; }
.ornament { color: rgba(164, 44, 37, .28); font-size: 28px; }
.ornament-right { transform: scaleX(-1); }
.hint { min-height: 18px; margin: 3px 0 0; color: var(--red); font-size: 9px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
.crest-card h2 { margin: 13px 0 23px; font-size: clamp(32px, 5vw, 44px); line-height: 1.04; }

.answers { display: grid; gap: 10px; width: min(620px, 100%); margin: 17px auto 0; }
.answer { position: relative; min-height: 59px; padding: 13px 55px; color: var(--ink); background: rgba(252, 248, 237, .82); border: 1px solid var(--line); font-weight: 600; transition: border-color .15s, transform .15s, background .15s; }
.answer:hover:not(:disabled) { transform: translateX(4px); border-color: var(--green); background: var(--paper-light); }
.answer .key { position: absolute; left: 16px; top: 50%; translate: 0 -50%; width: 27px; height: 27px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); font-family: var(--serif); font-size: 12px; }
.answer.correct { color: #fff; background: var(--green); border-color: var(--green); }
.answer.wrong { color: #fff; background: var(--red); border-color: var(--red); }
.answer.correct .key, .answer.wrong .key { color: #fff; border-color: rgba(255,255,255,.45); }
.feedback { min-height: 48px; padding-top: 17px; text-align: center; color: var(--muted); font-size: 12px; }
.feedback a { color: var(--red); }

.round-transition { position: absolute; z-index: 5; inset: 32px 0 auto; min-height: 650px; padding: 58px 24px 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: var(--paper); border: 1px solid rgba(194, 154, 61, .42); animation: round-reveal .35s ease-out both; }
.round-transition::before, .round-transition::after { content: "✦"; position: absolute; top: 18px; color: var(--gold); font-size: 11px; }
.round-transition::before { left: 22px; }
.round-transition::after { right: 22px; }
.round-stamp { width: 138px; height: 152px; margin: 22px auto 20px; display: grid; place-content: center; color: var(--paper-light); background: var(--green); clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%); filter: drop-shadow(7px 8px 0 rgba(164, 44, 37, .16)); animation: round-stamp-in .5s cubic-bezier(.2, .85, .25, 1.25) .08s both; }
.round-stamp span { font-family: var(--display); font-size: 62px; font-weight: 900; line-height: .8; }
.round-stamp small { margin-top: 8px; color: var(--gold-light); font-size: 8px; font-weight: 800; letter-spacing: .22em; }
.round-transition h2 { margin: 0; font-size: clamp(34px, 5vw, 46px); }
.round-progress-copy { margin: 8px 0 24px; color: var(--red); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.transition-stats { width: min(500px, 100%); display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); }
.transition-stats span { padding: 14px 8px; color: var(--muted); border-left: 1px solid var(--line); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.transition-stats span:first-child { border-left: 0; }
.transition-stats strong { display: block; margin-bottom: 3px; color: var(--ink); font-family: var(--display); font-size: 25px; letter-spacing: 0; }
.transition-track { width: min(500px, 100%); height: 4px; margin-top: 27px; overflow: hidden; background: rgba(25, 39, 34, .12); }
.transition-track span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--green)); transform-origin: left; animation: round-progress 2.1s linear both; }
.next-round-label { margin: 11px 0 0; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .18em; }
.finish-game { margin-top: 24px; }

@keyframes round-reveal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes round-stamp-in { from { opacity: 0; transform: scale(.72) rotate(-4deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes round-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes timer-pulse { from { transform: scale(1); } to { transform: scale(1.07); } }

footer { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 23px 0 30px; display: flex; justify-content: space-between; color: var(--muted); border-top: 1px solid var(--line); font-size: 9px; letter-spacing: .08em; }
footer a { color: inherit; }
.footer-signoff { display: inline-flex; align-items: center; gap: 7px; }
.estelada { width: 24px; height: 16px; flex: 0 0 auto; border: 1px solid rgba(25, 39, 34, .18); }

@media (max-width: 820px) {
  .welcome { grid-template-columns: 1fr; gap: 55px; padding: 58px 0 68px; }
  .hero-copy { width: min(590px, 100%); margin: 0 auto; }
  .setup-wrap { width: min(520px, 100%); margin: 0 auto; }
  h1 { font-size: clamp(70px, 16vw, 100px); }
}

@media (max-width: 560px) {
  .topbar { width: calc(100% - 28px); height: 72px; }
  main, footer { width: calc(100% - 28px); }
  .brand-shield { width: 35px; height: 39px; }
  .brand-copy strong { display: grid; gap: 1px; font-size: 16px; line-height: .72; }
  .brand-copy small { font-size: 6px; letter-spacing: .14em; }
  .scoreboard { gap: 11px; }
  .scoreboard span { flex-direction: column; align-items: flex-end; gap: 0; font-size: 7px; }
  .scoreboard strong { font-size: 16px; line-height: 1; }
  .welcome { padding-top: 45px; }
  .hero-copy { padding-left: 15px; }
  .hero-emblem { width: 92px; right: -6px; }
  h1 { margin-top: 16px; line-height: .76; }
  h1 em { margin-left: 13px; text-shadow: 3px 3px 0 rgba(194, 154, 61, .2); }
  .intro { font-size: 17px; }
  .hero-stats span { min-width: 31%; padding: 0 10px; }
  .hero-stats strong { font-size: 20px; }
  .leaderboard { padding-inline: 15px; }
  .leaderboard-list { grid-template-columns: 1fr; }
  .setup-wrap { padding: 9px; }
  .settings { padding: 34px 20px 23px; box-shadow: 7px 8px 0 rgba(40, 87, 71, .1); }
  .segmented span { font-size: 10px; }
  .round-meta { grid-template-columns: auto 1fr auto; gap: 10px; }
  .round-side { gap: 6px; }
  .question-timer { width: 39px; height: 39px; }
  .timer-face { width: 31px; height: 31px; }
  .timer-face strong { font-size: 18px; }
  .pill { display: none; }
  .crest-stage { height: 235px; gap: 12px; }
  .crest-stage img { max-width: 185px; max-height: 205px; }
  .ornament { font-size: 17px; }
  .crest-card { padding-inline: 8px; }
  footer { flex-direction: column; gap: 8px; text-align: center; }
  .footer-signoff { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .round-transition, .round-stamp, .transition-track span, .question-timer { animation: none !important; }
}
