/* =====================================================================
   Letter Swap · "game night" theme
   Deep indigo stage, ivory letter tiles, glossy chunky buttons, glowing rank emblems.
   Principles (see README): bold contrast, big touch targets, little text, and visible
   feedback for every action.
   ===================================================================== */
:root {
  /* Calm slate base, one accent (coral). Colour is saved for things that matter:
     the main action, the current player, ranks, and time running out. */
  --bg-0: #0e1220;
  --bg-1: #151a2c;
  --bg-2: #1c2238;
  --panel-a: #1f2539;
  --panel-b: #1b2033;
  --panel-line: rgba(255, 255, 255, .07);
  --panel-hi: rgba(255, 255, 255, .06);
  --panel-shadow: rgba(0, 0, 0, .35);
  --sunk: rgba(0, 0, 0, .22);
  --text: #f4f5fa;
  --text-2: #c3c8d8;
  --muted: #8a91a8;
  --coral-a: #ff7558; --coral-b: #f4524a; --coral-s: #a8322c;
  --blue-a: #353d5a;  --blue-b: #2c3350;  --blue-s: #191e31;
  --purple-a: #353d5a; --purple-b: #2c3350; --purple-s: #191e31;
  --green-a: #4fd18b; --green-b: #2fb06c; --green-s: #1b6b43;
  --gold: #f6c453;
  --good: #4fd18b;
  --bad: #ff6b72;
  --tile-a: #fffbf2;
  --tile-b: #f1e1bf;
  --tile-edge: #b58a52;
  --tile-ink: #24185a;
  --r: 16px;
  --r-lg: 24px;
  --f-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --f-body: 'Inter', system-ui, sans-serif;
  --p: #ff5d47;        /* current player's colour (set from JS) */
  --me-rank: #e08a4f;  /* this player's rank colour (set from JS) */
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg-0); }
body {
  margin: 0; min-height: 100dvh;
  color: var(--text); font-family: var(--f-body); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1000px 560px at 50% -12%, rgba(90, 110, 190, .22), transparent 65%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
}

button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; line-height: 1.1; letter-spacing: -.02em; }
p, ol, ul { margin: 0; }
b { font-weight: 800; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.mt6 { margin-top: 6px; }
.mt14 { margin-top: 14px; }

.app {
  position: relative; z-index: 1; max-width: 640px; margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  overflow-x: clip; /* decorative rays/glows must never cause sideways scrolling */
}
.screen { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.screen > *, .panel > *, .card > * { min-width: 0; } /* wide inputs/text never stretch a screen past the phone */

/* ---------------------------------------------------------------- Panels */
.panel, .card {
  position: relative;
  padding: 20px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  box-shadow: inset 0 1px 0 var(--panel-hi), inset 0 0 0 1px var(--panel-line), 0 10px 30px rgba(0, 0, 0, .25);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-title, .card-title { font-family: var(--f-display); font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.field { display: grid; gap: 10px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.field-label { font-weight: 700; font-size: 14px; color: var(--text-2); }
.field-error { min-height: 1.4em; color: var(--bad); font-size: 14px; font-weight: 700; }
.field-error:empty { min-height: 0; }
.eyebrow { font-weight: 800; text-transform: uppercase; letter-spacing: .16em; font-size: 13px; color: var(--muted); }
.lead { margin-top: 8px; font-size: 17px; color: var(--text-2); }
.link-btn { border: 0; background: none; padding: 4px 2px; color: var(--coral-a); font-weight: 800; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.link-btn:hover { color: #fff; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  --a: rgba(255, 255, 255, .12); --b: rgba(255, 255, 255, .06); --s: rgba(0, 0, 0, .45);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 16px;
  background: linear-gradient(180deg, var(--a), var(--b));
  color: #fff; font-family: var(--f-display); font-weight: 800; font-size: 16px; letter-spacing: .01em;
  text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 4px 0 var(--s);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 0 var(--s); }
.btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible, .tile:focus-visible, .key:focus-visible,
.play-btn:focus-visible, .mode-btn:focus-visible, .stat:focus-visible, .flag-btn:focus-visible, .hero-emblem:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 3px;
}
.btn-primary { --a: var(--coral-a); --b: var(--coral-b); --s: var(--coral-s); }
.btn-blue { --a: var(--blue-a); --b: var(--blue-b); --s: var(--blue-s); }
.btn-dark { --a: var(--purple-a); --b: var(--purple-b); --s: var(--purple-s); }
.btn-ghost { --a: rgba(255, 255, 255, .06); --b: rgba(255, 255, 255, .04); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .14), 0 3px 0 rgba(0, 0, 0, .35); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 13px; }
.btn-lg { min-height: 58px; font-size: 18px; padding: 0 26px; border-radius: 18px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

.icon-btn {
  width: 46px; height: 46px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 14px; color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .06));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .16), 0 4px 0 rgba(0, 0, 0, .4);
}
.icon-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .16); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn--sm { width: 36px; height: 36px; border-radius: 11px; }
.icon-btn--sm svg { width: 18px; height: 18px; }
.icon-btn .ico-off { display: none; }
.icon-btn[aria-pressed="false"] .ico-on { display: none; }
.icon-btn[aria-pressed="false"] .ico-off { display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 42px; padding: 0 16px; border: 0; border-radius: 999px;
  background: var(--sunk); color: var(--text-2); font-weight: 800; font-size: 15px;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .12);
}
.chip[aria-checked="true"] { background: var(--text); color: var(--bg-0); box-shadow: none; }
.chips.is-locked .chip { pointer-events: none; }
.chips.is-locked .chip[aria-checked="false"] { opacity: .5; }

/* ---------------------------------------------------------------- Letter tiles */
.tile {
  display: inline-grid; place-items: center;
  width: 64px; height: 72px; border: 0; border-radius: 15px;
  background: linear-gradient(180deg, var(--tile-a), var(--tile-b));
  color: var(--tile-ink);
  box-shadow: inset 0 -4px 0 rgba(181, 138, 82, .35), inset 0 2px 0 #fff, 0 6px 0 var(--tile-edge), 0 14px 20px rgba(0, 0, 0, .38);
  font-family: var(--f-display); font-weight: 800; font-size: 38px; text-transform: uppercase; line-height: 1;
  user-select: none;
}
.tile-sm { width: 34px; height: 40px; font-size: 20px; border-radius: 9px; box-shadow: inset 0 -3px 0 rgba(181, 138, 82, .35), 0 4px 0 var(--tile-edge), 0 8px 12px rgba(0, 0, 0, .3); }
.tile.is-new { background: linear-gradient(180deg, var(--coral-a), var(--coral-b)); color: #fff; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 6px 0 var(--coral-s), 0 14px 20px rgba(0, 0, 0, .38); }

/* ---------------------------------------------------------------- Flags */
.flag {
  flex: none; display: inline-block; width: 1.333em; height: 1em; line-height: 1em;
  border-radius: 3px; background-size: cover; background-position: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); vertical-align: -0.14em;
}
.flag-none { background: rgba(255, 255, 255, .12); }
.flag-btn { flex: none; padding: 4px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .08); line-height: 0; }
.flag-btn:hover { background: rgba(255, 255, 255, .16); }
.flag-btn .flag { font-size: 20px; }

