:root {
  --night: #121410;
  --night-2: #1b1e18;
  --paper: #f4efe4;
  --ink: #1b1914;
  --gold: #e4c27a;
  --gold-deep: #a9793a;
  --moss: #1e4634;
  --moss-ink: #d7f3e4;
  --miss: #4a2a26;
  --miss-ink: #f6e4df;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background:
    radial-gradient(ellipse at 50% -20%, rgba(228, 194, 122, 0.16), transparent 48%),
    radial-gradient(ellipse at 110% 80%, rgba(62, 86, 68, 0.45), transparent 42%),
    var(--night);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
}

body::before {
  content: "";
  position: fixed;
  top: -12vh;
  right: -18vw;
  width: min(88vw, 860px);
  height: min(88vw, 860px);
  background: url("/static/web.svg") center / contain no-repeat;
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 40;
  background: var(--gold);
  color: var(--ink);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
}

.skip:focus { top: 0.6rem; }

.top, main, footer, .flash { position: relative; z-index: 1; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-end;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.4rem 1.15rem 0.3rem;
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.35rem;
  color: rgba(244, 239, 228, 0.78);
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(228, 194, 122, 0.5);
  color: var(--gold);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

h1 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-family: var(--serif);
  font-weight: 520;
  font-size: clamp(2.4rem, 6vw, 3.5rem);
  letter-spacing: -0.035em;
  line-height: 0.95;
}

h1 a { color: inherit; text-decoration: none; }

.mark {
  width: 0.72em;
  height: 0.72em;
  color: var(--gold);
  flex: none;
}

.tagline {
  margin: 0.5rem 0 0;
  max-width: 36rem;
  color: #d8d3c4;
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  align-items: center;
  justify-content: flex-end;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.1rem;
  white-space: nowrap;
}

.sound-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
  display: block;
}

.sound-slash { display: none; }

.sound-toggle.is-muted .sound-wave { display: none; }
.sound-toggle.is-muted .sound-slash { display: block; }

.text-button, .primary, .ghost, .tile, .choice, .swatch {
  font: inherit;
  cursor: pointer;
}

.text-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.text-button:hover, .text-button:focus-visible { color: var(--paper); }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.15rem 2rem;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    rgba(28, 31, 25, 0.92);
  border-radius: 22px;
  padding: 1.15rem 1.15rem 1.3rem;
  box-shadow: inset 0 0 0 1px rgba(228, 194, 122, 0.22);
}

.kicker {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 0.72rem;
}

h2 {
  margin: 0.2rem 0 0.7rem;
  font-family: var(--serif);
  font-weight: 540;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  letter-spacing: -0.03em;
}

.lead { margin: 0 0 1rem; color: #d8d3c4; max-width: 40rem; }

label {
  display: grid;
  gap: 0.3rem;
  margin: 0 0 0.85rem;
  color: rgba(244, 239, 228, 0.8);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input, textarea, select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--paper);
  background: #121410;
  border: 1px solid rgba(228, 194, 122, 0.28);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  min-height: 48px;
}

textarea { min-height: 5.2rem; resize: vertical; }

input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.choice-row, .source-row, .actions, .swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 1rem;
}

.choice, .ghost, .primary {
  border-radius: 999px;
  min-height: 48px;
  padding: 0.65rem 1rem;
  border: 1px solid rgba(228, 194, 122, 0.45);
  background: transparent;
  color: var(--paper);
}

.choice[aria-pressed="true"], .primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}

.ghost { color: var(--gold); }

.primary { font-weight: 650; }

.swatch {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 0;
}

.swatch[aria-pressed="true"] { border-color: var(--paper); }

.editor { display: grid; gap: 0.6rem; margin: 0.2rem 0 1rem; }

details {
  border-radius: 16px;
  background: rgba(18, 20, 16, 0.55);
  box-shadow: inset 0 0 0 1px rgba(228, 194, 122, 0.16);
  padding: 0.35rem 0.8rem 0.2rem;
}

summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-family: var(--serif);
  font-size: 1.15rem;
}

.clue-edit {
  display: grid;
  gap: 0.2rem;
  margin: 0.3rem 0 0.8rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(244, 239, 228, 0.08);
}

.meters {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.room-code {
  font-family: var(--serif);
  font-size: clamp(2.8rem, 8vw, 4.2rem);
  letter-spacing: 0.18em;
  margin: 0.1rem 0 0.2rem;
  color: var(--gold);
}

.invite {
  margin: 0 0 0.8rem;
  color: #d8d3c4;
  overflow-wrap: anywhere;
}

.player-list, ol.scoreboard, .podium {
  list-style: none;
  margin: 0 0 0.95rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.player, .score-row, .podium-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: 14px;
  background: rgba(18, 20, 16, 0.55);
  box-shadow: inset 0 0 0 1px rgba(228, 194, 122, 0.12);
}

.dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  flex: none;
}

.player strong, .score-row strong, .who { font-weight: 650; }

.meta { margin-left: auto; color: rgba(244, 239, 228, 0.72); font-size: 0.85rem; }

.you { color: var(--gold); }

.play-layout {
  display: grid;
  gap: 1rem;
  align-items: start;
}

.play-layout > * { min-width: 0; }

.board-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 0.7rem;
}

