/* ==========================================================================
   Word Master: visual design. The default board theme is night pavilion (the Word Master masthead: pavilion
   green with honey and amber light). Plus Jakarta Sans for words and JetBrains Mono for numbers, both loaded by
   css/site.css. Motion is spring-based, transform and opacity only, and stops for reduced motion.
   ========================================================================== */

/* ---------- themes ---------- */
:root {
  /* clue colours: the tinted tiles and the legend share these (dark enough for white letters) */
  --clue0: color-mix(in srgb, var(--accent) 84%, #000);
  --clue1: color-mix(in srgb, var(--blue) 84%, #000);
  --clue2: color-mix(in srgb, var(--violet) 84%, #000);
  --font-title: 'Plus Jakarta Sans', 'Plus Jakarta Sans Fallback', system-ui, sans-serif;
  --font-body: var(--font-title);
  --font-verse: var(--font-title);
  --font-num: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 20px;
  --radius-sm: 14px;
  /* motion tokens for sliding chrome: ease-out-expo in, ease-in out (web.dev sidenav recipe) */
  --dur-in: 260ms; --dur-out: 200ms; --ease-in: cubic-bezier(.16, 1, .3, 1); --ease-out: cubic-bezier(.7, 0, .84, 0);
  /* springs: a damped oscillator sampled into linear(); soft overshoots about 4%, bouncy about 18% */
  --spring-soft: linear(0, 0.02 3%, 0.1 7%, 0.29 13%, 0.61 22%, 0.77 28%, 0.89 34%, 0.97 41%, 1.02 49%, 1.04 60%, 1);
  --spring-bouncy: linear(0, 0.01 2%, 0.07 4%, 0.19 6%, 0.47 11%, 0.78 16%, 0.95 19%, 1.06 22%, 1.13 25%, 1.17 28%, 1.18 33%, 1.12 39%, 1.01 50%, 0.97 57%, 0.98 69%, 1.01 90%, 1);
  /* the shared SVG tile gradients read these (games/word-master/index.html); letters on selected and clue tiles */
  --face-hi: #ffffff; --face: #f7fbff; --face-lo: #d9e8f8; --sel-hi: #ffe2a6; --sel: #ff9a3c; --sel-lo: #ff6a3d; --sel-ink: #3b1500;
  --clue-ink: #fff; --on-accent: #fff; --blob-o: .5;

  /* Sky blue (default): a bright, airy match-day blue with sunny coral and aqua highlights */
  --bg-grad: linear-gradient(180deg, #eef8ff 0%, #d6edff 42%, #b7dcff 100%);
  --blob-1: #8df1ff; --blob-2: #fff2a8; --blob-3: #ffb8d9;
  --card: rgba(255, 255, 255, .74);
  --card-solid: #ffffff;
  --ink: #0e2a5c;
  --ink-2: #4b6b9b;
  --line: rgba(14, 42, 92, .12);
  --accent: #ff7a45;
  --accent-2: #19b5ff;
  --indigo: #ff7a45;
  --indigo-2: #19b5ff;
  --gold: #ffb703;
  --gold-2: #ffd166;
  --green: #22c27a;
  --blue: #2f9cf5;
  --violet: #8f6bff;
  --red: #ff4d6d;
  --slate: #4b5563;
  --primary-grad: linear-gradient(180deg, #ffb35c 0%, #ff6a3d 100%);
  --primary-shadow: #c8441a;
  --primary-ink: #ffffff;
  --btn-shadow: rgba(30, 90, 160, .22);
  --tile-edge: #8ec6ff;
  --tile-face: linear-gradient(180deg, #ffffff 0%, #e4f2ff 100%);
  --tile-ink: #0e2a5c;
  --tile-sel: linear-gradient(180deg, #ffb35c 0%, #ff6a3d 100%);
  --tile-sel-edge: #c8441a;
  --tile-wrong: linear-gradient(180deg, #ff8585, #e63946);
  --tile-gold: linear-gradient(180deg, #fff1a8 0%, #ffb703 100%);
  --tile-blue: linear-gradient(180deg, #dff6ff 0%, #4cc9f0 100%);
  --tile-violet: linear-gradient(180deg, #f1e5ff 0%, #b57bee 100%);
  --tile-slate: linear-gradient(180deg, #9aa3b2 0%, #3f4753 100%);
  --tile-wild: linear-gradient(180deg, #17b3a8 0%, #0b5550 100%);
  --shadow: 0 14px 36px rgba(30, 90, 160, .18);
  --glow: 0 0 24px rgba(25, 181, 255, .45);
}
@supports not (transition-timing-function: linear(0, 1)) { :root { --spring-soft: cubic-bezier(.22, 1, .36, 1); --spring-bouncy: cubic-bezier(.34, 1.56, .64, 1); } }
:root[data-theme="green"], :root[data-theme="green"] body {
  --bg-grad: linear-gradient(180deg, #03241a 0%, #064d2f 50%, #0c7a46 100%);
  --blob-1: #ffd166; --blob-2: #2ecc71; --blob-3: #ffffff;
  --card: rgba(6, 50, 32, .80); --card-solid: #0a4a2f;
  --ink: #f6fff8; --ink-2: #a9dcbf; --line: rgba(255, 255, 255, .14);
  --accent: #ffd166; --accent-2: #7ee8a2; --indigo: #ffd166; --indigo-2: #7ee8a2;
  --gold: #ffcc4d; --gold-2: #ffe08a; --green: #34d399; --blue: #67d3ff; --violet: #c084fc; --red: #ff6b7a;
  --primary-grad: linear-gradient(180deg, #ffe08a 0%, #f4a300 100%); --primary-shadow: #8c5f10; --primary-ink: #1f2a1a;
  --btn-shadow: rgba(0, 0, 0, .45);
  --tile-edge: #6fc49a; --tile-face: linear-gradient(180deg, #ffffff 0%, #e2f8ea 100%); --tile-ink: #064d2f;
  --tile-sel: linear-gradient(180deg, #1fa463 0%, #0b6b3a 100%); --tile-sel-edge: #065f33;
  --shadow: 0 14px 36px rgba(0, 0, 0, .45); --glow: 0 0 24px rgba(255, 209, 102, .5);
}
:root[data-theme="floodlight"], :root[data-theme="floodlight"] body {
  --bg-grad: linear-gradient(180deg, #02040a 0%, #0a1430 55%, #12306e 100%);
  --blob-1: #4cc9f0; --blob-2: #ffffff; --blob-3: #ff9933;
  --card: rgba(14, 22, 48, .82); --card-solid: #131b3a;
  --ink: #f2f6ff; --ink-2: #9fb0d8; --line: rgba(255, 255, 255, .12);
  --accent: #4cc9f0; --accent-2: #ff9933; --indigo: #4cc9f0; --indigo-2: #ff9933;
  --gold: #ffcc4d; --gold-2: #ffe08a; --green: #34d399; --blue: #67d3ff; --violet: #c084fc; --red: #ff6b7a;
  --primary-grad: linear-gradient(180deg, #67d3ff 0%, #1d4ed8 100%); --primary-shadow: #12308a;
  --btn-shadow: rgba(0, 0, 0, .55);
  --tile-edge: #5b7bd6; --tile-face: linear-gradient(180deg, #ffffff 0%, #e4ecff 100%); --tile-ink: #0a1430;
  --tile-sel: linear-gradient(180deg, #67d3ff 0%, #1d4ed8 100%); --tile-sel-edge: #12308a;
  --shadow: 0 14px 36px rgba(0, 0, 0, .55); --glow: 0 0 24px rgba(76, 201, 240, .55);
}
:root[data-theme="turf"] {
  --bg-grad: linear-gradient(180deg, #e9fbe4 0%, #c8f0c0 50%, #a7e39d 100%);
  --blob-1: #86efac; --blob-2: #fde68a; --blob-3: #bae6fd;
  --card: rgba(255, 255, 255, .84); --card-solid: #ffffff;
  --ink: #163a22; --ink-2: #4f7d5c; --line: rgba(20, 90, 40, .14);
  --accent: #15803d; --accent-2: #f59e0b; --indigo: #15803d; --indigo-2: #f59e0b;
  --gold: #f4a300; --gold-2: #ffd166; --green: #16a34a; --blue: #0ea5e9; --violet: #9d4edd; --red: #ef476f;
  --primary-grad: linear-gradient(180deg, #4ade80 0%, #15803d 100%); --primary-shadow: #14532d;
  --btn-shadow: rgba(20, 90, 40, .22);
  --tile-edge: #7cc98f; --tile-face: linear-gradient(180deg, #ffffff 0%, #e8f9e8 100%); --tile-ink: #163a22;
  --tile-sel: linear-gradient(180deg, #ffb347 0%, #ff7a00 100%); --tile-sel-edge: #b84a00;
  --shadow: 0 14px 36px rgba(20, 90, 40, .18); --glow: 0 0 24px rgba(21, 128, 61, .45);
}
:root[data-theme="whites"] {
  --bg-grad: linear-gradient(180deg, #fbf7ee 0%, #f1e8d6 100%);
  --blob-1: #f3d9a4; --blob-2: #c7d7f5; --blob-3: #ffe9c9;
  --card: rgba(255, 253, 248, .9); --card-solid: #fffdf8;
  --ink: #16213e; --ink-2: #6b6f8a; --line: rgba(20, 30, 60, .14);
  --accent: #0b2a6f; --accent-2: #c9922f; --indigo: #0b2a6f; --indigo-2: #c9922f;
  --gold: #c9922f; --gold-2: #e8c15c; --green: #3f7d4f; --blue: #3b7fa8; --violet: #6b4ba3; --red: #a63a2f;
  --primary-grad: linear-gradient(180deg, #2f55b8 0%, #0b2a6f 100%); --primary-shadow: #061a45;
  --btn-shadow: rgba(20, 30, 60, .22);
  --tile-edge: #b9c3dc; --tile-face: linear-gradient(180deg, #ffffff 0%, #eef1f8 100%); --tile-ink: #0b2a6f;
  --tile-sel: linear-gradient(180deg, #5a7bd6 0%, #0b2a6f 100%); --tile-sel-edge: #061a45;
  --shadow: 0 14px 36px rgba(20, 30, 60, .16); --glow: 0 0 24px rgba(11, 42, 111, .35);
}
/* Sky blue is the default on every device; Green, Floodlight (the old navy night look), Whites and Turf are picked on the menu. */


/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
/* Pull-to-refresh works in the menus (it was off on every screen). Only during play does an overscroll do nothing,
   so a swipe that points off the board cannot reload the game. */
html:has(body.in-game), body.in-game { overscroll-behavior: none; }
body {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg-grad) fixed;
}
/* ambient breeze: two soft radial-gradient layers drift very slowly behind everything. No blur filter: each layer is a
   small texture scaled up (a gradient stays smooth), animated on the compositor, paused while the tab is hidden. */
body::before, body::after { content: ''; position: fixed; z-index: -1; width: 30vmax; height: 30vmax; border-radius: 50%; pointer-events: none; opacity: var(--blob-o); }
body::before { left: -6vmax; top: -6vmax; background: radial-gradient(closest-side, var(--blob-1), transparent); transform: scale(2.6); animation: breezeA 72s ease-in-out infinite alternate; }
body::after { right: -4vmax; bottom: -6vmax; background: radial-gradient(closest-side, var(--blob-2), transparent); transform: scale(2.4); animation: breezeB 88s ease-in-out infinite alternate; }
@keyframes breezeA { to { transform: translate(16vmax, 12vmax) rotate(20deg) scale(2.9); } }
@keyframes breezeB { to { transform: translate(-14vmax, -12vmax) rotate(-16deg) scale(2.7); } }
html.is-hidden body::before, html.is-hidden body::after { animation-play-state: paused; }

button { font: inherit; color: inherit; touch-action: manipulation; }
h1, h2, h3 { font-family: var(--font-title); font-weight: 800; margin: 0; letter-spacing: .01em; line-height: 1.1; }
.hint { color: var(--ink-2); font-size: .92em; }
.muted { color: var(--ink-2); }
.verse { font-family: var(--font-verse); font-size: 1.08em; line-height: 1.5; }
mark { background: color-mix(in srgb, var(--gold) 40%, transparent); color: inherit; padding: 0 .15em; border-radius: 6px; }
.label { font-size: .68em; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }

#app {
  height: 100vh; height: 100svh;
  max-width: 640px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  display: flex; flex-direction: column;
  transition: max-width .2s ease;
}
#app.wide { max-width: 1000px; }
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen.active { display: flex; animation: screenIn .35s ease; }
.screen.active[data-first] { animation: none; }   /* the menu as first painted: no fade from opacity 0, which hides it from LCP */
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; border-radius: var(--radius-sm); padding: 12px 18px; cursor: pointer;
  background: var(--card-solid); color: var(--ink);
  font-family: var(--font-title); font-weight: 600; font-size: 1em; line-height: 1.1;
  box-shadow: 0 4px 0 var(--btn-shadow), 0 10px 20px rgba(0, 0, 0, .06);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; user-select: none;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-shadow), 0 4px 10px rgba(0, 0, 0, .06); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--primary-grad); color: var(--primary-ink); box-shadow: 0 5px 0 var(--primary-shadow), 0 14px 28px rgba(255, 93, 143, .3); text-shadow: 0 1px 0 rgba(0, 0, 0, .12); }
.btn.primary:active { box-shadow: 0 1px 0 var(--primary-shadow), 0 6px 14px rgba(255, 93, 143, .25); }
.btn.big { padding: 16px 30px; font-size: 1.25em; border-radius: 18px; }
.btn.active { outline: 3px solid var(--accent); outline-offset: -1px; }
.btn.icon { padding: 10px 12px; min-width: 44px; min-height: 44px; }
.btn.whatsapp { background: linear-gradient(180deg, #34e07a, #1fbe5a); color: #fff; box-shadow: 0 4px 0 #14803c, 0 10px 20px rgba(31, 190, 90, .3); }
a.btn { text-decoration: none; }

/* ---------- menu ---------- */
#screen-menu { justify-content: flex-start; align-items: center; text-align: center; gap: 14px; overflow-y: auto; padding: 14px 0; scrollbar-width: none; }
#screen-menu::-webkit-scrollbar { display: none; }
.logo { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.logo-tiles { display: flex; }
.logo-tile {
  width: 60px; height: 52px; margin: 0 -7px; display: grid; place-items: center; position: relative;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: var(--tile-edge); font-family: var(--font-title); font-weight: 700; font-size: 26px; color: var(--tile-ink);
  animation: logoFloat 3.2s ease-in-out infinite;
}
.logo-tile:nth-child(2) { animation-delay: .3s; } .logo-tile:nth-child(3) { animation-delay: .6s; } .logo-tile:nth-child(4) { animation-delay: .9s; } .logo-tile:nth-child(5) { animation-delay: 1.2s; }
.logo-tile::before { content: ''; position: absolute; inset: 0 0 4px 0; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: linear-gradient(180deg, rgba(255,255,255,.8), rgba(255,255,255,0) 55%), var(--tile-face); z-index: -1; }
.logo-tile.gold { background: #c98a00; } .logo-tile.gold::before { background: linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,0) 55%), var(--tile-gold); }
.logo-tile.sel { background: var(--tile-sel-edge); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.2); } .logo-tile.sel::before { background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 55%), var(--tile-sel); }
@keyframes logoFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.tagline { color: var(--ink-2); margin: 0; font-weight: 600; }
.day-streak { margin: 0; font-family: var(--font-title); color: var(--accent); font-weight: 600; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); }
.menu-buttons .row { display: flex; gap: 10px; }
.menu-buttons .row .btn { flex: 1; }
.btn.daily { flex-direction: column; gap: 2px; padding: 11px 16px; }
.btn.daily small { font-family: var(--font-body); font-weight: 600; font-size: .72em; color: var(--ink-2); }
.menu-foot { font-size: .78em; color: var(--ink-2); margin: 0; }
.moment-card { width: min(440px, 100%); background: linear-gradient(180deg, rgba(255,255,255,.6), rgba(255,255,255,0)), var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; text-align: center; box-shadow: var(--shadow); }
.moment-card p { margin: 0; font-family: var(--font-verse); font-style: italic; font-size: 1.05em; line-height: 1.45; }
.moment-card .ref { font-family: var(--font-title); color: var(--accent); font-weight: 600; }
.moment-card .row { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.moment-card .row .btn { flex: 1; padding: 10px 10px; font-size: .95em; }
.theme-row { display: flex; gap: 10px; align-items: center; justify-content: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18); cursor: pointer; padding: 0; transition: transform .15s ease; }
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 3px var(--accent), 0 2px 6px rgba(0,0,0,.18); }
.swatch[data-theme="blue"] { background: linear-gradient(135deg, #ff7a45, #8ec6ff 55%, #ffffff); }
.swatch[data-theme="green"] { background: linear-gradient(135deg, #064d2f, #34d399 55%, #ffd166); }
.swatch[data-theme="floodlight"] { background: linear-gradient(135deg, #02040a, #1d4ed8 55%, #67d3ff); }
.swatch[data-theme="whites"] { background: linear-gradient(135deg, #f1e8d6, #0b2a6f 55%, #c9922f); }
.swatch[data-theme="turf"] { background: linear-gradient(135deg, #15803d, #a7e39d 55%, #ffd166); }

/* ---------- ad banner slots ---------- */
.ad-banner { width: 100%; min-height: 54px; display: flex; justify-content: center; }
.ad-banner-sim { width: 100%; max-width: 360px; height: 54px; border: 1px dashed var(--line); border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2); font-size: .78em; padding: 0 10px; background: var(--card); }
.ad-badge { display: inline-block; font: 800 .7em/1 sans-serif; letter-spacing: .05em; padding: 3px 5px; border-radius: 4px; background: var(--ink-2); color: #fff; }

/* ---------- game layout ---------- */
.game-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.game-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.game-side { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 900px) {
  .game-wrap { flex-direction: row; gap: 22px; }
  .game-main { flex: 1; min-width: 0; }
  .game-side { width: 310px; flex: none; padding-top: 10px; }
}

/* ---------- HUD ---------- */
.hud { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 10px; align-items: center; padding: 8px 14px; margin-bottom: 8px; background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 7%, transparent), transparent 70%), var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.hud .label { display: block; }
.hud .val { font-family: var(--font-num); font-weight: 800; font-size: 1.22em; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hud .timer .val { font-size: 1.8em; text-align: center; color: var(--accent); }
.hud .timer .val.low { color: var(--red); animation: heartbeat 1s ease-in-out infinite; }
@keyframes heartbeat { 0%, 45%, 100% { transform: scale(1); } 12% { transform: scale(1.13); } 24% { transform: scale(1.02); } 34% { transform: scale(1.08); } }
.hud .score { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.progress { height: 10px; background: color-mix(in srgb, var(--ink) 10%, transparent); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.progress > div { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent-2), color-mix(in srgb, var(--accent-2) 45%, var(--accent)) 50%, var(--accent)); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 55%, transparent); transition: width .7s var(--spring-soft); position: relative; overflow: hidden; }
.progress > div::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent); transform: translateX(-100%); animation: shimmer 3.4s ease-in-out infinite; }
@keyframes shimmer { 60%, 100% { transform: translateX(100%); } }
.streak-badge { display: none; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--primary-grad); color: var(--primary-ink); font-family: var(--font-num); font-weight: 800; font-size: .85em; position: relative; overflow: hidden; box-shadow: var(--glow); }
.streak-badge.on { display: inline-flex; animation: pulse .5s ease; }
.streak-badge i { position: absolute; left: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.9); width: 100%; transition: width 1s linear; }

.bonus-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 0 0 6px; background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 18px; }
.bonus-bar .label { white-space: nowrap; }
.bonus-letters { display: flex; gap: 4px; flex: 1; }
.bonus-letters .bl { width: 24px; height: 28px; border-radius: 8px; background: var(--line); display: grid; place-items: center; font-family: var(--font-title); font-weight: 800; color: var(--accent); }
.bonus-letters .bl.on { background: var(--gold-2); color: var(--tile-ink); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.bonus-len { font: 700 .78em var(--font-num); color: var(--ink-2); white-space: nowrap; }

/* ---------- board and tiles: candy hexagons drawn as SVG (a ledge below, the face, a clue chip) plus the letter ---------- */
#board-wrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
#board { position: relative; --tile-w: 64px; --tile-h: 56px; contain: layout; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.tile { position: absolute; width: var(--tile-w); height: var(--tile-h); display: grid; place-items: center; overflow: visible; font-family: var(--font-title); font-weight: 800; font-size: calc(var(--tile-w) * .44); color: var(--tile-ink); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; transition: transform 420ms var(--spring-soft); }
.tile[data-x="1"], .tile[data-x="3"], .tile[data-x="5"], .tile[data-x="7"], .tile[data-x="9"] { --leaf: 1; }   /* odd columns fall and drift the other way */
.tile.selected, .tile.appear, .tile.vanish, .tile.hint, .tile.wrong, .tile.close { will-change: transform; }
.tile .hx { position: absolute; left: 5%; top: 4%; width: 90%; height: 90%; overflow: visible; }
.tile .ledge { fill: var(--tile-edge); transform: translateY(4px); }
.tile .face { fill: url(#g-face); transition: transform .08s ease; }
.tile .chip { display: none; }
.tile .glyph { position: relative; z-index: 1; transform: translateY(-2px); transition: transform .08s ease; text-shadow: 0 1px 0 rgba(255, 255, 255, .55); }
.tile:active .face, .tile:active .glyph { transform: translateY(3px); }
.tile::after { content: attr(data-tag); display: none; position: absolute; z-index: 1; bottom: 14%; padding: 1px 6px; border-radius: 999px; font: 800 calc(var(--tile-w) * .15)/1.3 var(--font-body); color: #fff; background: rgba(0, 0, 0, .38); }
.tile[data-tag]::after, .tile.sp1::after, .tile.sp2::after, .tile.sp3::after, .tile.sp4::after { display: block; }
.tile.sp1::after { content: '×3'; } .tile.sp2::after { content: '+15s'; } .tile.sp3::after { content: '★'; } .tile.sp4::after { content: '✕'; } .tile.hint::after { content: attr(data-tag); }
/* states: each face is one of the shared gradients, each ledge its deeper shade */
.tile.selected, .tile.swap-src { color: var(--sel-ink); z-index: 3; }
.tile.selected { transform: translateY(-2px) scale(1.08); }
.tile.selected .face, .tile.swap-src .face { fill: url(#g-sel); stroke: color-mix(in srgb, var(--sel-hi) 70%, transparent); stroke-width: 5px; stroke-linejoin: round; }
.tile.selected .ledge, .tile.swap-src .ledge { fill: var(--tile-sel-edge); }
.tile.selected .glyph, .tile.swap-src .glyph { text-shadow: 0 1px 0 rgba(255, 255, 255, .4); }
.tile.wrong, .tile.sp4, .tile.wild { color: #fff; } .tile.wrong .glyph, .tile.sp4 .glyph, .tile.wild .glyph { text-shadow: none; }
.tile.wrong .face { fill: url(#g-wrong); } .tile.wrong .ledge { fill: #9b1c2e; }
.tile.hint, .tile.close { z-index: 2; }
.tile.hint .face, .tile.sp1 .face, .tile.close .face { fill: url(#g-gold); } .tile.hint .ledge, .tile.sp1 .ledge, .tile.close .ledge { fill: #b07800; }
.tile.sp2 .face { fill: url(#g-blue); } .tile.sp2 .ledge { fill: #157aa6; }
.tile.sp3 .face { fill: url(#g-violet); } .tile.sp3 .ledge { fill: #6a34ad; }
.tile.sp4 .face { fill: url(#g-slate); } .tile.sp4 .ledge { fill: #1f2329; }
.tile.wild .face { fill: url(#g-wild); } .tile.wild .ledge { fill: #073a36; }
/* the tiles that can come next: lifted, honey faces on plain tiles, brighter special tiles */
.tile.nb { transform: scale(1.05); z-index: 2; }
.tile.nb[class*=" sp"], .tile.nb[class*="given"], .tile.nb.wild { filter: brightness(1.15) saturate(1.1); }
.tile.nb:not([class*=" sp"], [class*="given"], .wild, .hint) .face { fill: url(#g-nb); }
.tile.nb:not([class*=" sp"], [class*="given"], .wild, .hint) .ledge { fill: #c8962c; }
/* clue tiles: gem faces in the clue colours, a light chip in the corner, letters in --clue-ink */
.tile.given:not(.selected, .hint, .wrong) { color: var(--clue-ink); animation: none; z-index: 2; }
.tile.given:not(.selected, .hint, .wrong) .glyph { text-shadow: none; }
.tile.given:not(.selected, .hint, .wrong) .chip { display: block; fill: rgba(255, 255, 255, .92); }
.tile.given:not(.selected, .hint, .wrong) .face { fill: var(--gf); }
.tile.given:not(.selected, .hint, .wrong) .ledge { fill: color-mix(in srgb, var(--gc) 60%, #000); }
.given0 { --gf: url(#g-c0); --gc: var(--clue0); } .given1 { --gf: url(#g-c1); --gc: var(--clue1); } .given2 { --gf: url(#g-c2); --gc: var(--clue2); }
#g-c0 { --c: var(--clue0); } #g-c1 { --c: var(--clue1); } #g-c2 { --c: var(--clue2); }
.gh { stop-color: color-mix(in srgb, var(--c) 42%, #fff); } .gm { stop-color: var(--c); } .gl { stop-color: color-mix(in srgb, var(--c) 72%, #000); }
.sf0 { stop-color: var(--face-hi); } .sf1 { stop-color: var(--face); } .sf2 { stop-color: var(--face-lo); }
.ss0 { stop-color: var(--sel-hi); } .ss1 { stop-color: var(--sel); } .ss2 { stop-color: var(--sel-lo); }
.c0 { background-color: var(--clue0); }
.c1 { background-color: var(--clue1); }
.c2 { background-color: var(--clue2); }
/* the selection path under the tiles, and the pond ripple a tap sends out (js/hexmap.js ripple()) */
.path-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.path-layer polyline { fill: none; stroke: color-mix(in srgb, var(--sel) 55%, transparent); stroke-width: 12; stroke-linejoin: round; stroke-linecap: round; }
#board .ripple { position: absolute; left: 0; top: 0; z-index: 4; width: var(--tile-w); height: var(--tile-w); margin: calc(var(--tile-w) * -.5) 0 0 calc(var(--tile-w) * -.5); border-radius: 50%; border: 2px solid color-mix(in srgb, var(--sel-hi) 80%, #fff); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sel-hi) 22%, transparent); opacity: 0; pointer-events: none; }
/* motion: a tap squishes and springs up; a fresh tile falls in like a leaf and settles with a wobble; a scored word
   blooms and drifts off like petals; a wrong word sways like a reed. Later rules win when two classes meet. */
.tile.appear { animation: leafFall 560ms var(--spring-bouncy) both, fadeIn 200ms ease-out both; }
.tile.hint { animation: hintPulse 1.1s ease-in-out infinite; }
.tile.swap-src { animation: pulse .9s ease-in-out infinite; }
.tile.selected { animation: tileSquish 380ms var(--spring-bouncy); }
.tile.wrong, .tile.close { transform-origin: 50% 85%; animation: sway 380ms ease-in-out; }
.tile.vanish { animation: bloomAway 460ms cubic-bezier(.3, 0, .5, 1) both; }
@media (hover: hover) { .tile:hover { transform: scale(1.06); z-index: 2; } .tile.selected:hover { transform: translateY(-2px) scale(1.1); } .tile.selected .hx { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--sel) 55%, transparent)); } }
@keyframes tileSquish { from { transform: translateY(1px) scale(.86, .9); } to { transform: translateY(-2px) scale(1.08); } }
@keyframes leafFall { from { transform: translate(calc(var(--leaf, -1) * 8%), -75%) rotate(calc(var(--leaf, -1) * 14deg)) scale(.92); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes bloomAway { 0% { opacity: 1; transform: scale(1.08); } 26% { opacity: 1; transform: scale(1.2) rotate(calc(var(--leaf, -1) * 3deg)); } 100% { opacity: 0; transform: translate(calc(var(--leaf, -1) * 22%), -60%) rotate(calc(var(--leaf, -1) * 24deg)) scale(.45); } }
@keyframes sway { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-5deg); } 45% { transform: rotate(4deg); } 70% { transform: rotate(-2deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes hintPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes appear { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

#ready-overlay, .level-banner {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 20;
  font-family: var(--font-title); font-weight: 700; font-size: 3.4em;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.12)); opacity: 0; transition: opacity .2s ease;
}
#ready-overlay.show { opacity: 1; animation: pop .3s cubic-bezier(.2, .9, .3, 1.4); }
.level-banner { opacity: 1; animation: levelIn 1.7s ease both; text-align: center; }
.level-banner small { display: block; font-size: .4em; letter-spacing: .3em; text-transform: uppercase; }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }
@keyframes levelIn { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: 1; transform: scale(1); } 85% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }

/* effects */
.fx-canvas { position: absolute; inset: 0; pointer-events: none; z-index: 25; }
.callout { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(.6); pointer-events: none; z-index: 26; font-family: var(--font-title); font-weight: 700; font-size: 3em; color: #fff; text-shadow: 0 4px 0 var(--accent), 0 0 30px rgba(255,255,255,.8); -webkit-text-stroke: 1px rgba(0,0,0,.08); animation: callout 1.1s cubic-bezier(.2, .9, .3, 1.2) forwards; white-space: nowrap; }
.callout.gold { text-shadow: 0 4px 0 #c98a00, 0 0 30px rgba(255, 220, 120, .95); }
@keyframes callout { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5) rotate(-4deg); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); } 35% { transform: translate(-50%, -50%) scale(1) rotate(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%) scale(1.05); } }

/* ---------- word bar + controls ---------- */
.word-bar + .dock { margin-top: 10px; }
.word-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 7px 12px; background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 18px; }
#current-word { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; min-height: 34px; }
#current-word .cw, .handle .cw { width: 32px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--tile-sel); color: var(--sel-ink); font-family: var(--font-title); font-weight: 800; box-shadow: 0 3px 0 var(--tile-sel-edge), inset 0 1px 0 rgba(255,255,255,.45); animation: chipIn 340ms var(--spring-bouncy); }
@keyframes chipIn { from { opacity: 0; transform: translateY(8px) scale(.5); } }
#current-word .cw.wild { background: var(--tile-gold); color: var(--tile-ink); box-shadow: 0 3px 0 #c98a00; }
#current-score { font-family: var(--font-num); font-weight: 800; color: var(--accent); white-space: nowrap; font-size: 1.1em; }
.controls { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 10px; margin-top: 10px; }
.controls.helps { grid-template-columns: 1fr 1fr 1fr; margin-top: 8px; }
.controls .btn { padding: 11px 6px; min-height: 44px; }
.controls.helps .btn { font-size: .95em; padding: 10px 6px; }
.swaps { display: inline-flex; gap: 3px; }
.swaps i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.swaps i.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
#btn-swap.empty { color: var(--ink-2); }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font: 800 .75em/1 var(--font-num); }
#btn-hint.empty .count { background: var(--line); color: var(--ink-2); }
#found-words { display: flex; gap: 6px; overflow-x: auto; padding: 8px 2px 2px; min-height: 34px; scrollbar-width: none; }
#found-words::-webkit-scrollbar { display: none; }
.chip { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--card-solid); border: 1px solid var(--line); font-size: .9em; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 0 var(--line); }
.chip.scrip { background: var(--gold-2); border-color: transparent; color: var(--tile-ink); box-shadow: 0 2px 0 #c98a00; }

/* ---------- clue panel ---------- */
.panel-card { background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 6%, transparent), transparent 60%), var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 24px; padding: 12px 14px; box-shadow: var(--shadow); }
.panel-card .label { display: block; }
.clues-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.clue-toggle { padding: 8px 12px; font-size: .9em; }
.clues-label { margin-top: 10px; }
.clues-foot { display: none; }
.wordcount { display: flex; align-items: baseline; gap: 8px; }
.wordcount strong { font-family: var(--font-num); font-weight: 800; font-size: 1.5em; color: var(--accent); }
.wordcount small { color: var(--ink-2); font-weight: 600; }
.clues { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.clue { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; padding: 11px 12px; border-radius: 18px; background: color-mix(in srgb, var(--card-solid) 91%, var(--ink)); border: 1px solid var(--line); animation: clueIn .5s var(--spring-soft) both; }
.clue .box { width: 30px; height: 30px; flex: none; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background-image: linear-gradient(180deg, rgba(255,255,255,.32), rgba(255,255,255,0) 55%); display: grid; place-items: center; font: 800 .8em/1 var(--font-body); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.clue p { margin: 0; font-size: .95em; line-height: 1.38; font-weight: 600; text-wrap: balance; }
.clue p .q { color: var(--accent); font-weight: 800; font-size: 1.25em; line-height: 0; vertical-align: -.1em; }
.clue .len { display: block; margin-top: 4px; font-size: .72em; color: var(--ink-2); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.clue.found { background: color-mix(in srgb, var(--green) 16%, var(--card-solid)); border-color: var(--green); animation: clueFound .6s ease; }
.clue.found .box { background-color: var(--green) !important; }
.clue.found p { text-decoration: line-through; color: var(--ink-2); }
.clue.found .len { color: var(--green); }
@keyframes clueIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes clueFound { 0% { transform: scale(1); } 35% { transform: scale(1.05); } 100% { transform: scale(1); } }
/* ---------- phones: the board fills the screen; the HUD and the controls slide in and out ---------- */
.top-links { display: flex; justify-content: center; gap: 8px; margin: 0 0 6px; }
.top-links { position: relative; }
.tl-gear { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; padding: 6px; border-radius: 50%; border: 1px solid var(--line); background: var(--card-solid); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; box-shadow: 0 2px 8px rgba(40,60,120,.15); }
.tl-gear svg { width: 100%; height: 100%; }
.tl-gear:active { transform: translateY(-50%) scale(.94); }
.top-links .tl { font: inherit; font-size: .78em; font-weight: 700; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-solid); color: var(--ink-2); cursor: pointer; }
.top-links .tl-lives { display: inline-flex; align-items: center; gap: 5px; color: #fff; background: linear-gradient(90deg, #d6336c, #f06595); border-color: transparent; }
.top-links .tl-lives { animation: tlBlink 3s ease-in-out infinite; }
.top-links #tl-howto { color: #fff; background: linear-gradient(135deg, #1d58d6 0%, #2f8cf0 55%, #3fb6ee 100%); border-color: transparent; text-shadow: 0 1px 2px rgba(0,0,0,.22); box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 3px 10px rgba(40,120,240,.4); }
.top-links #tl-howto:active { transform: scale(.97); }
.tl-swap { display: inline-grid; } .tl-swap > span { grid-area: 1 / 1; text-align: center; white-space: nowrap; }
.tl-a { animation: tlA 6s ease-in-out infinite; } .tl-b { animation: tlB 6s ease-in-out infinite; }
@keyframes tlBlink { 0%, 100% { opacity: .72; box-shadow: 0 0 0 0 rgba(240,101,149,0); } 50% { opacity: 1; box-shadow: 0 0 10px 2px rgba(240,101,149,.55); } }
@keyframes tlA { 0%, 40% { opacity: 1; } 50%, 90% { opacity: 0; } 100% { opacity: 1; } }
@keyframes tlB { 0%, 40% { opacity: 0; } 50%, 90% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .top-links .tl-lives, .tl-a, .tl-b { animation: none; } .tl-b { display: none; } }
.tl-heart { display: inline-block; animation: tlBeat 3s ease-in-out infinite; }
.tl-ecg { width: 30px; height: 12px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tl-ecg path { stroke-dasharray: 64; stroke-dashoffset: 64; animation: tlEcg 3s linear infinite; }
@keyframes tlEcg { 0% { stroke-dashoffset: 64; opacity: 1; } 55% { stroke-dashoffset: 0; opacity: 1; } 85% { stroke-dashoffset: 0; opacity: 0; } 100% { stroke-dashoffset: 64; opacity: 0; } }
@keyframes tlBeat { 0%, 100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.18); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tl-heart, .tl-ecg path { animation: none; } .tl-ecg path { stroke-dashoffset: 0; } }
.peek, .handle { display: none; }
@media (max-width: 899px) {
  #screen-game.active { position: fixed; inset: 0; z-index: 5; padding: 0; max-width: none; }
  .game-wrap { position: relative; height: 100%; gap: 0; }
  .game-main { position: relative; flex: 1; min-height: 0; overflow: hidden; }
  #board-wrap { position: absolute; left: 0; right: 0; top: calc(52px + env(safe-area-inset-top, 0px)); bottom: calc(66px + env(safe-area-inset-bottom, 0px)); top: calc(144px + env(safe-area-inset-top, 0px)); }
  .topbar, .dock, .handle, .peek, .game-side { transition: transform var(--dur-in) var(--ease-in), visibility 0s linear 0s; }
  .top-links { position: absolute; left: 10px; right: 10px; top: calc(4px + env(safe-area-inset-top, 0px)); z-index: 36; margin: 0; }
  .topbar { position: absolute; left: 10px; right: 10px; top: calc(32px + env(safe-area-inset-top, 0px)); z-index: 35; }
  .topbar .hud { margin-bottom: 6px; }
  .game-main.play .topbar { transform: translate3d(0, calc(-100% - 24px), 0); visibility: hidden; pointer-events: none; transition: transform var(--dur-out) var(--ease-out), visibility 0s linear var(--dur-out); }
  .peek { position: absolute; top: calc(32px + env(safe-area-inset-top, 0px)); left: 50%; z-index: 34; display: inline-flex; align-items: center; gap: 10px; padding: 5px 6px 7px 14px; border-radius: 999px; background: color-mix(in srgb, var(--card-solid) 94%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow); font-family: var(--font-title); font-weight: 700; color: var(--ink); appearance: none; cursor: pointer; transform: translate3d(-50%, calc(-100% - 24px), 0); visibility: hidden; transition: transform var(--dur-out) var(--ease-out), visibility 0s linear var(--dur-out); }
  .game-main.play .peek { transform: translate3d(-50%, 0, 0); visibility: visible; transition: transform var(--dur-in) var(--ease-in), visibility 0s; }
  .peek .pt { color: var(--accent); font-family: var(--font-num); font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3em; font-size: 1.15em; }
  .peek .pt.low { color: var(--red); animation: heartbeat 1s ease-in-out infinite; }
  .peek .ps { font-size: .95em; font-weight: 600; color: var(--ink-2); white-space: nowrap; } .peek .ps b { color: var(--ink); }
  .peek .pp { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: .75em; }
  .peek .pbar { position: absolute; left: 14px; right: 14px; bottom: 3px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
  .peek .pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .4s ease; }
  .dock { position: absolute; left: 10px; right: 10px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); z-index: 35; padding: 8px; border-radius: var(--radius); background: color-mix(in srgb, var(--card-solid) 94%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .dock .controls { margin-top: 8px; }
  .game-main.play .dock { transform: translate3d(0, calc(100% + 24px), 0); visibility: hidden; pointer-events: none; transition: transform var(--dur-out) var(--ease-out), visibility 0s linear var(--dur-out); }
  .handle { position: absolute; left: 10px; right: 10px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 34; display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-height: 52px; border-radius: 18px; background: color-mix(in srgb, var(--card-solid) 94%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .word-bar { position: absolute; left: 10px; right: 10px; top: calc(94px + env(safe-area-inset-top, 0px)); z-index: 33; min-height: 44px; padding: 4px 10px; transition: opacity var(--dur-in) ease; }
  .game-main:not(.play) .word-bar { opacity: 0; pointer-events: none; }
  #current-word:empty::before { content: 'Tap letters to spell'; color: var(--ink-2); font-size: .9em; font-weight: 600; }
  .handle .hw { flex: 1; display: flex; gap: 4px; overflow: hidden; align-items: center; min-height: 36px; padding-left: 4px; }
  .handle .hs { font-family: var(--font-num); font-weight: 800; color: var(--accent); white-space: nowrap; font-size: .9em; }
  .handle .btn { padding: 10px 12px; min-height: 44px; }
  .handle #handle-tools { flex: 1; } .handle #handle-clues { flex: 1; }
  .handle .hbtn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: #fff; font-weight: 800; letter-spacing: .01em; border: 0; text-shadow: 0 1px 2px rgba(0,0,0,.22); }
  .handle .hbtn .hi { width: 22px; height: 22px; flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
  .handle .hbtn .hi-sh { width: 34px; height: 34px; margin: -6px -3px; }
  .handle .hb-tools { color: #3a1a00; text-shadow: none; background: linear-gradient(135deg, #fde68a 0%, #fbbf24 40%, #f97316 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 6px 16px rgba(249,115,22,.38); }
  .handle .hb-clues { background: linear-gradient(135deg, #6d28d9 0%, #a21caf 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 16px rgba(162,28,175,.38); }
  .handle .hbtn { border-radius: 999px; transition: transform 420ms var(--spring-bouncy); }
  .handle .hbtn:active { transform: scale(.95); transition-duration: 80ms; }
  .handle:not(.selecting) #handle-submit, .handle:not(.selecting) #handle-clear { display: none; }
  .game-side { position: absolute; left: 10px; right: 10px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 36; max-height: 72%; transform: translate3d(0, calc(100% + 24px), 0); visibility: hidden; transition: transform var(--dur-out) var(--ease-out), visibility 0s linear var(--dur-out); }
  .game-wrap.sheet .game-side { transform: none; visibility: visible; transition: transform var(--dur-in) var(--ease-in), visibility 0s; }
  .game-side .panel-card { padding: 12px 12px 10px; max-height: 100%; display: flex; flex-direction: column; background: var(--card-solid); border-radius: 26px; }
  .game-side .clues { display: flex !important; overflow: auto; min-height: 0; }
  .game-side .clue-toggle { display: none; }
  .clues-foot { display: flex; justify-content: flex-end; flex: none; padding-top: 10px; }
  .clue-close { font: inherit; font-weight: 800; font-size: 1.05em; letter-spacing: .02em; color: var(--primary-ink); background: var(--primary-grad); border: 0; border-radius: 999px; min-width: 132px; min-height: 50px; padding: 12px 30px; box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 8px 20px color-mix(in srgb, var(--accent) 34%, transparent); cursor: pointer; transition: transform 420ms var(--spring-bouncy); }
  .clue-close:active { transform: scale(.95); transition-duration: 80ms; }
  .clues-label { display: none; }
  .clue p { font-size: .9em; }
  .hud, .bonus-bar, .word-bar, .panel-card, .moment-card { backdrop-filter: none; }
  .hud, .bonus-bar, .word-bar { background-color: color-mix(in srgb, var(--card-solid) 94%, transparent); }
  .hud .score { gap: 2px; }
}
@media (max-width: 899px) and (orientation: landscape) {
  #board-wrap { top: calc(8px + env(safe-area-inset-top, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); left: 150px; right: 150px; }
  .top-links { left: auto; right: 10px; flex-direction: column; align-items: flex-end; }
  .tl-gear { position: static; transform: none; }
  .peek { left: 10px; top: calc(6px + env(safe-area-inset-top, 0px)); transform: translate3d(0, calc(-100% - 24px), 0); } .game-main.play .peek { transform: none; }
  .handle, .dock, .game-side { left: 10px; right: auto; width: 320px; }
  .clues-foot { display: none; }
  .word-bar { right: auto; width: 132px; top: calc(60px + env(safe-area-inset-top, 0px)); flex-direction: column; align-items: flex-start; }
  #current-word .cw { width: 24px; height: 28px; font-size: .85em; }
}
@media (prefers-reduced-motion: reduce) { :root { --dur-in: 1ms; --dur-out: 1ms; } }
@media (min-width: 900px) {
  .game-side .clue-toggle, .clues-foot { display: none; }
  .game-side.collapsed .clues { display: flex; }
}

/* ---------- overlays, popups, toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(3, 14, 10, .58); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s ease; padding: 16px; }
.overlay.show { opacity: 1; pointer-events: auto; }
.panel { background: var(--card-solid); border-radius: 26px; box-shadow: var(--shadow); padding: 26px; width: min(420px, 100%); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.popup-x { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); font: 400 30px/1 var(--font-body); cursor: pointer; }
.popup-x:hover, .popup-x:focus-visible { background: var(--line); color: var(--ink); }
.popup { position: relative; background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 6%, transparent), transparent 45%), var(--card-solid); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); padding: 24px; width: min(470px, 100%); max-height: 90vh; overflow: auto; opacity: 0; transform: translateY(18px) scale(.94); transition: transform 560ms var(--spring-soft), opacity 180ms ease; }
.popup-overlay.show .popup { transform: none; opacity: 1; }
.popup h2 { font-size: 1.6em; letter-spacing: -.01em; margin-bottom: 8px; background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.popup-body p { margin: 8px 0; }
.popup-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.popup.tutorial ol { padding-left: 1.2em; margin: 0; }
.popup.tutorial li { margin: 7px 0; }
.sw { display: inline-block; padding: 0 7px; border-radius: 6px; font: 800 .8em/1.6 var(--font-body); color: #fff; }
.sw.gold { background: #e09b00; } .sw.blue { background: #1f8fc0; } .sw.violet { background: #7a3fc0; } .sw.dark { background: #23262b; }
.input { width: 100%; font: inherit; font-weight: 600; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card-solid); color: var(--ink); outline: none; }
.input:focus { border-color: var(--accent); }

#toast { position: fixed; left: 50%; bottom: 150px; transform: translate(-50%, 20px); z-index: 60; background: rgba(8, 24, 18, .95); border: 1px solid rgba(255, 255, 255, .1); color: #fff; padding: 12px 18px; border-radius: 18px; max-width: min(520px, 92vw); opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none; text-align: center; font-size: .95em; font-weight: 600; backdrop-filter: blur(8px); box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.verse { text-align: left; }
#toast.verse strong { font-family: var(--font-title); color: var(--gold-2); margin-right: 6px; }
#toast.verse .ref { opacity: .85; font-size: .9em; }
#toast.verse em { display: block; margin-top: 4px; font-weight: 500; opacity: .92; }
.float { position: fixed; z-index: 70; transform: translate(-50%, 0); pointer-events: none; font-family: var(--font-title); font-weight: 700; font-size: 1.5em; color: #fff; text-shadow: 0 3px 0 var(--accent), 0 0 12px rgba(0,0,0,.2); animation: floatUp 1.4s ease-out forwards; white-space: nowrap; }
.float.gold { font-size: 1.9em; text-shadow: 0 3px 0 #c98a00, 0 0 14px rgba(255, 200, 80, .8); }
.float.scrip { text-shadow: 0 3px 0 #c98a00, 0 0 12px rgba(255, 200, 80, .7); }
.float.note { font-size: 1em; font-family: var(--font-body); font-weight: 800; color: var(--ink); text-shadow: 0 1px 0 #fff, 0 0 8px #fff; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -70px) scale(1); } }

/* ---------- simulated ads ---------- */
.ad-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 90; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s ease; padding: 16px; }
.ad-overlay.show { opacity: 1; }
.ad-card { width: min(380px, 100%); background: #fff; color: #222; border-radius: 16px; overflow: hidden; font-family: Helvetica, Arial, sans-serif; }
.ad-top { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: .75em; color: #666; background: #f2f2f2; }
.ad-top .ad-badge { background: #ffd500; color: #222; }
.ad-creative { padding: 36px 24px; text-align: center; background: linear-gradient(160deg, #1d2b64, #f8cdda); color: #fff; }
.ad-creative .ad-logo { font-size: 42px; margin-bottom: 8px; }
.ad-creative h3 { font-family: inherit; font-size: 1.3em; margin: 0 0 6px; }
.ad-creative p { margin: 0; font-size: .95em; opacity: .9; }
.ad-bottom { display: flex; justify-content: space-between; align-items: center; padding: 12px; }
.ad-bottom .ad-timer { font-size: .9em; color: #444; }
.ad-bottom .btn { background: #fff; color: #222; box-shadow: 0 3px 0 #ccc; font-family: inherit; }
.ad-bottom .btn.primary { background: #1a73e8; color: #fff; box-shadow: 0 3px 0 #0b47a1; }

/* ---------- checkpoint ---------- */
#screen-checkpoint, #screen-results { justify-content: flex-start; align-items: center; text-align: center; gap: 14px; }
/* centred while it fits, top-aligned once it is taller than the screen (justify-content: center pushed the title and the
   final total above the screen, out of reach of scrolling) */
#screen-checkpoint > :first-child, #screen-results > :first-child { margin-top: auto; }
#screen-checkpoint > :last-child, #screen-results > :last-child { margin-bottom: auto; }
#screen-checkpoint h2, #screen-results h2 { font-size: 2em; background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cp-list { list-style: none; padding: 6px 0; margin: 0; width: min(400px, 100%); background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cp-list li { display: flex; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); animation: rowIn .4s ease both; font-weight: 600; }
.cp-list li:last-child { border-bottom: 0; }
.cp-list strong { font-family: var(--font-title); color: var(--accent); font-size: 1.1em; }
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.total { font-size: .8em; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.total strong { display: block; font-family: var(--font-num, var(--font-title)); font-size: 2.4em; color: var(--ink); letter-spacing: 0; text-transform: none; }

/* ---------- verse hunt ---------- */
#screen-hunt { gap: 10px; }
.vh-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 12px; background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.vh-head .val { font-family: var(--font-title); font-weight: 700; font-size: 1.35em; }
.vh-head .timer .val { font-size: 1.9em; text-align: center; font-variant-numeric: tabular-nums; color: var(--accent); }
.vh-head .timer .val.low { color: var(--red); animation: pulse .6s ease-in-out infinite; }
.vh-head .right { text-align: right; }
.vh-head .label { display: block; }
.vh-card { background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; min-height: 0; overflow: auto; box-shadow: var(--shadow); max-width: 680px; width: 100%; margin: 0 auto; }
.vh-card .kicker { font-family: var(--font-title); font-size: .8em; letter-spacing: .3em; color: var(--ink-2); font-weight: 700; }
#vh-verse { font-family: var(--font-verse); font-size: 1.2em; line-height: 1.5; font-style: italic; }
#vh-verse .blank { color: var(--accent); letter-spacing: .08em; font-style: normal; }
#vh-ref { color: var(--accent); font-family: var(--font-title); font-weight: 600; font-size: .95em; min-height: 1.2em; opacity: 0; transition: opacity .3s ease; }
#vh-ref.show { opacity: 1; }
.vh-slots, .vh-letters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.vh-slot, .vh-letter { width: 46px; height: 52px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; font-family: var(--font-title); font-weight: 700; font-size: 1.35em; border: 0; }
.vh-slot { background: var(--line); box-shadow: inset 0 2px 4px rgba(0,0,0,.08); }
.vh-slot.filled { background: var(--tile-sel); color: #fff; box-shadow: 0 4px 0 var(--tile-sel-edge); }
.vh-slot.ok { background: var(--green); color: #fff; box-shadow: 0 4px 0 #0a8a5c; }
.vh-slot.bad { background: var(--red); color: #fff; box-shadow: 0 4px 0 #b4213a; animation: shake .35s ease; }
.vh-letter { background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,0) 55%), var(--tile-face); color: var(--tile-ink); box-shadow: 0 4px 0 var(--tile-edge); transition: transform .08s ease; }
.vh-letter:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tile-edge); }
.vh-letter.used { opacity: .25; pointer-events: none; }
.vh-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- results ---------- */
.res-score { font-size: .8em; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.res-score strong { display: block; font-family: var(--font-title); font-size: 3.4em; letter-spacing: 0; text-transform: none; line-height: 1; background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
#screen-results.best .res-score strong { animation: pop .5s cubic-bezier(.2, .9, .3, 1.4); }
.res-mode { margin: 0; color: var(--accent); font-family: var(--font-title); font-weight: 600; }
.res-grid { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 10px; text-align: left; }
.res-grid > div { padding: 10px 14px; background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.res-grid .label { display: block; }
.res-grid strong { font-family: var(--font-title); font-size: 1.15em; }
.res-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-height: 110px; overflow: auto; }
.res-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- collection ---------- */
#screen-collection { gap: 10px; }
.alm-about { background: var(--card-solid, #fff); color: var(--ink); border: 1px solid var(--line, rgba(0,0,0,.1)); border-radius: var(--radius-sm, 12px); padding: 0 14px; }
.alm-about summary { cursor: pointer; font-weight: 800; padding: 12px 0; min-height: 24px; }
.alm-about summary:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }
.alm-about-in { padding-bottom: 12px; line-height: 1.5; }
.alm-about h3 { font-size: 1rem; margin: 12px 0 4px; }
.alm-about h3:first-child { margin-top: 0; }
.alm-about p, .alm-about ul { margin: 0 0 8px; }
.alm-about ul { padding-left: 20px; }
.alm-about li { margin: 4px 0; }
.alm-about a { color: inherit; font-weight: 700; text-decoration: underline; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }
.col-head h2 { font-size: 1.7em; background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { appearance: none; border: 0; background: var(--card-solid); border-radius: 999px; padding: 8px 14px; cursor: pointer; white-space: nowrap; font-family: var(--font-title); font-weight: 600; font-size: .95em; box-shadow: 0 3px 0 var(--btn-shadow); color: var(--ink); }
.tab small { color: var(--ink-2); font-family: var(--font-body); font-weight: 700; }
.tab.active { background: var(--primary-grad); color: #fff; box-shadow: 0 3px 0 var(--primary-shadow); }
.tab.active small { color: rgba(255,255,255,.85); }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; overflow: auto; flex: 1; min-height: 0; padding: 4px 2px 10px; }
.col-item { appearance: none; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card-solid); box-shadow: 0 3px 0 var(--line); }
.col-item strong { font-family: var(--font-title); letter-spacing: .03em; font-weight: 600; }
.col-item span { font-size: .8em; color: var(--ink-2); font-weight: 600; }
.col-item.found { cursor: pointer; border-color: var(--gold); box-shadow: 0 3px 0 var(--gold); }
.col-item.found strong { color: var(--accent); }
.col-item.locked { opacity: .55; }
.col-item.secret { cursor: default; } .col-item.locked.secret { opacity: .75; }

/* ---------- story page ---------- */
body.page { overflow: auto; height: auto; min-height: 100%; }
.doc { max-width: 780px; margin: 0 auto; padding: 0 16px 48px; display: flex; flex-direction: column; gap: 26px; }
.hero { background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 28px; padding: 30px 24px; text-align: center; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.big-verse { margin: 0; font-family: var(--font-verse); font-style: italic; font-size: 1.5em; line-height: 1.4; }
.hero .ref { font-family: var(--font-title); color: var(--accent); font-weight: 600; font-size: 1.05em; }
.share-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }
.story { background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 28px; padding: 28px 26px; box-shadow: var(--shadow); }
.story h1 { font-size: 2.1em; margin-bottom: 4px; background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.story h2 { font-size: 1.25em; margin: 28px 0 8px; color: var(--accent); }
.story p { margin: 0 0 15px; font-size: 1.1em; line-height: 1.7; }
.story blockquote { margin: 0 0 15px; padding: 12px 18px; border-left: 4px solid var(--gold); font-family: var(--font-verse); font-style: italic; color: var(--ink-2); background: color-mix(in srgb, var(--gold) 10%, transparent); border-radius: 0 12px 12px 0; }
.story .meta { font-size: .85em; color: var(--ink-2); font-weight: 700; }
.status { background: var(--card); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 28px; padding: 24px; box-shadow: var(--shadow); }
.status h2, .library-wrap h2 { font-size: 1.5em; margin-bottom: 6px; }
.status-grid { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 22px; align-items: start; margin-top: 14px; }
#card { width: 100%; height: auto; border-radius: 18px; box-shadow: var(--shadow); background: #222; }
.status-controls { display: flex; flex-direction: column; gap: 10px; }
.status-controls input[type=file] { font-size: .9em; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.lib-item { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card-solid); text-decoration: none; color: var(--ink); box-shadow: 0 3px 0 var(--line); transition: transform .1s ease; }
.lib-item:hover { transform: translateY(-2px); }
.lib-item strong { font-family: var(--font-title); font-size: .98em; font-weight: 600; }
.lib-item span { font-size: .85em; color: var(--ink-2); font-weight: 600; }
.lib-item.current { border-color: var(--accent); box-shadow: 0 3px 0 var(--accent); }
@media (max-width: 560px) { .status-grid { grid-template-columns: 1fr; } #card { max-width: 260px; margin: 0 auto; } }

@media (max-width: 400px) {
  body { font-size: 15.5px; }
  .controls { gap: 6px; }
  .controls .btn { padding: 10px 4px; font-size: .95em; }
  .bonus-letters .bl { width: 20px; height: 24px; }
  .hud .timer .val { font-size: 1.5em; }
}
@media (prefers-reduced-motion: reduce) { body::before, body::after, .logo-tile, .progress > div::after { animation: none; } }

/* ---------- team picker ---------- */
/* seven-letter top row of the logo */
.logo-tiles.seven .logo-tile { width: min(46px, 11.5vw); height: min(52px, 13vw); font-size: min(1.55em, 6.2vw); }

/* narrow phones: keep the bonus bar on one line */
@media (max-width: 480px) {
  .bonus-bar { gap: 6px; }
  .bonus-bar .label { display: none; }
  .bonus-len { font-size: .78em; white-space: nowrap; }
  .bonus-letters .bl { width: 18px; height: 26px; font-size: .82em; }
  .bonus-bar .btn { padding-left: 12px; padding-right: 12px; }
}

/* ---------- levels, leaderboard ---------- */
#screen-menu { position: relative; }
.btn.primary.big small { display: block; font-size: .58em; font-weight: 700; opacity: .92; letter-spacing: .02em; margin-top: 2px; }
.hud .tier { display: block; font-size: .62em; color: var(--ink-2); margin-top: 3px; font-weight: 700; letter-spacing: .04em; }
.cp-line { margin: 0; color: var(--gold-2); font-weight: 700; text-align: center; min-height: 1.4em; }
.screen.scroll { overflow: auto; gap: 12px; padding-bottom: 12px; }
.levels-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.lvl {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-family: var(--font-title); font-weight: 700; display: grid; place-items: center; cursor: pointer; font-size: .95em; position: relative; padding: 0;
}
.lvl.done { background: radial-gradient(circle at 32% 26%, #fff3c4, #fbbf24 48%, #f97316); color: #3a1a00; border-color: transparent; box-shadow: 0 3px 0 #b45309, 0 6px 14px rgba(245, 158, 11, .26); }   /* a candy for each cleared level */
.lvl.current { outline: 3px solid #22d3ee; outline-offset: 1px; box-shadow: 0 0 0 6px rgba(34, 211, 238, .16), 0 0 18px rgba(34, 211, 238, .45); animation: lvlGlow 2.4s ease-in-out infinite; }
@keyframes lvlGlow { 50% { box-shadow: 0 0 0 9px rgba(52, 211, 153, .07), 0 0 26px rgba(52, 211, 153, .55); } }
@media (prefers-reduced-motion: reduce) { .lvl.current { animation: none; } }
:root[data-motion="reduce"] .lvl.current { animation: none; }
.lvl.locked { opacity: .35; cursor: default; }
.lvl small { position: absolute; bottom: 1px; right: 3px; font-size: .55em; opacity: .95; }
.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--line); }
.board-list li.mine { border-color: var(--accent); box-shadow: var(--glow); }
.board-list .rank { width: 28px; font-family: var(--font-title); font-weight: 700; color: var(--accent); }
.board-list .who { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.board-list .who small { color: var(--ink-2); font-size: .8em; }
.board-list strong { font-family: var(--font-title); font-size: 1.1em; }
@media (max-width: 480px) { .levels-grid { gap: 4px; } .lvl { font-size: .8em; border-radius: 8px; } }

.lvl small { letter-spacing: -1px; }

/* Left over from the landscape media query removed in v1.6.0; these have applied to every screen since, so they stay.
*/
#app, .screen { min-height: 0; }
#board-wrap { min-height: 340px; }

/* ---------- tiny cricket animations: red ball, stumps, bat, old-school scoreboard ---------- */
/* split-flap scoreboard: dark board, cream digits that flip when the score changes */
.sb { display: inline-flex; gap: 2px; padding: 3px 4px; border-radius: 7px; background: #15191f; box-shadow: inset 0 0 0 1px #2b313a, 0 2px 0 rgba(0,0,0,.25); vertical-align: middle; }
.sb .sb-d { display: inline-grid; place-items: center; min-width: .78em; height: 1.25em; border-radius: 4px; background: linear-gradient(180deg, #30363f 0%, #30363f 49%, #262b33 51%, #262b33 100%); color: #fff2c2; font-family: var(--font-title); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; position: relative; transform-style: preserve-3d; }
.sb .sb-d::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0,0,0,.45); }
.sb .sb-d.sep { min-width: .35em; background: none; color: #fff2c2; }
.sb .sb-d.flip { animation: sbFlip .42s cubic-bezier(.3, .8, .4, 1.3); }
.sb.big { padding: 5px 6px; border-radius: 10px; font-size: .78em; }
.sb.big .sb-d { min-width: .82em; height: 1.3em; border-radius: 6px; }
@keyframes sbFlip { 0% { transform: rotateX(-90deg); filter: brightness(1.6); } 60% { transform: rotateX(12deg); } 100% { transform: rotateX(0); } }
.hud .score .sb { font-size: 1em; }
/* stumps beside the word bar: bails fly when a word is wrong, and on the time's-up card */
.fx-stumps { position: absolute; width: 40px; height: 40px; pointer-events: none; z-index: 27; transform: translate(-50%, -100%); animation: stumpsIn .9s ease both; }
.fx-stumps svg { width: 40px; height: 40px; overflow: visible; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.fx-stumps .bail-l { animation: bailL .8s cubic-bezier(.2, .8, .3, 1) both; transform-origin: 16px 9px; }
.fx-stumps .bail-r { animation: bailR .8s cubic-bezier(.2, .8, .3, 1) both .05s; transform-origin: 32px 9px; }
@keyframes bailL { 0% { transform: translate(0, 0) rotate(0); } 100% { transform: translate(-16px, -22px) rotate(-200deg); opacity: 0; } }
@keyframes bailR { 0% { transform: translate(0, 0) rotate(0); } 100% { transform: translate(18px, -26px) rotate(220deg); opacity: 0; } }
@keyframes stumpsIn { 0% { opacity: 0; transform: translate(-50%, -90%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -100%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -115%) scale(1); } }
.stumps-out { width: 64px; height: 64px; margin: 0 auto 4px; display: block; overflow: visible; }
.stumps-out .bail-l { animation: bailL 1s ease-out .3s both; transform-origin: 16px 9px; }
.stumps-out .bail-r { animation: bailR 1s ease-out .35s both; transform-origin: 32px 9px; }
/* a bat swings beside a big hit */
.fx-bat { position: absolute; left: 50%; top: 52%; width: 22px; height: 60px; margin-left: 80px; pointer-events: none; z-index: 26; transform-origin: 50% 8%; animation: batSwing .7s cubic-bezier(.2, .9, .3, 1.2) both; }
.fx-bat svg { width: 22px; height: 60px; display: block; filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); }
@keyframes batSwing { 0% { opacity: 0; transform: rotate(-70deg) scale(.8); } 20% { opacity: 1; } 45% { transform: rotate(40deg) scale(1.05); } 75% { opacity: 1; transform: rotate(28deg) scale(1); } 100% { opacity: 0; transform: rotate(24deg) translateY(-14px); } }
@media (prefers-reduced-motion: reduce) { .sb .sb-d.flip, .fx-stumps, .fx-bat, .stumps-out .bail-l, .stumps-out .bail-r { animation: none; } }

/* ---------- topic packs ---------- */
.btn.small { padding: 6px 12px; font-size: .85em; vertical-align: middle; }
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; padding: 4px 2px 12px; }
.topic-card { appearance: none; text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,.6), rgba(255,255,255,0)), var(--card); box-shadow: var(--shadow); cursor: pointer; color: var(--ink); transition: transform .1s ease; }
.topic-card:hover { transform: translateY(-2px); }
.topic-card .era { font-size: .7em; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.topic-card strong { font-family: var(--font-title); font-size: 1.1em; font-weight: 600; }
.topic-card .blurb { font-size: .85em; color: var(--ink-2); line-height: 1.35; }
.topic-card .prog { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.topic-card .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 3px; }
.topic-card small { font-size: .78em; color: var(--ink-2); font-weight: 700; }
.topic-card.locked { opacity: .72; }

/* ---------- rulebook and first-time demo ---------- */
.popup.rules { width: min(760px, 100%); }
.rules-grid { display: grid; grid-template-columns: 1fr; gap: 8px; text-align: left; }
.rule { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 12px; background: linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,.3)); border: 1px solid var(--line); }
.tier-box { margin-top: 10px; padding: 10px; border-radius: 12px; background: var(--card-solid); text-align: left; }
.tier-box p { margin: 6px 0 0; font-size: .84em; line-height: 1.3; color: var(--ink-2); }
.tier-ladder { display: flex; gap: 3px; margin-top: 8px; }
.tier-ladder span { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; padding: 5px 2px; border-radius: 8px; color: #fff; text-align: center; line-height: 1.15; font-size: .68em; }
.tier-ladder b { font-weight: 800; } .tier-ladder i { font-style: normal; opacity: .95; }
.tier-ladder .tl0 { background: #3fbf7f; } .tier-ladder .tl1 { background: #46b4d8; } .tier-ladder .tl2 { background: #f2a93b; } .tier-ladder .tl3 { background: #ef7d3a; } .tier-ladder .tl4 { background: #d6336c; } .tier-ladder .tl5 { background: #7b4dff; }
.skip-ahead { align-self: stretch; margin: 6px 0; }
.rule .ico { font-size: 1.3em; line-height: 1; width: 28px; flex: none; text-align: center; margin-top: 2px; }
.rule strong { font-family: var(--font-title); font-weight: 600; display: block; }
.rule p { margin: 1px 0 0; font-size: .86em; line-height: 1.3; color: var(--ink-2); }
@media (min-width: 700px) { .rules-grid { grid-template-columns: 1fr 1fr; } }
.popup.demo { width: min(520px, 100%); text-align: center; padding: 18px 18px 16px; }
.demo-title { font-size: 1.25em; margin: 0 0 8px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.demo-stage { position: relative; height: 232px; border-radius: 20px; background: linear-gradient(180deg, #fffaf0, #f3e2c0); overflow: hidden; cursor: pointer;
  --ink: #14271f; --ink-2: #4c5c54; --accent: #c1121f; --accent-2: #0f5c3c; color: var(--ink); }   /* always a light stage, so light-surface text in every theme */
.demo-board { position: absolute; left: 14px; top: 22px; width: 170px; height: 180px; }
.dt { position: absolute; width: 54px; height: 48px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: var(--tile-edge); display: grid; place-items: center; font: 700 22px var(--font-title); color: var(--tile-ink); transition: transform .2s ease; }
.dt::before { content: ''; position: absolute; inset: 0 0 4px 0; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,0) 55%), var(--tile-face); }
.dt span { position: relative; z-index: 1; }
.dt.on { background: var(--tile-sel-edge); color: var(--sel-ink); transform: scale(1.1); z-index: 2; animation: none; } .dt.on::before { background: linear-gradient(180deg, rgba(255,255,255,.4), rgba(255,255,255,0) 55%), var(--tile-sel); }
.demo-clue { position: absolute; right: 14px; top: 26px; width: 200px; text-align: left; background: #fff; border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; animation: clueIn .4s ease both; }
.demo-clue .box { width: 30px; height: 30px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background-image: linear-gradient(180deg, rgba(255,255,255,.32), rgba(255,255,255,0) 55%); display: grid; place-items: center; font: 800 .8em/1 var(--font-body); color: #fff; }
.demo-clue p { margin: 0; font-weight: 600; font-size: .88em; line-height: 1.3; }
.demo-clue small { display: block; grid-column: 2; font-size: .68em; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); margin-top: 3px; }
.demo-clue.found { background: color-mix(in srgb, var(--green) 16%, #fff); } .demo-clue.found .box { background-color: var(--green); } .demo-clue.found p { text-decoration: line-through; color: var(--ink-2); }
.demo-word { position: absolute; left: 14px; right: 14px; bottom: 12px; background: #fff; border-radius: 12px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; font-family: var(--font-title); font-weight: 700; letter-spacing: .12em; min-height: 40px; box-shadow: var(--shadow); }
.demo-word b { color: var(--accent); letter-spacing: 0; }
.demo-callout { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.5); font-family: var(--font-title); font-weight: 700; font-size: 2.4em; color: #fff; text-shadow: 0 4px 0 var(--accent), 0 0 24px rgba(255,255,255,.8); opacity: 0; transition: all .35s cubic-bezier(.2, .9, .3, 1.3); pointer-events: none; }
.demo-callout.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.demo-chip { position: absolute; left: 14px; bottom: 14px; padding: 6px 12px; border-radius: 999px; background: var(--primary-grad); color: var(--primary-ink); font-family: var(--font-title); font-weight: 600; font-size: .9em; box-shadow: var(--glow); animation: appear .4s ease .6s both; }
.demo-level, .demo-super, .demo-invite { position: absolute; inset: 18px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.demo-level .progress { height: 14px; } .demo-level .progress > div { width: 20%; transition: width 1.1s ease; }
.demo-stars { font-size: 2em; color: var(--gold); opacity: 0; transform: scale(.6); transition: all .4s cubic-bezier(.2, .9, .3, 1.4); }
.demo-gain { font-family: var(--font-title); font-weight: 600; color: var(--ink); opacity: 0; transition: opacity .4s ease .2s; }
.demo-level.done .demo-stars, .demo-level.done .demo-gain { opacity: 1; transform: none; }
.demo-scr, .demo-ans { display: flex; gap: 6px; justify-content: center; min-height: 44px; }
.demo-scr i, .demo-ans i { width: 38px; height: 44px; border-radius: 10px; display: grid; place-items: center; font: 700 1.2em var(--font-title); font-style: normal; }
.demo-scr i { background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,0) 55%), var(--tile-face); color: var(--tile-ink); box-shadow: 0 4px 0 var(--tile-edge); }
.demo-ans i { background: var(--tile-sel); color: #fff; box-shadow: 0 4px 0 var(--tile-sel-edge); animation: appear .25s ease; }
.demo-super small { color: var(--ink-2); font-weight: 600; }
.demo-invite .btn.whatsapp { align-self: center; pointer-events: none; }
.demo-reward { display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 12px; padding: 8px 14px; box-shadow: var(--shadow); font-weight: 600; }
.demo-reward span { color: var(--ink-2); font-size: .85em; } .demo-reward strong { font-family: var(--font-title); color: var(--accent); }
.demo-caption { margin: 10px 0 6px; min-height: 3.4em; font-size: .95em; line-height: 1.35; }
.demo-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.demo-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); } .demo-dots i.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.demo-nav { display: flex; gap: 10px; justify-content: center; }
@media (max-width: 480px) { .demo-board { transform: scale(.9); transform-origin: top left; } .demo-clue { width: 170px; right: 8px; } }

/* the legend mirrors the tile: same pale tint, same chip, the clue number in the clue colour */
.clue .box { position: relative; background-image: none; color: var(--clue0); text-shadow: none; }
.clue .box::after { content: ''; position: absolute; top: 3px; right: 7px; width: 7px; height: 7px; border-radius: 50%; }
.clue .box.c0 { background-color: var(--clue0); } .clue .box.c1 { background-color: var(--clue1); } .clue .box.c2 { background-color: var(--clue2); }
.clue .box.c0, .clue .box.c1, .clue .box.c2 { color: var(--clue-ink); } .clue .box.c0::after, .clue .box.c1::after, .clue .box.c2::after { background: var(--clue-ink); }
.clue.found .box { color: #fff; } .clue.found .box::after { display: none; }
/* the demo's mini tiles follow the same look */
.dt.tint0 { background: color-mix(in srgb, var(--clue0) 62%, #000); color: var(--clue-ink); animation: none; } .dt.tint0::before { background: var(--clue0); }
/* ---------- reward loop: callout pools, rank ribbons, warm bonus, so-close, board shake, peek streak ---------- */
.callout.rank { font-size: 1.5em; top: 22%; padding: 6px 18px; border-radius: 999px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); -webkit-text-stroke: 0; box-shadow: var(--glow); animation: rankIn 1.5s cubic-bezier(.2, .9, .3, 1.2) forwards; }
@keyframes rankIn { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -90%) scale(1); } }
.callout.close { color: #fff; text-shadow: 0 4px 0 #d98e00, 0 0 24px rgba(255, 200, 80, .8); font-size: 2.2em; }
.bonus-bar.warm { animation: warmPulse .9s ease; } .bonus-bar.warm .bl { background: color-mix(in srgb, var(--gold) 45%, var(--line)); }
@keyframes warmPulse { 0%, 100% { box-shadow: none; } 40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 60%, transparent), var(--glow); } }
#board-wrap.shake { animation: boardShake .09s ease 2; }
@keyframes boardShake { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(3px, -2px); } }
.peek .pk { display: none; font-size: .85em; padding: 2px 8px; border-radius: 999px; background: var(--primary-grad); color: #fff; }
.peek .pk.on { display: inline-block; }
.cp-best { margin: 0; font-family: var(--font-title); color: var(--ink); font-weight: 600; }
.cp-best .chip { margin-left: 6px; }
.cp-praise { margin: 0; color: var(--accent); font-family: var(--font-title); font-weight: 600; min-height: 1.3em; }
.hud .score .streak-badge, .peek .pk { font-variant-numeric: tabular-nums; }

/* ---------- challenge results (head to head) ---------- */
.vs-card { background: var(--card-solid); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.vs-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--font-title); margin-bottom: 6px; }
.vs-head span { color: var(--ink-2); font-size: .85em; }
.vs-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; text-align: center; padding: 5px 0; border-top: 1px solid var(--line); font-weight: 700; }
.vs-row em { color: var(--ink-2); font-style: normal; font-size: .8em; font-weight: 600; align-self: center; }
.vs-row .win { color: var(--accent); }
.vs-verdict { margin: 8px 0 0; text-align: center; font-family: var(--font-title); font-weight: 700; }

/* ---------- share nudge: the host slides in from the top ---------- */
.nudge { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 70; max-width: 460px; margin: 0 auto; display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 20px; background: var(--card-solid); border: 1px solid var(--line); box-shadow: var(--shadow); transform: translate3d(0, calc(100% + 30px), 0); opacity: 0; transition: transform var(--dur-in) var(--ease-in), opacity var(--dur-in) ease; }
.nudge.show { transform: none; opacity: 1; }
.nudge-pic { width: 56px; height: 56px; flex: none; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold, #ffd166); }
.nudge-body { flex: 1; min-width: 0; } .nudge-body p { margin: 0 0 6px; font-weight: 700; font-size: .95em; line-height: 1.3; }
.nudge-row { display: flex; gap: 8px; } .nudge-go { flex: 1; padding: 9px 10px; min-height: 40px; } .nudge-x { padding: 9px 12px; min-height: 40px; }

/* ---------- cookie notice ---------- */
.pause-legal { margin: 10px 0 0; font-size: .8em; text-align: center; color: var(--ink-2); } .pause-legal a { color: var(--accent); }
.consent-bar { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 90; max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 18px; background: var(--card-solid, #fff); color: var(--ink, #111); border: 1px solid var(--line, #ddd); box-shadow: 0 10px 30px rgba(0,0,0,.25); transform: translate3d(0, calc(100% + 30px), 0); transition: transform .26s cubic-bezier(.16, 1, .3, 1); font-size: .9em; }
.consent-bar.show { transform: none; } .consent-bar p { margin: 0 0 10px; line-height: 1.45; } .consent-bar a { color: var(--accent); }
.consent-row { display: flex; gap: 8px; } .consent-row .btn { flex: 1; min-height: 42px; padding: 9px 10px; }

/* ---------- home: the game takes the top 70% of a phone screen, stories the next 30% ---------- */
.menu-more { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.menu-stories { width: min(1000px, 100%); text-align: left; }
.menu-stories[hidden] { display: none; }
.ms-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 14px 6px; }
.ms-head h2 { margin: 0; font-family: var(--font-title); font-size: 1.05em; color: var(--ink); }
.ms-head a { font-weight: 700; font-size: .88em; color: var(--accent); text-decoration: none; white-space: nowrap; }
.ms-row { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 14px 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ms-row::-webkit-scrollbar { display: none; }
.ms-card { flex: 0 0 64%; max-width: 270px; scroll-snap-align: start; display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: var(--card-solid); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.ms-card img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--line); }
.ms-t { font-family: var(--font-title); font-weight: 600; font-size: .95em; line-height: 1.25; padding: 8px 10px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ms-r { font-size: .74em; color: var(--ink-2); padding: 2px 10px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 899px) {
  #screen-menu { gap: 0; padding-top: 10px; }
  .menu-stories { min-height: 30svh; }
  .menu-more { margin-top: 10px; }
  .menu-stories, .menu-more { flex-shrink: 0; }   /* on a short phone the menu scrolls; the blocks never shrink under their content and overlap */
}
@media (min-width: 900px) {
  #screen-menu { gap: 14px; }
  .ms-row { flex-wrap: wrap; overflow: visible; }
  .ms-card { flex: 0 0 calc(25% - 9px); max-width: none; }
}

/* A tile that two clues point at shows the first clue's colour with a ring in the other clue's colour. */
.tile.also0 .face { stroke: var(--clue0); stroke-width: 9px; stroke-linejoin: round; }
.tile.also1 .face { stroke: var(--clue1); stroke-width: 9px; stroke-linejoin: round; }
.tile.also2 .face { stroke: var(--clue2); stroke-width: 9px; stroke-linejoin: round; }

body.in-game .consent-bar, body.in-game .nudge { display: none; }   /* never over the board or its buttons */
/* Floodlight theme: the first two clue colours were two near-identical blues; footer links were the browser's default blue. */
:root[data-theme="floodlight"] { --clue0: color-mix(in srgb, var(--accent-2) 84%, #000); }
.menu-foot a, .pause-legal a { color: var(--accent); }

/* Phones: the automatic Clues slide-up is slower and softer than a tap on the Clues button. */
.game-wrap.auto-slide .game-side { transition: transform 1100ms cubic-bezier(.16, 1, .3, 1), visibility 0s; }
@media (prefers-reduced-motion: reduce) { .game-wrap.auto-slide .game-side { transition-duration: 1ms; } }

.res-day { width: 100%; max-width: 420px; margin: 4px auto 10px; text-align: left; }
.res-day h3 { margin: 0 0 6px; font-family: var(--font-title); font-size: 1.05em; }
.res-day .board-list li { padding: 5px 10px; }

.vh-letter.glow { background: #ffe27a; color: #4a3000; box-shadow: 0 4px 0 #c98a00, 0 0 14px 4px rgba(255,184,31,.8); animation: vhBlink .7s ease-in-out infinite; }
@keyframes vhBlink { 50% { transform: scale(1.1); filter: brightness(1.15); } }
@media (prefers-reduced-motion: reduce) { .vh-letter.glow { animation: none; } }

/* ==========================================================================
   v1.7.0 rebuild: the shared top bar sits above the game's screens, the Word Master menu, Pavilion (the new default
   board theme in the Badiyaa colours) and two more board themes. The top bar hides while a board is being played.
   ========================================================================== */
body:not(.in-game) #app { height: calc(100vh - var(--cw-top-h) - env(safe-area-inset-top, 0px)); height: calc(100svh - var(--cw-top-h) - env(safe-area-inset-top, 0px)); padding-top: 10px; }
body.in-game .cw-top { display: none; }
.cw-top { font-family: var(--cw-text); font-size: 17px; line-height: 1.4; }
#main { position: absolute; }
/* deep links (?daily, ?play): the game screen from the first paint, a first-time player's demo step already up (js/ui.js) */
#demo-static { display: none; }
body.wm-demo #demo-static { display: flex; }
body.wm-deep #screen-game { display: flex; }
body.wm-deep #screen-game:not(.active) { visibility: hidden; }   /* holds its place; shows once the game has set it up (no shift) */
body.wm-deep #screen-game.active { animation: none; }
body.wm-deep #app { max-width: 1000px; }
.overlay.instant, .overlay.instant .popup { transition: none !important; animation: none !important; }
#main.doc { position: static; }   /* legal and about pages: their content stays in the page flow, so the footer sits below it */
/* The Word Master menu in the site masthead's language: a dark pavilion panel (whatever the board theme), a big
   two-tone title, today's board as the hero action, gem cards with room reserved for their longest line (no shift). */
.wm-menu { display: flex; flex-direction: column; gap: 14px; width: 100%; padding-bottom: 12px; }
.wm-head { position: relative; display: grid; justify-items: center; gap: 6px; width: min(560px, 100%); margin: 0 auto; padding: 16px 16px 20px; border-radius: 28px; color: #f8fafc; border: 1px solid rgba(251, 191, 36, .3);
  background: radial-gradient(70% 60% at 92% 92%, rgba(245, 158, 11, .26), transparent 70%), radial-gradient(70% 60% at 0 0, rgba(34, 211, 238, .22), transparent 70%), linear-gradient(165deg, #1b1240, #2a1550 50%, #3d1747);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255, 255, 255, .08); }
.wm-logo { transform: scale(.72); margin: -16px 0 -18px; }
.wm-title { margin: 0; font-size: clamp(2.4rem, 12vw, 3.5rem); line-height: .94; font-weight: 900; letter-spacing: -.045em; color: #fff; }
.wm-title span { display: table; margin: 0 auto; background: linear-gradient(90deg, #fde68a, #f59e0b 50%, #fb7185); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (min-width: 640px) { .wm-title span { display: inline; } }
.wm-head .tagline { color: #a5f3fc; font-weight: 800; font-size: 1.08em; letter-spacing: -.01em; }
.wm-head .day-streak { color: #fde68a; }
.wm-play { display: grid; gap: 10px; width: min(560px, 100%); margin: 0 auto; }
.wm-play .btn.big { min-height: 62px; border-radius: 20px; }
.wm-daily { position: relative; background: linear-gradient(90deg, #fbbf24, #f97316) !important; color: #3a1a00 !important; box-shadow: 0 12px 30px rgba(245, 158, 11, .36), inset 0 1px 0 rgba(255, 255, 255, .4) !important; }
.wm-daily small { color: rgba(58, 26, 0, .78) !important; }
.wm-daily:not(.done)::after { content: ''; position: absolute; inset: -4px; border-radius: 24px; border: 3px solid rgba(251, 191, 36, .6); animation: cw-pulse 2.2s ease-out infinite; pointer-events: none; }
.wm-play #btn-play { background: linear-gradient(90deg, #67e8f9, #22d3ee 45%, #06b6d4); color: #052a33; box-shadow: 0 10px 26px rgba(34, 211, 238, .3), inset 0 1px 0 rgba(255, 255, 255, .35); }
.wm-play #btn-play small { color: rgba(2, 44, 34, .78); }
.wm-hooks:empty { display: none; }
.wm-hooks { width: min(560px, 100%); margin: 0 auto; display: grid; gap: 8px; }
.wm-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(560px, 100%); margin: 0 auto; }
.wm-tile { --gem: #fb7185; appearance: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 22px;
  background: radial-gradient(90% 70% at 100% 0, color-mix(in srgb, var(--gem) 20%, transparent), transparent 70%), var(--card); border: 1px solid color-mix(in srgb, var(--gem) 34%, transparent);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .2); transition: transform .42s var(--spring-bouncy); }
.wm-tile::before { content: ''; width: 18px; height: 18px; margin: 2px 0 6px 3px; border-radius: 5px; transform: rotate(45deg); box-shadow: 0 0 14px color-mix(in srgb, var(--gem) 55%, transparent);
  background: radial-gradient(circle at 30% 26%, #fff, var(--gem) 46%, color-mix(in srgb, var(--gem) 55%, #000)); }   /* the gem */
#btn-topics { --gem: #b07cff; } #btn-collection { --gem: #22c3e6; } #btn-board { --gem: #f6b51e; }
.wm-tile strong { font-family: var(--font-title); font-size: 1.12em; font-weight: 800; }
.wm-tile small { color: var(--ink-2); font-weight: 700; font-size: .82em; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.9em; }   /* three lines held: a pack's countdown never pushes the row */
.wm-tile .cw-meter { margin-top: auto; height: 8px; }
.wm-tile:active { transform: scale(.96); transition-duration: .08s; }
.wm-rank { appearance: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left; display: flex; align-items: center; gap: 12px; width: min(560px, 100%); margin: 0 auto; padding: 12px 14px; border-radius: 22px;
  background: radial-gradient(80% 90% at 0 50%, rgba(52, 211, 153, .14), transparent 70%), var(--card); border: 1px solid var(--line); }
.wm-rank-badge svg { width: 40px; height: 46px; display: block; }
.wm-rank-badge:empty { width: 40px; height: 46px; border-radius: 12px; background: var(--line); }
.wm-rank-txt { flex: 1; display: grid; gap: 2px; }
.wm-rank-txt strong { font-family: var(--font-title); font-size: 1.05em; font-weight: 800; }
.wm-rank-txt small { color: var(--ink-2); font-weight: 700; font-size: .82em; }
.wm-rank .cw-meter { height: 8px; }
@media (prefers-reduced-motion: reduce) { .wm-tile { transition: none; } .wm-daily::after { animation: none; } }
:root[data-motion="reduce"] .wm-tile { transition: none; } :root[data-motion="reduce"] .wm-daily::after { animation: none; }
.wm-league-btn { width: 100%; margin: 4px 0; }
#screen-menu .menu-stories, #screen-menu .menu-more { width: 100%; }
.cw-linkbtn { color: var(--accent); }
.pack-intro { color: var(--ink); }
@keyframes cw-pulse { 0% { opacity: .9; transform: scale(.98); } 70% { opacity: 0; transform: scale(1.05); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .wm-daily::after { animation: none !important; } }
.swatch[data-theme="pavilion"] { background: linear-gradient(135deg, #1b1240, #22d3ee 52%, #fbbf24); }
.swatch[data-theme="trophy"] { background: linear-gradient(135deg, #1a1406, #f4c542 55%, #fff3c4); }
.swatch[data-theme="pinkball"] { background: linear-gradient(135deg, #2a0f2e, #ff5fa2 55%, #ffd1e6); }

/* Pavilion, the board default when no theme is picked: dusk over the ground (10 Nov 2026: the user asked for less
   green): deep indigo to plum with sunset amber, coral and floodlight aqua. Green is left for "correct" moments only.
   The Light appearance (and Match my phone on a light phone) keeps the cream Pavilion. */
:root:not([data-theme]) {
  --bg-grad: linear-gradient(165deg, #1b1240 0%, #2a1550 52%, #3d1747 100%);
  --blob-1: rgba(34, 211, 238, .26); --blob-2: rgba(245, 158, 11, .30); --blob-3: rgba(251, 113, 133, .24); --blob-o: 1;
  --card: rgba(30, 20, 62, .86); --card-solid: #221846;
  --ink: #f7f3ff; --ink-2: #c4b8e6; --line: rgba(255, 255, 255, .12);
  --accent: #fbbf24; --accent-2: #22d3ee; --indigo: #fbbf24; --indigo-2: #22d3ee;
  --gold: #fbbf24; --gold-2: #fde68a; --green: #34d399; --blue: #38bdf8; --violet: #c084fc; --red: #fb7185;
  --primary-grad: linear-gradient(90deg, #fbbf24 0%, #f97316 100%); --primary-shadow: #9a3f06; --primary-ink: #3a1a00; --on-accent: #2a1600;
  --btn-shadow: rgba(0, 0, 0, .45);
  --tile-edge: #b8874a; --tile-face: radial-gradient(120% 110% at 30% 15%, #ffffff 0%, #fff6e4 48%, #f0d9ad 100%); --tile-ink: #1d1638;
  --face-hi: #ffffff; --face: #fff6e4; --face-lo: #f0d9ad; --sel-hi: #fff1b8; --sel: #f8a01c; --sel-lo: #f26a16; --sel-ink: #3b1700;
  --tile-sel: linear-gradient(180deg, #fde68a 0%, #f59e0b 55%, #f97316 100%); --tile-sel-edge: #b45309;
  --clue0: #f6b51e; --clue1: #22c3e6; --clue2: #b07cff; --clue-ink: #1b1305;
  --shadow: 0 16px 40px rgba(0, 0, 0, .45); --glow: 0 0 22px rgba(251, 191, 36, .45);
}
:root[data-mode="light"]:not([data-theme]) {
  --bg-grad: linear-gradient(180deg, #fbf7ec 0%, #f3ead3 60%, #e9dcbb 100%);
  --blob-1: #f4c542; --blob-2: #8fd3a8; --blob-3: #ffb3a7; --blob-o: .5;
  --card: rgba(255, 253, 247, .86); --card-solid: #fffdf7;
  --ink: #14271f; --ink-2: #4c5c54; --line: rgba(20, 39, 31, .12);
  --accent: #c1121f; --accent-2: #0f5c3c; --indigo: #c1121f; --indigo-2: #0f5c3c;
  --gold: #d9a21b; --gold-2: #f4c542; --green: #17804f; --blue: #2563c9; --violet: #7c3aed; --red: #c1121f;
  --primary-grad: linear-gradient(180deg, #22a06b 0%, #0f5c3c 100%); --primary-shadow: #083a26; --primary-ink: #ffffff; --on-accent: #fff;
  --btn-shadow: rgba(20, 39, 31, .22);
  --tile-edge: #c9b78a; --tile-face: linear-gradient(180deg, #fffef9 0%, #f4ecd7 100%); --tile-ink: #14271f;
  --face-hi: #ffffff; --face: #fffbf0; --face-lo: #efe2c2; --sel-hi: #ffe2a6; --sel: #ff9a3c; --sel-lo: #ff6a3d; --sel-ink: #3b1500;
  --clue0: color-mix(in srgb, var(--accent) 84%, #000); --clue1: color-mix(in srgb, var(--blue) 84%, #000); --clue2: color-mix(in srgb, var(--violet) 84%, #000); --clue-ink: #fff;
  --tile-sel: linear-gradient(180deg, #ff6b6b 0%, #c1121f 100%); --tile-sel-edge: #7a0b14;
  --shadow: 0 14px 36px rgba(20, 39, 31, .16); --glow: 0 0 24px rgba(217, 162, 27, .45);
}
@media (prefers-color-scheme: light) {
  :root[data-mode="system"]:not([data-theme]) {
    --bg-grad: linear-gradient(180deg, #fbf7ec 0%, #f3ead3 60%, #e9dcbb 100%);
    --blob-1: #f4c542; --blob-2: #8fd3a8; --blob-3: #ffb3a7; --blob-o: .5;
    --card: rgba(255, 253, 247, .86); --card-solid: #fffdf7;
    --ink: #14271f; --ink-2: #4c5c54; --line: rgba(20, 39, 31, .12);
    --accent: #c1121f; --accent-2: #0f5c3c; --indigo: #c1121f; --indigo-2: #0f5c3c;
    --gold: #d9a21b; --gold-2: #f4c542; --green: #17804f; --blue: #2563c9; --violet: #7c3aed; --red: #c1121f;
    --primary-grad: linear-gradient(180deg, #22a06b 0%, #0f5c3c 100%); --primary-shadow: #083a26; --primary-ink: #ffffff; --on-accent: #fff;
    --btn-shadow: rgba(20, 39, 31, .22);
    --tile-edge: #c9b78a; --tile-face: linear-gradient(180deg, #fffef9 0%, #f4ecd7 100%); --tile-ink: #14271f;
    --face-hi: #ffffff; --face: #fffbf0; --face-lo: #efe2c2; --sel-hi: #ffe2a6; --sel: #ff9a3c; --sel-lo: #ff6a3d; --sel-ink: #3b1500;
    --clue0: color-mix(in srgb, var(--accent) 84%, #000); --clue1: color-mix(in srgb, var(--blue) 84%, #000); --clue2: color-mix(in srgb, var(--violet) 84%, #000); --clue-ink: #fff;
    --tile-sel: linear-gradient(180deg, #ff6b6b 0%, #c1121f 100%); --tile-sel-edge: #7a0b14;
    --shadow: 0 14px 36px rgba(20, 39, 31, .16); --glow: 0 0 24px rgba(217, 162, 27, .45);
  }
}
:root[data-theme="trophy"], :root[data-theme="trophy"] body {
  --bg-grad: linear-gradient(180deg, #120d03 0%, #2b1f06 55%, #4a3608 100%);
  --blob-1: #f4c542; --blob-2: #fff3c4; --blob-3: #b97d05;
  --card: rgba(40, 30, 8, .84); --card-solid: #2b2108;
  --ink: #fff6dc; --ink-2: #e2cf98; --line: rgba(255, 240, 200, .16);
  --accent: #f4c542; --accent-2: #ffe9a8; --indigo: #f4c542; --indigo-2: #ffe9a8;
  --gold: #f4c542; --gold-2: #ffe08a; --green: #8fd3a8; --blue: #8fbaff; --violet: #d2b3ff; --red: #ff7a82;
  --primary-grad: linear-gradient(180deg, #ffe08a 0%, #d9a21b 100%); --primary-shadow: #7a5604; --primary-ink: #2a1d00;
  --btn-shadow: rgba(0, 0, 0, .5);
  --tile-edge: #b98d2a; --tile-face: linear-gradient(180deg, #fffaf0 0%, #f6e7bd 100%); --tile-ink: #2a1d00;
  --tile-sel: linear-gradient(180deg, #ffe08a 0%, #d9a21b 100%); --tile-sel-edge: #7a5604;
  --shadow: 0 14px 36px rgba(0, 0, 0, .5); --glow: 0 0 24px rgba(244, 197, 66, .6);
}
:root[data-theme="pinkball"], :root[data-theme="pinkball"] body {
  --bg-grad: linear-gradient(180deg, #1c0920 0%, #3d1238 55%, #6a1f55 100%);
  --blob-1: #ff5fa2; --blob-2: #ffd1e6; --blob-3: #7b5cff;
  --card: rgba(48, 14, 44, .84); --card-solid: #351233;
  --ink: #fff0f7; --ink-2: #f0b4d2; --line: rgba(255, 220, 240, .16);
  --accent: #ff5fa2; --accent-2: #ffd1e6; --indigo: #ff5fa2; --indigo-2: #ffd1e6;
  --gold: #ffcc4d; --gold-2: #ffe08a; --green: #5eead4; --blue: #93c5fd; --violet: #c4b5fd; --red: #ff6b7a;
  --primary-grad: linear-gradient(180deg, #ff8fc0 0%, #e0337f 100%); --primary-shadow: #7d1747; --primary-ink: #ffffff;
  --btn-shadow: rgba(0, 0, 0, .5);
  --tile-edge: #d97bab; --tile-face: linear-gradient(180deg, #ffffff 0%, #fde8f2 100%); --tile-ink: #3d1238;
  --tile-sel: linear-gradient(180deg, #ff8fc0 0%, #e0337f 100%); --tile-sel-edge: #7d1747;
  --shadow: 0 14px 36px rgba(0, 0, 0, .5); --glow: 0 0 24px rgba(255, 95, 162, .55);
}
.popup:has(> .popup-x) > h2 { padding: 0 36px; }   /* the close button never sits on a long title */

/* ==========================================================================
   v1.7.26 play screen: buttons as the site's pills (gradient primary, quiet ghost), springy presses, no blur on phones.
   :where() keeps these at plain-class weight, so the Tools and Clues gradients and themed buttons still win.
   ========================================================================== */
:where(#screen-game, .popup) .btn { border-radius: 999px; border: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 8%, transparent), transparent), var(--card-solid); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 6px 14px rgba(0, 0, 0, .18); font-weight: 800; transition: transform 420ms var(--spring-bouncy), filter .15s ease; }
:where(#screen-game, .popup) .btn:active { transform: scale(.95); transition-duration: 80ms; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 2px 6px rgba(0, 0, 0, .18); }
:where(#screen-game, .popup) .btn.primary { border-color: transparent; background: var(--primary-grad); color: var(--primary-ink); text-shadow: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 10px 24px color-mix(in srgb, var(--accent) 34%, transparent); }
.callout { font-weight: 800; letter-spacing: -.01em; white-space: normal; width: max-content; max-width: 92%; text-align: center; line-height: 1.02; text-wrap: balance; }   /* long calls wrap, never off screen */
#toast em, .popup em { font-style: normal; }   /* Plus Jakarta Sans has no italic: no fake slant */
/* phones, while spelling: Tools and Clues shrink to their icons (names kept for screen readers) so Submit fits on one line */
@media (max-width: 899px) { .handle .btn { white-space: nowrap; } .handle.selecting .hbtn { flex: 0 0 auto; min-width: 54px; padding: 10px 14px; } .handle.selecting #handle-submit { flex: 1; }
  .handle.selecting .hbtn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }
#ready-overlay, .level-banner { font-weight: 800; }
@media (hover: none), (max-width: 899px) { .overlay, #toast { -webkit-backdrop-filter: none; backdrop-filter: none; } .fx-stumps svg, .fx-bat svg { filter: none; } }
/* reduced motion (the phone's setting or the game's own): nothing drifts, falls, blooms or beats */
:root[data-motion="reduce"] :is(#screen-game, .overlay) *, :root[data-motion="reduce"] :is(#screen-game, .overlay) *::after, :root[data-motion="reduce"] .float, :root[data-motion="reduce"] body::before, :root[data-motion="reduce"] body::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { :is(#screen-game, .overlay) *, :is(#screen-game, .overlay) *::after, .float { animation: none !important; transition: none !important; } }