/* ---------------------------------------------------------------- Rank emblems */
.emblem { --es: 28px; --rc: #e08a4f; position: relative; display: inline-block; flex: none; width: var(--es); height: var(--es); vertical-align: middle; }
.emblem img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
/* The renders leave room for wings; the wingless ranks are scaled up to fill the same space. */
.emblem--unranked img, .emblem--novice img { scale: 1.32; }
.emblem--apprentice img { scale: 1.2; }
.emblem--scholar img { scale: 1.08; }
.emblem--glow::before {
  content: ''; position: absolute; inset: 8%; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, var(--rc), transparent 68%);
  filter: blur(calc(var(--es) * .14)); opacity: .35;
}
.rank-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--rc) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rc) 45%, transparent);
  color: #fff; font-weight: 800; font-size: 13px; white-space: nowrap;
}
.rank-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--rc); }

/* ---------------------------------------------------------------- Background tiles */
.bg-tiles { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-tile {
  position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s);
  transform: translate(-50%, -50%) rotate(var(--r));
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .45)) saturate(.85);
  opacity: .55;
  animation: tile-float 8s ease-in-out var(--d) infinite alternate;
  transition: opacity .4s ease;
}
@keyframes tile-float {
  from { transform: translate(-50%, -50%) rotate(var(--r)) translateY(0); }
  to { transform: translate(-50%, -50%) rotate(calc(var(--r) + 7deg)) translateY(-16px); }
}
body[data-screen="game"] .bg-tile, body[data-screen="end"] .bg-tile { opacity: .18; }

/* ================================================================ HOME */
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wordmark { display: flex; align-items: center; gap: 10px; flex: none; white-space: nowrap; margin: 0; font-size: inherit; letter-spacing: normal; line-height: 1; }
.wm-tile { width: 40px; height: 46px; display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(180deg, var(--coral-a), var(--coral-b)); color: #fff;
  font-family: var(--f-display); font-weight: 800; font-size: 26px;
  box-shadow: 0 3px 0 var(--coral-s); transform: rotate(-6deg); }
.wm-text { font-family: var(--f-display); font-weight: 800; font-size: 26px; letter-spacing: -.02em; }
/* Live "online now" stat: flag stack + big number + pulsing dot */
.online-chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .03));
  box-shadow: inset 0 0 0 1px var(--panel-line), 0 6px 18px rgba(0, 0, 0, .25);
  white-space: nowrap;
}
.online-chip:not(.has-flags) { padding-left: 14px; }
.online-flags { display: flex; }
.online-flags:empty { display: none; }
.online-flags .online-flag { /* beats flag-icons' own .fi.fis sizing */
  flex: none; width: 26px; height: 26px; line-height: 26px; border-radius: 50%; background-size: cover;
  box-shadow: 0 0 0 2.5px #1a1f33, 0 2px 6px rgba(0, 0, 0, .4);
}
.online-flags .online-flag + .online-flag { margin-left: -8px; }
.online-body { display: grid; line-height: 1.05; }
.online-num { display: inline-flex; align-items: center; gap: 7px; font-family: var(--f-display); font-size: 20px; font-variant-numeric: tabular-nums; }
.online-num b { font-weight: 800; letter-spacing: -.01em; }
.online-label { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--good); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.live-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--good); }
.live-dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--good); animation: live 1.8s ease-out infinite; }
@keyframes live { from { transform: scale(1); opacity: .7; } to { transform: scale(2.8); opacity: 0; } }

.home-grid, .home-main, .home-side { display: grid; gap: 16px; align-content: start; }

/* Hero profile */
.hero { padding: 18px 18px 16px; overflow: hidden; }
.hero::after { /* rank-coloured light behind the emblem */
  content: ''; position: absolute; left: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--me-rank) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.profile-loading { color: var(--muted); font-weight: 700; }
.hero-body { position: relative; z-index: 1; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.hero-emblem { padding: 0; border: 0; background: none; border-radius: 50%; }
.hero-emblem .emblem { --es: 120px; }
.hero-emblem:hover .emblem img { transform: scale(1.05) rotate(-3deg); }
.hero-emblem .emblem img { transition: transform .25s ease; }
.hero-info { display: grid; gap: 8px; min-width: 0; }
.hero-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hero-name { min-width: 0; font-family: var(--f-display); font-weight: 800; font-size: 24px; line-height: 1.1; overflow-wrap: break-word; hyphens: none; }
.hero-name.is-long { font-size: 20px; }
.hero-name.is-rolling { animation: pop .35s ease; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  display: grid; gap: 0; padding: 8px 10px; border: 0; border-radius: 12px; text-align: left;
  background: var(--sunk); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .08); color: #fff;
}
button.stat:hover { background: rgba(0, 0, 0, .45); }
.stat-value { font-family: var(--f-display); font-weight: 800; font-size: 20px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.next-rank { display: grid; gap: 4px; }
.bar { height: 10px; border-radius: 999px; background: var(--sunk); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5); overflow: hidden; }
.bar-fill { --to: var(--gold); height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--me-rank), var(--to)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.next-rank-text { font-size: 13px; font-weight: 700; color: var(--text-2); }
.hero-save { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1.5px dashed rgba(255, 255, 255, .14); }
.hero-save .small { font-size: 12.5px; }
.hero-save .btn { flex: none; white-space: nowrap; }
.hero .field-error:not(:empty) { margin-top: 10px; }

