:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-2: #232733;
  --text: #e9ecf1;
  --muted: #9aa3b2;
  --accent: #f5a623;
  --accent-2: #4a90e2;
  --tile: #f4ecd8;
  --tile-text: #2a2622;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--panel-2);
  color: var(--text);
  transition: filter 0.15s ease;
}
button:hover { filter: brightness(1.15); }
button.primary { background: var(--accent); color: #1a1300; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--panel-2); }

input, select {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--panel-2);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
}

/* --- Landing --- */
.landing {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  padding: 0 20px;
}
.landing h1 { font-size: 3rem; margin: 0 0 8px; letter-spacing: 1px; }
.tagline { color: var(--muted); margin-bottom: 32px; }
.landing .primary { font-size: 1.1rem; padding: 14px 28px; }
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); margin: 28px 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--panel-2);
}
.join-form { display: flex; gap: 8px; }
.join-form input { flex: 1; }

/* --- Room header --- */
.room-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid var(--panel-2);
}
.home-link { color: var(--accent); text-decoration: none; font-weight: 700; font-size: 1.3rem; }
.room-meta { display: flex; align-items: center; gap: 12px; }
.room-name { color: var(--muted); font-family: ui-monospace, monospace; }
.player-count { color: var(--text); font-size: 0.9rem; background: var(--panel-2); padding: 4px 10px; border-radius: 999px; }

/* --- Presence --- */
.presence {
  display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: space-between;
  align-items: center; background: var(--panel); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 24px;
}
.presence-list { display: flex; flex-wrap: wrap; gap: 8px; }
.player-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; background: var(--panel-2);
  font-size: 0.9rem;
}
.player-chip.me { outline: 1px solid var(--chip); }
.player-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--chip); flex: none; }
.player-name { color: var(--chip); font-weight: 600; }

.you-editor { display: flex; align-items: center; gap: 8px; }
.you-editor label { color: var(--muted); font-size: 0.9rem; }
.you-editor input { padding: 6px 10px; width: 140px; }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch {
  width: 20px; height: 20px; padding: 0; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
}
.swatch:hover { filter: brightness(1.1); }
.swatch.selected { border-color: var(--text); transform: scale(1.15); }

/* --- Room layout --- */
.room { max-width: 720px; margin: 0 auto; padding: 24px 20px 60px; }
.board-area { display: flex; flex-direction: column; align-items: center; gap: 20px; }

.board-zone { display: contents; } /* transparent wrapper; board + tracer flow as normal */
.board-wrap { position: relative; width: min(90vw, 480px); }
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: 8px;
  width: 100%;
  touch-action: none; /* let drag-to-trace work without scrolling on mobile */
}
.board.blurred { filter: blur(12px); pointer-events: none; user-select: none; }
.board-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 16px; color: var(--text); font-weight: 600; font-size: 1.1rem;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); pointer-events: none;
}
.board-hint[hidden] { display: none; }
.board-start {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 2; font-size: 1.25rem; padding: 16px 40px; pointer-events: auto;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.board-start[hidden] { display: none; }
.tile {
  aspect-ratio: 1 / 1;
  background: var(--tile);
  color: var(--tile-text);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: clamp(1.2rem, 6vw, 2.2rem);
  text-transform: uppercase;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35);
  user-select: none;
}
.tile.blank {
  background: var(--panel-2);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.06);
}
.tile.sel {
  outline: 4px solid var(--sel, var(--accent));
  outline-offset: -4px;
  filter: brightness(1.05);
}

/* Word being traced */
.tracer {
  /* Reserve enough height for the flash pill so showing a word never shifts the page. */
  min-height: 2.6rem;
  font-size: 1.6rem; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
}
/* The reason slides in to the right of the word pill; the flex re-centering
   slides the word left to make room. */
.t-reason {
  max-width: 0; overflow: hidden; opacity: 0; white-space: nowrap;
  font-size: 0.95rem; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--muted);
  transition: max-width 0.3s ease, opacity 0.3s ease, margin-left 0.3s ease;
}
.tracer.has-reason .t-reason { max-width: 60vw; opacity: 1; margin-left: 12px; }

.timer-area { text-align: center; }
.timer {
  font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.timer.running { color: var(--accent); }
.status { color: var(--accent-2); min-height: 1.4em; margin-top: 4px; }

/* --- Controls --- */
.controls {
  display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;
  margin-top: 28px;
}
.control-group {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); padding: 12px; border-radius: 12px;
}
.control-group label { color: var(--muted); font-size: 0.9rem; }

