/* ============================================================
   Marigold — warm, soft, iPhone-first.
   Palette: cream, sage, dusty rose, warm plum, marigold-orange.
   ============================================================ */

:root {
  --cream:        #fdf6ec;
  --cream-deep:   #f6ebd9;
  --sand:         #efe2cb;
  --rose:         #d9a18a;
  --rose-deep:    #c08367;
  --plum:         #6f4e57;
  --plum-soft:    #8a6770;
  --ink:          #3a2f29;
  --ink-soft:     #6e5b50;
  --ink-muted:    #9e8b80;
  --sage:         #9bb39a;
  --sage-deep:    #6f8e6f;
  --marigold:     #d97f3a;
  --marigold-deep:#b5612a;
  --yellow:       #e8c25c;
  --line:         rgba(58, 47, 41, 0.10);
  --shadow:       0 1px 0 rgba(58, 47, 41, 0.04), 0 12px 24px -16px rgba(58, 47, 41, 0.16);
  --radius:       16px;
  --radius-sm:    10px;
  --tap:          44px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
html {
  -webkit-text-size-adjust: 100%;
  /* Background moved here from <body> so the fixed flag decoration layer
     (z-index: -1) is visible against this color instead of being hidden
     behind body's own paint. iOS Safari has a long-standing quirk where
     position:fixed children of a stacking-context body can escape it. */
  background: var(--cream);
}

body {
  margin: 0;
  /* No background here — see html rule above. */
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* iPhone safe area */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  /* All site chrome text is lowercase. Game-letter elements override below. */
  text-transform: lowercase;
}

/* Reinforce lowercase on common chrome elements so heavy-weight headings
   or buttons don't bypass the body-level rule. */
h1, h2, h3, h4, h5, h6,
button, a, label, input, p, span, div, li, td, th, nav {
  text-transform: inherit;
}

/* Preserve case for actual game content (letter tiles, cells, found words,
   share grids, etc.) — these letters ARE the game and must stay uppercase. */
.quint-cell,
.kbd-key,
.knit-tile,
.knit-solved-row .cat-words,
.petal,
.pollen-entry,
.pollen-found li,
.pips-domino,
.pips-ghost,
.pips-value,
.xword-cell,
.xword-cell .xword-letter,
.strands-cell,
.found-item {
  text-transform: none !important;
}

h1, h2, h3, .brand, .title {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Apple Garamond", "Palatino", serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--rose-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------
   Topbar (used on every game page)
   ------------------------------------------------------------ */
.topbar {
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
  position: sticky; top: 0; z-index: 5;
}
.topbar.topbar-4 {
  grid-template-columns: var(--tap) 1fr var(--tap) var(--tap);
}
.topbar .back, .topbar .stats-link, .topbar .help-btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap);
  font-size: 22px;
  color: var(--plum);
  border-radius: 999px;
}
.topbar .help-btn {
  appearance: none;
  border: none;
  background: transparent;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  cursor: pointer;
}
.topbar .help-btn:hover { background: var(--cream-deep); }
.topbar .help-btn:active { transform: scale(0.95); }

/* Per-game sub-nav strip (injected by decor.js): My stats · X leaderboard */
.game-subnav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 8px;
  font-size: 13px;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
  background: var(--cream);
  position: sticky;
  top: var(--tap);
  z-index: 4;
}
.game-subnav a {
  color: var(--plum);
  font-weight: 600;
  padding: 4px 6px;
}
.game-subnav a:hover { color: var(--marigold-deep); text-decoration: none; }
.topbar .title {
  text-align: center;
  font-size: 22px;
  margin: 0;
  color: var(--plum);
}

/* ------------------------------------------------------------
   Generic blocks
   ------------------------------------------------------------ */
.btn {
  appearance: none;
  border: none;
  background: var(--rose-deep);
  color: var(--cream);
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  min-height: var(--tap);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:hover { background: var(--plum); }
.btn:active { transform: scale(0.98); }
.btn:disabled {
  background: var(--sand); color: var(--ink-muted); cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--plum);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { background: var(--cream-deep); color: var(--plum); }
.link-btn {
  background: none; border: none; color: var(--rose-deep);
  font: inherit; cursor: pointer; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.message {
  text-align: center;
  color: var(--plum-soft);
  min-height: 1.2em;
  font-size: 14px;
  margin: 8px 0;
}
.muted { color: var(--ink-muted); }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 380px;
  width: 92%;
  box-shadow: var(--shadow);
}

.centered {
  min-height: 100dvh;
  display: grid;
  /* Row 1: the clock-bar (auto height). Row 2: card area takes the rest. */
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  padding: 0;
}
.centered > main {
  align-self: center;
  justify-self: center;
}

.card .brand { font-size: 32px; margin: 0 0 4px; color: var(--marigold-deep); }
.card form { display: grid; gap: 12px; margin-top: 18px; }
.card input[type=email], .card input[type=text] {
  font: inherit; padding: 12px 14px; min-height: var(--tap);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--cream);
  width: 100%;
}
.card input:focus { outline: none; border-color: var(--rose); }
.card label {
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}
.setup-title {
  margin: 12px 0 4px;
  color: var(--plum);
  font-family: ui-serif, Georgia, serif;
  font-size: 22px;
}
.name-form { gap: 14px; }
.city-row { transition: all 0.2s ease; }

