:root {
  --page-text: #fff6f2;
  --link-color: #ffe7d9;
  --bg-radial: rgba(255, 122, 89, 0.16);
  --bg-start: #120d12;
  --bg-end: #1a1118;
  --surface-bg: rgba(28, 20, 32, 0.92);
  --surface-border: rgba(255, 122, 89, 0.18);
  --surface-shadow: rgba(0, 0, 0, 0.4);
  --accent: #ffd166;
  --accent-soft: rgba(255, 209, 102, 0.14);
  --title-color: #fff7f3;
  --subtitle-color: #ffe6db;
  --muted-color: #d2b8ae;
  --button-gradient-start: #ff7a59;
  --button-gradient-end: #ffd166;
  --button-text: #1a1114;
  --button-shadow: rgba(255, 122, 89, 0.28);
  --ghost-button-bg: rgba(255, 255, 255, 0.04);
  --panel-bg: rgba(40, 27, 44, 0.96);
  --panel-border: rgba(255, 122, 89, 0.16);
  --panel-label: #d9b4a6;
  --intro-color: #dfc0b3;
  --board-bg: #281b2c;
  --grid-cell-bg: rgba(255, 255, 255, 0.05);
  --overlay-bg: rgba(18, 10, 14, 0.96);
  --table-row-bg: rgba(255, 255, 255, 0.022);
  --input-bg: rgba(255, 255, 255, 0.045);

  /* Tile palette — dark-first, tuned to the board background */
  --tile-2-bg: #3a2a3f;
  --tile-2-fg: #ffd9c9;
  --tile-4-bg: #45313f;
  --tile-4-fg: #ffe3d4;
  --tile-8-bg: #6b3a33;
  --tile-8-fg: #fff1e8;
  --tile-16-bg: #8c4534;
  --tile-16-fg: #fff6ee;
  --tile-32-bg: #b3542f;
  --tile-32-fg: #fff8f2;
  --tile-64-bg: #d4693a;
  --tile-64-fg: #fffaf5;
  --tile-128-bg: #e08a3c;
  --tile-128-fg: #1d1210;
  --tile-256-bg: #eaa63f;
  --tile-256-fg: #1d1210;
  --tile-512-bg: #f2c04a;
  --tile-512-fg: #1d1210;
  --tile-1024-bg: #f7d05e;
  --tile-1024-fg: #1d1210;
  --tile-2048-bg: #ffdf7a;
  --tile-2048-fg: #1d1210;
  --tile-super-bg: #2e2533;
  --tile-super-fg: #ffe6db;
  --tile-shadow: rgba(0, 0, 0, 0.35);
}

[data-theme="midnight-pulse"] {
  --page-text: #eef2ff;
  --link-color: #dbe6ff;
  --bg-radial: rgba(124, 92, 255, 0.22);
  --bg-start: #071019;
  --bg-end: #0b1322;
  --surface-bg: rgba(16, 26, 43, 0.88);
  --surface-border: rgba(124, 92, 255, 0.22);
  --surface-shadow: rgba(0, 0, 0, 0.34);
  --accent: #3cf2c9;
  --accent-soft: rgba(60, 242, 201, 0.12);
  --title-color: #f7f9ff;
  --subtitle-color: #dfe7ff;
  --muted-color: #97a6c6;
  --button-gradient-start: #7c5cff;
  --button-gradient-end: #3cf2c9;
  --button-text: #08111f;
  --button-shadow: rgba(124, 92, 255, 0.32);
  --ghost-button-bg: rgba(255, 255, 255, 0.04);
  --panel-bg: rgba(28, 40, 67, 0.96);
  --panel-border: rgba(124, 92, 255, 0.2);
  --panel-label: #95a8d5;
  --intro-color: #a9b8d8;
  --board-bg: #18243a;
  --grid-cell-bg: rgba(255, 255, 255, 0.06);
  --overlay-bg: rgba(9, 15, 27, 0.96);
  --table-row-bg: rgba(255, 255, 255, 0.03);
  --input-bg: rgba(255, 255, 255, 0.05);

  /* Tile palette — violet-to-teal, matching the theme accents */
  --tile-2-bg: #232f4a;
  --tile-2-fg: #dbe6ff;
  --tile-4-bg: #2b3a5c;
  --tile-4-fg: #e2eaff;
  --tile-8-bg: #3b3f74;
  --tile-8-fg: #eef2ff;
  --tile-16-bg: #524f96;
  --tile-16-fg: #f3f6ff;
  --tile-32-bg: #6a5fb8;
  --tile-32-fg: #f8faff;
  --tile-64-bg: #7c6fd4;
  --tile-64-fg: #fafcff;
  --tile-128-bg: #4db8d8;
  --tile-128-fg: #08111f;
  --tile-256-bg: #46cfe0;
  --tile-256-fg: #08111f;
  --tile-512-bg: #3ce4c9;
  --tile-512-fg: #08111f;
  --tile-1024-bg: #54f0d6;
  --tile-1024-fg: #08111f;
  --tile-2048-bg: #7cffdf;
  --tile-2048-fg: #08111f;
  --tile-super-bg: #1c2740;
  --tile-super-fg: #dfe7ff;
  --tile-shadow: rgba(0, 0, 0, 0.4);
}

