/* Swoop. "Riso night": cream keycap tiles on a riso-blue board, a fluorescent pink ink ribbon
   with a blue misregistered shadow, paper grain. Light theme is the same print on cream stock. */

/* Inter, self-hosted (variable wght 100-900 + opsz). One family everywhere, picked for legibility. */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #141218;
  --bg2: #1d1a23;
  --bg3: #2a2632;
  --line: rgba(246, 239, 226, 0.13);
  --text: #f6efe2;
  --muted: #a8a1b3;
  --tile: #f6efe2;
  --lip: #cdbfa3;
  --ink: #1a1720;
  --panel: #2440c4;
  --panel-lip: #172a8a;
  --pink: #ff4fa3;
  --pink-lip: #c42f78;
  --blue: #3d6bff;
  --blue-lip: #2445c2;
  --mint: #2fe0a0;
  --mint-lip: #15a26f;
  --sun: #ffd23f;
  --sun-lip: #d3a312;
  --red: #ff5f57;
  --red-lip: #c13a33;
  --sel: #ffd7ea;
  --sel-lip: #e8a5c6;
  --shadow: rgba(0, 0, 0, 0.38);
  --font-d: 'Inter', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-u: 'Inter', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3ecdf;
    --bg2: #fbf6ec;
    --bg3: #e9dfcc;
    --line: rgba(27, 24, 34, 0.14);
    --text: #1b1822;
    --muted: #6d6676;
    --tile: #fffdf8;
    --lip: #dccfb6;
    --panel: #2f55e8;
    --panel-lip: #1d38a8;
    --pink: #f0368f;
    --pink-lip: #b51f66;
    --blue: #2f55e8;
    --blue-lip: #1d38a8;
    --mint: #1fcf8f;
    --mint-lip: #0f9563;
    --sun: #ffcc2e;
    --sun-lip: #cf9c00;
    --shadow: rgba(60, 40, 10, 0.22);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; background: var(--bg); overscroll-behavior: none; }
body {
  margin: 0;
  min-height: 100%;
  background: transparent; /* html paints --bg, so the .paper layer can sit between them */
  color: var(--text);
  font-family: var(--font-u);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* paper: two halftone ink blooms on a fixed layer, plus fine grain on top. Painted once. */
.paper { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.paper::before, .paper::after {
  content: ''; position: absolute; border-radius: 50%; opacity: 0.28;
  background: radial-gradient(circle, currentColor 0 1.9px, transparent 2.2px) 0 0 / 11px 11px;
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 68%);
  mask-image: radial-gradient(circle, #000 0%, transparent 68%);
}
.paper::before { width: 440px; height: 440px; top: -180px; right: -160px; color: var(--pink); }
.paper::after { width: 380px; height: 380px; bottom: -160px; left: -160px; color: var(--blue); }
@media (prefers-color-scheme: light) { .paper::before, .paper::after { opacity: 0.2; } }
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.06;
}
@media (prefers-color-scheme: light) { body::after { opacity: 0.08; } }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
.screen { min-height: 100vh; min-height: 100dvh; padding: calc(var(--safe-t) + 14px) 18px calc(var(--safe-b) + 22px); }

.eyebrow { font: 700 12px/1 var(--font-u); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0; }
.sub { color: var(--muted); margin: 6px 0 0; font-size: 15px; }
.fine { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 6px 0 var(--shadow);
}

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 18px;
  padding: 14px 18px;
  font: 800 17px/1.1 var(--font-u);
  background: var(--tile); color: var(--ink);
  box-shadow: 0 5px 0 var(--lip);
  transform: translateY(0);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--lip); }