/* ------------------------------------------------------------
   Home / tile picker
   ------------------------------------------------------------ */
.home-nav {
  padding: env(safe-area-inset-top) 16px 0;
  text-align: right;
  max-width: 520px;
  margin: 0 auto;
}
.home-nav-link {
  display: inline-block;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--plum);
  font-weight: 600;
}
.home-nav-link:hover { color: var(--marigold-deep); }

.home-header {
  text-align: center;
  padding: 12px 16px 8px;
}
.brand { font-size: 40px; margin: 0; color: var(--marigold-deep); }
.brand-sub { color: var(--plum-soft); margin: 4px 0 0; font-style: italic; }
.home-logo {
  display: block;
  width: min(80%, 420px);
  height: auto;
  margin: 0 auto;
}
.login-logo {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  margin: 0 auto 8px;
}
@media (max-width: 520px) {
  .home-logo { width: 88%; }
}

/* Wrapper that holds the tile grid, the leaderboard, and the footer — the
   decorative vine lives inside this same wrapper so it spans the full
   height of the home content (and ends right where the content ends, no
   matter how long the leaderboard becomes). */
.home-content {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}
.tiles {
  display: grid;
  gap: 14px;
  padding: 16px;
  position: relative;
  z-index: 1;
}
/* Vine that snakes through the tile area, behind every tile.
   Explicit height is REQUIRED — SVGs ignore the implicit top/bottom-derived
   height that <div>s get for free and would otherwise fall back to their
   intrinsic viewBox-derived height (here, ~10× too tall). */
.tiles-vine {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 84%;
  max-width: 460px;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.tiles > a.tile {
  position: relative;
  z-index: 1;
}
.tile {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.tile:hover { transform: translateY(-1px); }
.tile-art {
  background: var(--cream-deep);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  aspect-ratio: 1 / 1;
}
.tile-art svg { width: 70%; height: 70%; fill: var(--plum-soft); }
.tile-quint .art-on { fill: var(--sage-deep); }
.tile-knit  .art-on-a { fill: var(--yellow); }
.tile-knit  .art-on-b { fill: var(--sage); }
.tile-knit  .art-on-c { fill: var(--rose); }
.tile-pollen .art-center { fill: var(--marigold); }
.tile-pollen circle { fill: var(--yellow); }
.tile-pollen .art-center { fill: var(--marigold); }
.tile-garland svg     { color: var(--sage-deep); }
.tile-garland circle  { fill: var(--rose-deep); }
.tile-trellis .art-block { fill: var(--plum); }
.tile-trellis rect       { fill: var(--cream-deep); stroke: var(--plum-soft); stroke-width: 1; }
.tile-petal      .art-block { fill: var(--plum); }
.tile-petal      rect       { fill: var(--rose); stroke: var(--plum-soft); stroke-width: 1; }
.tile-tally rect    { fill: var(--cream-deep); stroke: var(--plum); stroke-width: 1.5; }
.tile-tally circle  { fill: var(--plum); }
.tile-tally .art-divider { stroke: var(--plum); }

.tile h2 { margin: 4px 0 2px; font-size: 22px; color: var(--plum); }
.tile p  { margin: 0; color: var(--ink-soft); font-size: 14px; }
.tile-status {
  display: inline-block; margin-top: 8px;
  font-size: 12px; color: var(--ink-muted);
}
.tile-status.done { color: var(--sage-deep); font-weight: 600; }

.home-lb {
  max-width: 520px;
  margin: 24px auto 8px;
  padding: 0 16px;
  /* Sit above the fixed MD-flag stamps. */
  position: relative;
  z-index: 2;
}
.home-lb-title {
  font-family: ui-serif, Georgia, serif;
  font-size: 18px;
  color: var(--marigold-deep);
  margin: 0 0 10px;
  text-align: center;
}
.home-lb-foot {
  text-align: center;
  margin-top: 14px;
}
.home-lb-more {
  font-size: 13px;
  color: var(--plum);
  font-weight: 600;
}
.home-lb-cards { display: grid; gap: 8px; position: relative; z-index: 2; }
.home-lb-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  align-items: center;
  /* Sit explicitly above the fixed MD-flag stamps. */
  position: relative;
  z-index: 2;
}
.home-lb-card.home-lb-leader {
  background: linear-gradient(135deg, #fff 0%, var(--cream-deep) 100%);
  border: 1.5px solid var(--marigold);
}
.home-lb-rank {
  grid-row: 1 / span 2;
  font-size: 22px;
  font-family: ui-serif, Georgia, serif;
  text-align: center;
  color: var(--plum);
}
.home-lb-leader .home-lb-rank { color: var(--marigold-deep); }
.home-lb-name {
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}
.home-lb-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--ink-soft);
}
.home-lb-stats strong { color: var(--ink); font-weight: 700; }

.home-foot {
  text-align: center;
  padding: 28px 16px calc(env(safe-area-inset-bottom) + 28px);
  color: var(--ink-muted); font-size: 13px;
  /* Sit above the vine SVG in .home-content */
  position: relative;
  z-index: 2;
}
.home-foot .inline { display: inline; }
.dot-sep { padding: 0 8px; }