[data-theme="graphite-neon"] {
  --page-text: #eef3ff;
  --link-color: #d9e6ff;
  --bg-radial: rgba(102, 163, 255, 0.16);
  --bg-start: #0d1117;
  --bg-end: #111822;
  --surface-bg: rgba(21, 27, 35, 0.9);
  --surface-border: rgba(102, 163, 255, 0.18);
  --surface-shadow: rgba(0, 0, 0, 0.36);
  --accent: #8bffb0;
  --accent-soft: rgba(139, 255, 176, 0.12);
  --title-color: #f5f8ff;
  --subtitle-color: #e5ebff;
  --muted-color: #a2afc3;
  --button-gradient-start: #66a3ff;
  --button-gradient-end: #8bffb0;
  --button-text: #09111a;
  --button-shadow: rgba(102, 163, 255, 0.26);
  --ghost-button-bg: rgba(255, 255, 255, 0.045);
  --panel-bg: rgba(29, 38, 51, 0.96);
  --panel-border: rgba(102, 163, 255, 0.16);
  --panel-label: #9eb0cc;
  --intro-color: #afbdd0;
  --board-bg: #1d2633;
  --grid-cell-bg: rgba(255, 255, 255, 0.055);
  --overlay-bg: rgba(9, 14, 22, 0.96);
  --table-row-bg: rgba(255, 255, 255, 0.025);
  --input-bg: rgba(255, 255, 255, 0.045);

  /* Tile palette — slate-to-neon, matching the theme accents */
  --tile-2-bg: #243040;
  --tile-2-fg: #d9e6ff;
  --tile-4-bg: #2c3c52;
  --tile-4-fg: #e2eaff;
  --tile-8-bg: #3d4a6e;
  --tile-8-fg: #eef3ff;
  --tile-16-bg: #54639b;
  --tile-16-fg: #f4f8ff;
  --tile-32-bg: #6b7cc9;
  --tile-32-fg: #f8fbff;
  --tile-64-bg: #66a3ff;
  --tile-64-fg: #09111a;
  --tile-128-bg: #6fd0a0;
  --tile-128-fg: #09111a;
  --tile-256-bg: #7fe6ad;
  --tile-256-fg: #09111a;
  --tile-512-bg: #8bffb0;
  --tile-512-fg: #09111a;
  --tile-1024-bg: #a0ffc4;
  --tile-1024-fg: #09111a;
  --tile-2048-bg: #c0ffd8;
  --tile-2048-fg: #09111a;
  --tile-super-bg: #1c2531;
  --tile-super-fg: #e5ebff;
  --tile-shadow: rgba(0, 0, 0, 0.4);
}

[data-theme="ember-grid"] {
}

html,
body {
  background:
    radial-gradient(circle at top, var(--bg-radial), transparent 30%),
    linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--page-text);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link-color);
}

.container {
  width: min(100%, 560px);
  max-width: 100%;
  box-sizing: border-box;
  padding: 32px 16px 56px;
  margin-left: auto;
  margin-right: auto;
}

/* ============ Mobile game-first shell ============ */

.container.game-first {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  justify-items: center;
  /* Shared board width so header, cards and the 4x4 board align. */
  --board-w: min(92vw, 460px);
}

@media screen and (min-width: 1024px) {
  .container.game-first {
    --board-w: min(92vw, 400px);
  }
}

.game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 460px;
  min-width: 0;
}

.header-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.header-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--title-color);
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.15s ease;
}

a.header-title:hover {
  color: var(--accent);
}

/* Mode pills in the header (same row as the logo). */
.header-modes {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-modes .mode-pill {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 11px;
  letter-spacing: 0.1em;
}

.mode-pill {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-pill-active {
  background: var(--accent-soft);
  color: var(--accent);
}

a.mode-pill {
  text-decoration: none;
}

.mode-pill-locked {
  background: var(--ghost-button-bg);
  color: var(--muted-color);
  border: 1px dashed var(--panel-border);
}

.mode-pill-daily {
  background: var(--ghost-button-bg);
  color: var(--muted-color);
  border: 1px dashed var(--panel-border);
  cursor: pointer;
  font-family: inherit;
}

.mode-pill-daily:disabled {
  cursor: not-allowed;
}

/* Header mode pills used as links (leaderboard): solid ghost style. */
.mode-pill-link {
  background: var(--ghost-button-bg);
  color: var(--page-text);
  border: 1px solid var(--surface-border);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mode-pill-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Daily challenge modal */
.daily-sheet-date {
  color: var(--muted-color);
  font-size: 14px;
  margin: 0 0 14px;
  letter-spacing: 0.08em;
}

.daily-sheet-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.daily-stat {
  display: grid;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 14px;
  background: var(--ghost-button-bg);
  border: 1px solid var(--panel-border);
  text-align: center;
}

.daily-stat span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--panel-label);
}

.daily-stat strong {
  font-size: 18px;
  color: var(--title-color);
}

.daily-sheet-copy {
  color: var(--muted-color);
  font-size: 14px;
  margin: 0 0 14px;
}

.daily-sheet-next {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  margin: -6px 0 14px;
}

/* Weekly best 5-of-7 progress */
.weekly-progress {
  background: var(--input-bg);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 14px;
  text-align: center;
}

.weekly-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.weekly-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--grid-cell-bg);
  border: 1px solid var(--surface-border);
}

.weekly-dot.is-done {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}

.weekly-summary {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--title-color);
}