.btn:disabled { filter: saturate(0.4) brightness(0.85); cursor: progress; }
.btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.btn-pink { background: var(--pink); color: #1c0812; box-shadow: 0 5px 0 var(--pink-lip); }
.btn-pink:active:not(:disabled) { box-shadow: 0 1px 0 var(--pink-lip); }
.btn-blue { background: var(--blue); color: #fff; box-shadow: 0 5px 0 var(--blue-lip); }
.btn-blue:active:not(:disabled) { box-shadow: 0 1px 0 var(--blue-lip); }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.btn-ghost:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--line); }
.btn-xl {
  width: 100%;
  flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 17px 52px 18px 22px; border-radius: 22px; text-align: left;
}
.btn-xl::after {
  content: ''; position: absolute; right: 24px; top: 50%;
  width: 11px; height: 11px; border-right: 3.5px solid currentColor; border-top: 3.5px solid currentColor;
  border-radius: 2px; transform: translateY(-50%) rotate(45deg);
}
.b-main { font: 800 27px/1 var(--font-d); letter-spacing: -0.01em; }
.b-sub { font: 650 14px/1.2 var(--font-u); opacity: 0.78; }
.linkbtn { background: none; border: 0; padding: 8px 4px; color: var(--muted); font: 700 14px var(--font-u); text-decoration: underline; text-underline-offset: 3px; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--bg2); box-shadow: inset 0 0 0 1.5px var(--line);
}
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn.ghost { background: none; box-shadow: none; }

/* ---------- loading ---------- */
#loading { display: grid; place-items: center; }
.loader { display: flex; gap: 10px; }
.loader i { width: 26px; height: 26px; border-radius: 7px; background: var(--tile); box-shadow: inset 0 -4px 0 var(--lip); animation: hop 0.9s ease-in-out infinite; }
.loader i:nth-child(2) { animation-delay: 0.1s; background: var(--pink); box-shadow: inset 0 -4px 0 var(--pink-lip); }
.loader i:nth-child(3) { animation-delay: 0.2s; }
.loader i:nth-child(4) { animation-delay: 0.3s; background: var(--blue); box-shadow: inset 0 -4px 0 var(--blue-lip); }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-12px); } }