/* Collapsible "about" blurb that lives at the very bottom of the home page.
   Hidden by default; the #about-toggle button reveals it in place. */
.about-blurb {
  max-width: 480px;
  margin: -8px auto 24px;
  padding: 16px 20px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  position: relative;
  z-index: 2;
}
.about-blurb p {
  margin: 0;
}
@media (max-width: 520px) {
  .about-blurb { margin: -8px 16px 24px; padding: 14px 16px; font-size: 13.5px; }
}

/* ------------------------------------------------------------
   Quint board
   ------------------------------------------------------------ */
.quint-main {
  display: grid; gap: 10px;
  padding: 14px 12px;
  max-width: 420px; margin: 0 auto;
  height: calc(100dvh - 60px);
  grid-template-rows: 1fr auto auto;
  align-content: stretch;
}
.quint-board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  justify-content: center; align-content: center;
  width: 100%;
}
.quint-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 320px);
  margin: 0 auto;
}
.quint-cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: clamp(20px, 7vw, 32px);
  color: var(--ink);
  background: var(--cream);
  user-select: none;
  transition: transform 0.12s ease;
}
.quint-cell.filled {
  border-color: var(--plum-soft);
  transform: scale(1.02);
}
.quint-cell.flipped {
  color: #fff;
  border-color: transparent;
  animation: flip 0.45s ease-out both;
  animation-delay: calc(var(--i, 0) * 110ms);
}
.quint-cell.hit  { background: var(--sage-deep); }
.quint-cell.near { background: var(--marigold); }
.quint-cell.miss { background: var(--plum-soft); }

