@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 (code name) — "One Word!"
 * 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;
}
.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); }
.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;
}
.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; }

.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); }
}

/* 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; }

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