/* ---------- home ---------- */
#home { display: flex; flex-direction: column; position: relative; }
.home-tools { position: absolute; top: calc(var(--safe-t) + 12px); right: 16px; z-index: 2; }
.home-head { text-align: center; padding-top: 18px; margin-top: auto; }
.hero {
  position: relative; isolation: isolate; display: block;
  width: min(330px, 86vw); aspect-ratio: 330 / 124; margin: 0 auto;
  background: none; border: 0; padding: 0;
}
/* tiles are not stacking contexts, so face (z1), ribbon (z2) and letter (z3) interleave */
.htile {
  position: absolute; width: 19%; height: 50.56%;
  left: calc((33 + var(--k) * 66) / 330 * 100% - 9.5%);
  top: 34.4%;
}
.htile:nth-of-type(even) { top: 11.8%; }
.htile::before, .htile::after { position: absolute; inset: 0; border-radius: 24%; }
.htile::before { content: ''; z-index: 1; background: var(--tile); box-shadow: inset 0 -6px 0 var(--lip), 0 5px 0 var(--shadow); }
.htile::after {
  content: attr(data-l); z-index: 3; display: grid; place-items: center; padding-bottom: 8%;
  font: 800 clamp(30px, 10vw, 42px)/1 var(--font-d); color: var(--ink);
}
.hero-trail { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.hero-trail path { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 19; stroke-dasharray: 1; stroke-dashoffset: 0; }
.ht-ink { stroke: var(--pink); opacity: 0.92; }
.ht-shadow { stroke: var(--blue); opacity: 0.95; }
.hero.go .hero-trail path { animation: draw 1.05s cubic-bezier(.5, 0, .3, 1) 0.15s both; }
.hero.go .htile::before { animation: hFace 0.55s cubic-bezier(.3, 1.6, .5, 1) calc(var(--k) * 190ms + 180ms) both; }
.hero.go .htile::after { animation: hGlyph 0.55s cubic-bezier(.3, 1.6, .5, 1) calc(var(--k) * 190ms + 180ms) both; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes hFace { 45% { transform: translateY(-9px) rotate(-4deg); background: var(--sel); } }
@keyframes hGlyph { 45% { transform: translateY(-9px) rotate(-4deg) scale(1.08); } }
.tagline { margin: 16px 0 0; font: 800 22px/1.1 var(--font-d); letter-spacing: -0.01em; }
.tagline em { font-style: normal; color: var(--pink); }

.home-body { display: flex; flex-direction: column; gap: 14px; margin-top: 30px; }
#home > .foot { margin-top: auto; }
.cta + .stats, .cta + .rules { margin-top: 6px; }
.namefield { display: flex; flex-direction: column; gap: 6px; }
.namefield span { font: 700 12px var(--font-u); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-left: 4px; }
.namefield input {
  width: 100%; font: 700 18px var(--font-u); padding: 13px 16px; border-radius: 16px;
  background: var(--bg2); border: 2px solid var(--line); outline: none;
  transition: border-color 0.15s;
}
.namefield input:focus { border-color: var(--pink); }
.namefield input::placeholder { color: var(--muted); opacity: 0.7; }
.cta { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }

/* points: a small switch before a round, with the table it picks */
.pointsbar { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 10px 12px 10px 14px; }
.pb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pb-label { font: 700 12px var(--font-u); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; gap: 4px; padding: 3px; background: var(--bg); border-radius: 12px; }
.seg button {
  border: 0; background: none; padding: 7px 14px; border-radius: 9px; min-height: 34px;
  font: 800 14px var(--font-u); color: var(--muted);
}
.seg button[aria-checked='true'] { background: var(--tile); color: var(--ink); box-shadow: 0 3px 0 var(--lip); }
.seg button:focus-visible { outline: 3px solid var(--sun); outline-offset: 1px; }
table.pts.mini { margin-top: 6px; font-size: 12px; }
table.pts.mini th { font-size: 13px; color: var(--muted); padding: 3px 2px; }
table.pts.mini td { font-size: 14px; font-weight: 800; padding: 4px 2px 2px; font-variant-numeric: tabular-nums; }
.pb-note { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats div { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 12px 10px; text-align: center; min-width: 0; }
.stats b { display: block; font: 800 22px/1.1 var(--font-d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats b.w { font-size: 17px; line-height: 1.3; }
.stats span { font: 650 12px var(--font-u); color: var(--muted); }

.rules summary { font: 800 16px var(--font-u); cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary::after { content: '+'; font: 800 24px/1 var(--font-d); color: var(--pink); transition: transform 0.2s; }
.rules[open] summary::after { transform: rotate(45deg); }
.rules ol { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: 15px; }
.rules li { margin: 0 0 8px; }
table.pts { border-collapse: collapse; margin-top: 8px; width: 100%; font-size: 13px; }
table.pts th, table.pts td { text-align: center; padding: 5px 2px; }
table.pts th { font: 800 16px var(--font-d); color: var(--text); }
table.pts td { font-weight: 700; color: var(--text); border-top: 1px solid var(--line); }

.foot { padding-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.foot-btns { display: inline-flex; gap: 10px; }

/* ---------- invite ---------- */
#invite { display: grid; place-items: center; }
.invite { width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 20px 18px; }
.invite h2 { font: 800 32px/1.08 var(--font-d); margin: 6px 0 0; }
.avatar {
  width: 74px; height: 74px; border-radius: 24px; display: grid; place-items: center; margin-bottom: 10px;
  background: var(--pink); box-shadow: inset 0 -7px 0 var(--pink-lip), 6px 6px 0 var(--blue);
  font: 800 40px/1 var(--font-d); color: #1c0812; transform: rotate(-6deg);
}
.backs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; width: 188px; margin: 20px 0 22px; padding: 10px; background: var(--panel); border-radius: 18px; transform: rotate(3deg); box-shadow: 0 6px 0 var(--panel-lip); }
.backs i { aspect-ratio: 1; border-radius: 9px; background: repeating-linear-gradient(135deg, var(--tile) 0 5px, var(--sel) 5px 10px); box-shadow: inset 0 -3px 0 var(--lip); }
.invite .namefield { width: 100%; text-align: left; margin-bottom: 12px; }
.invite .btn-xl { align-items: center; padding-right: 22px; }
.invite .btn-xl::after { display: none; }
.modepill {
  margin: 12px 0 0; padding: 6px 12px; border-radius: 999px; font: 800 13px var(--font-u); letter-spacing: 0.02em;
  background: var(--mint); color: var(--ink); box-shadow: 3px 3px 0 var(--blue);
}
.modepill[data-mode='1'] { background: var(--sun); }
.mini-rank { list-style: none; width: 100%; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.mini-rank li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 12px; background: var(--bg3); }
.mini-rank .r { font: 800 14px var(--font-u); color: var(--muted); text-align: center; }
.mini-rank .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-rank b { font: 800 18px var(--font-d); font-variant-numeric: tabular-nums; }
.mini-rank:not([hidden]) + .backs { width: 132px; gap: 5px; padding: 7px; margin: 16px 0 18px; }
.invite-links { display: flex; gap: 18px; justify-content: center; margin-top: 4px; }

/* ---------- game ---------- */
#game {
  display: flex; flex-direction: column; align-items: center;
  height: 100vh; height: 100dvh; overflow: hidden;
  padding-bottom: calc(var(--safe-b) + 10px);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hud { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 0; }
.scorebox { display: flex; flex-direction: column; gap: 3px; }
.scorebox b { font: 800 46px/0.95 var(--font-d); letter-spacing: -0.02em; transform-origin: left center; font-variant-numeric: tabular-nums; }
.scorebox.bump b { animation: bump 0.36s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 40% { transform: scale(1.12); color: var(--mint); } }
.scorebox .count { font: 700 14px var(--font-u); color: var(--muted); }
.timer { position: relative; width: 74px; height: 74px; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.t-track { fill: var(--bg2); stroke: var(--line); stroke-width: 5; }
.t-ring { fill: none; stroke: var(--text); stroke-width: 5.5; stroke-linecap: round; }
.timer span { position: relative; font: 800 21px/1 var(--font-d); font-variant-numeric: tabular-nums; }
.timer.urgent .t-ring { stroke: var(--red); }
.timer.urgent span { color: var(--red); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.14); } }

.preview { height: 58px; margin: 6px 0 10px; flex: none; display: flex; align-items: center; justify-content: center; }
.preview .pv-word, .preview .pv-tag { transition: opacity 0.12s; }
.preview[data-state=''] .pv-word, .preview[data-state=''] .pv-tag { opacity: 0; }
.pv-word {
  display: inline-flex; align-items: center; gap: 10px;
  font: 800 30px/1 var(--font-d); letter-spacing: 0.05em;
  padding: 11px 18px 12px; border-radius: 16px;
  background: var(--bg3); color: var(--text);
  box-shadow: 0 4px 0 var(--shadow);
  max-width: 82vw; overflow: hidden; white-space: nowrap;
}
.pv-tag { margin-left: -8px; transform: translateY(-16px) rotate(6deg); font: 800 14px/1 var(--font-u); padding: 6px 9px; border-radius: 10px; background: var(--ink); color: var(--tile); }
.preview .pv-tag:empty { display: none; }
.preview[data-state='good'] .pv-word { background: var(--mint); color: var(--ink); box-shadow: 0 4px 0 var(--mint-lip); }
.preview[data-state='dupe'] .pv-word { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 var(--sun-lip); }
.preview[data-state='bad'] .pv-word { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-lip); }
.preview[data-settled='1'] .pv-word { animation: settle 0.5s ease-out 0.25s forwards; }
.preview[data-settled='1'][data-state='good'] .pv-word { animation: rise 0.6s cubic-bezier(.2, .9, .3, 1) forwards; }
.preview.shake .pv-word { animation: shake 0.42s cubic-bezier(.36, .07, .19, .97), settle 0.4s ease-out 0.5s forwards; }
@keyframes shake { 15%, 85% { transform: translateX(-3px); } 30%, 70% { transform: translateX(6px); } 45%, 55% { transform: translateX(-8px); } }
@keyframes settle { to { opacity: 0; transform: scale(0.94); } }
@keyframes rise { 0% { transform: scale(1); } 25% { transform: scale(1.1); } 100% { transform: translateY(-14px) scale(0.98); opacity: 0; } }

.board-wrap { position: relative; flex: none; width: min(100%, 470px, calc(100dvh - 300px)); min-width: 280px; margin-bottom: 14px; }
@supports not (height: 100dvh) { .board-wrap { width: min(100%, 470px, calc(100vh - 300px)); } }

/* the board (also the replay board in the sheet) */
.board {
  --gap: 3.2%;
  --pitch: 80px;
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap);
  padding: 4.6%;
  aspect-ratio: 1; width: 100%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.07) 0 1.5px, transparent 1.8px) 0 0 / 10px 10px,
    var(--panel);
  border-radius: 9%;
  box-shadow: 0 9px 0 var(--panel-lip), 0 22px 40px var(--shadow);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.tile { position: relative; aspect-ratio: 1; }
.face {
  position: absolute; inset: 0; z-index: 1; border-radius: 24%;
  background: var(--tile);
  box-shadow: inset 0 calc(var(--pitch) * -0.075) 0 var(--lip), 0 calc(var(--pitch) * 0.035) 0 rgba(0, 0, 0, 0.22);
  transition: transform 0.1s ease, background-color 0.12s ease, box-shadow 0.1s ease;
}
.glyph {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center; padding-bottom: 8%;
  font: 800 calc(var(--pitch) * 0.5)/1 var(--font-d); color: var(--ink);
  pointer-events: none;
  transition: transform 0.1s ease;
}
.trail { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.trail path, .trail line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trail-ink { stroke: var(--pink); opacity: 0.9; }
.trail-shadow { stroke: var(--blue); opacity: 0.9; }
.trail-tail { stroke: var(--pink); opacity: 0.45; }
.board[data-state='good'] .trail-ink { stroke: var(--pink); }
.tile.on .face { background: var(--sel); transform: translateY(calc(var(--pitch) * 0.03)); box-shadow: inset 0 calc(var(--pitch) * -0.04) 0 var(--sel-lip); }
.tile.on .glyph { transform: translateY(calc(var(--pitch) * 0.03)); }
.tile.good .face { background: var(--mint); box-shadow: inset 0 calc(var(--pitch) * -0.04) 0 var(--mint-lip); }
.tile.dupe .face { background: var(--sun); box-shadow: inset 0 calc(var(--pitch) * -0.04) 0 var(--sun-lip); }
.tile.flash-good .face { animation: fGood 0.5s ease-out; }
.tile.flash-good .glyph { animation: popG 0.42s cubic-bezier(.3, 1.7, .5, 1); }
.tile.flash-dupe .face { animation: fDupe 0.5s ease-out; }
.tile.flash-bad .face { animation: fBad 0.45s ease-out; }
.tile.flash-bad .glyph { animation: wob 0.38s ease-out; }
@keyframes fGood { 0% { background: var(--mint); transform: scale(1.08); } 100% { background: var(--tile); transform: scale(1); } }
@keyframes popG { 40% { transform: scale(1.2); } }
@keyframes fDupe { 0% { background: var(--sun); } 100% { background: var(--tile); } }
@keyframes fBad { 0% { background: var(--red); } 100% { background: var(--tile); } }
@keyframes wob { 25% { transform: rotate(-9deg); } 60% { transform: rotate(7deg); } }

/* before the round: blank tiles; on "Go" the letters drop in, left to right, top to bottom */
#game:not(.revealed) .glyph { opacity: 0; }
#game:not(.revealed) .face { background: repeating-linear-gradient(135deg, var(--tile) 0 6px, var(--sel) 6px 12px); }
/* .revealing lives only for the drop-in, so it never masks the flash animations during play */
#game.revealing .glyph { animation: drop 0.42s cubic-bezier(.25, 1.5, .5, 1) calc(var(--i) * 22ms) both; }
#game.revealing .face { animation: land 0.42s ease-out calc(var(--i) * 22ms) both; }
#game.over .board { filter: saturate(0.7); }
#game.over .glyph, #game.over .face { animation: none; }
@keyframes drop { from { opacity: 0; transform: translateY(-40%) scale(0.5); } to { opacity: 1; transform: none; } }
@keyframes land { 0% { transform: scale(0.92); } 60% { transform: scale(1.04); } 100% { transform: none; } }

.countdown, .timeup { position: absolute; inset: 0; display: grid; place-items: center; z-index: 10; pointer-events: none; }
.cd-num { font: 800 120px/1 var(--font-d); color: var(--tile); text-shadow: 5px 6px 0 var(--pink), -1px -1px 0 var(--ink); }
.cd-num.tick { animation: cd 0.7s cubic-bezier(.2, 1.4, .4, 1) both; }
.cd-num.go { animation: go 0.45s cubic-bezier(.2, 1.4, .4, 1) both; color: var(--mint); text-shadow: 5px 6px 0 var(--ink); }
@keyframes cd { 0% { transform: scale(2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(0.85); opacity: 0; } }
@keyframes go { 0% { transform: scale(0.4) rotate(-12deg); opacity: 0; } 100% { transform: scale(1.1) rotate(-4deg); opacity: 1; } }
.timeup span {
  font: 800 76px/1 var(--font-d); color: var(--pink); padding: 6px 26px 12px; border: 7px solid var(--pink); border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  transform: rotate(-9deg); animation: stamp 0.4s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes stamp { from { transform: rotate(-9deg) scale(2.2); opacity: 0; } to { transform: rotate(-9deg) scale(1); opacity: 1; } }

.float {
  position: absolute; z-index: 12; pointer-events: none;
  font: 800 26px/1 var(--font-d); color: var(--mint); text-shadow: 2px 3px 0 var(--ink);
  transform: translate(-50%, -50%); animation: floatUp 0.95s cubic-bezier(.2, .8, .3, 1) forwards;
}
.float.big { font-size: 38px; color: var(--sun); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -20%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -80%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -240%) scale(1); } }

#found:empty::before {
  content: 'Swipe across touching letters. Diagonals count.';
  align-self: flex-end; width: 100%; text-align: center; color: var(--muted); font-weight: 700; font-size: 15px; padding: 0 12px 6px;
}
#found {
  width: 100%; flex: 1; min-height: 0; padding: 10px 2px 4px;
  display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: center; gap: 7px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 45%);
  mask-image: linear-gradient(transparent, #000 45%);
}
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 10px 7px; border-radius: 11px;
  background: var(--bg2); border: 1px solid var(--line);
  font: 800 14px/1 var(--font-u); letter-spacing: 0.04em;
}
.chip i { font-style: normal; font-weight: 700; font-size: 11px; color: var(--muted); }
.chip.long { border-color: var(--pink); }
.chip.long i { color: var(--pink); }
.chip.pop { animation: chipIn 0.35s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes chipIn { from { transform: scale(0.4); opacity: 0; } }

/* ---------- results ---------- */
#results { display: flex; flex-direction: column; gap: 14px; }
.res-top { display: flex; align-items: center; justify-content: space-between; }
.res-title { font: 800 22px var(--font-d); }
.summary { position: relative; overflow: hidden; padding: 20px 20px 18px; }
.summary .big { font: 800 68px/1 var(--font-d); margin: 6px 0 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.summary .line { margin: 0; font-weight: 700; color: var(--muted); }
.linkword { background: none; border: 0; padding: 0; font: 800 17px var(--font-d); color: var(--pink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.stamp {
  position: absolute; top: 18px; right: 14px; max-width: 46%;
  font: 800 17px/1.05 var(--font-d); color: var(--pink); text-align: center;
  padding: 7px 11px 8px; border: 3.5px solid var(--pink); border-radius: 12px;
  transform: rotate(8deg); animation: stampSoft 0.5s cubic-bezier(.2, 1.6, .4, 1) 0.5s both;
}
@keyframes stampSoft { from { transform: rotate(8deg) scale(2); opacity: 0; } to { transform: rotate(8deg) scale(1); opacity: 1; } }
.meter { height: 12px; border-radius: 8px; background: var(--bg3); margin-top: 14px; overflow: hidden; }
.meter i { display: block; height: 100%; width: calc(var(--p) * 1%); min-width: 6px; border-radius: 8px; background: linear-gradient(90deg, var(--pink), var(--sun)); transform-origin: left; animation: grow 0.9s cubic-bezier(.2, .8, .3, 1) 0.2s both; }
@keyframes grow { from { transform: scaleX(0); } }
.waiting { margin: 12px 0 0; font-weight: 700; display: flex; align-items: center; gap: 10px; color: var(--text); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); animation: hop 1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.12s; background: var(--sun); }
.dots i:nth-child(3) { animation-delay: 0.24s; background: var(--blue); }
.verdict { font: 800 30px/1.08 var(--font-d); margin: 8px 0 14px; }
.verdict.won { color: var(--pink); }
.board-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board-rank li {
  display: grid; grid-template-columns: 34px 1fr auto auto; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 16px; background: var(--bg3);
  animation: rowIn 0.4s cubic-bezier(.2, 1.3, .4, 1) both;
}
.board-rank li:nth-child(2) { animation-delay: 0.08s; }
.board-rank li:nth-child(3) { animation-delay: 0.16s; }
.board-rank li:nth-child(4) { animation-delay: 0.24s; }
@keyframes rowIn { from { opacity: 0; transform: translateY(10px); } }
.board-rank li.me { box-shadow: inset 0 0 0 2px var(--pink); }
.board-rank li.lead { background: var(--tile); color: var(--ink); box-shadow: 0 4px 0 var(--lip); }
.board-rank li.lead.me { box-shadow: 0 4px 0 var(--lip), inset 0 0 0 2px var(--pink); }
.board-rank .rank { font: 800 18px var(--font-d); text-align: center; color: var(--muted); }
.board-rank li.lead .rank { color: var(--ink); }
.crown { width: 26px; height: 18px; fill: var(--sun); stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; vertical-align: middle; }
.board-rank .who { font-weight: 800; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 7px; min-width: 0; }
.board-rank .nm { overflow: hidden; text-overflow: ellipsis; }
.board-rank .who small { flex: none; }
.board-rank .who small { font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--pink); margin-left: 4px; }
.board-rank .n { font-size: 13px; font-weight: 700; color: var(--muted); }
.board-rank li.lead .n { color: #6d6676; }
.board-rank .pts { font: 800 24px var(--font-d); font-variant-numeric: tabular-nums; }
.gstatus { margin: 12px 0 0; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.gstatus.done { color: var(--muted); }

.share h3 { margin: 0; font: 800 22px/1.1 var(--font-d); }
.share-text { margin: 12px 0 0; padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--bg3); font-weight: 700; font-size: 15px; }
.btn-share { margin-top: 14px; }
.share-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 12px; align-items: center; }
.share-row .btn { padding: 10px 16px; }
.share-url {
  width: 100%; min-width: 0; padding: 10px 12px; border-radius: 12px;
  background: var(--bg); border: 1px dashed var(--line); color: var(--muted);
  font: 600 13px ui-monospace, Menlo, monospace; text-overflow: ellipsis;
}
.res-actions { display: flex; flex-direction: column; gap: 12px; }
.res-actions .btn { width: 100%; padding: 16px 18px; font-size: 18px; }

.words { padding: 14px; }
.tabs { display: flex; gap: 6px; padding: 4px; background: var(--bg); border-radius: 14px; }
.tabs button {
  flex: 1; border: 0; background: none; padding: 10px 6px; border-radius: 11px;
  font: 800 14px var(--font-u); color: var(--muted); white-space: nowrap;
}
.tabs button em { font-style: normal; font-size: 12px; opacity: 0.8; margin-left: 2px; }
.tabs button[aria-selected='true'] { background: var(--tile); color: var(--ink); box-shadow: 0 3px 0 var(--lip); }
.wordlist { margin-top: 6px; }
.wordlist h4 { font: 800 18px var(--font-d); margin: 16px 0 2px; }
.wordlist h4 span { font: 700 14px var(--font-u); color: var(--muted); margin-left: 4px; }
.wordlist h4:empty { display: none; }
.glabel { margin: 14px 0 7px; font: 700 12px var(--font-u); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.glabel span { letter-spacing: 0.04em; text-transform: none; opacity: 0.8; margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.wchip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 11px; padding: 8px 10px 9px;
  font: 800 14px/1 var(--font-u); letter-spacing: 0.04em;
  background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line);
  transition: transform 0.08s;
}
.wchip:active { transform: scale(0.95); }
.wchip span { font-size: 11px; font-weight: 700; opacity: 0.75; }
.wchip.found { background: var(--tile); color: var(--ink); box-shadow: 0 3px 0 var(--lip); }
.wchip.theirs { background: color-mix(in srgb, var(--blue) 22%, transparent); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--blue); }
.wchip.best { box-shadow: 0 3px 0 var(--sun-lip), inset 0 0 0 2px var(--sun); }
.wchip.found.best { background: var(--sun); box-shadow: 0 3px 0 var(--sun-lip); }
.wchip.missed.best { color: var(--sun); box-shadow: inset 0 0 0 2px var(--sun); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
/* one colour per player: you pink, then blue, mint, sun */
.dot.c0 { background: var(--pink); }
.dot.c1 { background: var(--blue); }
.dot.c2 { background: var(--mint); }
.dot.c3 { background: var(--sun); }
.board-rank .dot { width: 10px; height: 10px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink) 18%, transparent); }
.pblock + .pblock { margin-top: 6px; }
.wordlist h4.ph { display: flex; align-items: center; gap: 8px; }
.wordlist h4.ph .dot { width: 11px; height: 11px; }
.wordlist h4.ph span { margin-left: auto; }
.pblock .chips { margin-top: 8px; }
.empty.small { padding: 8px 0; text-align: left; font-size: 14px; }
.missed-best { margin-top: 4px; }
.empty { color: var(--muted); text-align: center; padding: 20px 8px; margin: 0; }
.slot:empty { display: none; }