@keyframes flip {
  0%   { transform: rotateX(0); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

.quint-keyboard {
  display: grid; gap: 6px;
  margin-top: 4px;
  padding-bottom: env(safe-area-inset-bottom);
}
.kbd-row { display: flex; justify-content: center; gap: 5px; }
.kbd-key {
  appearance: none; border: none;
  font: inherit;
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  border-radius: 8px;
  background: var(--cream-deep);
  color: var(--ink);
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
}
.kbd-key.kbd-wide { flex: 1.6 1 0; font-size: 13px; }
.kbd-key.hit  { background: var(--sage-deep); color: #fff; }
.kbd-key.near { background: var(--marigold); color: #fff; }
.kbd-key.miss { background: #c9b9a8; color: #fff; }
.kbd-key:active { transform: scale(0.96); }

/* ------------------------------------------------------------
   Knit
   ------------------------------------------------------------ */
.knit-main {
  padding: 12px;
  max-width: 460px; margin: 0 auto;
}
.knit-blurb { color: var(--ink-soft); margin: 4px 4px 12px; font-size: 14px; }
.knit-solved { display: grid; gap: 6px; margin-bottom: 8px; }
.knit-solved-row {
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  text-align: center;
  font-size: 13px;
  line-height: 1.3;
}
.knit-solved-row .cat-name {
  font-family: ui-serif, Georgia, serif; font-weight: 700; font-size: 14px;
}
.knit-solved-row .cat-words { font-size: 12px; opacity: 0.85; }
.k-yellow { background: #f0d57a; }
.k-sage   { background: #b9d2b1; }
.k-rose   { background: #e8b3a3; }
.k-plum   { background: #c2a0c4; }

.knit-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.knit-tile {
  appearance: none; border: none;
  background: var(--cream-deep);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(11px, 3.2vw, 14px);
  letter-spacing: 0.02em;
  border-radius: 10px;
  aspect-ratio: 1 / 1;
  padding: 4px;
  display: grid; place-items: center;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.08s;
  word-break: break-word;
  hyphens: auto;
  overflow: hidden;
}
.knit-tile.tiny { font-size: clamp(9.5px, 2.6vw, 12px); }
.knit-tile:hover { background: var(--sand); }
.knit-tile.selected {
  background: var(--plum);
  color: #fff;
  transform: scale(0.98);
}

.knit-mistakes {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin: 14px 0;
  color: var(--ink-soft); font-size: 14px;
}
.dots { display: inline-flex; gap: 6px; }
.dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: var(--plum); display: inline-block;
}
.dot.spent { background: var(--line); }

.knit-controls {
  display: flex; gap: 8px; justify-content: center; margin-top: 8px;
}

/* ------------------------------------------------------------
   Pollen
   ------------------------------------------------------------ */
.pollen-main {
  padding: 12px;
  max-width: 440px; margin: 0 auto;
  display: grid; gap: 10px;
}
.pollen-tier-row {
  display: flex; align-items: baseline; justify-content: space-between;
}
.tier-name {
  font-family: ui-serif, Georgia, serif; font-weight: 700;
  color: var(--marigold-deep); font-size: 18px;
}
.tier-points { color: var(--ink-soft); font-size: 14px; }
/* "saved" indicator — invisible until a save lands, then fades for a sec. */
.save-indicator {
  font-size: 11px;
  color: var(--sage-deep);
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.save-indicator.saved-visible { opacity: 1; }
.pollen-tier-bar {
  position: relative;
  height: 6px; border-radius: 999px;
  background: var(--cream-deep);
  overflow: visible;
}
.tier-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--rose), var(--marigold));
  transition: width 0.4s ease;
}
.tier-ticks {
  position: absolute; top: 0; left: 0; right: 0; height: 100%;
}
.tier-tick {
  position: absolute; top: -3px;
  width: 2px; height: 12px;
  background: var(--plum-soft); opacity: 0.5;
  border-radius: 1px;
  transform: translateX(-1px);
}

.pollen-entry {
  text-align: center;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: clamp(20px, 6vw, 30px);
  min-height: 1.6em;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.pollen-entry .entry-center { color: var(--marigold-deep); }

.pollen-flower {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 6px;
  justify-content: center; align-content: center;
  margin: 8px auto 4px;
}
.petal {
  appearance: none; border: none;
  background: var(--cream-deep);
  color: var(--ink);
  font: inherit;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 22px;
  cursor: pointer;
  /* hexagon-ish corners via clip-path */
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%);
}
.petal-center { background: var(--marigold); color: #fff; }
.petal:active { transform: scale(0.95); }
/* arrange six outer petals around center */
.pollen-flower .petal:nth-child(1) { grid-area: 2 / 2; }   /* center */
.pollen-flower .petal:nth-child(2) { grid-area: 1 / 2; }   /* top */
.pollen-flower .petal:nth-child(3) { grid-area: 1 / 3; }   /* upper right */
.pollen-flower .petal:nth-child(4) { grid-area: 2 / 3; }   /* lower right */ /* approximate */
.pollen-flower .petal:nth-child(5) { grid-area: 3 / 2; }   /* bottom */
.pollen-flower .petal:nth-child(6) { grid-area: 2 / 1; }   /* lower left */ /* approximate */
.pollen-flower .petal:nth-child(7) { grid-area: 1 / 1; }   /* upper left */
/* center cell visually overlaps; nudge it slightly */
.pollen-flower .petal-center { transform: scale(1.04); }

.pollen-controls {
  display: flex; gap: 8px; justify-content: center; margin-top: 4px;
}
.pollen-found-wrap {
  margin-top: 8px;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: var(--shadow);
}
.pollen-found-wrap summary {
  cursor: pointer; color: var(--plum); font-weight: 600; padding: 6px 0;
}
.pollen-found {
  list-style: none; margin: 0; padding: 6px 0 4px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
  font-size: 14px; color: var(--ink-soft);
  max-height: 280px; overflow-y: auto;
}
.pollen-found li.pangram { color: var(--marigold-deep); font-weight: 700; }

/* ------------------------------------------------------------
   Done dialog
   ------------------------------------------------------------ */
.done-dialog {
  border: none; padding: 0;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 64px -16px rgba(58, 47, 41, 0.4);
  max-width: 360px; width: 90%;
}
.done-dialog::backdrop { background: rgba(58, 47, 41, 0.4); }
.done-dialog h2 { margin: 0; padding: 20px 24px 4px; color: var(--marigold-deep); font-size: 22px; }
.done-dialog p { padding: 4px 24px 12px; color: var(--ink-soft); margin: 0; }
.done-dialog .btn, .done-dialog .btn-ghost {
  margin: 4px 12px 12px;
}

/* ------------------------------------------------------------
   Stats
   ------------------------------------------------------------ */
.stats-main {
  padding: 16px;
  max-width: 520px; margin: 0 auto;
}
.stats-summary {
  display: grid; gap: 10px; margin-bottom: 24px;
}
.summary-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.summary-card h2 {
  margin: 0 0 12px; font-size: 18px; color: var(--plum);
}
.summary-quint h2     { color: var(--sage-deep); }
.summary-knit h2      { color: var(--rose-deep); }
.summary-pollen h2    { color: var(--marigold-deep); }
.summary-garland h2   { color: var(--sage-deep); }
.summary-trellis h2 { color: var(--plum); }
.summary-petal h2      { color: var(--plum); }
.summary-tally h2      { color: var(--marigold-deep); }
.stat-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  text-align: center;
}
.stat-grid .big {
  display: block; font-family: ui-serif, Georgia, serif;
  font-weight: 700; font-size: 22px; color: var(--ink);
}
.stat-grid .lab {
  display: block; font-size: 11px; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}

.stats-recent h2 { font-size: 18px; color: var(--plum); margin: 0 0 8px; }
.stats-list { list-style: none; margin: 0; padding: 0; }
.stats-list li {
  display: grid;
  grid-template-columns: 90px 70px 1fr;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.r-date { color: var(--ink-muted); font-feature-settings: "tnum"; }
.r-game { color: var(--plum); font-weight: 600; }
.r-score.won { color: var(--sage-deep); }
.r-score.lost { color: var(--rose-deep); }

/* ------------------------------------------------------------
   Tweaks for small phones
   ------------------------------------------------------------ */
@media (max-width: 360px) {
  .quint-row { gap: 5px; }
  .quint-cell { font-size: 22px; }
  .kbd-key { min-height: 44px; }
  .pollen-flower { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); }
  .petal { font-size: 18px; }
  .tile { grid-template-columns: 72px 1fr; }
}
@media (min-width: 700px) {
  .home-content { max-width: 720px; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .tile  { grid-template-columns: 1fr; gap: 8px; padding: 18px; }
  .tile-art { aspect-ratio: 1 / 1; }
}

/* Reduce iOS double-tap zoom on tiles */
button { touch-action: manipulation; }

/* ------------------------------------------------------------
   Bonus play banner — shown at top of body when ?attempt=2+
   ------------------------------------------------------------ */
.bonus-banner {
  background: var(--marigold);
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
  text-align: center;
  font-weight: 500;
  position: relative;
  z-index: 7;
}
.bonus-banner strong { font-weight: 700; }

/* Play again button (added to done dialogs by attempt.js) */
.play-again-btn {
  display: block;
  margin: 4px 12px 12px;
  background: var(--plum);
}
.play-again-btn:hover { background: var(--plum-soft); }

/* ------------------------------------------------------------
   EST clock + date pill (prepended to every page)
   ------------------------------------------------------------ */
.clock-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px 6px;
  background: var(--cream);
  position: relative;
  z-index: 12;
}
.brand-mark-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.brand-mark {
  height: 28px;
  width: auto;
  display: block;
}
@media (max-width: 520px) {
  .brand-mark { height: 22px; }
}
/* Spacer when banner logo is hidden (home/login show big logo) */
.brand-mark-slot { display: inline-block; }

/* Right-side group of the clock-bar: music toggle + EST clock pill */
.clock-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Wrapper around the music toggle button + volume slider. Lives in the
   clock-bar's right group. The slider only renders when wrapper has .music-on. */
.music-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.music-controls .music-vol,
.music-controls .music-skip,
.music-controls .music-track {
  /* Hidden by default (music is off). Shown once the user turns music on. */
  display: none;
}
.music-controls.music-on .music-vol {
  display: inline-block;
}
.music-controls.music-on .music-skip {
  display: inline-flex;
}
.music-controls.music-on .music-track {
  display: inline-block;
}

/* "1/3" track counter — quiet typographic chip, no border. */
.music-track {
  font-family: ui-sans-serif, system-ui;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--plum);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  padding: 3px 6px;
  min-width: 26px;
  text-align: center;
  /* Game-like numbers stay in their normal case, override the body lowercase */
  text-transform: none;
}
@media (max-width: 520px) {
  .music-track { font-size: 10px; padding: 2px 4px; min-width: 22px; }
}

/* Skip-to-next-track button. Same chip shape as the toggle, slightly slimmer. */
.music-skip {
  appearance: none;
  background: #fff;
  border: 1.5px solid var(--marigold);
  border-radius: 12px;
  padding: 4px 6px;
  width: 30px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: var(--marigold-deep);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(58, 47, 41, 0.18);
  touch-action: manipulation;
}
.music-skip:hover { color: var(--marigold); }
.music-skip:active { transform: translateY(1px); }
.music-skip .music-icon { width: 14px; height: 14px; }
@media (max-width: 520px) {
  .music-skip { width: 26px; height: 28px; padding: 3px 4px; }
  .music-skip .music-icon { width: 12px; height: 12px; }
}

/* Slim, marigold-themed range slider. Cross-browser styling for both
   WebKit (Safari/Chrome) and Firefox track/thumb pseudos. */
.music-vol {
  -webkit-appearance: none;
  appearance: none;
  width: 78px;
  height: 24px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
  vertical-align: middle;
  touch-action: manipulation;
}
.music-vol:focus { outline: none; }
.music-vol::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--marigold), var(--marigold-deep));
  opacity: 0.85;
}
.music-vol::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--marigold), var(--marigold-deep));
  opacity: 0.85;
}
.music-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--marigold-deep);
  box-shadow: 0 1px 2px rgba(58, 47, 41, 0.2);
  margin-top: -5px;
  cursor: grab;
}
.music-vol::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--marigold-deep);
  box-shadow: 0 1px 2px rgba(58, 47, 41, 0.2);
  cursor: grab;
}
@media (max-width: 520px) {
  .music-vol { width: 60px; }
}

