:root {
  color-scheme: dark;
  --bg: #17111e;
  --panel: #241b2b;
  --panel-raised: #302337;
  --border: #594151;
  --ink: #fff6ef;
  --muted: #d4c3ce;
  --accent: #ff907a;
  --accent-light: #ffb1a2;
  --valid: #bcecc9;
  --pending: #f9dca2;
  --space: clamp(18px, 4vw, 54px);
  font-family: ui-sans-serif, system-ui, "Avenir Next", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main {
  width: min(100%, 1240px);
  min-height: 100svh;
  margin: auto;
  padding: 0 var(--space) max(36px, env(safe-area-inset-bottom));
}
main:fullscreen { overflow: auto; width: 100%; padding-inline: max(var(--space), calc((100% - 1036px) / 2)); background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 4px;
}
h1, h2, p { margin: 0; }
a { color: inherit; }
.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.masthead {
  min-height: 79px;
  border-bottom: 1px solid #443040;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding-top: env(safe-area-inset-top);
}
.brand { display: inline-flex; padding-block: 8px; }
.brand img { width: 112px; height: auto; }
.quiet, .primary {
  min-height: 46px;
  border-radius: 8px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  font-weight: 740;
}
.quiet { color: var(--ink); background: #251a2b; }
.quiet:hover { background: #36273c; border-color: #89667c; }
.primary { color: #27151c; background: var(--accent); border-color: var(--accent); }
.primary:hover { background: var(--accent-light); }
.primary span { margin-left: 8px; }
.fullscreen { min-height: 39px; font-size: .82rem; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.lobby {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.2fr);
  margin-top: clamp(34px, 9vh, 110px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #25182b;
  overflow: clip;
}
.intro { align-self: center; padding: clamp(24px, 5vw, 64px); padding-right: clamp(18px, 3vw, 36px); }
.intro h1 { font-size: clamp(4.6rem, 10vw, 9rem); line-height: .82; letter-spacing: -.095em; font-weight: 940; }
.intro h1 span { color: var(--accent); }
.intro > p { margin: 16px 0 24px; color: #f4dce0; max-width: 25ch; font-size: clamp(1rem, 1.65vw, 1.2rem); line-height: 1.4; }
.lobby-cover { width: 100%; height: 100%; min-height: 370px; object-fit: cover; object-position: 51% 50%; }
details { margin-top: 20px; font-size: .88rem; }
details summary { color: #f3c1b7; cursor: pointer; width: fit-content; }
details p { margin-top: 9px; color: var(--muted); line-height: 1.6; }
noscript { display: block; margin-top: 18px; }

.round-panel, .final-panel { max-width: 840px; margin: clamp(26px, 6vh, 66px) auto 0; }
.game-meta, .results-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.mode-label { display: block; font-size: .73rem; color: #f5b8ad; font-weight: 800; line-height: 1.45; }
.round-track, .final-rounds {
  display: flex; flex-wrap: wrap; margin: 8px 0 0; padding: 0; gap: 8px; list-style: none;
}
.round-track li, .final-rounds b {
  display: grid;
  width: 33px;
  height: 33px;
  place-content: center;
  border-radius: 6px;
  border: 1px solid #624c60;
  color: var(--muted);
  font-weight: 760;
}
.round-track [data-done] { color: var(--ink); background: #452e40; }
.round-track [aria-current] { color: #27151c; background: var(--accent); border-color: var(--accent); }
.score { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.score span, .clock span { display: block; color: var(--muted); font-size: .73rem; }
.score strong { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 880; }
.score small { color: var(--muted); font-size: .78rem; }
.round-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(11px, 2.8vw, 24px);
  margin-top: 22px;
  min-height: 86px;
}
.letter {
  width: clamp(62px, 10vw, 92px);
  height: clamp(66px, 11vw, 99px);
  display: grid;
  place-content: center;
  border-radius: 12px;
  background: #fde5d2;
  color: #361d2a;
  font-weight: 940;
  font-size: clamp(3.1rem, 7vw, 5rem);
  line-height: 1;
  box-shadow: 0 5px #bb716b;
}
.round-heading h2, .results h2, .paused h2 {
  margin-top: 2px;
  font-size: clamp(1.26rem, 5vw, 2.3rem);
  line-height: 1.08;
  letter-spacing: -.037em;
}
.clock { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.clock strong { display: block; font-size: clamp(1.7rem, 6vw, 2.8rem); font-weight: 900; line-height: 1.1; }
[data-urgent] .clock strong { color: var(--accent); }
progress {
  appearance: none;
  width: 100%;
  margin: 20px 0 15px;
  height: 6px;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
  background: #452e41;
}
progress::-webkit-progress-bar { background: #452e41; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.fields, .answer-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--panel);
  padding: 13px 15px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
}
.field:focus-within { border-color: #fcac9a; background: var(--panel-raised); }
.field > span { color: #f8d7d3; font-size: .8rem; font-weight: 760; }
.field input {
  display: block;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-bottom: 1px solid #795668;
  border-radius: 2px;
  padding: 7px 1px;
  background: transparent;
  color: var(--ink);
  font-size: 1.14rem;
  font-weight: 680;
}
.field input::placeholder { color: #c2aab8; }
.field input:focus-visible { outline-offset: 2px; }
.field input[data-wrong] { border-bottom-color: var(--accent); }
.field-feedback { color: #ffb9a8; font-size: .72rem; min-height: 17px; }
.round-actions { margin-top: 16px; }
.stop-button { min-width: 106px; }
.filled, .key-guide { color: var(--muted); font-size: .82rem; }
.key-guide { margin-top: 14px; }
.paused, .final-panel, .results { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: clamp(17px, 4vw, 30px); }
.paused { margin-top: 6px; }
.paused p { margin: 8px 0 14px; color: var(--muted); }
.results { margin-top: 24px; }
.answer-results { margin: 15px 0 20px; }
.answer-result {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 7px;
  border: 1px solid #60495d;
  border-radius: 8px;
  background: #2d2231;
  padding: 12px;
}
.answer-result .given { display: block; overflow-wrap: anywhere; font-size: 1rem; }
.answer-result p { color: var(--muted); margin-top: 5px; font-size: .78rem; line-height: 1.4; }
.answer-result .example { color: #ecc4b0; }
.points { font-variant-numeric: tabular-nums; }
[data-verdict="valid"] .points { color: var(--valid); }
[data-verdict="pending"] .points { color: var(--pending); }
.review-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.review-actions button { min-height: 38px; padding: 5px 8px; font-size: .72rem; }
.final-panel { margin-top: clamp(34px, 10vh, 88px); }
.final-panel h2 { font-size: clamp(2rem, 6.2vw, 4rem); line-height: 1.05; letter-spacing: -.055em; }
.final-score { margin: 8px 0; font-variant-numeric: tabular-nums; }
.final-score strong { color: var(--accent); font-size: clamp(3rem, 10vw, 6rem); line-height: .95; font-weight: 920; }
.final-score small, #final-detail { color: var(--muted); }
.final-rounds { margin: 16px 0 18px; }
.final-rounds li { display: flex; align-items: center; gap: 7px; color: var(--muted); padding-right: 7px; font-size: .85rem; }
.final-rounds b { color: var(--ink); }

@media (max-width: 660px) {
  .masthead { min-height: 63px; }
  .brand img { width: 101px; }
  .lobby { margin-top: 22px; grid-template-columns: 1fr; }
  .lobby-cover { grid-row: 1; height: clamp(175px, 44vw, 240px); min-height: 0; object-position: 50% 47%; }
  .intro { padding: 22px; }
  .intro h1 { font-size: clamp(4.1rem, 13vw, 6rem); }
  .intro > p { margin-block: 12px 18px; }
  .field { padding: 10px 10px 6px; gap: 5px; }
  .field input { font-size: 1rem; }
  .fields, .answer-results { gap: 8px; }
  .answer-result { padding: 9px; }
}
@media (max-width: 430px) {
  .answer-results { grid-template-columns: 1fr; }
  .review-actions button { min-height: 44px; }
}
@media (pointer: coarse) { .key-guide { display: none; } }

.word-languages { display: flex; gap: 5px; }
.word-languages a {
  display: grid;
  place-items: center;
  min-width: 38px;
  min-height: 44px;
  padding-inline: 5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 750;
  text-decoration: none;
}
.word-languages a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #27151c;
}
@media (max-width: 430px) {
  .masthead { gap: 8px; }
  .brand img { width: 78px; }
  .fullscreen { padding-inline: 7px; font-size: .73rem; }
  .word-languages { gap: 3px; }
  .word-languages a { min-width: 34px; }
}