.weekly-rank {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

/* Daily retention card (PHASE 5) */
.daily-card {
  display: flex;
  align-items: center;
  gap: 10px 12px;
  width: var(--board-w);
  max-width: 100%;
  box-sizing: border-box;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 10px 12px;
  box-shadow: 0 10px 30px var(--surface-shadow);
}

.daily-card-main {
  flex: 1 1 auto;
  min-width: 0;
}

.daily-card-label {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
  text-transform: uppercase;
  white-space: nowrap;
}

.daily-card-status {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--title-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.daily-card-streak {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.daily-card-countdown {
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted-color);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.daily-card-cta {
  flex: 0 0 auto;
  min-height: 40px;
  min-width: 96px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 8px 20px var(--button-shadow);
  white-space: nowrap;
}

/* Narrow screens: shrink paddings and the countdown. */
@media screen and (max-width: 520px) {
  .daily-card {
    gap: 6px 8px;
    padding: 8px 10px;
  }

  .daily-card-countdown {
    font-size: 11px;
  }

  .daily-card-cta {
    min-height: 38px;
    min-width: 84px;
    padding: 0 12px;
    font-size: 12px;
  }
}

/* Very narrow screens (<=380px): stack — main on top, button below. */
@media screen and (max-width: 380px) {
  .daily-card {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .daily-card-countdown {
    align-self: flex-start;
  }

  .daily-card-cta {
    width: 100%;
  }
}

@media screen and (min-width: 520px) {
  .daily-card-cta {
    min-width: 104px;
  }
}

/* Compact on short screens */
@media screen and (max-height: 700px) and (orientation: landscape) {
  .daily-card {
    padding: 8px 12px;
    gap: 6px 12px;
  }

  .daily-card-cta {
    min-height: 36px;
    font-size: 13px;
  }
}



/* Status row: Social Pulse (left) + PB / streak (right) — one fixed-height
   line so the board never shifts. */
.social-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: var(--board-w);
  max-width: 100%;
  box-sizing: border-box;
  min-height: 26px;
  max-height: 26px;
}

/* Social Pulse / Live Activity (adaptive social proof) */
.social-pulse {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted-color);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.social-pulse[data-activity="high"] {
  color: var(--accent);
}

.social-pulse.sp-fade-out {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.social-pulse.sp-fade-in {
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Right column: PB status + streak badge (unchanged content, right-aligned) */
.social-row .pb-status,
.social-row .streak-badge {
  flex: 0 0 auto;
  margin: 0;
  min-height: 0;
  height: auto;
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.social-row .pb-status.pb-hidden {
  visibility: hidden;
  width: 0;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .social-pulse,
  .social-pulse.sp-fade-out,
  .social-pulse.sp-fade-in {
    transition: none;
  }
}

/* Compact on short screens */
@media screen and (max-height: 700px) and (orientation: landscape) {
  .social-row {
    min-height: 22px;
    max-height: 22px;
  }

  .social-pulse {
    font-size: 11px;
  }

  .social-row .pb-status,
  .social-row .streak-badge {
    font-size: 11px;
  }
}

/* Friend challenge sheet */
.challenge-sheet-score {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 4px;
}

.challenge-sheet-creator {
  font-size: 14px;
  color: var(--muted-color);
  margin: 0 0 12px;
}

.daily-start-button {
  width: 100%;
  min-height: 50px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 12px 30px var(--button-shadow);
}

/* Player name editor (daily modal) */
.player-name-editor {
  margin-bottom: 12px;
  text-align: left;
}

.player-name-editor label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--panel-label);
  margin-bottom: 6px;
}

.player-name-row {
  display: flex;
  gap: 8px;
}

.player-name-row input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--page-text);
  font-size: 15px;
}

.player-name-row button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--ghost-button-bg);
  color: var(--page-text);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.player-name-hint {
  font-size: 12px;
  color: var(--accent);
  margin: 6px 0 0;
}

.player-name-hint.player-name-error {
  color: #ff7a6e;
}

.daily-rank-link {
  display: block;
  text-align: center;
  margin: 10px 0 4px;
  padding: 12px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--ghost-button-bg);
  color: var(--page-text);
  text-decoration: none;
  font-weight: 700;
}

.submit-score-button {
  min-width: 220px;
}

.submit-score-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.scores-container {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 460px;
}

.score-container,
.best-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  background: var(--panel-bg);
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  color: var(--title-color);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  padding: 10px 8px 8px;
  position: relative;
  text-align: center;
  box-sizing: border-box;
}

.score-container:after,
.best-container:after {
  position: static;
  width: auto;
  top: auto;
  left: auto;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--panel-label);
}

.score-container:after {
  content: "Score";
}

.best-container:after {
  content: "Best";
}

.best-container.best-beaten {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 10px 28px var(--accent-soft);
}

.pb-status {
  grid-column: 1 / -1;
  min-height: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--accent);
}

.pb-status.pb-hidden {
  visibility: hidden;
  min-height: 0;
  height: 0;
}

.streak-badge {
  margin: 0;
  min-height: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--accent);
}

/* PWA install banner */
.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px var(--surface-shadow);
  color: var(--page-text);
  font-size: 14px;
  font-weight: 600;
}

.install-banner[hidden] {
  display: none;
}

.install-banner span {
  flex: 1;
  min-width: 0;
}

.install-banner button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.install-banner #installDismiss {
  background: transparent;
  color: var(--muted-color);
  border-color: transparent;
  padding: 0 6px;
  font-size: 16px;
}

.game-container {
  background: var(--board-bg);
  border-radius: 28px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.45);
  width: min(92vw, 460px);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 14px;
}

.game-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 460px;
}