/* Music on/off toggle — sits next to the clock on every page */
.music-toggle {
  appearance: none;
  background: #fff;
  border: 1.5px solid var(--marigold);
  border-radius: 12px;
  padding: 5px 8px;
  width: 36px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--marigold-deep);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(58, 47, 41, 0.18);
  position: relative;
  z-index: 13;
  touch-action: manipulation;
}
.music-toggle:hover { color: var(--marigold); }
.music-toggle:active { transform: translateY(1px); }
.music-icon { width: 18px; height: 18px; display: block; }
/* By default (no class) show the "off" icon. */
.music-toggle .music-icon-on  { display: none; }
.music-toggle.music-on  .music-icon-on  { display: block; }
.music-toggle.music-on  .music-icon-off { display: none; }
.music-toggle.music-off .music-icon-on  { display: none; }
.music-toggle.music-off .music-icon-off { display: block; }
@media (max-width: 520px) {
  .music-toggle { width: 32px; height: 28px; padding: 4px 6px; }
  .music-icon { width: 16px; height: 16px; }
}
.est-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  background: #fff;
  border: 1.5px solid var(--marigold);
  border-radius: 12px;
  padding: 5px 12px;
  box-shadow: 0 2px 4px rgba(58, 47, 41, 0.18);
  font-family: ui-sans-serif, system-ui;
  font-size: 11px;
  line-height: 1.15;
  position: relative;
  z-index: 13;
  min-width: 90px;
}
.est-clock .est-date {
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.est-clock .est-time {
  color: var(--marigold-deep);
  font-family: ui-serif, Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   Vine + marigold decorations (corners of every page)
   ------------------------------------------------------------ */
.vine-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.vine-decor .vine-svg {
  position: absolute;
  width: 180px;
  height: 180px;
  opacity: 0.85;
}
.vine-decor .vine-tl { top: 0;    left: 0; }
.vine-decor .vine-tr { top: 0;    right: 0; }
.vine-decor .vine-bl { bottom: 0; left: 0; }
.vine-decor .vine-br { bottom: 0; right: 0; }

/* Maryland flag stamps — sit BEHIND all content (z-index: -1, against the
   html background which holds the cream color). They never block taps,
   text, or layout. iOS Safari's "fixed children escape parent stacking
   context" quirk doesn't matter here because z-index -1 is below anything
   anyone else has set, with html bg being the only thing further behind. */
.md-flag-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}
.md-flag-stamp {
  width: 40px;
  opacity: 0.92;
  transform: rotate(-6deg);
  filter: drop-shadow(0 1px 2px rgba(58, 47, 41, 0.2));
}
.md-flag-stamp:nth-child(even) { transform: rotate(7deg); }
.md-flag-stamp svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  /* Crisper rendering at small sizes — kills the pixelated edge halos */
  shape-rendering: geometricPrecision;
}

