@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:ital,wght@0,400;0,600;0,700;0,800;1,700&display=swap');

/*
 * Eldoria — a platform for real-time party games on a shared TV.
 * Crayon Storybook theme: cream construction-paper page, crayon-box brights,
 * chunky cut-paper sticker shapes, squishy candy buttons, rounded display type.
 * TV shows the board (.board); phones show controls (.phone).
 */

:root {
  --paper: #fff6e3;
  --paper-2: #ffedca;
  --card: #fffdf7;
  --ink: #4a3526;
  --ink-soft: #98826c;
  --outline: #41301f;

  --red: #ff5d5d;
  --red-deep: #e23b48;
  --sun: #ffc233;
  --sun-deep: #f0a31e;
  --sky: #45c4e8;
  --sky-deep: #2a9fcc;
  --leaf: #6fcf73;
  --grape: #a472e8;
  --berry: #ff8fc0;

  --good: #2fb96f;
  --bad: #ef4d5b;

  /* cut-paper: hard offset "stack" + soft cast shadow */
  --pop: 0 7px 0 rgba(65, 48, 31, 0.16), 0 16px 26px rgba(150, 95, 35, 0.16);
  --pop-sm: 0 4px 0 rgba(65, 48, 31, 0.15), 0 9px 16px rgba(150, 95, 35, 0.16);
  --radius: 26px;
  --display: "Baloo 2", ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  --body: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--body);
  font-weight: 600;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(closest-side at 12% 18%, rgba(69, 196, 232, 0.18), transparent),
    radial-gradient(closest-side at 88% 12%, rgba(255, 143, 192, 0.20), transparent),
    radial-gradient(closest-side at 80% 92%, rgba(111, 207, 115, 0.18), transparent),
    radial-gradient(closest-side at 18% 88%, rgba(255, 194, 51, 0.20), transparent),
    radial-gradient(rgba(65, 48, 31, 0.05) 1.6px, transparent 1.7px);
  background-size: 60% 60%, 55% 55%, 60% 60%, 55% 55%, 26px 26px;
  background-position: 0 0, 0 0, 0 0, 0 0, 0 0;
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; line-height: 1.05; }
a { color: var(--sky-deep); }

.crest {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--red);
}
.crest::first-letter { color: inherit; }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  border: 3px solid var(--outline);
  background: var(--sun);
  color: var(--outline);
  font: 800 1.15rem/1 var(--display);
  letter-spacing: 0.01em;
  padding: 0.85em 1.5em;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--sun-deep), 0 12px 20px rgba(150, 95, 35, 0.22);
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.04) saturate(1.05); }
.btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--sun-deep), 0 4px 10px rgba(150, 95, 35, 0.22);
}
.btn[disabled], .btn.is-disabled {
  background: #e9e0cf;
  color: #a99c87;
  border-color: #cfc3ad;
  box-shadow: 0 6px 0 #d4c8b2;
  cursor: not-allowed;
  transform: none;
}
.btn--ghost {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 6px 0 rgba(65, 48, 31, 0.14);
}
.btn--block { width: 100%; }

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--pop);
}

/* ============================================================= TV / BOARD = */
.board {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.2vh, 2rem);
  padding: clamp(1.2rem, 4vw, 3rem);
  text-align: center;
  overflow: hidden;
}
/* floating storybook doodles */
.board::before,
.board::after {
  content: "";
  position: absolute;
  font-size: clamp(3rem, 9vw, 7rem);
  opacity: 0.5;
  pointer-events: none;
  animation: float 7s ease-in-out infinite;
}
.board::before { content: "🌈"; top: 6%; left: 5%; }
.board::after { content: "⭐"; bottom: 7%; right: 6%; animation-delay: -3.5s; }

.board__title { font-size: clamp(1.8rem, 5vw, 3.8rem); color: var(--ink); }
.board__sub { color: var(--ink-soft); font-size: clamp(1rem, 1.9vw, 1.45rem); font-weight: 700; }

.round-tag {
  font-family: var(--display);
  font-weight: 700;
  color: var(--grape);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: clamp(0.9rem, 1.5vw, 1.2rem);
}