.game-actions .restart-button,
.game-actions .game-button {
  flex: 1;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.game-hint {
  margin: 0;
  min-height: 22px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-align: center;
  animation: vynumo-pulse 2s ease-in-out infinite;
}

.game-hint.hint-celebrate {
  animation: none;
  color: var(--button-gradient-start);
}

@keyframes vynumo-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

button {
  font-family: inherit;
}

button:focus-visible,
a:focus-visible,
.theme-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Theme picker bottom sheet */
.theme-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.theme-sheet[hidden] {
  display: none;
}

.theme-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.theme-sheet-panel {
  position: relative;
  width: min(100%, 480px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -20px 60px var(--surface-shadow);
  animation: vynumo-sheet-up 240ms ease-out;
}

@keyframes vynumo-sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.theme-sheet-title {
  margin: 0 0 14px;
  color: var(--title-color);
  font-size: 18px;
}

.theme-sheet-options {
  display: grid;
  gap: 10px;
}

.theme-sheet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--ghost-button-bg);
  color: var(--page-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.theme-sheet-option.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.theme-swatch-midnight {
  background: linear-gradient(135deg, #7c5cff, #3cf2c9);
}

.theme-swatch-graphite {
  background: linear-gradient(135deg, #66a3ff, #8bffb0);
}

.theme-swatch-ember {
  background: linear-gradient(135deg, #ff7a59, #ffd166);
}

.theme-sheet-check {
  margin-left: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--panel-border);
}

.theme-sheet-option.is-active .theme-sheet-check {
  border-color: var(--accent);
  background: var(--accent);
}

.theme-sheet-option.is-active .theme-sheet-check:after {
  content: "";
  display: block;
  width: 8px;
  height: 4px;
  margin: 4px auto 0;
  border-left: 2px solid var(--button-text);
  border-bottom: 2px solid var(--button-text);
  transform: rotate(-45deg);
}

.theme-sheet-close {
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--ghost-button-bg);
  color: var(--page-text);
  font-weight: 700;
  cursor: pointer;
}

body.theme-sheet-open {
  overflow: hidden;
}

/* Below-the-fold sections keep the SEO/marketing content */
.below-fold {
  margin-top: 10px;
}

.theme-section {
  margin-top: 18px;
  padding: 20px;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  box-shadow: 0 20px 60px var(--surface-shadow);
}

.theme-section h2 {
  margin: 0 0 8px;
  color: var(--title-color);
  font-size: 24px;
}

.theme-section-copy {
  color: var(--muted-color);
  margin: 0 0 14px;
}

.hero-card,
.mode-card,
.game-explanation,
.footer-links {
  background: rgba(13, 21, 37, 0.88);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  box-shadow: 0 20px 60px var(--surface-shadow);
  background: var(--surface-bg);
}

.hero-card {
  padding: 24px;
  margin-bottom: 18px;
}

.hero-copy {
  display: grid;
  gap: 6px;
}

.hero-kicker,
.mode-label {
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.18em;
  font-size: 12px;
  font-weight: 700;
}

h1.title {
  float: none;
  color: var(--title-color);
  font-size: 54px;
  letter-spacing: 0.06em;
}

.hero-tagline {
  margin-bottom: 10px;
  font-size: 24px;
  font-weight: 700;
  color: var(--subtitle-color);
}

.hero-subtitle,
.mode-card p,
.leaderboard-hero p {
  color: var(--muted-color);
}

.hero-actions,
.heading .box-game {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.heading .box-game {
  margin-top: 0;
  flex: 1;
}

.box-game {
  width: 100%;
}

.restart-button,
.game-button,
.keep-playing-button,
.retry-button,
.mode-link,
.mode-badge {
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.restart-button,
.keep-playing-button,
.retry-button,
.mode-link {
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  box-shadow: 0 12px 30px var(--button-shadow);
}

.game-button {
  background: var(--ghost-button-bg);
  color: var(--page-text);
}

.hero-actions .restart-button,
.hero-actions .game-button,
.heading .restart-button,
.heading .game-button {
  float: none;
  flex: 1;
}

.theme-tester {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.theme-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--ghost-button-bg);
  color: var(--page-text);
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.theme-chip.is-active {
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  box-shadow: 0 12px 30px var(--button-shadow);
}

.scores-container {
  display: flex;
  gap: 10px;
  float: none;
}

.game-container {
  background: var(--board-bg);
  border-radius: 28px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.45);
  width: min(92vw, 460px);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Mobile-first board geometry: keep main.css's 500px design but scale the
   fixed px internals via CSS custom properties. --board-w (defined on the
   .game-first parent) drives both the container width and the cell size so
   the board stays square and the cells always match the rendered width. */
.game-container {
  --board-pad: 15px;
  --board-gap: 15px;
  --board-cell: calc((var(--board-w) - (var(--board-pad) * 2) - (var(--board-gap) * 3)) / 4);
  --board-step: calc(var(--board-cell) + var(--board-gap));
}

.game-container {
  width: var(--board-w);
  height: var(--board-w);
  padding: var(--board-pad);
  box-sizing: border-box;
}

.game-container .grid-cell {
  width: var(--board-cell);
  height: var(--board-cell);
  margin-right: var(--board-gap);
}

.game-container .grid-row {
  margin-bottom: var(--board-gap);
}

.game-container .grid-row:last-child {
  margin-bottom: 0;
}

.game-container .tile,
.game-container .tile .tile-inner {
  width: var(--board-cell);
  height: var(--board-cell);
  line-height: var(--board-cell);
}

/* Theme-matched tile colors (override legacy beige 2048 palette) */
.game-container .tile .tile-inner {
  border-radius: 8px;
  box-shadow: 0 6px 18px var(--tile-shadow);
  font-size: calc(var(--board-cell) * 0.5);
}

.game-container .tile.tile-2 .tile-inner { background: var(--tile-2-bg); color: var(--tile-2-fg); }
.game-container .tile.tile-4 .tile-inner { background: var(--tile-4-bg); color: var(--tile-4-fg); }
.game-container .tile.tile-8 .tile-inner { background: var(--tile-8-bg); color: var(--tile-8-fg); }
.game-container .tile.tile-16 .tile-inner { background: var(--tile-16-bg); color: var(--tile-16-fg); }
.game-container .tile.tile-32 .tile-inner { background: var(--tile-32-bg); color: var(--tile-32-fg); }
.game-container .tile.tile-64 .tile-inner { background: var(--tile-64-bg); color: var(--tile-64-fg); }
.game-container .tile.tile-128 .tile-inner { background: var(--tile-128-bg); color: var(--tile-128-fg); }
.game-container .tile.tile-256 .tile-inner { background: var(--tile-256-bg); color: var(--tile-256-fg); }
.game-container .tile.tile-512 .tile-inner { background: var(--tile-512-bg); color: var(--tile-512-fg); }
.game-container .tile.tile-1024 .tile-inner { background: var(--tile-1024-bg); color: var(--tile-1024-fg); }
.game-container .tile.tile-2048 .tile-inner { background: var(--tile-2048-bg); color: var(--tile-2048-fg); }
.game-container .tile.tile-super .tile-inner { background: var(--tile-super-bg); color: var(--tile-super-fg); }

.game-container .tile.tile-position-1-2,
.game-container .tile.tile-position-2-2,
.game-container .tile.tile-position-3-2,
.game-container .tile.tile-position-4-2 {
  -webkit-transform: translate(0px, var(--board-step));
  -moz-transform: translate(0px, var(--board-step));
  -ms-transform: translate(0px, var(--board-step));
  transform: translate(0px, var(--board-step));
}

.game-container .tile.tile-position-1-3,
.game-container .tile.tile-position-2-3,
.game-container .tile.tile-position-3-3,
.game-container .tile.tile-position-4-3 {
  -webkit-transform: translate(0px, calc(var(--board-step) * 2));
  -moz-transform: translate(0px, calc(var(--board-step) * 2));
  -ms-transform: translate(0px, calc(var(--board-step) * 2));
  transform: translate(0px, calc(var(--board-step) * 2));
}

.game-container .tile.tile-position-1-4,
.game-container .tile.tile-position-2-4,
.game-container .tile.tile-position-3-4,
.game-container .tile.tile-position-4-4 {
  -webkit-transform: translate(0px, calc(var(--board-step) * 3));
  -moz-transform: translate(0px, calc(var(--board-step) * 3));
  -ms-transform: translate(0px, calc(var(--board-step) * 3));
  transform: translate(0px, calc(var(--board-step) * 3));
}

.game-container .tile.tile-position-2-1,
.game-container .tile.tile-position-2-2,
.game-container .tile.tile-position-2-3,
.game-container .tile.tile-position-2-4 {
  -webkit-transform: translate(var(--board-step), 0px);
  -moz-transform: translate(var(--board-step), 0px);
  -ms-transform: translate(var(--board-step), 0px);
  transform: translate(var(--board-step), 0px);
}

.game-container .tile.tile-position-3-1,
.game-container .tile.tile-position-3-2,
.game-container .tile.tile-position-3-3,
.game-container .tile.tile-position-3-4 {
  -webkit-transform: translate(calc(var(--board-step) * 2), 0px);
  -moz-transform: translate(calc(var(--board-step) * 2), 0px);
  -ms-transform: translate(calc(var(--board-step) * 2), 0px);
  transform: translate(calc(var(--board-step) * 2), 0px);
}

.game-container .tile.tile-position-4-1,
.game-container .tile.tile-position-4-2,
.game-container .tile.tile-position-4-3,
.game-container .tile.tile-position-4-4 {
  -webkit-transform: translate(calc(var(--board-step) * 3), 0px);
  -moz-transform: translate(calc(var(--board-step) * 3), 0px);
  -ms-transform: translate(calc(var(--board-step) * 3), 0px);
  transform: translate(calc(var(--board-step) * 3), 0px);
}

.game-container .tile.tile-position-2-2 {
  -webkit-transform: translate(var(--board-step), var(--board-step));
  -moz-transform: translate(var(--board-step), var(--board-step));
  -ms-transform: translate(var(--board-step), var(--board-step));
  transform: translate(var(--board-step), var(--board-step));
}

.game-container .tile.tile-position-2-3 {
  -webkit-transform: translate(var(--board-step), calc(var(--board-step) * 2));
  -moz-transform: translate(var(--board-step), calc(var(--board-step) * 2));
  -ms-transform: translate(var(--board-step), calc(var(--board-step) * 2));
  transform: translate(var(--board-step), calc(var(--board-step) * 2));
}

.game-container .tile.tile-position-2-4 {
  -webkit-transform: translate(var(--board-step), calc(var(--board-step) * 3));
  -moz-transform: translate(var(--board-step), calc(var(--board-step) * 3));
  -ms-transform: translate(var(--board-step), calc(var(--board-step) * 3));
  transform: translate(var(--board-step), calc(var(--board-step) * 3));
}

.game-container .tile.tile-position-3-2 {
  -webkit-transform: translate(calc(var(--board-step) * 2), var(--board-step));
  -moz-transform: translate(calc(var(--board-step) * 2), var(--board-step));
  -ms-transform: translate(calc(var(--board-step) * 2), var(--board-step));
  transform: translate(calc(var(--board-step) * 2), var(--board-step));
}

.game-container .tile.tile-position-3-3 {
  -webkit-transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 2));
  -moz-transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 2));
  -ms-transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 2));
  transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 2));
}