@media (max-width: 520px) {
  .md-flag-stamp { width: 30px; opacity: 0.9; }
}

/* Horizontal MD flag accent strip, sits just below the clock-bar on every
   page — mirrors the strip element in the Marigold logo. */
.md-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 6px;
  background: var(--cream);
  position: relative;
  z-index: 11;
  height: 14px;
}
.md-strip-calvert {
  width: 56px;
  height: 8px;
  background:
    repeating-linear-gradient(
      45deg,
      #FFD200 0 6px,
      #000000 6px 12px
    );
  border-radius: 2px;
  display: inline-block;
}
.md-strip-crossland {
  width: 56px;
  height: 8px;
  background: #9F1F1F;
  border-radius: 2px;
  position: relative;
  display: inline-block;
}
.md-strip-crossland::before,
.md-strip-crossland::after {
  content: '';
  position: absolute;
  background: #ffffff;
}
.md-strip-crossland::before {
  /* vertical bar of the cross */
  left: 50%;
  top: 0;
  width: 4px;
  height: 100%;
  transform: translateX(-50%);
}
.md-strip-crossland::after {
  /* horizontal bar of the cross */
  top: 50%;
  left: 8px;
  right: 8px;
  height: 3px;
  transform: translateY(-50%);
}
.md-strip-line {
  flex: 1;
  height: 1.5px;
  background: var(--marigold);
  max-width: 140px;
  border-radius: 1px;
}
.md-strip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--marigold);
}
@media (max-width: 520px) {
  .md-strip-calvert, .md-strip-crossland { width: 40px; height: 7px; }
  .md-strip-line { max-width: 80px; }
}

/* Make sure ALL direct content children of body sit above the decoration —
   includes <section> blocks like the home overall-leaderboard. The flag
   decorations are always behind everything. */
body > main,
body > header,
body > footer,
body > nav,
body > section,
body > dialog { position: relative; z-index: 1; }

/* On phones, keep all 4 corners — just shrink them */
@media (max-width: 520px) {
  .vine-decor .vine-svg { width: 100px; height: 100px; opacity: 0.7; }
  /* Push the top vines below the clock-bar so they don't crowd the time */
  .vine-decor .vine-tl, .vine-decor .vine-tr { top: 38px; }
}

/* On game pages, dial back the decoration so the playfield breathes */
.game .vine-decor .vine-svg { width: 100px; height: 100px; opacity: 0.5; }
@media (max-width: 520px) {
  .game .vine-decor .vine-svg { width: 80px; height: 80px; opacity: 0.5; }
}

/* ------------------------------------------------------------
   How-to-play dialog (per-game)
   ------------------------------------------------------------ */
.help-dialog {
  border: none; padding: 0;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 64px -16px rgba(58, 47, 41, 0.4);
  max-width: 380px; width: 92%;
  color: var(--ink);
}
.help-dialog::backdrop { background: rgba(58, 47, 41, 0.45); }
.help-dialog h2 {
  margin: 0; padding: 20px 24px 6px;
  color: var(--marigold-deep);
  font-size: 22px;
}
.help-list {
  list-style: none;
  margin: 0; padding: 4px 24px 16px;
}
.help-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.help-list li:last-child { border-bottom: none; }
.help-list strong { color: var(--ink); }
.help-list em { color: var(--plum); font-style: italic; }