/* lobby */
.lobby {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  padding: clamp(1.6rem, 3vw, 2.8rem);
  max-width: 1100px;
  width: 100%;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.join-card { text-align: center; }
.qr {
  background: #fff;
  padding: 16px;
  border: 3px solid var(--outline);
  border-radius: 22px;
  width: clamp(170px, 24vw, 280px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 0 auto;
  box-shadow: var(--pop-sm);
  transform: rotate(-2deg);
}
.qr svg { width: 100%; height: 100%; display: block; }
.join-url { margin-top: 1rem; color: var(--ink-soft); font-size: 0.95rem; word-break: break-all; }
.code-chip {
  display: inline-flex;
  gap: 0.1em;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6.5vw, 4.4rem);
  letter-spacing: 0.16em;
  color: var(--outline);
  background: var(--sun);
  border: 3px dashed var(--outline);
  border-radius: 18px;
  padding: 0.2em 0.55em 0.2em 0.7em;
  margin-top: 0.7rem;
  box-shadow: var(--pop-sm);
  transform: rotate(1.5deg);
}

.roster {
  list-style: none;
  margin: 1.3rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
}
.roster li {
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 999px;
  padding: 0.45em 1.1em;
  font-family: var(--display);
  font-weight: 700;
  color: var(--ink);
  font-size: clamp(1rem, 1.7vw, 1.3rem);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  box-shadow: var(--pop-sm);
}
.roster li:nth-child(5n+1) { background: #ffe1e1; }
.roster li:nth-child(5n+2) { background: #d9f3fb; }
.roster li:nth-child(5n+3) { background: #e3f8e4; }
.roster li:nth-child(5n+4) { background: #fff0cc; }
.roster li:nth-child(5n+5) { background: #efe3fc; }
.roster li:nth-child(odd) { transform: rotate(-2deg); }
.roster li:nth-child(even) { transform: rotate(2deg); }
.roster .host-badge { color: var(--sun-deep); font-size: 0.85em; font-weight: 800; }
.roster.roster--status li.done { border-color: var(--good); background: #e3f8e4; color: var(--good); }
.roster.roster--status li.waiting { opacity: 0.55; }
.tick { color: var(--good); }
.hourglass { color: var(--ink-soft); }

/* guesser spotlight */
.spotlight { font-size: clamp(1.4rem, 2.8vw, 2.2rem); }
.spotlight strong { color: var(--red); }

/* clue cards on the board */
.clue-grid {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.9rem, 1.8vw, 1.4rem);
  justify-content: center;
  max-width: 1100px;
}
.clue-card {
  background: var(--card);
  color: var(--ink);
  border: 4px solid var(--sky);
  border-radius: 20px;
  padding: clamp(0.7rem, 1.8vw, 1.25rem) clamp(1.1rem, 2.6vw, 2rem);
  font-family: var(--display);
  font-size: clamp(1.4rem, 3.2vw, 2.5rem);
  font-weight: 700;
  box-shadow: var(--pop-sm);
  /* opacity-only entrance so the per-card rotate() tilts below are preserved */
  animation: appear 0.4s ease both;
}
.clue-grid .clue-card:nth-child(4n+1) { border-color: var(--red); transform: rotate(-2.5deg); }
.clue-grid .clue-card:nth-child(4n+2) { border-color: var(--sky); transform: rotate(1.5deg); }
.clue-grid .clue-card:nth-child(4n+3) { border-color: var(--leaf); transform: rotate(-1deg); }
.clue-grid .clue-card:nth-child(4n+4) { border-color: var(--grape); transform: rotate(2.5deg); }
.clue-grid .clue-card:nth-child(2) { animation-delay: 0.06s; }
.clue-grid .clue-card:nth-child(3) { animation-delay: 0.12s; }
.clue-grid .clue-card:nth-child(4) { animation-delay: 0.18s; }
.clue-grid .clue-card:nth-child(5) { animation-delay: 0.24s; }
.clue-grid .clue-card:nth-child(6) { animation-delay: 0.30s; }
.clue-card.struck {
  background: #fbeeee;
  color: var(--ink-soft);
  border-color: #f3c4c4 !important;
  text-decoration: line-through;
  text-decoration-color: var(--bad);
  text-decoration-thickness: 3px;
  font-size: clamp(1.05rem, 2.3vw, 1.7rem);
  box-shadow: none;
  transform: rotate(-3deg) !important;
}
.clue-card .why {
  display: block;
  font-family: var(--body);
  font-weight: 800;
  font-size: 0.42em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--bad);
  margin-top: 0.35em;
}
.clue-card .by {
  display: block;
  font-family: var(--body);
  font-weight: 800;
  font-size: 0.4em;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--sky-deep);
  margin-top: 0.45em;
}
.clue-card.struck .by { color: var(--ink-soft); }

/* result */
.reveal-word {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 8.5vw, 6rem);
  color: var(--grape);
  -webkit-text-stroke: 3px var(--outline);
  paint-order: stroke fill;
  animation: bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.verdict { font-family: var(--display); font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 800; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.guess-echo { color: var(--ink-soft); font-size: clamp(1rem, 2vw, 1.45rem); font-weight: 700; }
.scoreline { color: var(--ink); font-size: clamp(1rem, 2vw, 1.45rem); font-weight: 700; }

/* finale */
.grade {
  position: relative;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(6rem, 24vw, 16rem);
  line-height: 0.9;
  color: var(--sun);
  -webkit-text-stroke: 5px var(--outline);
  paint-order: stroke fill;
  animation: bounce-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.grade::before {
  content: "";
  position: absolute;
  inset: -18% -18%;
  z-index: -1;
  background:
    conic-gradient(from 0deg, var(--sun) 0 18deg, transparent 18deg 36deg,
      var(--sun) 36deg 54deg, transparent 54deg 72deg, var(--sun) 72deg 90deg,
      transparent 90deg 108deg, var(--sun) 108deg 126deg, transparent 126deg 144deg,
      var(--sun) 144deg 162deg, transparent 162deg 180deg, var(--sun) 180deg 198deg,
      transparent 198deg 216deg, var(--sun) 216deg 234deg, transparent 234deg 252deg,
      var(--sun) 252deg 270deg, transparent 270deg 288deg, var(--sun) 288deg 306deg,
      transparent 306deg 324deg, var(--sun) 324deg 342deg, transparent 342deg 360deg);
  border-radius: 50%;
  opacity: 0.28;
  animation: spin 28s linear infinite;
}
/* An emoji glyph is taller than the tight line-box tuned for letter grades, so
   it would bleed into the neighbouring lines. Give the emoji finales room. */
.grade--emoji { line-height: 1.25; }
.recap {
  list-style: none; padding: 0; margin: 1.2rem 0 0;
  display: grid; gap: 0.5rem; width: min(560px, 92vw);
}
.recap li {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  padding: 0.55em 1em; border-radius: 14px;
  background: #fff; border: 3px solid var(--outline);
  font-weight: 700;
  box-shadow: var(--pop-sm);
}
.recap .word { font-family: var(--display); font-weight: 700; }

/* =============================================================== PHONE === */
.phone {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: clamp(1.1rem, 5vw, 1.8rem);
  justify-content: center;
}
.phone__head { text-align: center; }
.phone__head .crest { font-size: 1.05rem; }
.phone h2 { font-size: 1.9rem; margin-top: 0.25rem; color: var(--ink); }
.phone .muted { color: var(--ink-soft); }
.phone .panel { padding: 1.4rem; animation: pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.field {
  width: 100%;
  font: 800 1.6rem var(--display);
  padding: 0.75em 0.7em;
  border-radius: 18px;
  border: 3px solid var(--outline);
  background: #fff;
  color: var(--ink);
  text-align: center;
  box-shadow: inset 0 2px 6px rgba(65, 48, 31, 0.08);
}
.field::placeholder { color: #c9bba6; font-weight: 700; }
.field:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(69, 196, 232, 0.35); }

.field-hint { margin: -0.3rem 0 -0.2rem; font-size: 0.85rem; }

.form-stack { display: grid; gap: 1rem; }

.secret-word {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 13vw, 3.6rem);
  color: var(--grape);
  text-align: center;
  letter-spacing: 0.01em;
  -webkit-text-stroke: 2.5px var(--outline);
  paint-order: stroke fill;
  animation: bounce-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
/* Hide the secret word until the giver focuses the clue box, so the guesser
   can't read it from a glance. Blurred (not removed) to keep the layout
   stable and signal "tap to reveal". */
.secret-word--masked { filter: blur(16px); transition: filter 0.18s ease; user-select: none; }
.panel:has(.field:focus) .secret-word--masked { filter: none; user-select: auto; }
.label-kicker {
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  color: var(--sun-deep);
}
.flash {
  background: #ffe1e4;
  border: 3px solid var(--bad);
  color: var(--red-deep);
  border-radius: 16px;
  padding: 0.7em 1em;
  text-align: center;
  font-weight: 700;
  font-size: 0.98rem;
  box-shadow: var(--pop-sm);
}
.error-text { color: var(--bad); text-align: center; font-size: 0.95rem; font-weight: 800; }

.role-pill {
  align-self: center;
  background: var(--sky);
  border: 3px solid var(--outline);
  color: var(--outline);
  border-radius: 999px;
  padding: 0.4em 1.2em;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: var(--pop-sm);
  transform: rotate(-2deg);
}
.role-pill.guesser { background: var(--sun); }

.waiting-dots { text-align: center; color: var(--ink-soft); font-size: 1.05rem; }
.big-status { text-align: center; font-size: 1.4rem; line-height: 1.45; font-weight: 700; }
.big-status strong { color: var(--red); font-family: var(--display); }

/* landing */
.landing {
  position: relative;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.6rem; padding: 2rem; text-align: center;
  overflow: hidden;
}
.landing::before { content: "✏️"; position: absolute; top: 10%; right: 12%; font-size: clamp(2.5rem, 8vw, 5rem); opacity: 0.55; animation: float 6s ease-in-out infinite; }
.landing::after { content: "📚"; position: absolute; bottom: 9%; left: 11%; font-size: clamp(2.5rem, 8vw, 5rem); opacity: 0.55; animation: float 6s ease-in-out infinite -3s; }
.landing h1 { font-size: clamp(2.8rem, 10vw, 5.2rem); color: var(--red); }
.landing p { color: var(--ink); max-width: 32rem; line-height: 1.5; font-weight: 700; }

/* --------------------------------------------------------------- catalog */
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 20rem));
  gap: 1.4rem; width: 100%; max-width: 66rem; justify-content: center;
}
.catalog-card { text-align: center; display: grid; gap: 0.5rem; align-content: start; }
.catalog-card h2 { font-size: 1.7rem; color: var(--red); }
.catalog-card .btn { margin-top: 0.6rem; }

.center { text-align: center; }
.stack { display: grid; gap: 0.9rem; place-items: center; }

/* ------------------------------------------------------------------ motion */
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.82) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes bounce-in {
  0%   { opacity: 0; transform: scale(0.5) rotate(-6deg); }
  60%  { opacity: 1; transform: scale(1.08) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-14px) rotate(4deg); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* ----------------------------------------------------- emoji reactions */
/* TV: stacked toasts in the bottom-right corner, newest at the bottom. */
.reactions-layer {
  position: fixed;
  right: clamp(12px, 2vw, 28px);
  bottom: clamp(12px, 2vw, 28px);
  z-index: 50;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0.6rem;
  pointer-events: none;
}
.reaction-toast {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 999px;
  padding: 0.35em 0.95em 0.35em 0.6em;
  box-shadow: var(--pop-sm);
  font-family: var(--display);
  font-weight: 700;
  color: var(--ink);
  animation: toast-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.reaction-toast__emoji { font-size: clamp(1.9rem, 3.8vw, 3.1rem); line-height: 1; }
.reaction-toast__name { font-size: clamp(0.9rem, 1.5vw, 1.3rem); padding-right: 0.2em; }
.reaction-toast.is-leaving { animation: toast-out 0.5s ease forwards; }

@keyframes toast-in {
  0%   { opacity: 0; transform: translateX(40px) scale(0.6); }
  60%  { opacity: 1; transform: translateX(-6px) scale(1.06); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(30px) scale(0.7); }
}

/* --------------------------------------------------- board voice controls */
/* Opt-in host voice, tucked into the TV's corner: a toggle plus a picker for
   choosing the least-robotic of the OS's installed voices. */
.voice-controls {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.voice-toggle,
.voice-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  border: 3px solid var(--outline);
  background: var(--card);
  color: var(--ink);
  font: 800 0.95rem/1 var(--display);
  padding: 0.55em 0.95em;
  border-radius: 999px;
  box-shadow: var(--pop-sm);
  cursor: pointer;
}
.voice-toggle:hover { filter: brightness(1.03) saturate(1.04); }
.voice-toggle.is-on { background: var(--sun); }
.voice-toggle__icon { font-size: 1.2rem; line-height: 1; }
.voice-picker { max-width: 12rem; }
.voice-picker:empty { display: none; } /* nothing to pick until voices load */

/* Phone: the tappable reaction palette shown while waiting. */
.reaction-bar { margin-top: 0.6rem; text-align: center; }
.reaction-bar__label {
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 0.6rem;
}
.reaction-bar__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}
.reaction-form { margin: 0; display: inline-flex; }
.reaction-btn {
  width: 3.3rem;
  height: 3.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  line-height: 1;
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(65, 48, 31, 0.16);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.reaction-btn:active { transform: translateY(4px); box-shadow: 0 0 0 rgba(65, 48, 31, 0.16); }
.reaction-bar__grid .reaction-form:nth-child(5n+1) .reaction-btn { background: #ffe1e1; }
.reaction-bar__grid .reaction-form:nth-child(5n+2) .reaction-btn { background: #d9f3fb; }
.reaction-bar__grid .reaction-form:nth-child(5n+3) .reaction-btn { background: #e3f8e4; }
.reaction-bar__grid .reaction-form:nth-child(5n+4) .reaction-btn { background: #fff0cc; }
.reaction-bar__grid .reaction-form:nth-child(5n+5) .reaction-btn { background: #efe3fc; }

/* ------------------------------------------------------ wavelength spectrum */
/* The shared spectrum band: TV clueing/dialing/reveal + the psychic's phone. */
.spectrum { width: min(52rem, 92%); margin: 1.6rem auto 0; }
.spectrum--phone { width: 100%; margin-top: 0.8rem; }
.spectrum__ends {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--display);
  font-weight: 800;
  color: var(--ink);
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  margin-bottom: 0.5rem;
}
.spectrum--phone .spectrum__ends, .dial .spectrum__ends { font-size: 1rem; }
.spectrum__band {
  position: relative;
  height: clamp(2.6rem, 6vw, 4rem);
  background: linear-gradient(90deg, #d9f3fb, var(--paper-2), #ffe1e1);
  border: 4px solid var(--outline);
  border-radius: 999px;
  box-shadow: var(--pop-sm);
  overflow: visible;
}
.spectrum--phone .spectrum__band { height: 2.4rem; }
.spectrum__zone { position: absolute; top: 0; bottom: 0; }
.spectrum__zone--1 { background: rgba(255, 194, 51, 0.45); }
.spectrum__zone--2 { background: rgba(240, 163, 30, 0.55); }
.spectrum__zone--3 { background: rgba(111, 207, 115, 0.65); }
.spectrum__zone--4 { background: var(--good); }
.spectrum__target {
  position: absolute;
  top: -0.55rem; bottom: -0.55rem;
  width: 6px;
  margin-left: -3px;
  background: var(--outline);
  border-radius: 3px;
  z-index: 3;
}
.spectrum__target-flag {
  position: absolute;
  top: -1.7rem; left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.95rem;
  background: var(--outline);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.05em 0.55em;
  white-space: nowrap;
}
.spectrum__tick {
  position: absolute;
  top: 15%; bottom: 15%;
  width: 4px;
  margin-left: -2px;
  background: var(--sky-deep);
  border-radius: 2px;
  z-index: 2;
}
.spectrum__tick-name {
  position: absolute;
  top: calc(100% + 0.9rem); left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.75rem, 1.4vw, 1rem);
  font-weight: 800;
  color: var(--ink-soft);
  white-space: nowrap;
}
/* Alternate label rows so neighbouring names don't pile up. */
.spectrum__tick--low .spectrum__tick-name { top: calc(100% + 2.1rem); }
.spectrum--reveal { margin-bottom: 3.4rem; }
.spectrum__team {
  position: absolute;
  top: -0.8rem; bottom: -0.8rem;
  width: 10px;
  margin-left: -5px;
  background: var(--red);
  border: 3px solid var(--outline);
  border-radius: 6px;
  z-index: 4;
}
.spectrum__team-label {
  position: absolute;
  bottom: calc(100% + 0.35rem); left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(0.85rem, 1.6vw, 1.15rem);
  background: var(--red);
  color: #fff;
  border: 3px solid var(--outline);
  border-radius: 999px;
  padding: 0.05em 0.6em;
  white-space: nowrap;
}
/* Team dial landed on (or near) the target: raise the target's stem and flag
   above the team pill so both numbers stay readable. */
.spectrum--stacked-labels { margin-top: 3rem; }
.spectrum--stacked-labels .spectrum__target { top: -2.75rem; }

/* The clue on the TV during dialing (and echoed on phones). */
.clue-banner {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  color: var(--ink);
  background: var(--card);
  border: 4px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--pop-sm);
  padding: 0.5em 0.9em;
  display: inline-block;
  margin-top: 0.8rem;
  transform: rotate(-1deg);
}
.clue-banner--phone { font-size: 1.25rem; display: block; text-align: center; transform: none; margin: 0.4rem 0 0.9rem; }

/* Phone dial: the range slider players drag. */
.dial { width: 100%; display: grid; gap: 0.55rem; }
.dial__slider {
  width: 100%;
  height: 2.2rem;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, #d9f3fb, var(--paper-2), #ffe1e1);
  border: 3px solid var(--outline);
  border-radius: 999px;
  box-shadow: var(--pop-sm);
}
.dial__slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 2.6rem; height: 2.6rem;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid var(--outline);
  box-shadow: 0 3px 0 rgba(65, 48, 31, 0.2);
  cursor: grab;
}
.dial__slider::-moz-range-thumb {
  width: 2.6rem; height: 2.6rem;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid var(--outline);
  box-shadow: 0 3px 0 rgba(65, 48, 31, 0.2);
  cursor: grab;
}
.dial__readout {
  text-align: center;
  font-family: var(--display);
  font-weight: 800;
  color: var(--ink);
  font-size: 1.1rem;
}

/* -------------------------------------------------------------- hot streak */
/* TV: the grid of every player's face-up tableau. */
.hs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.1rem;
  width: min(76rem, 96%);
  margin: 1.6rem auto 0;
}
.hs-player {
  background: var(--card);
  border: 4px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--pop-sm);
  padding: 0.9rem 1rem 1rem;
  text-align: left;
  display: grid;
  gap: 0.55rem;
  align-content: start;
}
.hs-player--turn {
  border-color: var(--sun-deep);
  animation: hs-glow 1.5s ease-in-out infinite;
}
@keyframes hs-glow {
  0%, 100% { box-shadow: var(--pop-sm), 0 0 0 0 rgba(255, 194, 51, 0.7); }
  50%      { box-shadow: var(--pop-sm), 0 0 0 12px rgba(255, 194, 51, 0); }
}
/* Hands that are out of the round sit dimmed behind their stamp. */
.hs-player--busted, .hs-player--stayed, .hs-player--frozen { opacity: 0.55; }
.hs-player--streak7 { border-color: var(--sun-deep); background: #fff4d6; }
.hs-player__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}
.hs-player__name { font-family: var(--display); font-weight: 800; font-size: 1.25rem; }
.hs-player__bank { color: var(--ink-soft); font-weight: 800; white-space: nowrap; }
.hs-player__score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
}
.hs-player__score strong { font-family: var(--display); font-size: 1.3rem; }

/* Face-up cards. */
.hs-tableau {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 3rem;
}
.hs-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 3rem;
  padding: 0 0.45rem;
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 10px;
  box-shadow: 0 3px 0 rgba(65, 48, 31, 0.14);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--ink);
}
.hs-card--adder { background: #e3f8e4; color: var(--good); }
.hs-card--multiplier { background: #efe3fc; color: var(--grape); }
.hs-card--chance { background: #d9f3fb; }
.hs-tableau--phone .hs-card { height: 2.4rem; min-width: 1.9rem; font-size: 1rem; }
.hs-empty { color: var(--ink-soft); font-size: 0.95rem; }

/* The freshly flipped card pops so a flip is obvious from the couch. */
.hs-card--fresh {
  animation: hs-flip-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes hs-flip-in {
  0%   { opacity: 0; transform: perspective(400px) rotateY(90deg) scale(1.6); }
  60%  { opacity: 1; transform: perspective(400px) rotateY(0) scale(1.3); }
  100% { opacity: 1; transform: none; }
}

/* The round result is held hidden during a staggered flip, then popped in once
   the last card lands (see hs_flip_controller) so the score can't run ahead. */
.hs-player__score--reveal {
  animation: hs-score-pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes hs-score-pop {
  0%   { opacity: 0; transform: scale(0.7); }
  100% { opacity: 1; transform: none; }
}

/* How a hand left the round. */
.hs-stamp {
  display: inline-block;
  font-family: var(--display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
  border: 3px solid currentColor;
  border-radius: 8px;
  padding: 0.05em 0.5em;
  transform: rotate(-5deg);
}
.hs-stamp--busted { color: var(--bad); }
.hs-stamp--frozen { color: var(--sky-deep); }
.hs-stamp--stayed { color: var(--good); }
.hs-stamp--active { color: var(--good); }
.hs-stamp--streak7 { color: var(--sun-deep); }

/* Phone: the big press-your-luck buttons. */
.hs-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.hs-actions .btn { font-size: 1.3rem; padding: 1.05em 0.5em; }
.hs-btn--hit { background: var(--red); color: #fff; box-shadow: 0 6px 0 var(--red-deep), 0 12px 20px rgba(150, 95, 35, 0.22); }
.hs-btn--hit:active { box-shadow: 0 1px 0 var(--red-deep), 0 4px 10px rgba(150, 95, 35, 0.22); }
.hs-btn--stay { background: var(--sky); color: var(--outline); box-shadow: 0 6px 0 var(--sky-deep), 0 12px 20px rgba(150, 95, 35, 0.22); }
.hs-btn--stay:active { box-shadow: 0 1px 0 var(--sky-deep), 0 4px 10px rgba(150, 95, 35, 0.22); }

/* --------------------------------------------------------------- play nine */
/* TV: every player's 2x4 grid, four columns of two stacked cards. */
.pn-tables {
  display: grid;
  /* A tableau (four cards + padding) is ~14.4rem wide; narrower tracks would
     let the cards overflow into the next card. Keep columns at least that wide
     so 8 players wrap onto a second row instead of colliding. */
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.1rem;
  width: min(82rem, 97%);
  margin: 1.2rem auto 0;
  justify-content: center;
}
.pn-player {
  background: var(--card);
  border: 4px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--pop-sm);
  padding: 0.8rem 0.9rem 0.9rem;
  display: grid;
  gap: 0.6rem;
  align-content: start;
  text-align: left;
}
.pn-player--turn { border-color: var(--sun-deep); animation: hs-glow 1.5s ease-in-out infinite; }
.pn-player--ready { border-color: var(--leaf); background: #eafbe9; }
.pn-player--out { background: #f3ecff; }
.pn-player__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.2rem 0.5rem; }
.pn-player__name { font-family: var(--display); font-weight: 800; font-size: 1.15rem; min-width: 0; }
.pn-player__tag, .pn-player__bank { color: var(--ink-soft); font-weight: 800; white-space: nowrap; font-size: 0.9rem; }
.pn-player__score { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--ink-soft); }
.pn-player__score strong { font-family: var(--display); font-size: 1.25rem; color: var(--ink); }

.pn-grid { display: flex; gap: 0.4rem; justify-content: center; }
.pn-col { display: flex; flex-direction: column; gap: 0.4rem; border-radius: 12px; padding: 2px; }
.pn-col--matched {
  background: repeating-linear-gradient(45deg, rgba(111, 207, 115, 0.28), rgba(111, 207, 115, 0.28) 6px, transparent 6px, transparent 12px);
  box-shadow: 0 0 0 3px var(--leaf);
}

.pn-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 3.2rem;
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 10px;
  box-shadow: 0 3px 0 rgba(65, 48, 31, 0.14);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ink);
}
.pn-card--ace  { background: #efe0ff; color: var(--grape); }
.pn-card--zero { background: #fffaf0; color: var(--ink-soft); }
.pn-card--low  { background: #e3f8e4; color: var(--good); }
.pn-card--mid  { background: #fff0cf; color: var(--sun-deep); }
.pn-card--high { background: #ffe1e1; color: var(--red-deep); }
.pn-card--down {
  color: #fff;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.35), transparent 40%), var(--grape);
}
/* The held card sliding into hand still uses the simple flip-in reveal. */
.pn-card--fresh { animation: hs-flip-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* A single grid card mid-reveal: a real two-sided flip. Two faces (the ★ back
   and the number front) are stacked in one grid cell and share the inner's 3D
   rotation; backface-visibility hides whichever is turned away. The spin is
   opt-in (pn-flip--spin, added by the pn_flip controller for a new flip only),
   so a re-rendered card sits still on its face. Works for both the TV card
   (pn-card) and phone slot (pn-slot) sizes — the faces carry the sizing. */
.pn-flip { display: inline-flex; perspective: 600px; }
.pn-flip__inner { display: inline-grid; transform-style: preserve-3d; }
.pn-flip__face { grid-area: 1 / 1; backface-visibility: hidden; }
.pn-flip__back { transform: rotateY(180deg); }
.pn-flip--spin .pn-flip__inner { animation: pn-flip 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes pn-flip {
  from { transform: rotateY(180deg); }
  to   { transform: rotateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .pn-flip--spin .pn-flip__inner { animation: none; }
}

/* A card named inside a sentence/button — a mini chip sized to the line so
   "Take", "In hand:", "swap in your …" clearly point at a card, not a number. */
.pn-card--inline {
  width: auto;
  min-width: 1.4em;
  height: 1.7em;
  padding: 0 0.35em;
  font-size: 1em;
  border-width: 2px;
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(65, 48, 31, 0.14);
  vertical-align: middle;
  position: relative;
  top: -0.06em;
  margin: 0 0.12em;
}

/* Draw + discard piles on the TV. */
.pn-piles { display: flex; gap: 1.6rem; justify-content: center; align-items: flex-start; margin-top: 0.4rem; }
.pn-pile { display: grid; gap: 0.35rem; justify-items: center; }
.pn-pile .pn-card { width: 3.2rem; height: 4rem; font-size: 1.7rem; }
.pn-pile__label { font-weight: 800; color: var(--ink-soft); font-size: 0.85rem; }
.pn-pile--held .pn-card { border-color: var(--sun-deep); }

/* Phone: the player's own tappable grid. button_to wraps each cell in a form;
   display:contents lets the button itself be the flex item. */
.pn-phone-grid { display: flex; gap: 0.4rem; justify-content: center; margin: 0.5rem 0; }
.pn-phone-grid .pn-col { display: flex; flex-direction: column; gap: 0.4rem; }
.pn-phone-grid form { display: contents; margin: 0; }
.pn-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.4rem;
  height: 4rem;
  background: #fff;
  border: 3px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(65, 48, 31, 0.14);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--ink);
}
.pn-slot--down { color: #fff; background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.35), transparent 40%), var(--grape); }
.pn-slot--ace  { background: #efe0ff; color: var(--grape); }
.pn-slot--zero { background: #fffaf0; color: var(--ink-soft); }
.pn-slot--low  { background: #e3f8e4; color: var(--good); }
.pn-slot--mid  { background: #fff0cf; color: var(--sun-deep); }
.pn-slot--high { background: #ffe1e1; color: var(--red-deep); }
.pn-slot--btn { cursor: pointer; transition: transform 0.06s ease, box-shadow 0.06s ease; }
.pn-slot--btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(65, 48, 31, 0.14); }
/* Highlight the cells a tap can act on. */
.pn-phone-grid--place .pn-slot--btn:not(:disabled),
.pn-phone-grid--flip .pn-slot--btn:not(:disabled),
.pn-phone-grid--reveal .pn-slot--btn:not(:disabled) { outline: 3px dashed rgba(240, 163, 30, 0.7); outline-offset: 2px; }
/* A slot the current mode can't act on (e.g. a face-up card while flipping). */
.pn-slot--btn:disabled { cursor: default; opacity: 0.5; }
.pn-slot--btn:disabled:active { transform: none; box-shadow: 0 3px 0 rgba(65, 48, 31, 0.14); }

.pn-draw-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; align-items: stretch; }
/* button_to wraps each action in a form; display:contents lets the buttons be
   the grid items so both stretch to equal height (the card chip in "Take"
   would otherwise make only that button taller). */
.pn-draw-actions form { display: contents; margin: 0; }
.pn-draw-actions .btn { font-size: 1.15rem; padding: 1em 0.5em; }
.pn-btn--draw { background: var(--grape); color: #fff; box-shadow: 0 6px 0 #7d4fc0, 0 12px 20px rgba(150, 95, 35, 0.22); }
.pn-btn--draw:active { box-shadow: 0 1px 0 #7d4fc0, 0 4px 10px rgba(150, 95, 35, 0.22); }
.pn-btn--discard { background: var(--sky); color: var(--outline); box-shadow: 0 6px 0 var(--sky-deep), 0 12px 20px rgba(150, 95, 35, 0.22); }
.pn-btn--discard:active { box-shadow: 0 1px 0 var(--sky-deep), 0 4px 10px rgba(150, 95, 35, 0.22); }
.pn-or { margin: 0.9rem 0 0.4rem; font-size: 0.9rem; }
/* The last-resort "keep my final card hidden" skip — deliberately understated
   so it reads as the fallback, not the main move. */
.pn-btn--skip { background: #fff; color: var(--outline); box-shadow: 0 5px 0 var(--outline); }
.pn-btn--skip:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--outline); }

/* The draw decision: a segmented "radio" choosing what a slot tap does. The
   real radio input is hidden; its label is a chunky pill that lights up when
   checked, and the matching hint below is shown while the rest are hidden. */
.pn-mode { display: flex; gap: 0.6rem; margin: 0.2rem 0 0.6rem; }
.pn-mode__opt { flex: 1; }
.pn-mode__opt input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pn-mode__opt span {
  display: block; text-align: center;
  padding: 0.6em 0.4em; font-weight: 800; line-height: 1.15;
  color: var(--outline); background: #fff;
  border: 3px solid var(--outline); border-radius: 14px;
  box-shadow: 0 5px 0 var(--outline); cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, background 0.08s;
}
.pn-mode__opt:has(input:checked) span {
  background: var(--sun);
  transform: translateY(3px); box-shadow: 0 2px 0 var(--outline);
}
.pn-mode__opt:has(input:focus-visible) span {
  box-shadow: 0 5px 0 var(--outline), 0 0 0 4px rgba(69, 196, 232, 0.5);
}
.pn-decision__hint { margin: 0 0 0.2rem; }
.pn-decision__hint--flip { display: none; }
.pn-decision:has(input[value="flip"]:checked) .pn-decision__hint--place { display: none; }
.pn-decision:has(input[value="flip"]:checked) .pn-decision__hint--flip { display: block; }

/* Lobby: the host's segmented picker for how many holes to play. Each option
   is a button_to (its own form); the host's choice is persisted server-side, so
   the selected option is styled from that value (not fragile DOM state) and
   survives the re-renders that fire as players join. */
.hole-picker { margin: 0 0 1rem; }
.hole-picker__options { display: flex; gap: 0.6rem; }
.hole-picker__options form { display: contents; margin: 0; }
.hole-picker__option {
  flex: 1; text-align: center;
  padding: 0.7em 0; font-size: 1.5rem; font-weight: 800; font-family: inherit;
  color: var(--outline); background: #fff;
  border: 3px solid var(--outline); border-radius: 14px;
  box-shadow: 0 5px 0 var(--outline); cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, background 0.08s;
}
.hole-picker__option.is-selected {
  background: var(--sky);
  transform: translateY(3px); box-shadow: 0 2px 0 var(--outline);
}

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