.game-container .tile.tile-position-3-4 {
  -webkit-transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 3));
  -moz-transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 3));
  -ms-transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 3));
  transform: translate(calc(var(--board-step) * 2), calc(var(--board-step) * 3));
}

.game-container .tile.tile-position-4-2 {
  -webkit-transform: translate(calc(var(--board-step) * 3), var(--board-step));
  -moz-transform: translate(calc(var(--board-step) * 3), var(--board-step));
  -ms-transform: translate(calc(var(--board-step) * 3), var(--board-step));
  transform: translate(calc(var(--board-step) * 3), var(--board-step));
}

.game-container .tile.tile-position-4-3 {
  -webkit-transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 2));
  -moz-transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 2));
  -ms-transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 2));
  transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 2));
}

.game-container .tile.tile-position-4-4 {
  -webkit-transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 3));
  -moz-transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 3));
  -ms-transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 3));
  transform: translate(calc(var(--board-step) * 3), calc(var(--board-step) * 3));
}

@media screen and (max-width: 520px) {
  .game-container .tile .tile-inner {
    font-size: calc(var(--board-cell) * 0.45);
  }
}

.grid-cell {
  background: var(--grid-cell-bg);
}

.game-message {
  background: var(--overlay-bg);
}

.game-message p {
  color: var(--title-color);
}

/* Game Over / You Win overlay */
.game-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  padding: 14px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* Force the overlay to sit exactly over the 4x4 board with a dark, mostly
   opaque background. The legacy main.css uses a LIGHTER, translucent
   background (.game-container .game-message → rgba(238,228,218,0.5)) with
   higher specificity, which washes the summary out — override it here. */
.game-container .game-message {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--overlay-bg);
  border-radius: inherit;
}

/* Override legacy 2048 styles (main.css) that push the overlay content
   far below the board: .game-message p gets margin-top:222px, height:60px,
   font-size:60px, line-height:60px and .lower margin-top:59px, shoving the
   buttons off-screen. Must match/exceed the legacy specificity
   (.game-container .game-message p / .lower). */
.game-container .game-message p {
  margin-top: 0;
  height: auto;
  line-height: normal;
}

/* Restore the phase-1 typography on the overlay elements (the legacy
   font-size:60px would otherwise win over .game-message .game-message-*). */
.game-container .game-message .game-message-title {
  font-size: 28px;
}

.game-container .game-message .game-message-score {
  font-size: 38px;
}

.game-container .game-message .game-message-pb {
  font-size: 12px;
}

.game-container .game-message .game-message-tile {
  font-size: 12px;
}

.game-container .game-message .game-message-next {
  font-size: 13px;
}

.game-container .game-message .game-message-summary {
  margin: 0 0 8px;
}

.game-container .game-message .lower {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  width: 100%;
}

.game-container .game-message .lower a {
  margin-left: 0;
}

.game-message .game-message-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.game-message .game-message-score {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 4px;
  color: var(--accent);
}

.game-message .game-message-pb {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
  color: var(--accent);
  min-height: 16px;
}

.game-message .game-message-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.game-message .game-summary-item {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-align: left;
}

.game-message .game-summary-item span,
.game-message .game-summary-item em {
  margin: 0;
  font-style: normal;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--page-text);
  opacity: 0.85;
}

.game-message .game-summary-item strong {
  font-size: 15px;
  line-height: 1.1;
  color: var(--title-color);
}

.game-message .lower button,
.game-message .game-message-rank {
  min-height: 38px;
  min-width: 170px;
  width: auto;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-sizing: border-box;
}