.show-words { display: block; margin: 28px auto 0; font-size: 1.05rem; }
.show-words[hidden] { display: none; }

/* --- Words --- */
.words { margin-top: 32px; background: var(--panel); border-radius: 12px; padding: 18px; }
.words-header { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.words-header h2 { margin: 0; font-size: 1.2rem; }
.muted { color: var(--muted); font-weight: 400; }
#words-filter { min-width: 200px; }
.words-list {
  list-style: none; padding: 0; margin: 16px 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 4px 12px;
  max-height: 50vh; overflow-y: auto;
}
.words-list li {
  font-family: ui-monospace, monospace; color: var(--text);
  padding: 2px 0; border-bottom: 1px solid var(--panel-2);
}
.words-list li.found { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.word-dots { display: inline-flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.word-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* --- Your words (during a round) --- */
.my-words, .results { margin-top: 28px; background: var(--panel); border-radius: 12px; padding: 18px; }
.my-words h2, .results h2 { margin: 0 0 4px; font-size: 1.2rem; }
.hint-text { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; }
.type-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.type-form input { text-transform: uppercase; min-width: 160px; letter-spacing: 1px; }
.found-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 2px 12px;
}
.found-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-family: ui-monospace, monospace; color: var(--text);
  padding: 2px 0; border-bottom: 1px solid var(--panel-2);
}
.found-list li .p { color: var(--muted); }
.found-list li.dup { text-decoration: line-through; color: var(--muted); }
.found-list li.dup .p { color: var(--muted); }

/* --- Results --- */
.results-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-top: 12px;
}
.result-card { background: var(--panel-2); border-radius: 10px; padding: 12px; border-top: 4px solid var(--c, var(--accent)); }
.result-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.result-name { font-weight: 700; color: var(--c, var(--text)); }
.result-score { font-size: 1.4rem; font-weight: 700; }
.result-card .found-list { grid-template-columns: 1fr; max-height: 40vh; overflow-y: auto; }
.result-card.recorded { opacity: 0.92; border-top-style: dashed; }
.result-head .tag {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); border: 1px solid var(--muted); border-radius: 4px;
  padding: 1px 4px; margin-left: 6px; font-weight: 600;
}
.results-header { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.results-header h2 { margin: 0; }

/* --- Challenge (replay) --- */
.replay-banner {
  background: var(--panel); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; color: var(--text);
}
.player-chip.recorded { opacity: 0.7; border: 1px dashed var(--chip); background: transparent; }

/* --- Landing actions --- */
.landing-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.landing-actions .primary { min-width: 240px; }
/* The daily entry is an <a>, so it needs the button look explicitly (the base
   button styles only target <button> elements). */
.daily-btn {
  display: inline-block; text-decoration: none; text-align: center;
  background: var(--accent); color: #1a1300; font-weight: 600;
  border-radius: 8px; cursor: pointer; transition: filter 0.15s ease;
}
.daily-btn:hover { filter: brightness(1.15); }

/* --- Daily layout --- */
.daily {
  max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px;
  display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap;
}
.daily-main { flex: 1 1 420px; min-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.daily-title { margin: 0; font-size: 1.6rem; }
.daily-side { flex: 1 1 240px; min-width: 220px; display: flex; flex-direction: column; gap: 18px; }
.daily-main .board-wrap { width: min(90vw, 440px); }

/* Mobile-only daily chrome — hidden on desktop, shown in the mobile media query. */
.m-score, .m-chips, .m-sheet, .m-backdrop { display: none; }

.leaderboard, .yesterday-board, .hints-box, .hint-box, .reveal-box { background: var(--panel); border-radius: 12px; padding: 16px; }
.leaderboard h2 { margin: 0 0 10px; font-size: 1.1rem; }
.lb-you { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--panel-2); color: var(--muted); font-size: 0.9rem; }
.lb-you b { color: var(--text); }
.leaderboard-list { list-style: none; counter-reset: rank; margin: 0; padding: 0; }
.leaderboard-list li {
  counter-increment: rank; display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-bottom: 1px solid var(--panel-2);
}
.leaderboard-list li::before { content: counter(rank); color: var(--muted); width: 1.4em; text-align: right; font-variant-numeric: tabular-nums; }
.leaderboard-list li.me { background: rgba(255,255,255,0.04); border-radius: 6px; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-badges { display: inline-flex; gap: 2px; flex: none; }
.lb-badges .badge { font-size: 0.85rem; cursor: help; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 700; }
/* Tap a leaderboard row -> player detail modal (badges + yesterday's finish) */
.leaderboard-list li { cursor: pointer; }
.lb-detail-list { display: flex; flex-direction: column; gap: 10px; }
.lb-detail-row { font-size: 0.98rem; }

.hints-box button, .hint-box button, .reveal-box button, .yesterday-board button { width: 100%; }
#hints-panel, #hint-panel, #reveal-panel, #yesterday-panel { margin-top: 12px; }
.dist-wrap { overflow-x: auto; margin-top: 6px; }
.dist-grid { border-collapse: collapse; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.dist-grid th, .dist-grid td { padding: 2px 7px; text-align: center; color: var(--text); }
.dist-grid th { color: var(--muted); font-weight: 600; }
.dist-grid .t { color: var(--accent); font-weight: 700; }

.mini-board { width: 180px; gap: 4px; margin: 10px 0; }
.tile.mini { border-radius: 6px; font-size: 0.9rem; box-shadow: 0 2px 0 rgba(0,0,0,0.35); }
.reveal-mode { margin: 4px 0 10px; font-size: 0.8rem; padding: 4px 12px; }
.reveal-words { max-height: 40vh; overflow-y: auto; }
.reveal-words li.got { color: #7ed321; font-weight: 700; }

/* --- Daily rank meter + rarity --- */
.rank-meter { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; }
.rank-name { font-weight: 700; color: var(--accent); white-space: nowrap; }
.rank-bar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.rank-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
.rarest { color: var(--muted); font-size: 0.9rem; margin: 0 0 10px; }

/* Daily word bank: uncommon finds pop yellow, common ones sit grey. */
.found-list li .word-row { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
#my-words-list li { cursor: pointer; } /* tap a found word for its definition */
.def-pos { color: var(--accent); font-style: italic; margin-right: 4px; }
.def-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.def-tag {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid transparent;
}
.tag-scrabble { color: #34d27a; background: rgba(52, 210, 122, 0.14); border-color: rgba(52, 210, 122, 0.4); }
.tag-slang { color: var(--accent); background: rgba(245, 166, 35, 0.14); border-color: rgba(245, 166, 35, 0.4); }
.pct-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  background: var(--panel-2); color: #e3e6ec;
  font-size: 0.55rem; font-variant-numeric: tabular-nums; font-weight: 700;
}
/* Rarer finds get more vivid backgrounds; light-grey text on all (the rarest
   <1% tier flips to a white badge with dark text). */
.pct-badge.pc-grey   { background: var(--panel-2); color: #e3e6ec; }
.pct-badge.pc-green  { background: rgb(0, 91, 50); color: #e3e6ec; }
.pct-badge.pc-blue   { background: rgb(14, 0, 72); color: #e3e6ec; }
.pct-badge.pc-purple { background: rgb(43, 0, 54); color: #e3e6ec; }
.pct-badge.pc-orange { background: rgb(133, 74, 0); color: #e3e6ec; }
.pct-badge.pc-yellow { background: #ffffff; color: #333333; }
.found-list li.w-uncommon .w { color: var(--muted); }
.found-list li.w-common .w { color: #f1c40f; }

/* --- Suggest-a-word footer (all pages) --- */
.site-footer {
  border-top: 1px solid var(--panel-2); margin-top: 40px;
  padding: 16px 20px; display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.petition-lead { margin: 0; color: var(--muted); font-size: 0.95rem; }
.petition-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.petition-form input { text-transform: uppercase; min-width: 200px; }
.petition-msg { font-size: 0.9rem; }

/* About / SEO copy (below the fold on the landing page) */
.about {
  max-width: 640px; margin: 56px auto 0; padding: 0 20px;
  color: var(--muted); font-size: 0.95rem; line-height: 1.6;
}
.about h2 { font-size: 1.15rem; color: var(--text); margin: 28px 0 6px; }
.about p { margin: 0; }
.about a { color: var(--accent); }

/* --- Admin --- */
.admin { max-width: 560px; margin: 0 auto; padding: 24px 20px 60px; }
.admin h1 { font-size: 1.4rem; margin: 0 0 6px; }
.admin-list { list-style: none; padding: 0; margin: 16px 0 0; }
.admin-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--panel-2);
}
.admin-word { font-family: ui-monospace, monospace; font-size: 1.1rem; letter-spacing: 1px; }
.admin-actions { display: flex; gap: 8px; }
.admin-h2 { margin: 28px 0 8px; font-size: 1.1rem; }
.word-search { display: flex; gap: 8px; margin-bottom: 12px; }
.word-search input { flex: 1; text-transform: uppercase; }
.word-results {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2px 16px; max-height: 50vh; overflow-y: auto;
  font-family: ui-monospace, monospace;
}
.word-results li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 3px 0; color: var(--muted);
}
.word-results li.wl-common { color: var(--text); }
.wl-word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-tag { font-size: 0.65rem; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 4px; }
.wl-toggle { font-size: 0.7rem; padding: 2px 8px; flex: none; }

/* --- Admin: metrics + leaderboard --- */
.metrics { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 4px 0 0; }
.metric { font-size: 0.95rem; }
.metric b { color: var(--text); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.admin-leaderboard { list-style: none; padding: 0; margin: 8px 0 0; }
.lb-entry { border-bottom: 1px solid var(--panel-2); }
.lb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
}
.lb-rank { width: 1.6em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stat { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.lb-remove, .lb-words-toggle { font-size: 0.7rem; padding: 2px 8px; flex: none; }
.lb-words {
  list-style: none; margin: 0 0 10px; padding: 0 0 0 calc(1.6em + 24px);
  display: flex; flex-wrap: wrap; gap: 4px 8px;
}
.lb-words li { font-size: 0.82rem; letter-spacing: 0.02em; }
.lb-words li.muted { font-style: italic; }

/* --- Drag trail --- */
.drag-trail { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; }
.drag-trail polyline { opacity: 0.5; }

/* --- Long-word board shimmer (diagonal glint in the word's rarity color) ---
   Two oversized stripes (::before + a delayed ::after) sweep from the lower-left
   corner up to the top-right. The main band has a bright white core for gloss,
   and the offset secondary glint makes it read as a shimmer rather than one
   sweeping line. --ripple-color is set inline in JS. */
.board-shimmer {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  pointer-events: none; z-index: 3; opacity: 0;
  animation: shimmer-fade 1s ease-out forwards;
}
.board-shimmer::before,
.board-shimmer::after {
  content: ''; position: absolute; left: -100%; top: -100%; width: 300%; height: 300%;
  transform: translate(-16.7%, 16.7%); /* band at the lower-left corner */
}
/* Main glossy band: rarity color with a bright white core. */
.board-shimmer::before {
  background: linear-gradient(45deg,
    transparent 34%,
    var(--ripple-color, #f5a623) 46%,
    rgba(255, 255, 255, 0.95) 50%,
    var(--ripple-color, #f5a623) 54%,
    transparent 66%);
  animation: shimmer-sweep 1s ease-out forwards;
}
/* Thinner, slightly delayed white glint for sparkle. */
.board-shimmer::after {
  background: linear-gradient(45deg,
    transparent 45%,
    rgba(255, 255, 255, 0.85) 50%,
    transparent 55%);
  opacity: 0.85;
  animation: shimmer-sweep 1s ease-out 0.13s forwards;
}
@keyframes shimmer-sweep {
  from { transform: translate(-16.7%, 16.7%); } /* lower-left */
  to   { transform: translate(16.7%, -16.7%); } /* top-right */
}
@keyframes shimmer-fade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  82% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Floating +points --- */
.float-points {
  position: absolute; left: 50%; top: 88%; transform: translate(-50%, 0);
  font-size: 2.2rem; font-weight: 800; pointer-events: none; z-index: 4;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.8);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  animation: float-up 1.8s ease-out forwards;
}
/* Match the word's rarity tier (brightened for legibility over the board). */
.float-points.pc-grey   { color: #cdd2db; }
.float-points.pc-green  { color: #34d27a; }
.float-points.pc-blue   { color: #6ea0ff; }
.float-points.pc-purple { color: #c07be0; }
.float-points.pc-orange { color: #f5a83a; }
.float-points.pc-yellow { color: #ffffff; }
@keyframes float-up {
  from { transform: translate(-50%, 0); opacity: 1; }
  to { transform: translate(-50%, -280px); opacity: 0; }
}

/* --- "Level up!" pops in and floats up on a rank advance --- */
.float-levelup {
  position: absolute; left: 50%; top: 55%; transform: translate(-50%, 0);
  font-size: 1.5rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  white-space: nowrap; color: #f5a623; pointer-events: none; z-index: 5;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.85);
  text-shadow: 0 0 14px rgba(245, 166, 35, 0.8), 0 1px 3px rgba(0, 0, 0, 0.6);
  animation: levelup-float 1.6s ease-out forwards;
}
@keyframes levelup-float {
  0% { transform: translate(-50%, 12px) scale(0.7); opacity: 0; }
  20% { transform: translate(-50%, 0) scale(1.12); opacity: 1; }
  35% { transform: translate(-50%, 0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -200px) scale(1); opacity: 0; }
}
/* --- "You're a star!" floats up when all common words are found --- */
.float-star {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, 0);
  width: max-content; max-width: 90%; text-align: center;
  font-size: 1.4rem; font-weight: 800; letter-spacing: 0.5px; line-height: 1.3;
  color: #ffd34d; pointer-events: none; z-index: 6;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.85);
  text-shadow: 0 0 16px rgba(255, 211, 77, 0.85), 0 1px 3px rgba(0, 0, 0, 0.7);
  animation: star-float 2.5s ease-out forwards;
}
@keyframes star-float {
  0% { transform: translate(-50%, 16px) scale(0.7); opacity: 0; }
  15% { transform: translate(-50%, 0) scale(1.12); opacity: 1; }
  30% { transform: translate(-50%, 0) scale(1); opacity: 1; }
  80% { transform: translate(-50%, -60px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -220px) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .board-shimmer, .board-shimmer::before, .board-shimmer::after,
  .float-points, .float-levelup, .float-star { animation-duration: 0.01s; }
}

/* --- Distribution toggle / goal / hint --- */
.dist-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.dist-mode { padding: 4px 10px; font-size: 0.8rem; }
.dist-mode.on { background: var(--accent); color: #1a1300; font-weight: 700; }
.dist-goal { margin: 8px 0 2px; color: var(--muted); font-size: 0.85rem; }
.dist-allfound { margin: 18px 0; text-align: center; color: var(--accent); font-weight: 700; font-size: 1rem; }
.dist-hint { margin: 4px 0 0; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.hint-pattern {
  margin: 4px 0 0; text-align: center;
  font-family: ui-monospace, monospace; font-size: 1.6rem; font-weight: 700;
  letter-spacing: 6px; color: var(--accent); text-transform: uppercase;
}

/* --- Word-found pill (green new / yellow duplicate / red invalid) --- */
.t-word.flash {
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; padding: 7px 18px 5px; border-radius: 999px;
  color: #34d27a; background: var(--panel-2); /* new word = green */
}
.t-word.flash.special { animation: word-pop 0.7s ease; box-shadow: 0 0 22px 5px rgba(245, 166, 35, 0.75); }
/* Already-found: yellow pill with a little shake */
.t-word.flash.dup { color: #f1c40f; animation: tracer-shake 0.45s ease; }
/* Rejected (not a word / not on board / too short): red pill with a shake */
.t-word.flash.bad { color: #e74c3c; animation: tracer-shake 0.45s ease; }
@keyframes tracer-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
/* Uncommon finds get a diagonal sheen sweeping up-and-right, like the board. */
.t-word.flash.sheen { position: relative; overflow: hidden; }
.t-word.flash.sheen::after {
  content: ''; position: absolute; inset: -60%;
  background: linear-gradient(45deg, transparent 42%, rgba(255, 255, 255, 0.9) 50%, transparent 58%);
  transform: translate(-40%, 40%);
  animation: pill-sheen 0.85s ease-out;
}
@keyframes pill-sheen {
  from { transform: translate(-40%, 40%); }
  to   { transform: translate(40%, -40%); }
}
@keyframes word-pop {
  0% { transform: scale(0.6); }
  45% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .t-word.flash.special { animation: none; }
}

/* --- How-to-play modal (centered, works on mobile + desktop) --- */
.info-modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); padding: 20px;
}
.info-modal[hidden] { display: none; }
.info-card {
  background: var(--panel); border-radius: 14px; padding: 22px;
  width: 100%; max-width: 420px; max-height: 85dvh; overflow-y: auto;
}
.info-card h2 { margin: 0 0 12px; font-size: 1.3rem; }
.info-body { color: var(--text); font-size: 0.95rem; line-height: 1.55; }
.info-body p { margin: 0 0 10px; }
.info-body ul { margin: 0; padding-left: 18px; }
.info-body li { margin: 6px 0; }
.info-card .primary { width: 100%; margin-top: 16px; }

/* --- Mobile --- */
@media (max-width: 640px) {
  .type-form { display: none; } /* trace-to-find still works */
}

/* --- Daily mobile overhaul (no scroll; sheets + score pill + chips) --- */
@media (max-width: 640px) {
  body.daily-page {
    height: 100dvh; overflow: hidden;
    display: flex; flex-direction: column;
    /* No accidental text selection / long-press callout while dragging to trace. */
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
    touch-action: manipulation; /* no double-tap-to-zoom */
  }
  .daily-page input { -webkit-user-select: text; user-select: text; }
  .daily-page .room-header { flex: none; padding: 10px 16px; }
  .daily-page #daily-date { display: none; }        /* drop the date */
  .daily-page .daily-title { display: none; }        /* drop the title */
  .daily-page .daily ~ .site-footer,
  .daily-page .site-footer { display: none; }        /* no petition footer on mobile daily */

  .daily-page .daily {
    flex: 1; min-height: 0; height: auto;
    max-width: none; margin: 0;
    padding: 6px 12px max(10px, env(safe-area-inset-bottom));
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px;
  }
  .daily-page .daily-side { display: none; }          /* moved into sheets */
  .daily-page .daily-main {
    flex: 1; width: 100%; min-width: 0; min-height: 0;
    gap: 10px; justify-content: flex-start;
  }

  /* Score pill (tap → Your Words sheet): points + words above a taller bar,
     rank + place at right, recent words below. */
  .daily-page .m-score {
    display: flex; flex-direction: column; gap: 7px; flex: none; width: 100%;
    background: var(--panel); border: none; border-radius: 12px;
    padding: 11px 16px; color: var(--text); text-align: left; cursor: pointer;
  }
  .m-score-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .m-score-pts { font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
  .m-score-pts b { font-size: 1.35rem; font-weight: 800; color: var(--accent); }
  .m-score-rank { font-size: 0.85rem; color: var(--accent); font-weight: 700; white-space: nowrap; }
  .m-score-place { color: var(--muted); }
  .m-score-place.place-1 { color: #ffcf33; } /* gold */
  .m-score-place.place-2 { color: #cdd2db; } /* silver */
  .m-score-place.place-3 { color: #c8813c; } /* copper */
  .m-score-bar { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
  #m-score-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
  .m-score-recent {
    font-size: 0.8rem; color: var(--muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }

  /* Flat top-anchored layout: score pill, board, tracer, chips stacked from the
     top. The board is sized against 100svh (the stable small viewport, so it
     never clips when the address bar shows/hides) minus the measured chrome
     height (--chrome, set in JS — no magic numbers). */
  .daily-page .daily-main .board-wrap {
    position: relative; margin: 0 auto;
    width: min(92vw, calc(100svh - var(--chrome, 340px)));
  }

  /* Action chips sit just under the board, always on screen. */
  .daily-page .m-chips { display: flex; gap: 10px; flex: none; width: 100%; }
  .m-chip {
    flex: 1; padding: 14px 10px; border: none; border-radius: 12px;
    background: var(--panel); color: var(--text); font-size: 1rem; font-weight: 600; cursor: pointer;
  }

  /* Bottom sheets */
  .daily-page .m-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
    z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .daily-page .m-backdrop.open { opacity: 1; pointer-events: auto; }
  .daily-page .m-sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
    background: var(--panel); border-radius: 16px 16px 0 0;
    padding: 0 16px 24px; max-height: 86dvh; overflow-y: auto;
    transform: translateY(100%); transition: transform 0.25s ease;
  }
  .daily-page .m-sheet.open { transform: translateY(0); }
  /* Distribution sheet is tall by default so revealing the hint doesn't resize it. */
  .daily-page #sheet-dist { min-height: 70dvh; }
  .m-sheet-head {
    position: sticky; top: 0; background: var(--panel); z-index: 1;
    display: flex; align-items: center; gap: 8px; padding: 14px 0 8px;
  }
  .m-sheet-head h2 { margin: 0; font-size: 1.1rem; padding-top: 6px; }
  .m-grab {
    position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 36px; height: 4px; border-radius: 999px; background: var(--panel-2);
  }

  /* Flatten the nested card styling once sections live inside a sheet */
  .m-sheet .my-words, .m-sheet .leaderboard, .m-sheet .yesterday-board,
  .m-sheet .hints-box, .m-sheet .hint-box, .m-sheet .reveal-box,
  .m-sheet .you-editor {
    background: none; padding: 0; margin: 0 0 16px;
  }
  .m-sheet .you-editor { flex-wrap: wrap; margin-top: 8px; }
  #hints-toggle { display: none; }                    /* distribution auto-shows in its sheet */
}