/* Inline hint chips inside the help list */
.hint {
  display: inline-block;
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-family: ui-serif, Georgia, serif;
  color: #fff;
  text-align: center;
  margin-right: 2px;
}
.hint-hit    { background: var(--sage-deep); }
.hint-near   { background: var(--marigold); }
.hint-miss   { background: var(--plum-soft); }
.hint-center { background: var(--marigold); }

.help-dialog .btn { margin: 4px 24px 20px; }

/* ------------------------------------------------------------
   Pips
   ------------------------------------------------------------ */
.pips-main {
  padding: 14px 12px;
  max-width: 440px; margin: 0 auto;
  display: grid; gap: 12px;
}
.pips-board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 0;
  width: min(100%, 320px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border: 2px solid var(--plum);
  border-radius: 8px;
  overflow: hidden;
}
.pips-cell {
  appearance: none; border: none;
  font: inherit;
  position: relative;
  background: var(--cream);
  cursor: pointer;
  display: grid; place-items: center;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--ink);
}
.pips-region-0 { background: #e9d8a8; }
.pips-region-1 { background: #c2dac0; }
.pips-region-2 { background: #e8c0b3; }
.pips-region-3 { background: #c9b7d2; }
.pips-cell.border-top    { border-top:    2px solid var(--plum); }
.pips-cell.border-left   { border-left:   2px solid var(--plum); }
.pips-cell.border-right  { border-right:  2px solid var(--plum); }
.pips-cell.border-bottom { border-bottom: 2px solid var(--plum); }
.pips-region-label {
  position: absolute; top: 2px; left: 4px;
  font-size: 12px; color: var(--plum); font-weight: 700;
  font-family: ui-sans-serif, system-ui;
}
.pips-cell.pending { outline: 3px solid var(--marigold); outline-offset: -3px; }
.pips-cell.covered .pips-value { color: var(--cream); }
.pips-cell.covered::before {
  content: ''; position: absolute; inset: 6px;
  background: var(--plum);
  border-radius: 6px;
  z-index: 0;
}
.pips-cell.covered .pips-value, .pips-cell.covered .pips-region-label {
  position: relative; z-index: 1;
}
.pips-cell.covered .pips-region-label { color: var(--cream); opacity: 0.6; }

.pips-tray {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.pips-domino {
  appearance: none; border: 2px solid var(--plum);
  background: var(--cream);
  border-radius: 6px;
  padding: 8px 4px;
  font: inherit;
  display: flex; justify-content: center; align-items: center; gap: 6px;
  cursor: pointer;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  min-height: 44px;
}
.pips-domino .pip-divider {
  width: 1px; height: 20px; background: var(--plum);
}
.pips-domino.selected { background: var(--marigold); color: #fff; border-color: var(--marigold-deep); }
.pips-domino.placed { opacity: 0.3; pointer-events: none; }
.pips-domino { touch-action: none; user-select: none; -webkit-user-select: none; }

/* Drag-and-drop ghost domino that follows the finger/pointer */
.pips-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  width: 76px;
  height: 44px;
  background: var(--marigold);
  color: #fff;
  border: 2px solid var(--marigold-deep);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 6px 14px -4px rgba(58, 47, 41, 0.4);
  opacity: 0.95;
}
.pips-ghost.vertical {
  width: 44px;
  height: 76px;
  flex-direction: column;
}
.pips-ghost .pip-divider {
  width: 1px; height: 24px;
  background: rgba(255, 255, 255, 0.5);
}
.pips-ghost.vertical .pip-divider {
  width: 24px; height: 1px;
}

/* Cells highlight while a domino is being dragged over them */
.pips-cell { touch-action: none; user-select: none; -webkit-user-select: none; }
.pips-cell.drop-primary {
  box-shadow: inset 0 0 0 3px var(--marigold);
}
.pips-cell.drop-secondary {
  box-shadow: inset 0 0 0 3px var(--marigold);
  opacity: 0.85;
}
.pips-cell.selected-cell::before {
  outline: 2px solid var(--marigold);
}

.pips-controls {
  display: flex; gap: 8px; justify-content: center;
}

/* ------------------------------------------------------------
   Crossword (Mini and Full)
   ------------------------------------------------------------ */
.xword-main {
  padding: 12px;
  max-width: 460px; margin: 0 auto;
  display: grid; gap: 10px;
}
.xword-active-clue {
  background: var(--cream-deep);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  display: flex; align-items: center; gap: 8px;
  color: var(--ink);
  font-size: 15px;
}
.clue-pill {
  background: var(--marigold-deep); color: #fff;
  font-weight: 700; font-family: ui-serif, Georgia, serif;
  padding: 2px 8px; border-radius: 999px; font-size: 13px;
}
.xword-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  grid-template-rows: repeat(var(--rows, 4), 1fr);
  gap: 0;
  /* Total grid size — default; specific games override below */
  width: min(82vw, 280px);
  aspect-ratio: var(--cols, 4) / var(--rows, 4);
  margin: 0 auto;
  border: 2px solid var(--plum);
  background: var(--plum);
  box-sizing: border-box;
  /* The Full crossword overrides --grid-w via body class */
}
.game-petal      .xword-grid { width: min(82vw, 280px); }
.game-trellis .xword-grid { width: min(92vw, 360px); }

.xword-grid.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.xword-cell {
  /* Aggressive button reset for iOS Safari */
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--plum);
  background: #fff;
  padding: 0;
  margin: 0;
  font: inherit;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: clamp(16px, 5.5vw, 26px);
  color: var(--ink);
  cursor: pointer;
  position: relative;
  /* Cell sizing comes from the parent grid track, not aspect-ratio. */
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.xword-cell.block { background: var(--plum); cursor: default; }
.xword-cell.active { background: #e8d3a8; }
.xword-cell.cursor { background: var(--marigold); color: #fff; }
.xword-cell .xword-num {
  position: absolute;
  top: 2px; left: 4px;
  font-family: ui-sans-serif, system-ui;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  pointer-events: none;
}
.xword-cell.cursor .xword-num { color: rgba(255, 255, 255, 0.85); }
.xword-cell .xword-letter { pointer-events: none; }

/* Per-cell check feedback (✓ for right, ✗ for wrong) */
.xword-cell .check-mark {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  font-family: ui-sans-serif, system-ui;
}
.xword-cell.cell-correct { background: #e1efd9; }
.xword-cell.cell-correct.cursor { background: var(--marigold); }
.xword-cell.cell-correct .check-mark { color: var(--sage-deep); }
.xword-cell.cell-wrong  { background: #f7d8d4; }
.xword-cell.cell-wrong.cursor  { background: var(--marigold); }
.xword-cell.cell-wrong .check-mark { color: #c92020; }

.xword-controls { display: flex; gap: 8px; justify-content: center; }

.xword-clues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  max-height: 240px;
  overflow-y: auto;
}
.clue-section h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--plum);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.clue-row {
  display: flex; gap: 8px;
  padding: 5px 4px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink-soft);
}
.clue-row.active { background: var(--cream-deep); color: var(--ink); }
.clue-num { color: var(--plum); font-weight: 700; min-width: 18px; }
.clue-text { flex: 1; }

/* Hidden keyboard bridge — focusing this invisible <input> pops up the
   native iOS keyboard. We position it over the active cell so iOS doesn't
   try to scroll somewhere weird, and we hide it visually.            */
#kbd-bridge {
  position: fixed;
  top: 0; left: 0;
  width: 1px; height: 1px;
  padding: 0; margin: 0; border: 0;
  opacity: 0;
  caret-color: transparent;
  background: transparent;
  color: transparent;
  font-size: 16px;          /* prevents iOS from zooming on focus */
  outline: none;
  /* Don't intercept taps — taps go to the underlying cell. */
  pointer-events: none;
  z-index: -1;
}

/* ------------------------------------------------------------
   Strands
   ------------------------------------------------------------ */
.strands-main {
  padding: 14px 12px;
  max-width: 460px; margin: 0 auto;
  display: grid; gap: 12px;
}
.strands-theme {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}
.strands-theme strong { color: var(--marigold-deep); font-family: ui-serif, Georgia, serif; }
.strands-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 4px;
  max-width: 380px;
  margin: 0 auto;
}
.strands-cell {
  appearance: none; border: none;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--cream-deep);
  font: inherit;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
}
.strands-cell.traced { background: var(--marigold); color: #fff; transform: scale(1.04); }
.strands-cell.found { background: var(--sage); color: var(--ink); }
.strands-cell.spangram { background: var(--rose); color: #fff; }
.strands-controls { display: flex; gap: 8px; justify-content: center; }
.strands-found {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center;
}
.found-item {
  background: var(--sage); color: var(--ink);
  padding: 4px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.found-spangram { background: var(--rose); color: #fff; }

/* ------------------------------------------------------------
   Leaderboard
   ------------------------------------------------------------ */
.lb-main {
  padding: 16px;
  max-width: 520px; margin: 0 auto;
}
.lb-tabs {
  display: flex; gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.lb-tabs::-webkit-scrollbar { display: none; }
.lb-tab {
  appearance: none; border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.lb-tab:hover { background: var(--cream-deep); }
.lb-tab.active { background: var(--marigold); color: #fff; border-color: var(--marigold-deep); }

.lb-heading {
  text-align: center;
  font-family: ui-serif, Georgia, serif;
  color: var(--plum);
  font-size: 18px;
  margin: 4px 0 12px;
}

.lb-cards { display: grid; gap: 12px; }
.lb-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative;
}
.lb-card.lb-leader {
  background: linear-gradient(135deg, #fff 0%, var(--cream-deep) 100%);
  border: 1.5px solid var(--marigold);
}
.lb-rank {
  position: absolute; top: 12px; right: 14px;
  font-size: 22px;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  color: var(--plum);
}
.lb-leader .lb-rank { color: var(--marigold-deep); }
.lb-name {
  font-family: ui-serif, Georgia, serif;
  font-size: 20px; font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}
.lb-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  text-align: center;
}
.lb-stats .big {
  display: block; font-family: ui-serif, Georgia, serif;
  font-weight: 700; font-size: 22px; color: var(--ink);
}
.lb-stats .lab {
  display: block; font-size: 10px; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.lb-last { margin-top: 10px; font-size: 12px; color: var(--ink-muted); }
.lb-foot { text-align: center; margin-top: 16px; font-size: 13px; }