.game-message .lower .retry-button {
  width: 100%;
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  border: none;
  box-shadow: 0 12px 30px var(--button-shadow);
}

.game-message .lower .keep-playing-button {
  width: 100%;
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  border: none;
  box-shadow: 0 12px 30px var(--button-shadow);
}

.game-message .game-message-secondary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.game-message .game-message-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ghost-button-bg);
  color: var(--page-text);
  border: 1px solid var(--surface-border);
  text-decoration: none;
  min-width: 0;
  padding: 0 10px;
  font-size: 13px;
}

.game-message.game-won {
  background: var(--overlay-bg);
}

/* PHASE 3 — post-game retention: NEW TILE badge, challenge/share, countdown */
.game-message .game-message-tile {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: -4px 0 10px;
}

.game-message .lower .challenge-button,
.game-message .lower .share-button {
  background: var(--ghost-button-bg);
  color: var(--page-text);
  border: 1px solid var(--surface-border);
  min-width: 0;
  width: 100%;
  padding: 0 12px;
}

.game-message .lower .challenge-button {
  border-color: var(--accent);
  color: var(--accent);
}

.game-message .game-message-next {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted-color);
  margin: 4px 0 0;
}

/* Toast (share feedback) */
.vynumo-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  background: var(--panel-bg);
  color: var(--page-text);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 400;
  max-width: min(90vw, 420px);
  text-align: center;
}

.vynumo-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Leaderboard: my rank + highlight */
.leaderboard-myrank {
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 12px;
}

.daily-leaderboard tr.is-me td {
  background: var(--accent-soft);
  color: var(--title-color);
  font-weight: 700;
}

.mode-preview {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.progression-card,
.milestones-card {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.progression-empty,
.milestones-empty {
  display: grid;
  gap: 6px;
  padding: 22px 18px;
  border: 1px dashed var(--surface-border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
}

.progression-empty-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--title-color);
}

.progression-empty-copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted-color);
}

.progression-heading {
  display: grid;
  gap: 6px;
}

.progression-heading h2 {
  margin: 0;
  color: var(--title-color);
  font-size: 24px;
}

.progression-highlight {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
}

.progression-hero,
.progression-next,
.progression-stat,
.milestone-chip {
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
}

.progression-hero,
.progression-next {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.progression-hero span,
.progression-next span,
.progression-stat span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-color);
}

.progression-hero strong,
.progression-next strong {
  font-size: 36px;
  line-height: 1;
  color: var(--title-color);
}

.progression-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.progression-stat {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.progression-stat strong {
  font-size: 18px;
  color: var(--title-color);
}

.milestones-callout {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.milestones-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.milestone-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  font-weight: 800;
  color: var(--muted-color);
}

.milestone-chip.is-unlocked {
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  border-color: transparent;
  box-shadow: 0 12px 30px var(--button-shadow);
}

.mode-card {
  padding: 20px;
}

.mode-card h2 {
  margin: 0 0 10px;
  color: var(--title-color);
  font-size: 24px;
}

.mode-link {
  display: inline-block;
  padding: 12px 18px;
}

.mode-badge {
  display: inline-block;
  padding: 10px 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.game-explanation,
.footer-links {
  margin-top: 18px;
  padding: 18px 20px;
}

/* Leaderboard empty state */
.leaderboard-empty {
  display: none;
  text-align: center;
  padding: 40px 20px;
}

.leaderboard-empty.is-visible {
  display: block;
}

.leaderboard-empty .leaderboard-empty-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--title-color);
}

.leaderboard-empty p {
  color: var(--muted-color);
  margin: 0 0 18px;
}

.leaderboard-empty .restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  text-decoration: none;
}

/* Leaderboard page: primary actions need 44px+ touch targets */
.leaderboard-hero + .box-game .restart-button,
.leaderboard .box-game .restart-button,
.box-game .restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  text-decoration: none;
}

/* Leaderboard tabs (Classic / Daily) */
.leaderboard-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.leaderboard-tab {
  flex: 1;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--ghost-button-bg);
  color: var(--muted-color);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 13px;
  cursor: pointer;
}

.leaderboard-tab.is-active {
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  border-color: transparent;
  box-shadow: 0 12px 30px var(--button-shadow);
}

/* Classic range sub-tabs (Today / 7 Days / All-Time) */
.range-tabs {
  display: flex;
  gap: 6px;
  margin: 4px 0 2px;
}

.range-tab {
  flex: 1;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--ghost-button-bg);
  color: var(--muted-color);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 11px;
  cursor: pointer;
  padding: 0 10px;
}

.range-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Daily leaderboard table */
.daily-leaderboard {
  margin-top: 18px;
  padding: 18px 20px;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  box-shadow: 0 20px 60px var(--surface-shadow);
}

#dailyTable {
  width: 100%;
  border-collapse: collapse;
}

#dailyTable th,
#dailyTable td {
  padding: 10px 8px;
  text-align: left;
  color: var(--page-text);
  border-bottom: 1px solid var(--panel-border);
}

#dailyTable th {
  color: var(--panel-label);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#dailyTable td:first-child,
#dailyTable th:first-child {
  width: 48px;
}

#dailyTable tr:last-child td {
  border-bottom: none;
}

.footer-links {
  color: var(--panel-label);
  text-align: center;
}

.leaderboard-hero {
  margin-bottom: 16px;
}

#yourName,
h1,
h2,
h3 {
  color: var(--title-color);
}

table.dataTable thead th,
table.dataTable thead td,
table.dataTable tbody th,
table.dataTable tbody td {
  color: var(--page-text);
}

table.dataTable.stripe tbody tr.odd,
table.dataTable.display tbody tr.odd,
table.dataTable.hover tbody tr:hover,
table.dataTable.display tbody tr:hover {
  background-color: var(--table-row-bg);
}

input,
select {
  background: var(--input-bg);
  color: var(--page-text);
  border: 1px solid var(--panel-border);
}

@media screen and (min-width: 768px) {
  .mode-preview {
    grid-template-columns: 1fr 1fr;
  }

  .game-container {
    width: min(92vw, 460px);
  }
}