/* Play button */
.play-btn {
  position: relative; display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 18px 20px; border: 0; border-radius: 22px; text-align: left; color: #fff; overflow: hidden;
  background: linear-gradient(180deg, var(--coral-a), var(--coral-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 5px 0 var(--coral-s), 0 12px 24px rgba(244, 82, 74, .18);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.play-btn:hover { filter: brightness(1.06); }
.play-btn:active { transform: translateY(4px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 0 var(--coral-s); }
.play-btn:disabled { opacity: .5; pointer-events: none; }
.play-btn-icon { flex: none; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .18); }
.play-btn-icon svg { width: 28px; height: 28px; fill: #fff; margin-left: 3px; }
.play-btn-text { display: grid; gap: 2px; }
.play-btn-title { font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1.05; }
.play-btn-sub { font-weight: 700; font-size: 14px; color: rgba(255, 255, 255, .92); }

.mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mode-row > #challenge-btn svg { stroke: var(--gold); }
.mode-btn {
  --a: var(--blue-a); --b: var(--blue-b); --s: var(--blue-s);
  display: grid; justify-items: start; gap: 2px; padding: 14px 16px; border: 0; border-radius: 20px; text-align: left; color: #fff;
  background: linear-gradient(180deg, var(--a), var(--b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 1px var(--panel-line), 0 4px 0 var(--s);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.mode-btn--purple { --a: var(--purple-a); --b: var(--purple-b); --s: var(--purple-s); }
.mode-btn:hover { filter: brightness(1.07); }
.mode-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1px var(--panel-line), 0 1px 0 var(--s); }
.mode-btn:disabled { opacity: .5; pointer-events: none; }
.mode-btn svg { width: 26px; height: 26px; fill: none; stroke: var(--coral-a); stroke-width: 2.2; stroke-linecap: round; margin-bottom: 4px; }
.mode-title { font-family: var(--f-display); font-weight: 800; font-size: 18px; line-height: 1.1; }
.mode-sub { font-size: 13px; font-weight: 600; color: var(--muted); }

.how summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.how summary::-webkit-details-marker { display: none; }
.how summary::after { content: '+'; font-size: 24px; font-weight: 800; color: var(--muted); }
.how[open] summary::after { content: '−'; }
.rules { margin-top: 12px; padding-left: 22px; display: grid; gap: 6px; color: var(--text-2); }
.rules b { color: #fff; letter-spacing: .04em; }
.rules-note { margin-top: 12px; }

/* ================================================================ RANKING LISTS */
.ranking { list-style: none; padding: 0; display: grid; gap: 8px; }
.rank-row {
  display: grid; grid-template-columns: 30px auto 1fr auto; align-items: center; gap: 10px;
  padding: 10px 14px 10px 10px; border-radius: 16px;
  background: var(--sunk); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .07);
}
.rank-row > .emblem { --es: 50px; }
.rank-row.is-me { background: color-mix(in srgb, var(--coral-b) 12%, rgba(0, 0, 0, .2)); box-shadow: inset 0 0 0 1.5px var(--coral-a); }
.rank-pos { font-family: var(--f-display); font-weight: 800; font-size: 18px; text-align: center; color: var(--text-2); }
.rank-row.is-top-1 .rank-pos { color: var(--gold); }
.rank-row.is-top-2 .rank-pos { color: #d9e2f2; }
.rank-row.is-top-3 .rank-pos { color: #f0a06a; }
.rank-who { min-width: 0; }
.rank-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 800; }
.rank-name .flag { font-size: 14px; }
.rank-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.rank-score { text-align: right; font-family: var(--f-display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.rank-score small { display: block; font-family: var(--f-body); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ranking--compact .rank-row { padding: 8px 12px 8px 8px; grid-template-columns: 22px auto 1fr auto; gap: 8px; }
.ranking--compact .rank-row > .emblem { --es: 42px; }
.ranking--compact .rank-score { font-size: 17px; }
.ranking-me { display: grid; gap: 6px; padding-top: 10px; margin-top: 2px; border-top: 1.5px dashed rgba(255, 255, 255, .14); }
.top-card .ranking-me { margin-bottom: 12px; }
.top-card .ranking { margin-bottom: 12px; }
.ranking-empty { padding: 22px 14px; text-align: center; color: var(--muted); font-weight: 600; background: var(--sunk); border-radius: 14px; }

/* ================================================================ RANKS PAGE */
.ranks-intro { padding: 0 8px; }
.ladder { list-style: none; padding: 0; display: grid; gap: 10px; }
.rung {
  --rc: #e08a4f;
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 12px 18px 12px 10px; border-radius: 22px; overflow: hidden;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rc) 10%, var(--panel-b)), var(--panel-b) 55%);
  box-shadow: inset 0 1px 0 var(--panel-hi), inset 0 0 0 1px var(--panel-line);
}
.rung-badge { padding: 0; border: 0; background: none; border-radius: 50%; cursor: zoom-in; }
.rung-badge .emblem { --es: 160px; margin: -14px -4px; transition: transform .2s ease; }
.rung-badge:hover .emblem { transform: scale(1.05); }
.rung.is-mine { box-shadow: inset 0 1px 0 var(--panel-hi), inset 0 0 0 2px var(--rc); }
.rung.is-locked .rung-badge .emblem img { filter: saturate(.85) brightness(.92) drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
.rung-body { display: grid; gap: 4px; min-width: 0; }
.rung-name { font-family: var(--f-display); font-weight: 800; font-size: 26px; line-height: 1.05; }
.rung-range { font-weight: 700; color: var(--text-2); font-size: 14px; }
.rung-progress { font-size: 13px; font-weight: 700; color: #fff; }
.rung .bar { margin-top: 6px; }
.rung .bar-fill { background: linear-gradient(90deg, var(--rc), var(--to)); }
.rung-state { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.rung.is-mine .rung-state { color: #fff; background: var(--rc); padding: 4px 10px; border-radius: 999px; color: #1a1033; }
.facts { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 8px; }
.facts li { padding: 10px 14px; border-radius: 12px; background: var(--sunk); color: var(--text-2); font-size: 15px; }
.facts b { color: #fff; }
.head-link { margin-left: auto; }

/* ================================================================ OTHER SCREENS */
.screen-head { display: flex; align-items: center; gap: 12px; }
.screen-head h2 { font-size: 28px; font-weight: 800; }

/* Pass and play setup */
#setup-form { display: grid; gap: 22px; }
.player-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.player-row { display: flex; align-items: center; gap: 10px; }
.player-swatch { flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.player-row input, .own-start input, .join-row input, .country-pick select {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px;
  border: 0; border-radius: 13px; background: var(--sunk); color: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .14);
  font: inherit; font-size: 16px; font-weight: 700;
}
.player-row input:focus, .own-start input:focus, .join-row input:focus, .country-pick select:focus { outline: none; box-shadow: inset 0 0 0 2px var(--gold); }
.remove-player { width: 40px; height: 40px; flex: none; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.remove-player:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.remove-player:disabled { visibility: hidden; }
#add-player { justify-self: start; }
.start-word { display: grid; gap: 12px; }
.start-tiles { display: flex; gap: 8px; flex-wrap: wrap; }
.start-tiles .tile { width: 52px; height: 58px; font-size: 30px; }
.start-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.own-start { display: flex; gap: 8px; }
.own-start input { letter-spacing: .14em; text-transform: uppercase; font-size: 18px; }

/* Matchmaking */
.search { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 12vh 0 0; }
.search h2 { font-size: 32px; font-weight: 800; }
.search-tiles { display: flex; gap: 8px; margin-bottom: 10px; }
.search-tiles .tile { animation: hop 1.2s ease-in-out infinite; }
.search-tiles .tile:nth-child(2) { animation-delay: .15s; }
.search-tiles .tile:nth-child(3) { animation-delay: .3s; }
.search-tiles .tile:nth-child(4) { animation-delay: .45s; }
.search-time { font-family: var(--f-display); font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; color: var(--gold); }
.search.is-found .search-tiles .tile { animation: none; background: linear-gradient(180deg, var(--coral-a), var(--coral-b)); color: #fff; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 6px 0 var(--coral-s); }
#search-sub { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; color: var(--text-2); }

/* Friends + room */
.join-row { display: flex; gap: 8px; }
.join-row input { width: 100%; height: 56px; font-family: var(--f-display); font-size: 26px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; }
.room-code-card { display: grid; justify-items: center; gap: 8px; text-align: center; }
.room-code { font-family: var(--f-display); font-weight: 800; font-size: 56px; letter-spacing: .18em; line-height: 1; padding-left: .18em; color: var(--text); }
.room-players { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 8px; }
.room-players li { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 14px; background: var(--sunk); font-weight: 700; }
.room-players li > .emblem { --es: 44px; }
.room-players .rp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-players .rp-tag { font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: rgba(255, 255, 255, .14); }
.room-players .rp-tag--you { background: var(--coral-b); }
.room-players .rp-rank { font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-players li.is-away { opacity: .5; }

/* ================================================================ GAME */
.screen-game { display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-title { font-family: var(--f-display); font-size: 18px; font-weight: 700; color: var(--text-2); }
.topbar-title b { color: #fff; }
.topbar-actions { display: flex; gap: 8px; }
.game-side { display: contents; }
.side-title { display: none; }

.scoreboard { list-style: none; padding: 0 0 2px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.score {
  flex: 1 1 calc(50% - 4px); min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 8px; border-radius: 16px;
  background: var(--panel-a);
  box-shadow: inset 3px 0 0 var(--c), inset 0 0 0 1px var(--panel-line);
  font-weight: 800; font-size: 14px; white-space: nowrap;
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.score > .emblem { --es: 30px; margin: -6px 0; }
.score-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.score .flag { font-size: 13px; }
.score-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.score-you { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 999px; background: #fff; color: var(--tile-ink); }
.score-lives { display: flex; gap: 2px; }
.heart { width: 15px; height: 15px; fill: var(--coral-b); }
.heart.is-lost { fill: rgba(255, 255, 255, .15); }
.score.is-turn { background: color-mix(in srgb, var(--c) 14%, var(--panel-a)); box-shadow: inset 0 0 0 2px var(--c); }
.score.is-out { opacity: .4; }
.score.is-out .score-name { text-decoration: line-through; }
.score.is-away .score-name::after { content: ' (offline)'; font-weight: 600; color: var(--muted); }

.chain-wrap { position: relative; }
.chain { list-style: none; padding: 2px 2px 6px; display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; }
.chain::-webkit-scrollbar { display: none; }
.chain li { flex: none; display: flex; align-items: center; gap: 6px; font-family: var(--f-display); font-weight: 800; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; }
.chain li + li::before { content: '→'; color: var(--muted); font-weight: 700; }
.chain-word { padding: 3px 10px; border-radius: 9px; background: var(--panel-a); box-shadow: inset 0 -2px 0 var(--c), inset 0 0 0 1px var(--panel-line); }
.chain-word mark { background: none; color: var(--coral-a); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.turn {
  position: relative; display: grid; justify-items: center; gap: 10px;
  padding: 18px 16px 20px; border-radius: 26px;
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  box-shadow: inset 0 3px 0 var(--p), inset 0 0 0 1px var(--panel-line), 0 10px 30px rgba(0, 0, 0, .25);
  transition: box-shadow .4s;
}
.turn-label { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 800; font-size: 24px; text-align: center; }
.turn-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--p); }
.turn-label.pop { animation: pop .4s ease; }

.timer { width: 100%; height: 14px; border-radius: 999px; background: var(--sunk); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .55); overflow: hidden; }
.timer-fill { height: 100%; width: 100%; border-radius: 999px; transform-origin: left center; background: var(--green-b); }
.timer-fill.is-low { background: var(--bad); box-shadow: 0 0 12px rgba(255, 107, 114, .5); animation: pulse .5s ease-in-out infinite alternate; }
.timer-text { margin-top: -4px; font-family: var(--f-display); font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.timer-text.is-low { color: var(--bad); animation: pulse .5s ease infinite alternate; }

.board { display: flex; justify-content: center; gap: 10px; margin: 10px 0 6px; }
.board .tile { position: relative; cursor: pointer; padding: 0; transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s; -webkit-tap-highlight-color: transparent; }
.board .tile:hover { transform: translateY(-3px) rotate(-1.5deg); }
.board .tile.is-selected {
  transform: translateY(-8px) scale(1.04);
  background: linear-gradient(180deg, #fff, #f7ecd6);
  box-shadow: inset 0 -4px 0 rgba(181, 138, 82, .35), 0 6px 0 var(--tile-edge), 0 0 0 3px var(--p);
}
.board .tile.is-selected:empty::after { content: ''; width: 4px; height: 45%; border-radius: 2px; background: var(--tile-ink); animation: blink 1s steps(1) infinite; }
.board .tile.is-changed { background: linear-gradient(180deg, var(--coral-a), var(--coral-b)); color: #fff; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), 0 6px 0 var(--coral-s), 0 0 0 3px var(--p); }
.board.shake { animation: shake .38s ease; }
.board.win .tile { animation: hop .5s cubic-bezier(.3, 1.5, .5, 1) both; }
.board.win .tile:nth-child(2) { animation-delay: .05s; }
.board.win .tile:nth-child(3) { animation-delay: .1s; }
.board.win .tile:nth-child(4) { animation-delay: .15s; }
.board.win .tile:nth-child(5) { animation-delay: .2s; }
.turn.is-waiting .board .tile { cursor: default; }
.turn.is-waiting .board .tile:hover { transform: none; }

.message { min-height: 1.5em; text-align: center; font-weight: 700; color: var(--text-2); font-size: 15px; }
.message.is-bad { color: var(--bad); }
.message.is-good { color: var(--good); }
.turn-actions { display: flex; gap: 10px; width: 100%; margin-top: 4px; }
.turn-actions .btn { flex: 1; }
.turn-actions .btn-primary { flex: 1.6; }

/* Word-burst particles (spawned by view.mjs on a good word) */
.burst { position: absolute; left: 50%; top: 50%; pointer-events: none; z-index: 5; }
.burst span {
  position: absolute; left: 0; top: 0; font-family: var(--f-display); font-weight: 800; font-size: 18px; color: var(--c, #fff);
  text-shadow: 0 0 10px currentColor; animation: burst .9s cubic-bezier(.2, .8, .3, 1) forwards;
}
@keyframes burst {
  from { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(var(--rot)); opacity: 0; }
}

/* On-screen keyboard */
.keyboard { display: grid; gap: 7px; user-select: none; }
.krow { display: flex; justify-content: center; gap: 5px; }
.key {
  flex: 1; max-width: 50px; height: 52px; padding: 0; border: 0; border-radius: 11px;
  background: #2c3350; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 3px 0 #141828;
  font-family: var(--f-display); font-weight: 800; font-size: 19px; text-transform: uppercase;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #141828; }
.key-wide { flex: 1.6; max-width: 84px; font-family: var(--f-body); font-size: 13px; text-transform: none; }
.key-enter { background: var(--coral-b); box-shadow: 0 3px 0 var(--coral-s); }
.keyboard.is-idle .key:not(.key-wide) { color: rgba(255, 255, 255, .35); background: #252b44; }

/* ================================================================ OVERLAYS */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 3, 20, .7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.overlay-card {
  width: min(400px, 100%); display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; text-align: center; padding: 28px 22px;
  border-radius: var(--r-lg); background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  box-shadow: inset 0 1px 0 var(--panel-hi), inset 0 0 0 1.5px var(--panel-line), 0 6px 0 var(--panel-shadow), 0 30px 60px rgba(0, 0, 0, .5);
}
.overlay-card h2 { font-size: 32px; font-weight: 800; }
.google-btn { display: flex; justify-content: center; min-height: 44px; }
/* Google draws its button in a light-scheme iframe. On our dark page the browser would paint
   that iframe with an opaque white backdrop (the "white box"); matching the scheme removes it. */
.google-btn iframe { color-scheme: light; background: transparent !important; }
.google-btn > div { color-scheme: light; }
.country-pick { display: flex; align-items: center; gap: 12px; }
.country-preview { flex: none; font-size: 36px; width: 1.333em; height: 1em; border-radius: 5px; background-size: cover; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.country-pick select { height: 50px; width: 100%; }
.country-pick select option { color: #111; }
#country-form { text-align: left; }

.banner {
  position: fixed; left: 50%; top: 22%; z-index: 40; transform: translateX(-50%);
  width: min(440px, calc(100% - 32px)); padding: 18px 22px; text-align: center;
  border-radius: var(--r-lg); color: #fff;
  background: #2a3150;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 24px 50px rgba(0, 0, 0, .5);
  font-family: var(--f-display); font-weight: 800; font-size: 26px; line-height: 1.2;
  animation: banner-in .35s cubic-bezier(.3, 1.5, .5, 1) both; pointer-events: none;
}
.banner small { display: block; margin-top: 6px; font-family: var(--f-body); font-weight: 600; font-size: 15px; text-shadow: none; opacity: .95; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px; background: #fff; color: var(--tile-ink); font-weight: 700;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 16px 30px rgba(0, 0, 0, .4); animation: banner-in .25s ease both;
}

/* ================================================================ RESULTS */
.winner { position: relative; text-align: center; padding: 22px 0 6px; }
.winner-rays {
  position: absolute; left: 50%; top: 60px; width: 380px; height: 380px; transform: translate(-50%, -50%); z-index: -1;
  background: repeating-conic-gradient(from 0deg, rgba(246, 196, 83, .08) 0 10deg, transparent 10deg 24deg);
  mask-image: radial-gradient(circle, #000 20%, transparent 68%);
  animation: spin 18s linear infinite;
}
.trophy {
  width: 96px; height: 96px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3b0, var(--gold) 45%, #d8920c);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18), 0 5px 0 #8a5a00;
  animation: pop .6s cubic-bezier(.3, 1.6, .5, 1) both;
}
.trophy svg { width: 52px; height: 52px; fill: none; stroke: #6b3f00; stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.winner .winner-name { margin-top: 4px; font-family: var(--f-display); font-size: clamp(40px, 11vw, 64px); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; overflow-wrap: anywhere; }

.rewards { display: grid; gap: 14px; }
.reward-row { display: flex; align-items: center; justify-content: center; gap: 16px; }
.reward-emblem .emblem { --es: 110px; }
.reward-text { display: grid; }
.reward-value { font-family: var(--f-display); font-weight: 800; font-size: 46px; line-height: 1; font-variant-numeric: tabular-nums; }
.reward-value.is-up { color: var(--good); }
.reward-value.is-down { color: var(--bad); }
.reward-label { margin-top: 6px; font-weight: 700; color: var(--text-2); }
.rankup {
  display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px; border-radius: 18px;
  background: rgba(246, 196, 83, .08);
  box-shadow: inset 0 0 0 1.5px rgba(246, 196, 83, .55);
}
.rankup.is-down { background: rgba(0, 0, 0, .25); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15); }
.rankup-badge { position: relative; z-index: 0; flex: none; display: grid; place-items: center; }
.rankup-badge .emblem { --es: 100px; }
.rankup-badge::before {
  content: ''; position: absolute; inset: -18px; border-radius: 50%; z-index: -1;
  background: repeating-conic-gradient(from 0deg, rgba(246, 196, 83, .3) 0 12deg, transparent 12deg 30deg);
  mask-image: radial-gradient(circle, #000 35%, transparent 70%);
}
.rankup.is-down .rankup-badge::before { display: none; }
.rankup-title { font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1.1; color: var(--gold); }
.rankup.is-down .rankup-title { color: var(--text-2); }
.rankup-sub { font-weight: 700; color: var(--text-2); }
.rankup.is-new .rankup-badge .emblem { animation: rankup-pop .8s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes rankup-pop { from { transform: scale(.2) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }

.final-scores { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 8px; }
.final-scores li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 14px 10px 10px; border-radius: 14px; background: var(--sunk); font-weight: 700; }
.final-scores li.is-me { box-shadow: inset 0 0 0 1.5px var(--coral-a); }
.final-scores li > .emblem { --es: 46px; }
.final-scores .fs-place { width: 26px; font-family: var(--f-display); font-weight: 800; color: var(--text-2); }
.final-scores .fs-who { flex: 1; min-width: 0; display: grid; }
.final-scores .fs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-scores .fs-name .flag { font-size: 14px; }
.final-scores .fs-stat { color: var(--muted); font-size: 13px; font-weight: 600; }
.final-scores .fs-delta { font-family: var(--f-display); font-weight: 800; font-size: 16px; white-space: nowrap; }
.final-scores .fs-delta.is-up { color: var(--good); }
.final-scores .fs-delta.is-down { color: var(--bad); }
.final-chain { list-style: none; padding: 0; margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px 6px; }
.final-chain li { display: flex; align-items: center; gap: 6px; font-family: var(--f-display); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.final-chain li + li::before { content: '→'; color: var(--muted); }
.missed { margin-top: 10px; color: var(--text-2); line-height: 1.9; }
.missed span { display: inline-block; margin: 0 4px 4px 0; padding: 2px 9px; border-radius: 8px; background: var(--sunk); font-family: var(--f-display); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 14px; }
.end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ================================================================ SPLASH SCREENS */
.boot-splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 22px;
  background:
    radial-gradient(700px 420px at 50% 30%, rgba(90, 110, 190, .25), transparent 65%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  transition: opacity .5s ease, transform .5s ease; cursor: pointer;
}
.boot-splash.is-leaving { opacity: 0; transform: scale(1.06); pointer-events: none; }
.bs-tiles { display: flex; gap: 10px; }
.bs-tile { position: relative; width: 72px; height: 82px; animation: bs-drop .55s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: calc(var(--i) * .09s); }
.bs-face {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 16px;
  background: linear-gradient(180deg, var(--tile-a), var(--tile-b)); color: var(--tile-ink);
  box-shadow: inset 0 -4px 0 rgba(181, 138, 82, .35), 0 6px 0 var(--tile-edge), 0 16px 24px rgba(0, 0, 0, .45);
  font-family: var(--f-display); font-weight: 800; font-size: 44px;
}
/* The swap: W squeezes flat, then a coral T springs open in its place (2D only). */
.bs-back { background: linear-gradient(180deg, var(--coral-a), var(--coral-b)); color: #fff; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), 0 6px 0 var(--coral-s); transform: scaleX(0); }
.bs-tile:first-child .bs-front { animation: bs-squeeze .22s ease-in .8s both; }
.bs-tile:first-child .bs-back { animation: bs-open .42s cubic-bezier(.3, 1.6, .5, 1) 1.02s both; }
.bs-title { font-family: var(--f-display); font-weight: 800; font-size: clamp(38px, 9vw, 58px); letter-spacing: -.02em; animation: bs-rise .5s ease 1.05s both; }
.bs-bar { width: 170px; height: 8px; border-radius: 999px; background: var(--sunk); overflow: hidden; animation: bs-rise .4s ease 1.2s both; }
.bs-bar span { display: block; height: 100%; width: 40%; border-radius: 999px; background: var(--coral-b); animation: bs-load 1s ease-in-out infinite; }
@keyframes bs-drop { from { transform: translateY(-60vh) rotate(-25deg); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes bs-squeeze { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes bs-open { from { transform: scaleX(0); } 60% { transform: scaleX(1.08) translateY(-10px); } to { transform: scaleX(1); } }
@keyframes bs-rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bs-load { from { transform: translateX(-110%); } to { transform: translateX(260%); } }

.game-splash {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: rgba(9, 12, 22, .9);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .3s ease;
}
.game-splash.is-in { opacity: 1; }
.game-splash.is-leaving { opacity: 0; transform: scale(1.04); transition: opacity .4s ease, transform .4s ease; }
.gs-inner { width: min(780px, 100%); display: grid; justify-items: center; gap: 14px; text-align: center; }
.gs-title { font-weight: 800; letter-spacing: .18em; text-transform: uppercase; font-size: 14px; color: var(--muted); animation: bs-rise .4s ease .05s both; }
.gs-players { display: flex; align-items: center; justify-content: center; gap: 18px; width: 100%; }
.is-group .gs-players { flex-wrap: wrap; gap: 12px; }
.gs-player {
  position: relative; display: grid; justify-items: center; gap: 6px; min-width: 0; flex: 1 1 0; max-width: 290px;
  padding: 18px 14px 18px; border-radius: 24px;
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  box-shadow: inset 0 4px 0 var(--c), inset 0 0 0 1px var(--panel-line), 0 16px 40px rgba(0, 0, 0, .35);
  animation: gs-in-left .55s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(.15s + var(--i) * .08s);
}
.is-versus .gs-player:last-child { animation-name: gs-in-right; }
.is-group .gs-player { flex: 0 1 170px; padding: 12px 10px; animation-name: gs-pop; }
.gs-player .emblem { --es: 128px; }
.is-group .gs-player .emblem { --es: 72px; }
.gs-dot { width: 46px; height: 46px; border-radius: 50%; background: var(--c); }
.gs-name { font-family: var(--f-display); font-weight: 800; font-size: 22px; line-height: 1.15; overflow-wrap: break-word; }
.is-group .gs-name { font-size: 17px; }
.gs-name .flag { font-size: 18px; }
.gs-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-items: center; }
.gs-rank { font-size: 13px; font-weight: 700; color: var(--text-2); }
.gs-you { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); padding: 2px 12px; border-radius: 999px; background: #fff; color: var(--tile-ink); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.gs-vs {
  flex: none; display: grid; place-items: center; width: 70px; height: 70px; border-radius: 50%;
  background: linear-gradient(180deg, var(--coral-a), var(--coral-b)); color: #fff;
  box-shadow: 0 4px 0 var(--coral-s);
  font-family: var(--f-display); font-weight: 800; font-size: 26px;
  animation: gs-vs .5s cubic-bezier(.3, 1.8, .5, 1) .55s both;
}
.gs-label { margin-top: 8px; font-size: 13px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); animation: bs-rise .4s ease .8s both; }
.gs-word { display: flex; gap: 8px; }
.gs-tile { animation: gs-flip .5s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(.9s + var(--i) * .12s); }
.gs-first { font-family: var(--f-display); font-weight: 800; font-size: 24px; animation: bs-rise .4s ease 1.5s both; }
.gs-count { font-family: var(--f-display); font-weight: 800; font-size: 64px; line-height: 1; color: var(--text); }
.gs-count.pop { animation: gs-count .5s ease both; }
.gs-count.is-ready { font-size: 26px; letter-spacing: .04em; animation: bs-rise .4s ease 1.7s both; }
@keyframes gs-in-left { from { transform: translateX(-60px) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gs-in-right { from { transform: translateX(60px) rotate(6deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gs-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gs-vs { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }
@keyframes gs-flip { from { transform: translateY(-20px) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gs-count { from { transform: scale(1.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* ================================================================ MOTION */
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-16px) scale(1.05); } }
@keyframes pop { 0% { transform: scale(.8); opacity: .3; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse { to { opacity: .6; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.rankup.is-new .rankup-badge::before { animation: spin-plain 8s linear infinite; }
@keyframes spin-plain { to { transform: rotate(360deg); } }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, 14px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bg-tile { animation: none; }
}

/* ================================================================ PHONES */
@media (max-width: 600px) {
  .screen-game { min-height: calc(100dvh - 40px - env(safe-area-inset-bottom)); gap: 10px; }
  .screen-game .turn { margin-block: auto; }
  .screen-game .topbar .icon-btn { width: 42px; height: 42px; }
  .screen-game .topbar-title { font-size: 16px; }
  .turn-label { font-size: 21px; }
  .score > .emblem { --es: 26px; }
  .score-you { display: none; }
  .score:has(.score-you) .score-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
  /* Tiles sized to the screen width so the board fills the card */
  .board { --n: 4; gap: 8px; }
  .board.len-3 { --n: 3; } .board.len-5 { --n: 5; } .board.len-6 { --n: 6; }
  .board .tile {
    width: min(80px, calc((100vw - 96px - (var(--n) - 1) * 8px) / var(--n)));
    height: auto; aspect-ratio: 7 / 8;
    font-size: min(46px, calc((100vw - 96px) / var(--n) * .56));
  }
  .keyboard { gap: 6px; }
  .key { height: 50px; font-size: 18px; border-radius: 9px; }
  .krow { gap: 4px; }
  .panel, .card { padding: 16px; }
  .turn { padding: 14px 12px 16px; }
  .bg-tile { display: none; }
  .bg-tile:nth-child(1) { display: block; left: 93%; top: 96px; width: 40px; height: 40px; }
  body[data-screen="game"] .bg-tile, body[data-screen="end"] .bg-tile { display: none; }
  /* Profile: badge + name/rank on top, stats and progress full width below */
  .hero-body { grid-template-columns: auto 1fr; grid-template-areas: "em name" "em rank" "stats stats" "next next"; gap: 8px 12px; }
  .hero-info { display: contents; }
  .hero-emblem { grid-area: em; }
  .hero-name-row { grid-area: name; align-self: end; }
  .hero-rank { grid-area: rank; align-self: start; }
  .hero-stats { grid-area: stats; margin-top: 4px; }
  .next-rank { grid-area: next; }
  .hero-emblem .emblem { --es: 84px; }
  .stat-label { font-size: 10px; letter-spacing: .06em; }
  .hero-name { font-size: 21px; }
  .stat { padding: 7px 8px; }
  .stat-value { font-size: 17px; }
  .hero-save { flex-wrap: wrap; }
  .play-btn { padding: 16px; gap: 12px; }
  .play-btn-icon { width: 50px; height: 50px; }
  .play-btn-title { font-size: 24px; }
  .mode-btn { padding: 12px 14px; }
  .mode-title { font-size: 16px; }
  .rank-row > .emblem { --es: 44px; }
  .ranking--compact .rank-row > .emblem { --es: 40px; }
  .rung-badge .emblem { --es: 112px; margin: -10px 2px -10px -4px; }
  .rung { padding: 10px 14px 10px 8px; gap: 10px; }
  .rung-name { font-size: 22px; }
  .gs-players { gap: 8px; }
  .gs-player { padding: 14px 8px 12px; border-radius: 18px; }
  .gs-player .emblem { --es: 92px; }
  .gs-name { font-size: 16px; }
  .gs-vs { width: 48px; height: 48px; font-size: 18px; }
  .gs-meta .rank-pill { font-size: 11px; }
  .gs-rank { font-size: 11px; }
  .gs-tile { width: 50px !important; height: 58px !important; font-size: 30px !important; }
  .reward-emblem .emblem { --es: 80px; }
  .reward-value { font-size: 40px; }
  .rankup-badge .emblem { --es: 80px; }
  .rankup-title { font-size: 24px; }
}
@media (max-width: 600px) and (max-height: 700px) {
  .key { height: 44px; }
  .turn { gap: 8px; padding-top: 12px; padding-bottom: 14px; }
}
@media (max-width: 420px) {
  .end-actions { grid-template-columns: 1fr !important; }
  .bs-tile { width: 58px; height: 66px; } .bs-face { font-size: 34px; border-radius: 13px; }
  .wm-text { font-size: 21px; }
  .wm-tile { width: 34px; height: 40px; font-size: 22px; }
  .online-chip { gap: 8px; padding: 5px 10px 5px 6px; }
  .online-flags .online-flag { width: 22px; height: 22px; line-height: 22px; }
  .online-flags .online-flag + .online-flag { margin-left: -7px; }
  .online-num { font-size: 17px; gap: 6px; }
  .online-label { font-size: 9.5px; }
  .hero-name { font-size: 20px; }
  .hero-name.is-long { font-size: 18px; }
  .room-code { font-size: 46px; }
}

/* ================================================================ DESKTOP */
@media (min-width: 960px) {
  .app { max-width: 1140px; padding: 28px 32px 48px; }
  .screen:not(.screen-home):not(.screen-game):not(.screen-end) { max-width: 660px; margin-inline: auto; width: 100%; }
  .screen-home { gap: 22px; }
  .home-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .home-side { position: sticky; top: 24px; }
  .hero-emblem .emblem { --es: 140px; }
  .hero-name { font-size: 28px; }

  .screen-game {
    display: grid; grid-template-columns: minmax(0, 1fr) 330px;
    grid-template-areas: "top top" "turn side" "keys side";
    gap: 20px 28px; align-items: start;
  }
  .screen-game .topbar { grid-area: top; }
  .game-side { grid-area: side; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 24px; }
  .side-block {
    padding: 16px; border-radius: var(--r-lg);
    background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
    box-shadow: inset 0 1px 0 var(--panel-hi), inset 0 0 0 1.5px var(--panel-line), 0 6px 0 var(--panel-shadow);
  }
  .side-title { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
  .screen-game .scoreboard { flex-direction: column; flex-wrap: nowrap; padding: 0; }
  .screen-game .score { flex: none; width: 100%; padding: 10px 12px 10px 10px; font-size: 15px; }
  .screen-game .score > .emblem { --es: 40px; }
  .side-block--chain .chain { flex-wrap: wrap; overflow: auto; max-height: 360px; padding: 0; gap: 8px 6px; scroll-behavior: auto; }
  .screen-game .turn { grid-area: turn; padding: 30px 36px 32px; gap: 14px; }
  .screen-game .turn-label { font-size: 30px; }
  .screen-game .timer { height: 16px; max-width: 580px; }
  .screen-game .timer-text { font-size: 18px; }
  .screen-game .board { gap: 14px; margin: 16px 0 8px; }
  .screen-game .board .tile { width: 96px; height: 106px; font-size: 56px; border-radius: 20px; }
  .screen-game .board.len-5 .tile { width: 86px; height: 96px; font-size: 50px; }
  .screen-game .message { font-size: 16px; }
  .screen-game .turn-actions { max-width: 540px; }
  .screen-game .keyboard { grid-area: keys; width: 100%; max-width: 660px; justify-self: center; }
  .screen-game .key { max-width: 58px; height: 56px; }
  .screen-game .key-wide { max-width: 96px; }

  .screen-end { max-width: 980px; margin-inline: auto; width: 100%; grid-template-columns: 1fr 1fr; grid-auto-flow: dense; column-gap: 24px; align-items: start; }
  .screen-end > .winner, .screen-end > #end-note, .screen-end > .end-actions { grid-column: 1 / -1; }
  .screen-end > #rewards, .screen-end > .end-scores { grid-column: 1; }
  .screen-end > .end-chain, .screen-end > #missed-card { grid-column: 2; }
  .screen-end > .end-actions { max-width: 560px; width: 100%; justify-self: center; }
}

/* ================================================================ INSTALL (PWA) */
.install-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.install-card img { flex: none; width: 52px; height: 52px; border-radius: 13px; box-shadow: 0 4px 12px rgba(0, 0, 0, .35); }
.install-text { flex: 1; min-width: 0; }
.install-title { font-family: var(--f-display); font-weight: 800; font-size: 17px; }
.install-text .small { font-size: 13px; line-height: 1.35; }
.install-card .btn { flex: none; }
.install-close { flex: none; width: 32px; height: 32px; margin-right: -6px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 22px; line-height: 1; }
.install-close:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.ios-steps { text-align: left; padding-left: 22px; display: grid; gap: 10px; color: var(--text-2); }
.ios-steps b { color: #fff; }
.ios-steps svg { width: 18px; height: 18px; vertical-align: -3px; fill: none; stroke: #4c9bff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ================================================================ CHALLENGES */
.challenge-card { display: grid; justify-items: center; gap: 14px; text-align: center; }
.challenge-vs { display: flex; align-items: center; gap: 14px; }
.challenge-vs-text { font-family: var(--f-display); font-weight: 800; font-size: 22px; color: var(--coral-a); }
.challenge-them {
  width: 88px; height: 88px; display: grid; place-items: center; border-radius: 50%;
  background: var(--sunk); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .14);
  font-family: var(--f-display); font-weight: 800; font-size: 40px; color: var(--muted);
  animation: pulse 1.2s ease-in-out infinite alternate;
}
.challenge-title { font-family: var(--f-display); font-weight: 800; font-size: 24px; }
.link-box { display: flex; gap: 8px; width: 100%; }
.link-box input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 0; border-radius: 12px;
  background: var(--sunk); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--panel-line);
  font: inherit; font-size: 14px; font-weight: 600;
}
.waiting-line { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; color: var(--text-2); font-size: 14px; }

.invite-card { display: grid; justify-items: center; gap: 10px; text-align: center; padding-top: 26px; }
.invite-emblem .emblem { --es: 150px; }
.invite-name { font-size: clamp(28px, 8vw, 40px); font-weight: 800; overflow-wrap: break-word; }
.invite-name .flag { font-size: .7em; vertical-align: .05em; }
.invite-meta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.invite-rules { list-style: none; padding: 0; margin: 4px 0 6px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.invite-rules li { padding: 6px 12px; border-radius: 999px; background: var(--sunk); font-size: 13px; font-weight: 600; color: var(--text-2); }
.invite-rules b { color: var(--text); }
.invite-card .btn-block { max-width: 420px; }
@media (max-width: 600px) {
  .mode-row { grid-template-columns: 1fr 1fr; }
  .mode-row > #challenge-btn { grid-column: 1 / -1; grid-template-columns: auto 1fr; grid-template-areas: "icon title" "icon sub"; column-gap: 12px; align-items: center; }
  .mode-row > #challenge-btn svg { grid-area: icon; margin: 0; width: 30px; height: 30px; }
  .mode-row > #challenge-btn .mode-title { grid-area: title; }
  .mode-row > #challenge-btn .mode-sub { grid-area: sub; }
  .invite-emblem .emblem { --es: 120px; }
}

/* ================================================================ BADGE VIEWER */
.badge-viewer { z-index: 80; background: rgba(6, 8, 18, .86); }
.bv-card {
  --rc: #e08a4f;
  position: relative; width: min(440px, 100%); max-height: 100%; overflow-x: hidden; overflow-y: auto; scrollbar-width: none;
  display: grid; justify-items: center; gap: 8px; padding: 18px 22px 22px; text-align: center;
  border-radius: 28px; background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 10%, var(--panel-a)), var(--panel-b));
  box-shadow: inset 0 1px 0 var(--panel-hi), inset 0 0 0 1px var(--panel-line), 0 30px 80px rgba(0, 0, 0, .55);
}
.bv-close { position: absolute; top: 10px; right: 12px; z-index: 2; width: 38px; height: 38px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .06); color: var(--text-2); font-size: 24px; line-height: 1; }
.bv-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.bv-stage { position: relative; width: min(320px, 78vw); aspect-ratio: 1; display: grid; place-items: center; perspective: 900px; touch-action: pan-y; }
.bv-rays {
  position: absolute; inset: -6%; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--rc) 22%, transparent) 0 8deg, transparent 8deg 20deg);
  mask-image: radial-gradient(circle, #000 25%, transparent 68%); -webkit-mask-image: radial-gradient(circle, #000 25%, transparent 68%);
  animation: spin-plain 30s linear infinite;
}
.bv-stage::before { /* soft glow in the rank colour */
  content: ''; position: absolute; inset: 18%; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--rc) 45%, transparent), transparent 70%); filter: blur(18px);
}
.bv-tilt { --gx: 30%; --gy: 20%; position: relative; width: 100%; height: 100%; transition: transform .25s ease-out; transform-style: preserve-3d; animation: bv-float 5s ease-in-out infinite; }
.bv-tilt img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .55)); }
.bv-tilt img.is-in { animation: bv-in .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.bv-glint { /* a light sweep that follows the pointer, clipped to the badge's shape */
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, .7), transparent 35%);
  -webkit-mask-image: var(--mask); mask-image: var(--mask); -webkit-mask-size: contain; mask-size: contain;
}
.bv-card[data-rank="unranked"] .bv-tilt, .bv-card[data-rank="novice"] .bv-tilt { scale: 1.25; }
.bv-card[data-rank="apprentice"] .bv-tilt { scale: 1.12; }
.bv-card.is-locked .bv-tilt img { filter: saturate(.8) brightness(.85) drop-shadow(0 18px 24px rgba(0, 0, 0, .55)); }
.bv-name { font-size: 40px; font-weight: 800; color: #fff; }
.bv-card .eyebrow { color: var(--rc); }
.bv-range { font-weight: 700; color: var(--text-2); }
.bv-motto { max-width: 340px; color: var(--text-2); font-size: 15px; font-style: italic; }
.bv-progress { width: 100%; display: grid; gap: 6px; margin-top: 4px; }
.bv-progress .bar-fill { background: linear-gradient(90deg, var(--rc), var(--to, var(--rc))); }
.bv-progress-text { font-size: 13px; font-weight: 700; color: var(--text); }
.bv-nav { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.bv-nav .icon-btn:disabled { opacity: .3; }
.bv-dots { display: flex; gap: 6px; }
.bv-dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .2); }
.bv-dots span.is-on { width: 20px; border-radius: 999px; background: var(--rc); }
@keyframes bv-float { 50% { translate: 0 -8px; } }
@keyframes bv-in { from { transform: scale(.6) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 420px) { .bv-name { font-size: 32px; } }

/* ================================================================ PRACTICE BOTS */
.emblem--bot svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .4)); }
.bot-tag {
  display: inline-block; padding: 1px 6px; border-radius: 6px; vertical-align: middle;
  background: #5ae5ff22; box-shadow: inset 0 0 0 1px #5ae5ff88; color: #8fe9ff;
  font-family: var(--f-body); font-size: 10px; font-weight: 800; letter-spacing: .08em;
}
.score .bot-tag { flex: none; }
.bot-offer { display: grid; justify-items: center; gap: 8px; max-width: 360px; padding: 14px 16px; border-radius: 18px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--panel-line); animation: bs-rise .35s ease both; }
.practice-link { justify-self: center; font-size: 13.5px; color: var(--text-2); text-decoration-color: rgba(255, 255, 255, .3); }
.practice-link:hover { color: #fff; }
.gs-player .emblem--bot { --es: 104px; }
.is-group .gs-player .emblem--bot { --es: 64px; }

/* ================================================================ RANK LEVELS (stars) */
.emblem-stars, .rung-stars, .bv-star-row { display: inline-flex; gap: 1px; line-height: 1; }
.emblem-stars {
  position: absolute; left: 50%; bottom: -2%; transform: translateX(-50%);
  padding: 2px 5px; border-radius: 999px; background: rgba(8, 10, 22, .78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  font-size: max(8px, calc(var(--es) * .085));
}
.star { color: rgba(255, 255, 255, .22); }
.star.is-on { color: #ffd451; text-shadow: 0 0 6px rgba(255, 212, 81, .55); }
.rung-stars { font-size: 18px; gap: 3px; }
.bv-star-row { font-size: 24px; gap: 4px; margin-top: -2px; }
#bv-stars:empty { display: none; }

/* "new today" segment in the online counter */
.online-new { padding-left: 12px; margin-left: 2px; border-left: 1px solid rgba(255, 255, 255, .12); }
.online-new .online-num { color: #ffd451; }
.online-new .online-label { color: var(--muted); }
@media (max-width: 420px) { .online-new { padding-left: 8px; } }

/* ================================================================ ABOUT + FAQ (also what search engines read) */
.about { display: grid; gap: 8px; }
.faq { border-top: 1px solid var(--panel-line); padding: 10px 0 2px; }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; font-weight: 700; font-size: 15px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--muted); font-weight: 800; }
.faq[open] summary::after { content: '−'; }
.faq p { margin-top: 6px; color: var(--text-2); font-size: 14px; line-height: 1.55; }

/* Narrow phones: keep the logo + online counter on one line (wrap only as a last resort). */
.home-top { flex-wrap: wrap; row-gap: 10px; }
@media (max-width: 480px) {
  .home-top .wm-text { font-size: 19px; }
  .home-top .wm-tile { width: 32px; height: 38px; font-size: 21px; }
  .online-chip { gap: 7px; padding: 5px 9px 5px 6px; }
  .online-flags .online-flag:nth-child(n+3) { display: none; }
  .online-num { font-size: 16px; gap: 5px; }
  .online-label { font-size: 9px; letter-spacing: .08em; }
  .online-new { padding-left: 7px; }
}

.hero-save-actions { display: flex; gap: 8px; flex: none; }
@media (max-width: 600px) { .hero-save-actions { width: 100%; } .hero-save-actions .btn { flex: 1; } }

/* ================================================================ LOADING FEEDBACK */
/* Thin bar at the very top while the game waits on the server (after 120 ms). */
.loadbar { position: fixed; top: 0; left: 0; right: 0; z-index: 200; height: 3px; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .2s; }
.loadbar span { display: block; width: 35%; height: 100%; border-radius: 0 3px 3px 0; background: linear-gradient(90deg, var(--coral-a), var(--gold)); box-shadow: 0 0 8px rgba(255, 117, 88, .7); animation: loadbar 1s ease-in-out infinite; }
.is-loading .loadbar { opacity: 1; }
@keyframes loadbar { from { transform: translateX(-100%); } to { transform: translateX(320%); } }

/* Spinner: on busy buttons, and on its own (e.g. while Google's button loads). */
.spinner, .is-busy::after {
  content: ''; display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent; animation: spin-plain .7s linear infinite;
}
.btn.is-busy, .mode-btn.is-busy, .play-btn.is-busy, .icon-btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy > *, .mode-btn.is-busy > *, .icon-btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after, .mode-btn.is-busy::after, .icon-btn.is-busy::after { position: absolute; left: 50%; top: 50%; margin: -9px 0 0 -9px; color: #fff; }
.btn:disabled.is-busy { opacity: 1; }
.google-btn .spinner { color: var(--muted); margin: 12px auto; }
.link-box.is-busy input { color: var(--muted); font-style: italic; }
.link-box.is-busy::after { display: none; }

/* Skeleton ranking rows */
.rank-row.is-skeleton { pointer-events: none; }
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.12), rgba(255,255,255,.05)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-pos { width: 18px; height: 18px; justify-self: center; }
.sk-badge { width: 42px; height: 42px; border-radius: 50%; }
.ranking:not(.ranking--compact) .sk-badge { width: 50px; height: 50px; }
.sk-text { height: 30px; width: 70%; }
.sk-score { width: 44px; height: 26px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Every tappable thing reacts the instant it's pressed */
.mode-btn, .play-btn, .btn, .chip, .key, .tile, .icon-btn, .rank-stat, .hero-emblem, .rung-badge { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