/* ---------- path sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet .scrim { position: absolute; inset: 0; background: rgba(8, 6, 12, 0.55); opacity: 0; transition: opacity 0.25s; }
.sheet-card {
  position: relative; width: 100%; max-width: 520px;
  background: var(--bg2); border-radius: 28px 28px 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding: 10px 20px calc(var(--safe-b) + 18px);
  display: flex; flex-direction: column; align-items: center;
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(.2, .9, .3, 1);
}
.sheet.open .scrim { opacity: 1; }
.sheet.open .sheet-card { transform: none; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin-bottom: 12px; }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h3 { margin: 0; font: 800 34px/1 var(--font-d); letter-spacing: 0.04em; }
.sheet-pts { font: 800 14px var(--font-u); padding: 6px 10px; border-radius: 10px; background: var(--mint); color: var(--ink); }
.mini { width: min(82vw, 340px); margin: 16px 0 4px; cursor: pointer; }
.sheet .btn { width: 100%; margin-top: 14px; }

/* ---------- add to home screen ---------- */
.install-card { text-align: center; }
.install-icon { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 5px 0 var(--shadow); margin: 4px 0 12px; }
.install-card h3 { margin: 0; font: 800 24px/1.15 var(--font-d); }
.install-card .sub { max-width: 320px; }
.install-steps { list-style: none; margin: 18px 0 4px; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.install-steps li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--bg3); font-size: 16px; }
.step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--pink); color: #1c0812; font: 800 15px var(--font-u); }
.step-t { flex: 1; }
.ios-glyph { flex: none; width: 30px; height: 30px; padding: 3px; border-radius: 8px; background: var(--tile); fill: none; stroke: #0a7aff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.install-bar {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 14px); z-index: 45; width: min(calc(100vw - 24px), 496px);
  display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 12px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 6px 0 var(--shadow), 0 16px 34px var(--shadow);
  transform: translate(-50%, 150%); transition: transform 0.32s cubic-bezier(.2, 1.2, .4, 1);
}
.install-bar.open { transform: translate(-50%, 0); }
.install-bar img { border-radius: 12px; flex: none; }
.ib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ib-text b { font: 800 16px var(--font-u); }
.ib-text span { font-size: 13px; color: var(--muted); }
.install-bar .btn { padding: 10px 16px; }
.install-bar .iconbtn { width: 38px; height: 38px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 22px); z-index: 60;
  transform: translate(-50%, 140%); opacity: 0;
  background: var(--tile); color: var(--ink); font-weight: 800; font-size: 15px;
  padding: 12px 18px; border-radius: 14px; box-shadow: 0 5px 0 var(--lip), 0 14px 30px var(--shadow);
  transition: transform 0.3s cubic-bezier(.2, 1.3, .4, 1), opacity 0.2s;
  max-width: calc(100vw - 32px); text-align: center; pointer-events: none;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }
.noscript { padding: 40px; text-align: center; }

/* short phones: tighten the game screen so the board stays big */
@media (max-height: 700px) {
  .scorebox b { font-size: 38px; }
  .timer { width: 62px; height: 62px; }
  .preview { height: 50px; margin: 6px 0 6px; }
  .pv-word { font-size: 25px; padding: 9px 14px 10px; }
  .home-body { margin-top: 18px; }
}
@media (min-width: 700px) {
  .screen { padding-top: calc(var(--safe-t) + 30px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