/* Landscape / short screens: keep the board fully visible */
@media screen and (max-height: 700px) and (orientation: landscape) {
  .container.game-first {
    gap: 8px;
  }

  .header-logo {
    width: 36px;
    height: 36px;
  }

  .score-container,
  .best-container {
    min-height: 48px;
    font-size: 22px;
  }

  .game-actions .restart-button,
  .game-actions .game-button {
    min-height: 44px;
  }

  /* Compact overlay so all buttons fit the board height (~400px). */
  .game-message {
    padding: 14px;
  }

  .game-container .game-message .game-message-title {
    font-size: 28px;
    margin-bottom: 8px;
  }

  .game-container .game-message .game-message-score {
    font-size: 42px;
    margin-bottom: 6px;
  }

  .game-container .game-message .game-message-pb {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .game-container .game-message .game-message-tile {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .game-container .game-message .lower {
    gap: 8px;
  }

  .game-container .game-message .lower button,
  .game-container .game-message .game-message-rank {
    min-height: 40px;
    font-size: 13px;
  }

  .game-message .game-summary-item strong {
    font-size: 17px;
  }
}

/* Very small portrait screens (e.g. 320x568): compact everything */
@media screen and (max-width: 380px) and (max-height: 620px) {
  .container.game-first {
    gap: 6px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  }

  .header-logo {
    width: 34px;
    height: 34px;
  }

  .header-title {
    font-size: 18px;
  }

  .mode-pill {
    padding: 5px 10px;
    font-size: 11px;
  }

  .score-container,
  .best-container {
    min-height: 44px;
    font-size: 20px;
  }

  .container.game-first {
    --board-w: min(92vw, 400px);
  }

  .game-actions .restart-button,
  .game-actions .game-button {
    min-height: 46px;
  }
  .game-hint {
    min-height: 16px;
    font-size: 12px;
  }

  .pb-status {
    min-height: 16px;
    font-size: 12px;
  }
}

@media screen and (max-width: 520px) {
  body {
    padding: 0;
  }

  /* Tighter overlay padding so the post-game summary fits the board. */
  .game-message {
    padding: 12px;
  }

  .game-message .game-message-title {
    font-size: 20px !important;
    line-height: 1.1 !important;
    margin: 0 0 4px !important;
    height: auto !important;
  }

  .game-message .game-message-score {
    font-size: 30px !important;
    line-height: 1.1 !important;
    margin: 0 0 2px !important;
    height: auto !important;
  }

  .game-message .game-message-pb {
    font-size: 11px !important;
    margin: 0 0 6px !important;
    height: auto !important;
    line-height: 1.2 !important;
  }

  .game-message .lower {
    margin-top: 0 !important;
    gap: 6px !important;
  }

  .game-message .lower button,
  .game-message .game-message-rank {
    min-height: 36px !important;
    min-width: 0 !important;
    font-size: 12px !important;
  }

  .game-message .game-message-tile {
    font-size: 11px !important;
    margin: 0 0 2px !important;
    line-height: 1.2;
  }

  .game-message .game-message-next {
    font-size: 11px !important;
  }

  /* On small phones hide PREVIOUS RUN / IMPROVEMENT (SCORE and PERSONAL BEST
     are already shown large above the grid) so the summary fits the board. */
  .game-message .game-summary-item.summary-item-optional {
    display: none;
  }

  .game-message .game-message-summary,
  .progression-highlight,
  .progression-stats,
  .milestones-grid {
    grid-template-columns: 1fr;
  }

  /* Phones: keep the summary in a compact 2-column grid (3 rows of 2) and the
     secondary CTAs side by side in one row so the whole overlay fits inside
     the 4x4 board without scrolling. */
  .game-message .game-message-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .game-message .game-message-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .game-message .game-summary-item {
    padding: 5px 8px;
    border-radius: 10px;
    gap: 2px;
  }

  .game-message .game-summary-item span,
  .game-message .game-summary-item em {
    font-size: 9px;
    letter-spacing: 0.08em;
  }

  .game-message .game-summary-item strong {
    font-size: 14px;
  }

  .game-message .game-message-secondary .challenge-button,
  .game-message .game-message-secondary .share-button,
  .game-message .game-message-rank {
    padding: 0 4px;
    font-size: 10px !important;
    min-height: 34px !important;
    letter-spacing: 0.02em;
  }

  .container {
    width: min(100%, 420px);
    max-width: 100%;
    box-sizing: border-box;
    padding: 18px 6px 42px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 42px);
  }

  h1.title {
    font-size: 34px;
    margin-top: 0;
  }

  .hero-tagline {
    font-size: 20px;
  }

  .hero-actions,
  .heading,
  .heading .box-game {
    display: grid;
  }

  .hero-actions,
  .heading .box-game,
  .theme-tester {
    grid-template-columns: 1fr;
  }

  .scores-container {
    justify-content: flex-start;
    width: 100%;
    flex-wrap: wrap;
  }

  .score-container,
  .best-container {
    flex: 1;
    min-width: 0;
  }

  .game-container {
    margin-top: 12px;
  }

  .theme-chip,
  .hero-actions .restart-button,
  .hero-actions .game-button,
  .heading .restart-button,
  .heading .game-button {
    width: 100%;
    box-sizing: border-box;
  }

  .game-explanation,
  .footer-links,
  .hero-card,
  .mode-card {
    padding: 16px;
  }

  .game-explanation,
  .footer-links,
  .hero-card,
  .mode-card {
    border-radius: 18px;
  }
}

/* Desktop: breathing room and a slightly smaller board */
@media screen and (min-width: 1024px) {
  .container.game-first {
    gap: 8px;
    padding-top: 14px;
    padding-bottom: 72px;
  }

  .game-container {
    width: var(--board-w);
  }

  /* Desktop board is 400px (same as a large phone), so the 6-cell summary
     does not fit without scrolling — show the core 4 cells instead. */
  .game-message .game-summary-item.summary-item-optional {
    display: none;
  }

  .game-header,
  .scores-container,
  .game-actions {
    max-width: 400px;
  }

  .game-header {
    gap: 8px;
  }

  .header-logo {
    width: 38px;
    height: 38px;
  }

  .header-title {
    font-size: 20px;
  }

  .score-container,
  .best-container {
    min-height: 46px;
    font-size: 22px;
  }

  .mode-pill {
    padding: 6px 12px;
  }

  .game-hint {
    min-height: 18px;
    font-size: 13px;
  }

  .game-actions .restart-button,
  .game-actions .game-button {
    min-height: 48px;
  }
}

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

/* ============================================================
   Shared Vynumo UI shell (consistency redesign)
   ============================================================ */

/* CTA hierarchy under the board: one strong primary + ghost secondary. */
.game-actions .restart-button {
  flex: 1.6;
}

.game-actions .game-button {
  flex: 0.9;
}

.game-actions .restart-button {
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  border: none;
  box-shadow: 0 12px 30px var(--button-shadow);
}

.game-actions .game-button {
  background: var(--ghost-button-bg);
  border: 1px solid var(--surface-border);
  text-decoration: none;
}

.game-actions .game-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Leaderboard redesign: strong single hero + podium + empty state */
.rank-hero {
  width: 100%;
  max-width: 460px;
  padding: 22px 0 14px;
  margin-bottom: 10px;
  text-align: center;
  border-bottom: 1px solid var(--surface-border);
}

.rank-title {
  margin: 0 0 6px;
  color: var(--title-color);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.rank-subtitle {
  margin: 0;
  color: var(--muted-color);
  font-size: 14px;
}

.rank-hero .leaderboard-myrank {
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}

/* Podium (top 3) */
.rank-podium {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.podium-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
}

.podium-item:nth-child(1) {
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-soft);
}

.podium-item:nth-child(2) {
  border-color: rgba(255, 255, 255, 0.18);
}

.podium-item:nth-child(3) {
  border-color: rgba(255, 255, 255, 0.10);
}

.podium-item.is-me {
  outline: 2px solid var(--accent);
}

.podium-medal {
  font-size: 22px;
  flex: 0 0 auto;
}

.podium-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  color: var(--title-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-score {
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Empty state — gaming, not an empty table */
.leaderboard-empty {
  display: none;
  text-align: center;
  padding: 40px 20px;
  border-radius: 20px;
  background: var(--surface-bg);
  border: 1px dashed var(--surface-border);
  margin-top: 10px;
}

.leaderboard-empty.is-visible {
  display: block;
}

.leaderboard-empty-title {
  margin: 0 0 8px;
  color: var(--title-color);
  font-size: 22px;
  font-weight: 800;
}

.leaderboard-empty p {
  color: var(--muted-color);
  margin: 0 0 18px;
  font-size: 15px;
}

.leaderboard-empty .restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  float: none;
  width: max-content;
  margin: 0 auto;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 999px;
  text-decoration: none;
  background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
  color: var(--button-text);
  border: none;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
  box-shadow: 0 12px 30px var(--button-shadow);
}

/* Mobile: keep "SET THE FIRST SCORE" on one line */
@media screen and (max-width: 520px) {
  .leaderboard-empty .restart-button {
    padding: 0 16px;
    font-size: 13px;
    letter-spacing: 0.04em;
    min-height: 44px;
  }
}

/* Mobile: podium rows compact */
@media screen and (max-width: 520px) {
  .podium-item {
    padding: 8px 12px;
  }

  .podium-medal {
    font-size: 18px;
  }

  .rank-title {
    font-size: 26px;
  }
}

/* Header nav: PLAY / RANK links (Rank + Legal pages) */
.header-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  min-height: 32px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--page-text);
  border: 1px solid var(--surface-border);
  background: var(--ghost-button-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-link-active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Page intensity levels */
body[data-page="rank"] .game-header,
body[data-page="legal"] .game-header {
  max-width: 400px;
}

body[data-page="legal"] {
  /* Calmer reading experience: no glow, quieter background */
}

/* Legal layout (Privacy / Terms) */
.legal-page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.legal-hero {
  padding: 28px 0 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--surface-border);
}

.legal-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.legal-title {
  margin: 0 0 8px;
  color: var(--title-color);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.legal-updated {
  margin: 0;
  color: var(--muted-color);
  font-size: 14px;
}

.legal-summary {
  margin: 14px 0 0;
  color: var(--page-text);
  font-size: 16px;
  line-height: 1.6;
}

.legal-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--page-text);
}

