/* Bold arcade look on a midnight slate court: sticker chips for the clue, pill inputs and
   buttons with hard offset shadows, and chunky colour-coded result rows. Mobile-first. */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;700&family=Nunito+Sans:wght@400;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root{
  --bg:#0f1237;
  --card:#1e2470;
  --card-2:#262d8c;
  --text:#ffffff;
  --muted:#a2a7e5;
  --yellow:#fffa0b;
  --gold:#f5b301;
  --silver:#d7dee6;
  --bronze:#d9965a;
  --accent:#7acaf6;
  --green:#65c853;
  --red:#ff4d4d;
  --accent-2:#7c73c7;
  --orange:#ff9f5a;
  --ink:#0f1237;
  --paper:#fff8e6;

  --font-display:"Chakra Petch", "Arial Black", Impact, sans-serif;
  --font-body:"Nunito Sans", "Segoe UI", -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-mono:"Space Mono", ui-monospace, Consolas, monospace;
}

*{ box-sizing:border-box; }
html, body{ margin:0; }
body{
  min-height:100vh;
  font-family:var(--font-body);
  color:var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(124,115,199,.14), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(122,202,246,.14), transparent 38%),
    var(--bg);
  display:flex; flex-direction:column; align-items:center;
  padding:16px;
}

h1{ font-family:var(--font-display); font-weight:400; text-transform:uppercase; letter-spacing:.02em; margin:8px 0 4px; font-size:1.7em; text-align:center; text-shadow:4px 4px 0 var(--accent-2); }
.sub{ color:var(--muted); font-size:.92em; margin:0; text-align:center; }
.hint{ color:var(--muted); font-size:.8em; margin:0; text-align:center; }
.mono{ font-family:var(--font-mono); font-variant-numeric:tabular-nums; }

#app{
  width:100%; max-width:720px;
  display:flex; flex-direction:column; align-items:stretch; gap:16px;
}

@media (max-width:480px){
  body{ padding:12px; }
  h1{ font-size:1.4em; }
}