.board-scroll { overflow-x: auto; padding-bottom: 0.4rem; }

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(6.8rem, 1fr));
  gap: 0.55rem;
  min-width: 40rem;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.category {
  margin: 0;
  min-height: 4.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.65rem 0.4rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #2a261f, #17150f);
  font-size: 0.76rem;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.3;
  box-shadow: inset 0 0 0 1px rgba(228, 194, 122, 0.16);
}

.tile {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 5.6rem;
  min-width: 0;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 42%),
    #243028;
  color: #f3e6c4;
  box-shadow: inset 0 0 0 1px rgba(228, 194, 122, 0.2);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.15rem;
  touch-action: manipulation;
}

.tile-value {
  font-family: var(--serif);
  font-size: 1.25rem;
}

.tile-mark {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  min-height: 0.9rem;
}

.tile:hover { transform: translateY(-1px); }

.tile.correct { background: var(--moss); color: var(--moss-ink); }
.tile.missed { background: var(--miss); color: var(--miss-ink); }
.tile.live { box-shadow: inset 0 0 0 2px var(--gold); }
.tile:disabled { cursor: default; }

aside.scoreboard { align-self: start; overflow: hidden; }

.score-row { align-items: center; }

.score-copy { display: grid; min-width: 0; }
.score-copy span { color: rgba(244, 239, 228, 0.7); font-size: 0.82rem; }

.silk {
  margin-left: auto;
  font-family: var(--serif);
  color: var(--gold);
  font-size: 1.15rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgba(10, 12, 9, 0.86);
  backdrop-filter: blur(4px);
}

.sheet {
  width: min(42rem, 100%);
  margin: 0 auto;
  max-height: min(92vh, 44rem);
  overflow: auto;
  background: #1c1f19;
  border-radius: 18px 18px 0 0;
  padding: 1.15rem 1.15rem 1.4rem;
  box-shadow: inset 0 0 0 1px rgba(228, 194, 122, 0.32);
}

.timer {
  height: 8px;
  border-radius: 999px;
  background: rgba(244, 239, 228, 0.14);
  overflow: hidden;
  margin: 0.7rem 0;
}

.timer span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--gold);
}

.timer.is-urgent span { background: #e7b8c0; }

.seconds {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.8rem;
  color: var(--gold);
}

.clue-copy {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.35;
  margin: 0.35rem 0 0.8rem;
}

.buzz {
  width: 100%;
  min-height: 4.6rem;
  border: 0;
  border-radius: 18px;
  background: var(--gold);
  color: var(--ink);
  font: inherit;
  font-size: 1.45rem;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.answer-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.answer-row input { flex: 1 1 12rem; }
.answer-row .primary, .answer-row .ghost { flex: 0 0 auto; }

.results { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.results li { display: flex; justify-content: space-between; gap: 0.6rem; }
.hit { color: var(--moss-ink); }
.miss { color: var(--miss-ink); }

.gold-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background: rgba(228, 194, 122, 0.18);
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.podium {
  display: grid;
  gap: 0.7rem;
}

.podium-card {
  align-items: center;
  padding: 0.8rem;
}

.podium-card .place {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--gold);
  width: 2rem;
}

.spider-badge, .score-spider { overflow: visible; flex: none; }
.podium-card .spider-badge { width: 7.2rem; height: 6rem; }
.score-spider { width: 2.8rem; height: 2.5rem; overflow: hidden; }

.panel > .primary,
.sheet > .primary { margin-top: 0.9rem; }

.flash {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 30;
  max-width: min(22rem, calc(100% - 2rem));
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: var(--miss);
  color: var(--miss-ink);
  box-shadow: inset 0 0 0 1px rgba(246, 228, 223, 0.25);
}

.flash[hidden] { display: none; }

.error { color: #f0b7ae; margin: 0.4rem 0; }

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.15rem 2rem;
  color: rgba(244, 239, 228, 0.62);
  font-size: 0.92rem;
}

footer a { color: var(--gold); }

@media (min-width: 960px) {
  .play-layout { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; }
  .modal { align-items: center; padding: 1.5rem; }
  .sheet { border-radius: 18px; }
}

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: stretch; }
  .status { justify-content: flex-start; }
  .board { grid-template-columns: repeat(5, minmax(8.2rem, 1fr)); min-width: 44rem; }
  .tile { min-height: 4.6rem; }
  .category { min-height: 3.4rem; font-size: 0.92rem; color: #d8d3c4; }
}

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: rise 180ms ease-out; }
  .spider.is-idle .spider-leg-odd,
  .spider.is-crawling .spider-leg-odd {
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: leg-scuttle var(--scuttle, 0.32s) ease-in-out infinite;
  }
  .spider.is-idle .spider-leg-even,
  .spider.is-crawling .spider-leg-even {
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: leg-scuttle var(--scuttle, 0.32s) ease-in-out infinite reverse;
  }
  .spider.is-idle .spider-body,
  .spider.is-crawling .spider-body {
    transform-box: fill-box;
    transform-origin: center;
    animation: spider-bob var(--scuttle, 0.32s) ease-in-out infinite;
  }
}

@keyframes leg-scuttle {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(13deg); }
}

@keyframes spider-bob {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(0.35px, 0.6px); }
}

@keyframes rise {
  from { transform: translateY(10px); }
}

@media (prefers-reduced-motion: reduce) {
  .spider.is-idle .spider-leg-odd,
  .spider.is-idle .spider-leg-even,
  .spider.is-idle .spider-body,
  .spider.is-crawling .spider-leg-odd,
  .spider.is-crawling .spider-leg-even,
  .spider.is-crawling .spider-body { animation: none; }
}