.legal-body p {
  margin: 0 0 16px;
}

.legal-body h2 {
  margin: 28px 0 12px;
  color: var(--title-color);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding-top: 8px;
  border-top: 1px solid var(--surface-border);
}

.legal-body h3 {
  margin: 22px 0 8px;
  color: var(--title-color);
  font-size: 17px;
  font-weight: 700;
}

.legal-body h4 {
  margin: 18px 0 6px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}

.legal-body ul,
.legal-body ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.legal-body li {
  margin: 4px 0;
}

.legal-body a {
  color: var(--accent);
}

.legal-body strong {
  color: var(--title-color);
}

/* Legal footer — same links footer, quiet */
body[data-page="legal"] .footer-links {
  margin-top: 40px;
}

/* Legal table of contents */
.legal-toc {
  margin: 0 0 24px;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
}

.legal-toc-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.legal-toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-toc li {
  margin: 4px 0;
}

.legal-toc a {
  color: var(--page-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.legal-toc a:hover {
  color: var(--accent);
}

/* Footer consistency */
.footer-links a {
  text-decoration: none;
  color: var(--link-color);
}

.footer-links a:hover {
  color: var(--accent);
}

/* Mobile: nav shrinks on very narrow screens */
@media screen and (max-width: 380px) {
  .nav-link {
    padding: 4px 10px;
    font-size: 10px;
  }

  /* Very narrow phones (≤380px): tighten the post-game overlay further so it
     fits the smaller board. The ≤520px block already compacts the summary;
     here we only shrink the header type. */
  .game-message .game-message-title {
    font-size: 18px !important;
    margin-bottom: 2px !important;
  }

  .game-message .game-message-score {
    font-size: 26px !important;
  }

  .game-message .game-message-pb {
    margin-bottom: 4px !important;
    min-height: 0 !important;
  }

  .game-message .lower button,
  .game-message .game-message-rank {
    min-height: 34px !important;
  }

  .game-message .lower {
    gap: 5px !important;
  }
}

/* Narrow screens (≤400px): hide the wordmark so header fits without
   horizontal overflow (logo + mode pills / nav stay). */
@media screen and (max-width: 400px) {
  .game-header .header-title {
    display: none;
  }

  .header-modes .mode-pill {
    padding: 4px 8px;
    font-size: 10px;
    letter-spacing: 0.08em;
  }
}