/* ---------- Buttons: pill with a hard offset shadow ---------- */
.btn{
  font-family:var(--font-display); font-size:.95em; letter-spacing:.02em; text-transform:uppercase;
  padding:14px 22px; border-radius:999px; cursor:pointer;
  border:2px solid var(--yellow); background:transparent; color:var(--yellow);
  transition:transform .08s ease, box-shadow .08s ease, opacity .15s ease;
  /* Every button is shaded, like Lock in. Outlined buttons get a softer shade than filled ones. */
  box-shadow:0 5px 0 rgba(255,250,11,.35);
}
.btn:hover:not(:disabled){ transform:translate(-1px,-1px); }
.btn:active:not(:disabled){ transform:translate(2px,3px); box-shadow:none !important; }
.btn:disabled{ opacity:.35; cursor:not-allowed; }
.btn.primary{ background:var(--yellow); color:var(--ink); border-color:var(--yellow); box-shadow:0 5px 0 #b2aa00; }
.btn.ghost{ border-color:transparent; color:var(--yellow); font-family:var(--font-body); text-transform:none; font-size:.9em; box-shadow:none; }
.btn.ghost:hover:not(:disabled){ transform:none; }
.btn:focus-visible{ outline:3px solid var(--yellow); outline-offset:3px; }

/* ---------- Round progress ---------- */
.table-top{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.round-label{ font-size:.78em; color:var(--muted); text-transform:uppercase; letter-spacing:.1em; font-weight:600; }
.pips{ display:flex; gap:6px; }
/* Round pips: one per round. Completed rounds are blue, the current round is yellow, upcoming rounds are dim.
   Each pip is a fixed size so the current one can't grow or squash. */
.pip{ flex:0 0 18px; width:18px; height:8px; border-radius:999px; background:rgba(255,255,255,.14); }
.pip.done{ background:var(--accent); }
.pip.now{ background:var(--yellow); }

/* ---------- Players strip ---------- */
.players{ display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }
.player{
  flex:0 1 auto; min-width:140px; display:flex; align-items:center; justify-content:center;
  padding:9px 12px; border-radius:999px; background:var(--card-2); font-size:.9em;
  border:2px solid transparent;
}
.player.me{ border-color:var(--yellow); }
.p-name{ font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.p-wins{ color:var(--yellow); font-weight:700; }
.p-dist{ color:var(--muted); font-size:.85em; }
.status{ text-align:center; color:var(--muted); font-family:var(--font-display); text-transform:uppercase; letter-spacing:.06em; padding:24px 0; margin:0; }

/* ---------- Cards: guess, results, start ---------- */
.guess-card, .result-card, .start-card{
  background:var(--card); color:var(--text);
  border-radius:20px; padding:18px;
  box-shadow:0 8px 0 #0a0c24;
}
.guess-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; flex-wrap:wrap; }
.guess-prompt{ font-size:1em; line-height:1.35; font-weight:600; }
.guess-prompt b{ font-family:var(--font-display); font-weight:400; color:var(--yellow); }
.countdown{
  font-family:var(--font-display); font-size:1.3em; min-width:3.2em; text-align:center;
  background:var(--accent-2); color:#fff; padding:6px 10px; border-radius:999px;
}
.locked{ margin:6px 0 10px; font-size:1em; }
.locked b{ font-family:var(--font-display); font-weight:400; color:var(--accent); }
.table-status{ margin-top:10px; font-size:.8em; color:var(--muted); text-align:center; font-weight:600; }

/* ---------- Search: pill input and suggestions ---------- */
.search{ position:relative; }
.search input{
  width:100%; font:inherit; font-size:1.05em; padding:14px 18px; border-radius:999px;
  border:3px solid var(--accent); background:var(--paper); color:var(--ink); font-weight:600;
}
.search input::placeholder{ color:#8a7aa8; font-weight:500; }
.search input:focus{ outline:none; box-shadow:0 0 0 4px rgba(255,250,11,.45); }
.suggest{
  position:absolute; left:0; right:0; top:calc(100% + 6px); z-index:5;
  list-style:none; margin:0; padding:6px; max-height:280px; overflow-y:auto;
  background:var(--paper); border-radius:18px; box-shadow:0 10px 24px rgba(0,0,0,.4);
}
.suggest[hidden]{ display:none; }
.suggest li{ padding:10px 14px; border-radius:999px; cursor:pointer; color:var(--ink); font-weight:600; }
.suggest li:hover, .suggest li:focus{ background:var(--yellow); }
.guess-card .btn{ width:100%; margin-top:14px; }

/* ---------- Results: closeness-ranked rows ---------- */
.result-head{ margin-bottom:10px; }
.winner-tag{
  display:inline-block; font-family:var(--font-display); font-size:.9em; text-transform:uppercase;
  background:var(--accent-2); color:#fff; padding:8px 16px; border-radius:999px; box-shadow:3px 3px 0 var(--yellow);
}
.winner-tag.none{ background:var(--card-2); color:var(--muted); box-shadow:none; }

.closeness{ list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px; }
.closeness .row{
  position:relative; overflow:hidden;
  display:grid; grid-template-columns:34px 1fr auto; gap:10px; align-items:center;
  padding:10px 14px; border-radius:16px; background:var(--card-2);
}
.closeness .pos{ font-family:var(--font-display); font-size:1.1em; text-align:center; color:var(--accent); }
.closeness .who{ display:flex; flex-direction:column; min-width:0; }
.who-name{ font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.who-guess{ font-size:.82em; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dist{ font-family:var(--font-display); font-size:1em; }
/* Each tier just names its color; the sliding fill bar / edge mark below (shared with .review-guess)
   reads it. gold/silver/bronze are rank-scored placements (multiplayer and bot games); green/yellow/
   orange are the daily's closeness bands. */
.row.gold, .review-guess.gold{ --tier-color:var(--gold); }
.row.silver, .review-guess.silver{ --tier-color:var(--silver); }
.row.bronze, .review-guess.bronze{ --tier-color:var(--bronze); }
.row.green, .review-guess.green{ --tier-color:var(--green); }
.row.yellow, .review-guess.yellow{ --tier-color:var(--yellow); }
.row.orange, .review-guess.orange{ --tier-color:var(--orange); }

/* The colored highlight behind a daily result row: a translucent bar that slides in from the left and
   stops at the share of that round's max the guess actually earned (so text always sits on a mix of
   the dark row background and a tinted overlay, never a fully solid bright color — avoids needing a
   different text color per tier, which broke down once the fill stopped being the whole row).
   Driven by JS (see wireTierFills in js/ui.js) flipping --fill from 0 to its target a frame after
   insertion, the same two-step technique the countdown timer bar uses — a plain CSS @keyframes
   `to{ transform:scaleX(var(--fill)) }` does not reliably pick up a per-element custom property set
   via inline style, confirmed live (it resolves fine as a static transform, just not inside a
   keyframe), so this uses an ordinary transition instead. */
.row .tier-fill, .review-guess .tier-fill{
  position:absolute; inset:0; z-index:0; border-radius:inherit;
  transform-origin:left center; transform:scaleX(var(--fill, 0));
  background:var(--tier-color, transparent); opacity:.85;
  transition:transform .7s cubic-bezier(.22,.9,.3,1);
}
/* The rank-scored place marker: just a thin colored strip along the left edge, not a fill — place
   isn't a share of anything, so coloring in the row like a progress bar doesn't mean anything there. */
.row .tier-edge, .review-guess .tier-edge{
  position:absolute; inset:0; z-index:0; width:5px; border-radius:inherit;
  background:var(--tier-color, transparent);
}
/* A dark text-shadow keeps the row's always-light text readable over a bright, mostly-opaque tier
   color (gold/yellow especially) without needing a different text color per tier. Only the fill bar
   needs this — the edge mark is only a few pixels wide, so the rest of the row stays on its normal
   dark background. */
.row > *:not(.tier-fill):not(.tier-edge), .review-guess > *:not(.tier-fill):not(.tier-edge){
  position:relative; z-index:1;
}
.row:has(.tier-fill) > *:not(.tier-fill), .review-guess:has(.tier-fill) > *:not(.tier-fill){
  text-shadow:0 1px 3px rgba(0,0,0,.5);
}
.legend{ margin:14px 0 0; font-size:.8em; color:var(--muted); text-align:center; font-weight:600; }
.key{ display:inline-block; width:12px; height:12px; border-radius:999px; margin:0 4px 0 12px; vertical-align:middle; }
.key:first-child{ margin-left:0; }
.key.gold{ background:var(--gold); }
.key.green{ background:var(--green); }
.key.yellow{ background:var(--yellow); }

/* ---------- Standings ---------- */
.guess-list{ list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px; }
.guess-list li{
  display:grid; grid-template-columns:1.3fr 1.1fr .6fr .8fr; gap:8px; align-items:center;
  padding:10px 14px; border-radius:16px; background:var(--card-2); font-size:.95em;
}
.guess-list li.win{ background:var(--yellow); color:var(--ink); font-weight:700; }
.guess-list.standings li{ grid-template-columns:1.4fr 1fr .6fr .8fr; }
.g-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:700; }
.g-guess{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); }
.guess-list li.win .g-guess{ color:#5a4300; }
.g-rank, .g-dist{ text-align:right; font-family:var(--font-mono); font-size:.9em; }
/* The match-total pill on the final standings: a dark translucent panel with a bright inset shadow on
   top and a faint highlight along the bottom edge, so the pill reads as pressed into the row rather
   than sitting on top of it. Background stays translucent (not a solid dark color) so it still works
   over the winner row's bright yellow background, not just the normal card-2 rows. */
.g-pts{
  justify-self:end; display:inline-block; padding:4px 10px; border-radius:999px;
  font-size:.85em; white-space:nowrap; background:rgba(0,0,0,.28);
  box-shadow:inset 0 2px 4px rgba(0,0,0,.55), inset 0 -1px 0 rgba(255,255,255,.12);
}
.guess-list li.win .g-pts{ background:rgba(0,0,0,.18); }

/* ---------- Start / lobby ---------- */
.start-card{ display:flex; flex-direction:column; gap:14px; align-items:stretch; text-align:center; }
.start-card .btn{ width:100%; }
.lobby-title{ font-family:var(--font-display); font-weight:400; text-transform:uppercase; margin:0; font-size:1.2em; }
.lobby-error{ color:#ff8a8a; font-size:.9em; font-weight:700; min-height:1.1em; text-align:center; }
.lobby-actions{ display:flex; gap:12px; }
.lobby-actions .btn{ flex:1; }
.seat-list{ display:flex; flex-direction:column; gap:8px; }
.seat-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 14px; border-radius:999px; background:var(--card-2);
}
.seat-name{ font-weight:700; }
.seat-tag{
  font-family:var(--font-display); font-size:.62em; text-transform:uppercase; letter-spacing:.04em;
  padding:5px 10px; border-radius:999px; margin-left:4px;
}
.seat-tag.ready{ background:var(--accent); color:var(--ink); }
.seat-tag.waiting{ background:rgba(255,255,255,.12); color:var(--muted); }
.seat-tag.host{ background:var(--yellow); color:var(--ink); }
.room-list{ display:flex; flex-direction:column; gap:10px; max-height:340px; overflow-y:auto; }
.room-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 14px; border-radius:999px; background:var(--card-2);
}
.room-row .btn{ padding:9px 18px; }
.room-info{ display:flex; flex-direction:column; text-align:left; }
.room-host{ font-weight:700; }
.room-seats{ font-size:.78em; color:var(--muted); }
.room-empty{ color:var(--muted); font-size:.9em; padding:14px 0; text-align:center; }

.toast{
  position:sticky; top:8px; z-index:10; align-self:center;
  background:var(--accent-2); color:#fff; padding:9px 16px; border-radius:999px; font-weight:700; font-size:.9em;
  box-shadow:0 6px 0 #a52150;
}

/* ---------- Home-page cards ---------- */
.home-wrap{ width:100%; min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:24px; }
.home-title{ text-align:center; }
.home-link{ align-self:flex-start; color:var(--muted); font-size:.85em; text-decoration:none; font-weight:600; }
.home-link:hover{ color:var(--text); }
.mode-row{ width:100%; max-width:640px; display:flex; gap:18px; flex-wrap:wrap; justify-content:center; }
.mode-card{
  flex:1 1 240px; max-width:300px; padding:24px 20px;
  text-decoration:none; color:var(--ink); background:var(--yellow); border-radius:22px;
  box-shadow:6px 6px 0 var(--accent-2);
  display:flex; flex-direction:column; align-items:flex-start; gap:8px;
  transition:transform .1s ease;
}
.mode-card:nth-child(1){ transform:rotate(-1deg); }
.mode-card:nth-child(2){ background:var(--accent); box-shadow:6px 6px 0 var(--yellow); transform:rotate(1deg); }
.mode-card:hover{ transform:translateY(-3px) rotate(0deg); }
.mode-card:focus-visible{ outline:3px solid #fff; outline-offset:4px; }
.mode-label{ font-family:var(--font-display); text-transform:uppercase; font-size:1.2em; }
.mode-desc{ font-size:.9em; line-height:1.4; font-weight:600; }

/* ---------- Question: the one thing on screen that matters, set as a bright sticker ---------- */
.question-card{
  background:var(--yellow); color:var(--ink); border-radius:22px; padding:18px 20px;
  box-shadow:6px 6px 0 var(--accent-2); transform:rotate(-.6deg);
}
.question{ margin:0; font-family:var(--font-display); font-size:1.15em; line-height:1.3; text-transform:uppercase; }

/* ---------- Number box + unit dropdown, side by side ---------- */
.answer-row{ display:flex; gap:10px; align-items:stretch; }
.answer-row input{
  flex:1; min-width:0; font:inherit; font-size:1.1em; padding:14px 18px; border-radius:999px;
  border:3px solid var(--accent); background:var(--paper); color:var(--ink); font-weight:700;
}
.answer-row input::placeholder{ color:#8a7aa8; font-weight:500; }
.answer-row input:focus{ outline:none; box-shadow:0 0 0 4px rgba(255,250,11,.45); }
.answer-row select{
  flex:0 0 auto; font-family:var(--font-display); font-size:.9em; text-transform:uppercase;
  padding:0 34px 0 16px; border-radius:999px; border:3px solid var(--yellow);
  background:var(--yellow) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%231d0b3b'/%3E%3C/svg%3E") no-repeat right 12px center;
  color:var(--ink); appearance:none; -webkit-appearance:none; cursor:pointer;
}
.answer-row select:focus{ outline:none; box-shadow:0 0 0 4px rgba(122,202,246,.5); }
.preview{ min-height:1.3em; margin:10px 4px 0; font-size:.95em; color:var(--accent); font-weight:600; }
.answer{ margin:0 0 14px; font-size:.95em; color:var(--muted); }
.answer b{ font-family:var(--font-display); font-weight:400; font-size:1.05em; color:var(--yellow); }

/* ---------- The answer, big, under the question during a round result ---------- */
.answer-block{ display:flex; flex-direction:column; align-items:center; gap:4px; padding:10px 0; }
.answer-label{ font-size:.75em; text-transform:uppercase; letter-spacing:.1em; color:var(--muted); font-weight:700; }
.answer-big{ font-family:var(--font-display); font-size:2.6em; color:var(--accent); text-shadow:4px 4px 0 var(--accent-2); line-height:1.1; text-align:center; word-break:break-word; }

/* ---------- Calmer pass: fewer effects, one accent, no tilted cards ---------- */
body{ background:var(--bg); }
h1{ text-shadow:none; }
.question-card{ transform:none; box-shadow:none; background:var(--yellow); }
.question{ font-size:1.05em; }
.guess-card, .result-card, .start-card{ box-shadow:none; }
.winner-tag{ box-shadow:none; }
.mode-card, .mode-card:nth-child(1), .mode-card:nth-child(2){ transform:none; box-shadow:none; }
.mode-card:hover{ transform:none; opacity:.9; }
.answer-block .answer-big{ text-shadow:none; }

/* ---------- Timer bar: drains left to right during guessing and the result pause ---------- */
.timer{ height:8px; border-radius:999px; background:rgba(0,0,0,.25); overflow:hidden; margin-bottom:14px; }
.timer-fill{ height:100%; width:100%; background:var(--accent); transform-origin:left center; transform:scaleX(1); }
.result-card .timer-fill{ background:var(--yellow); }

/* ---------- Final standings: place badge first, then name, rating change, and points ---------- */
.guess-list.standings li{ grid-template-columns:44px 1fr auto auto; gap:10px; }
.guess-list.standings .g-rank{ text-align:center; }
.place-num{ font-family:var(--font-display); font-size:1em; }
.medal{ width:30px; height:39px; display:block; margin:0 auto; }

/* Round results have no place numbers, so the row is just the player and their points. */
.closeness .row{ grid-template-columns:1fr auto; }

/* Lobby seat rows: long names wrap inside the row, and the Host and Ready tags stay on one line. */
.seat-row{ flex-wrap:nowrap; }
.seat-row .seat-name{ flex:1; min-width:0; overflow-wrap:anywhere; text-align:left; }
.seat-row .seat-tags{ display:flex; gap:6px; flex-shrink:0; align-items:center; }
.seat-row .seat-tag{ margin-left:0; white-space:nowrap; }

/* ---------- Back navigation: one pill-with-arrow style, used on every page ---------- */
.nav-back{
  display:inline-flex; align-items:center; gap:8px; align-self:flex-start;
  font-family:var(--font-display); font-size:.9em; text-transform:uppercase; letter-spacing:.03em;
  color:var(--text); background:var(--card); border:none; border-radius:999px;
  padding:10px 18px 10px 14px; text-decoration:none; cursor:pointer;
  transition:transform .08s ease, background .15s ease;
}
.nav-back:hover{ background:var(--card-2); transform:translateX(-2px); }
.nav-back:focus-visible{ outline:3px solid var(--yellow); outline-offset:3px; }
.nav-icon{ flex-shrink:0; }

/* hidden nav buttons must stay hidden, even though .nav-back sets display */
.nav-back[hidden]{ display:none; }

/* ---------- Small celebrations: answer pop and exact-answer confetti ---------- */
@keyframes answerPop{
  0%{ transform:scale(.4); opacity:0; }
  60%{ transform:scale(1.12); opacity:1; }
  100%{ transform:scale(1); }
}
.answer-big{ display:inline-block; animation:answerPop .6s cubic-bezier(.2,.9,.3,1.3) both; }

.confetti{ position:fixed; inset:0; pointer-events:none; overflow:hidden; z-index:50; }
.confetti-piece{
  position:absolute; top:-14px; width:9px; height:13px; border-radius:2px;
  animation-name:confettiFall; animation-timing-function:cubic-bezier(.25,.5,.5,1); animation-fill-mode:both;
}
@keyframes confettiFall{
  0%{ transform:translate(0,0) rotate(0deg); opacity:1; }
  100%{ transform:translate(var(--drift), 110vh) rotate(var(--spin)); opacity:0; }
}

@media (prefers-reduced-motion: reduce){
  .answer-big{ animation:none; }
  .confetti{ display:none; }
}

/* ---------- Side navigation (social/sidebar.js) ----------
   A fixed icon strip on the left. Phones keep it collapsed and an open panel floats over the
   content. From 768px up it starts open and pushes the page over, so the lobby column keeps its width. */
body.side-layout{ margin-left:56px; transition:margin-left .2s ease; }
@media (min-width:768px){ body.side-layout.side-open{ margin-left:220px; } }
.side{
  position:fixed; top:0; bottom:0; left:0; z-index:100; width:56px;
  display:flex; flex-direction:column; gap:6px; padding:12px 8px; overflow:hidden;
  background:var(--card-2); transition:width .2s ease;
}
.side.open{ width:220px; box-shadow:4px 0 0 #0a0c24; }
.side-toggle{
  flex-shrink:0; width:40px; height:40px; display:inline-flex; align-items:center; justify-content:center;
  border-radius:999px; border:2px solid var(--yellow); background:transparent; color:var(--yellow); cursor:pointer;
}
.side-toggle:focus-visible, .side-link:focus-visible{ outline:3px solid var(--yellow); outline-offset:2px; }
.side-nav{ display:flex; flex-direction:column; gap:6px; margin-top:8px; }
.side-link{
  display:flex; align-items:center; gap:12px; padding:10px; border-radius:999px;
  color:var(--text); text-decoration:none; font-weight:600; white-space:nowrap;
}
.side-link:hover{ background:var(--card); }
.side-link.current{ background:var(--card); color:var(--yellow); }
.side-link svg{ flex-shrink:0; }
.side-label{ font-size:.95em; }
.side:not(.open) .side-label{ display:none; }

/* ---------- Social pages: profile, friends, leaderboard (social/social.js) ---------- */
.social-card{ background:var(--card); border-radius:20px; padding:18px; display:flex; flex-direction:column; gap:14px; }
.social-card h1{ margin:0; }
.social-card .sub{ margin:-6px 0 0; }
.section-title{
  font-family:var(--font-display); font-weight:400; font-size:.8em; text-transform:uppercase; letter-spacing:.06em;
  color:var(--muted); margin:8px 0 0; text-align:left;
}
.add-friend{ display:flex; gap:10px; }
.add-friend input{
  flex:1; min-width:0; font:inherit; font-size:1em; padding:12px 16px; border-radius:999px;
  border:3px solid var(--accent); background:var(--paper); color:var(--ink); font-weight:600;
}
.add-friend input:focus{ outline:none; box-shadow:0 0 0 4px rgba(255,250,11,.45); }
.row-item{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 14px; border-radius:16px; background:var(--card-2);
}
.row-main{ min-width:0; display:flex; flex-direction:column; gap:2px; }
.row-actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; flex-shrink:0; }
.row-item .btn{ padding:9px 16px; }
.row-meta{ font-size:.8em; color:var(--muted); }
.profile-actions{ justify-content:flex-start; }
.name-link{ color:inherit; text-decoration:none; font-weight:700; overflow-wrap:anywhere; }
.name-link:hover{ text-decoration:underline; text-decoration-color:var(--yellow); }
.name-link:focus-visible{ outline:3px solid var(--yellow); outline-offset:2px; border-radius:4px; }
.stat-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.stat{ background:var(--card-2); border-radius:16px; padding:12px 6px; text-align:center; }
.stat-value{ font-family:var(--font-display); font-size:1.3em; color:var(--accent); }
.stat-label{ font-size:.72em; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); font-weight:700; }
.win-tag{ color:var(--accent); font-weight:700; }
.loss-tag{ color:#ff8a8a; font-weight:700; }
.lb-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.lb-row{
  display:grid; grid-template-columns:44px 1fr auto; gap:10px; align-items:center;
  padding:10px 14px; border-radius:16px; background:var(--card-2);
}
.lb-row.me{ background:var(--yellow); color:var(--ink); }
.lb-row.me .name-link, .lb-row.me .row-meta{ color:var(--ink); }
.lb-rank{ font-family:var(--font-display); text-align:center; }
.lb-name{ min-width:0; overflow-wrap:anywhere; }
.lb-elo{ font-weight:700; }
@media (max-width:480px){ .stat-grid{ grid-template-columns:repeat(2,1fr); } }

/* ---------- Sidebar on phones and during a match ---------- */
/* Phones: nothing but the three-lines button until it's pressed, then the panel floats over the page. */
@media (max-width:767px){
  body.side-layout{ margin-left:0; }
  .side{ width:auto; padding:12px; overflow:visible; background:transparent; box-shadow:none; }
  .side:not(.open) .side-nav{ display:none; }
  .side.open{ width:220px; height:100%; background:var(--card-2); box-shadow:4px 0 0 #0a0c24; overflow:hidden; }
}
/* During a match the sidebar is gone, on every screen size. */
body.in-game .side{ display:none; }
body.in-game.side-layout, body.in-game.side-layout.side-open{ margin-left:0; }

/* ---------- Page chrome: top bar, phone tab bar, help dialog (social/chrome.js) ---------- */
.topbar{
  width:100%; max-width:720px; display:grid; grid-template-columns:44px 1fr 44px; align-items:center; gap:8px;
  min-height:52px; margin-bottom:6px;
}
.top-side{ display:flex; }
.top-side.right{ justify-content:flex-end; }
.top-title{
  margin:0; font-family:var(--font-display); font-weight:400; font-size:1.1em; text-transform:uppercase;
  letter-spacing:.05em; text-align:center; text-shadow:none;
}
.top-btn{
  width:44px; height:44px; border-radius:999px; display:inline-flex; align-items:center; justify-content:center;
  background:var(--card); color:var(--text); border:none; cursor:pointer; text-decoration:none;
  transition:background .15s ease;
}
.top-btn:hover{ background:var(--card-2); }
.top-btn:focus-visible{ outline:3px solid var(--yellow); outline-offset:3px; }

/* Help dialog: a native <dialog>, so Escape and focus are handled by the browser */
.help-dialog{ border:none; border-radius:20px; padding:0; background:transparent; width:min(92vw, 420px); color:var(--text); }
.help-dialog::backdrop{ background:rgba(8,9,12,.7); }
.help-card{ background:var(--card); padding:22px; border-radius:20px; display:flex; flex-direction:column; gap:14px; }
.help-title{ margin:0; font-family:var(--font-display); font-weight:400; text-transform:uppercase; font-size:1.1em; text-align:left; text-shadow:none; }
.help-steps{ margin:0; padding-left:20px; display:flex; flex-direction:column; gap:8px; font-size:.95em; line-height:1.4; }
.help-card .btn{ align-self:stretch; }

/* Tab bar: phones only, fixed to the bottom, the four main destinations */
.tabbar{ display:none; }
@media (max-width:767px){
  .tabbar{
    display:flex; position:fixed; left:0; right:0; bottom:0; z-index:90;
    background:var(--card-2); padding:6px 6px calc(6px + env(safe-area-inset-bottom));
    box-shadow:0 -4px 0 #0a0c24;
  }
  .tab{
    flex:1; display:flex; flex-direction:column; align-items:center; gap:3px; padding:8px 2px;
    color:var(--muted); text-decoration:none; font-size:.72em; font-weight:700; border-radius:14px;
  }
  .tab.current{ color:var(--yellow); background:var(--card); }
  .tab:focus-visible{ outline:3px solid var(--yellow); outline-offset:-3px; }
  body.has-tabs{ padding-bottom:calc(84px + env(safe-area-inset-bottom)); }
  /* phones use the tab bar, so the sidebar is never shown there */
  .side{ display:none !important; }
  body.side-layout{ margin-left:0 !important; }
}
/* during a match the tab bar and sidebar are out of the way, on every screen size */
body.in-game .tabbar{ display:none !important; }
body.in-game .side{ display:none !important; }
body.in-game.side-layout{ margin-left:0 !important; }
body.in-game.has-tabs{ padding-bottom:16px; }

/* Rating change on the final standings */
.g-dist.elo-up{ color:var(--green); font-weight:700; }
.g-dist.elo-down{ color:var(--red); font-weight:700; }

/* ---------- Main menu: the first screen after sign-in ---------- */
.menu{ width:100%; max-width:420px; margin:24px auto 0; display:flex; flex-direction:column; gap:14px; }
.menu-signed{ margin:0 0 6px; text-align:center; color:var(--muted); font-size:.92em; }
.menu a.btn{ display:block; width:100%; text-align:center; text-decoration:none; }
.menu .btn.big{ padding:13px; font-size:1.05em; font-weight:900; }
.menu-logo{ display:flex; flex-direction:column; align-items:center; gap:6px; margin-bottom:6px; }
.menu-logo .landing-mark{ width:72px; height:72px; }
.menu-logo .landing-title{ font-size:1.6em; margin:0; }
.menu button.btn{ width:100%; }

/* ---------- Friends and profile: chess.com-style panels and list rows ---------- */
.social-page{ width:100%; max-width:520px; margin:0 auto; display:flex; flex-direction:column; gap:12px; }
.cc-panel{ background:var(--card); border-radius:16px; padding:16px; display:flex; flex-direction:column; gap:10px; }
.cc-heading{ margin:0; font-family:var(--font-display); font-size:.9em; font-weight:500; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); display:flex; align-items:center; gap:8px; }
.cc-badge{ background:var(--card-2); color:var(--muted); border-radius:999px; padding:1px 9px; font-family:var(--font-mono); font-size:.85em; letter-spacing:0; }
.cc-empty{ margin:0; color:var(--muted); font-size:.9em; text-align:center; padding:8px 0; }

.cc-hero{ background:var(--card); border-radius:16px; padding:22px 16px 18px; display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center; }
.cc-name{ margin:10px 0 0; font-family:var(--font-display); font-size:1.5em; font-weight:700; color:var(--text); overflow-wrap:anywhere; }
.cc-sub{ margin:0; color:var(--muted); font-size:.9em; }
.cc-rating{ margin:0; color:var(--muted); font-size:.9em; display:flex; align-items:baseline; gap:6px; }
.cc-rating b{ color:var(--text); font-size:1.2em; }
.cc-hero-actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:center; width:100%; margin-top:10px; }
.cc-hero-actions .btn{ flex:1; min-width:140px; }

.cc-avatar{ width:44px; height:44px; border-radius:10px; display:inline-grid; place-items:center; font-family:var(--font-display); font-size:18px; font-weight:700; color:var(--ink); flex-shrink:0; }
.cc-avatar.lg{ width:88px; height:88px; border-radius:14px; font-size:36px; }

.cc-tiles{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.cc-tile{ background:var(--card); border-radius:14px; padding:14px 6px; display:flex; flex-direction:column; align-items:center; gap:6px; }
.cc-tile b{ font-size:1.25em; color:var(--text); }
.cc-tile-label{ font-size:.72em; color:var(--muted); font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
@media (max-width:480px){ .cc-tiles{ grid-template-columns:repeat(2,1fr); } }

.cc-form{ display:flex; gap:8px; }
.cc-input{ flex:1; min-width:0; height:46px; border-radius:999px; border:2px solid var(--card-2); background:var(--card); color:var(--text); padding:0 16px; font:600 15px var(--font-body); }
.cc-input:focus{ outline:none; border-color:var(--accent); }
/* A pill shape (border-radius:999px) only reads right on a single-line input — selects and
   textareas get a less extreme radius and their own height instead of the fixed 46px. */
select.cc-input{ border-radius:14px; height:46px; }
textarea.cc-input{ border-radius:14px; height:auto; padding:10px 16px; resize:vertical; }

.cc-field{ display:flex; flex-direction:column; gap:6px; text-align:left; }
.cc-field label{ font-size:.75em; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }

/* Wraps a password input with a show/hide eye button, added via social/chrome.js's
   addPasswordToggle(). The wrapper replaces the input in the flex layout, so it needs its own
   full-width rule — the input itself no longer stretches on its own once it's not a direct
   flex child of the field. */
.pw-wrap{ position:relative; display:block; width:100%; }
.pw-wrap input{ width:100%; padding-right:42px; }
.pw-toggle{ position:absolute; right:4px; top:50%; transform:translateY(-50%); background:none; border:none; padding:6px; display:flex; cursor:pointer; color:var(--muted); }
.pw-toggle:hover{ color:var(--text); }

.cc-list{ display:flex; flex-direction:column; }
.cc-row{ display:flex; align-items:center; gap:12px; padding:10px 2px; border-bottom:1px solid var(--card-2); }
.cc-row:last-child{ border-bottom:0; }
.cc-row-main{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.cc-row-title{ font-weight:700; color:var(--text); }
.cc-row-sub{ font-size:.8em; color:var(--muted); font-family:var(--font-mono); }
.cc-row-actions{ display:flex; gap:6px; flex-shrink:0; align-items:center; }
.cc-row-actions .btn{ padding:8px 14px; font-size:.85em; }
.cc-row .name-link{ font-weight:700; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.cc-result{ width:40px; height:40px; border-radius:10px; display:grid; place-items:center; font-family:var(--font-display); font-size:16px; color:var(--ink); flex-shrink:0; }
.cc-result.win{ background:var(--green); }
.cc-result.loss{ background:var(--red); }
.cc-delta{ font-weight:700; color:var(--muted); }
.cc-delta.up{ color:var(--green); }
.cc-delta.down{ color:var(--red); }

/* Leaderboard rows use the same list rows as friends and profile. */
.lb-row{ display:flex; align-items:center; gap:12px; padding:10px 2px; border-bottom:1px solid var(--card-2); background:none; border-radius:0; }
.lb-row:last-child{ border-bottom:0; }
.lb-row.me{ background:var(--card-2); border-radius:12px; padding:10px 10px; border-bottom:0; }
.lb-rank{ width:22px; text-align:center; color:var(--muted); font-weight:700; flex-shrink:0; }
.lb-elo{ font-weight:700; color:var(--text); flex-shrink:0; }
.lb-row.me .lb-elo{ color:var(--accent); }

/* Invite a friend to a challenge room */
.invite-box{ margin-top:14px; padding-top:14px; border-top:1px solid var(--card-2); display:flex; flex-direction:column; gap:8px; align-items:center; }
.invite-box .sub{ margin:0; }

/* "…" button and its pop-up menu on friend rows and profiles */
.cc-menu-wrap{ position:relative; }
.cc-more{ width:38px; height:38px; padding:0; font-size:18px; line-height:1; letter-spacing:.1em; display:grid; place-items:center; }
.cc-menu{ position:absolute; right:0; top:calc(100% + 6px); z-index:10; min-width:170px; background:var(--card-2); border-radius:12px; padding:6px; box-shadow:0 8px 20px rgba(0,0,0,.45); display:flex; flex-direction:column; }
.cc-menu[hidden]{ display:none; }
.cc-menu button{ background:none; border:0; border-radius:8px; padding:10px 12px; text-align:left; font:700 14px var(--font-body); color:var(--red); cursor:pointer; }
.cc-menu button:hover, .cc-menu button:focus-visible{ background:var(--card); outline:none; }

/* "Play a Friend" screen: full-width action rows, search, and a friends list */
.pap-actions{ display:flex; flex-direction:column; gap:10px; }
.pap-action{ width:100%; min-height:58px; background:var(--card); color:var(--text); border:0; border-radius:16px; padding:0 18px; text-align:left; font-family:var(--font-display); font-size:15px; font-weight:500; letter-spacing:.02em; cursor:pointer; }
.pap-action:hover, .pap-action:focus-visible{ background:var(--card-2); outline:none; }
.cc-heading-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.cc-link{ color:var(--accent); font-weight:700; font-size:.9em; text-decoration:none; }
.cc-link:hover{ text-decoration:underline; }
.cc-row[hidden], .friend-row[hidden]{ display:none; }
.cc-challenge{ padding:8px 14px; font-size:.85em; }

/* Signed-out landing page: logo, one line, three pill buttons (modelled on Wordle's front page) */
.landing{ width:100%; max-width:460px; margin:40px auto 0; display:flex; flex-direction:column; align-items:center; gap:18px; text-align:center; }
.landing-mark{ width:120px; height:120px; }
.landing-title{ margin:4px 0 0; font-family:var(--font-display); font-weight:900; font-size:2.6em; letter-spacing:.02em; color:var(--text); }
.landing-tagline{ margin:0 0 14px; font-size:1.25em; color:var(--muted); line-height:1.4; }
.landing-actions{ width:100%; display:flex; gap:10px; flex-wrap:wrap; justify-content:center; }
.landing-actions .btn{ flex:1 1 120px; }

/* Small Privacy/Terms links shown at the bottom of the landing page, main menu, and sign-in page. */
.legal-footer{ text-align:center; font-size:.75em; padding:24px 16px; color:var(--muted); }
.legal-footer a{ color:inherit; }

/* Yellow buttons, for the main menu and the post-game buttons. Same shapes as the teal ones. */
.btn.yellow{ border-color:var(--yellow); color:var(--yellow); box-shadow:0 5px 0 rgba(255,250,11,.35); }
.btn.yellow.primary{ background:var(--yellow); color:var(--ink); border-color:var(--yellow); box-shadow:0 5px 0 #b2aa00; }

/* Filled purple buttons, the sidebar's lighter purple, with yellow text (main menu) */
.btn.panel{ background:var(--card-2); border-color:var(--card-2); color:var(--text); box-shadow:0 5px 0 #0a0c24; }
.menu .btn{ font-weight:900; }
.menu .btn.primary.yellow{ color:var(--text); }
/* Gradient fills for the main menu buttons: a lighter top edge fading into the base colour */
.menu .btn.primary.yellow{ background:linear-gradient(180deg, #fffa0b 0%, #d6d100 100%); border-color:#d6d100; }
.menu .btn.panel{ background:linear-gradient(180deg, #262d8c 0%, #1e2470 100%); border-color:#1e2470; }
.menu .btn.primary.yellow{ color:var(--bg); }
.menu .btn.primary.yellow{ color:var(--text); -webkit-text-stroke:4px var(--bg); paint-order:stroke fill; }
/* Start game: plain white label on a darker yellow gradient */
.menu .btn.primary.yellow{ color:var(--text); -webkit-text-stroke:0; paint-order:normal; background:linear-gradient(180deg, #e6b800 0%, #a06f00 100%); border-color:#a06f00; }
/* Start game: bright yellow, white label with a soft dark shadow so it reads clearly */
.menu .btn.primary.yellow{ background:linear-gradient(180deg, #fffa0b 0%, #d6d100 100%); border-color:#d6d100; color:var(--text); text-shadow:0 2px 3px rgba(40,20,0,.55); }
/* Start game: bright yellow with the dark purple background colour for the label, the most readable pairing on yellow */
.menu .btn.primary.yellow{ color:var(--bg); text-shadow:none; }

/* End-of-match heading on the final results board: big, centred, display font */
.final-title{ margin:0; text-align:center; font-family:var(--font-display); font-weight:700; text-transform:uppercase; letter-spacing:.04em; font-size:2em; color:var(--text); }

/* Challenge notices on the home menu */
.challenges{ display:flex; flex-direction:column; gap:10px; }
.challenges:empty{ display:none; }
.challenge-card{ background:var(--card-2); border-radius:16px; padding:12px 14px; display:flex; flex-direction:column; gap:10px; border:2px solid var(--yellow); }
.challenge-text{ margin:0; text-align:center; color:var(--text); }
.challenge-actions{ display:flex; gap:8px; justify-content:center; }
.challenge-actions .btn{ flex:1; padding:10px 14px; font-size:.9em; }

/* Play the Daily: filled with the palette's green, dark label for contrast */
.btn.lime{ background:linear-gradient(180deg, #8fdc6f 0%, #65c853 100%); border-color:#65c853; color:var(--bg); box-shadow:0 5px 0 #3f8f33; }

/* Round result while the match is still going: no answers shown until the end */
.round-complete{ margin:0; text-align:center; font-family:var(--font-display); text-transform:uppercase; letter-spacing:.04em; font-size:1.3em; color:var(--text); }

/* End-of-match review: scroll down for every question, its answer and each player's guess */
.review{ width:100%; max-width:560px; margin:8px auto 0; display:flex; flex-direction:column; gap:12px; }
.review-title{ margin:0; font-family:var(--font-display); font-weight:700; font-size:1.2em; text-transform:uppercase; letter-spacing:.04em; text-align:center; color:var(--text); }
.review-round{ background:var(--card); border-radius:16px; padding:14px; display:flex; flex-direction:column; gap:8px; }
.review-question{ margin:0; font-weight:700; color:var(--text); }
.review-answer{ margin:0; color:var(--muted); font-size:.92em; }
.review-answer b{ color:var(--yellow); }
.review-guesses{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px; }
.review-guess{
  position:relative; overflow:hidden;
  display:grid; grid-template-columns:1fr auto auto; gap:10px; align-items:center;
  padding:8px 12px; border-radius:12px; background:var(--card-2); color:var(--text);
}
.review-name{ font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.review-value{ font-size:.9em; }
.review-pts{ font-size:.85em; opacity:.85; }

/* Daily score: one big point total, the round emojis, and a share button */
.daily-score{ align-items:center; text-align:center; gap:12px; }
.daily-label{ margin:0; font-family:var(--font-display); text-transform:uppercase; letter-spacing:.06em; color:var(--muted); font-size:.9em; }
.daily-pct{ margin:0; font-family:var(--font-display); font-weight:700; font-size:4.5em; line-height:1; color:var(--yellow); }
.daily-pct .daily-max{ font-size:.4em; color:var(--muted); font-weight:600; }
.daily-emojis{ margin:0; font-size:1.8em; letter-spacing:.1em; }

/* The question drops into place when a new round starts */
@keyframes questionDrop{
  from{ opacity:0; transform:translateY(-22px) scale(.97); }
  to{ opacity:1; transform:none; }
}
.question-card.drop-in{ animation:questionDrop .45s cubic-bezier(.2,.9,.3,1.15) both; }
@media (prefers-reduced-motion: reduce){ .question-card.drop-in{ animation:none; } }

/* Daily results: copy and share buttons side by side */
.daily-actions{ display:flex; gap:10px; width:100%; }
.daily-actions .btn{ flex:1; }
