/* ==========================================================================
   2048 ROGUE — Obsidian & Warm Paper Style System
   Approved design mock fidelity (design/index_updated.html)
   Strict Design Tokens • Pure Vanilla CSS • Zero external network requests
   ========================================================================== */

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-display: block;
  font-weight: 100 900;
  src: url('fonts/outfit-latin-variable.woff2') format('woff2-variations'),
       url('fonts/outfit-latin-variable.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Font Stack Token */
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Color Tokens */
  --bg: #100f11;
  --shell: #191719;
  --panel: #242123;
  --panel2: #2c282a;
  --line: #40393b;
  --text: #f5eee5;
  --muted: #b5a9a0;
  --soft: #ddd0c3;
  --accent: #f2c77e;
  --accentInk: #2b1d0d;
  --warn: #f27d70;
  --board: #141315;
  --well: #211f20;
  --wellLine: #393336;

  /* Mock tile ramp tokens verbatim */
  --t2: #343336;
  --t4: #4b4949;
  --t8: #696867;
  --t16: #8e8c86;
  --t32: #b8b3a7;
  --t64: #e4ded0;
  --t128: #f1d7a4;
  --t256: #e9c17c;
  --t512: #dba65f;
  --t1024: #e6c7a8;
  --t2048: #f5e4bf;
  --t4096: #fff3d8;

  /* Targeting Ring Tokens */
  --ring-light: #ffffff;
  --ring-dark: #141315;
  --ring-glow: rgba(255, 255, 255, 0.7);

  /* Geometry & Layout Tokens */
  --header-height: 154px;
  --cell-gap: 6px;
  --board-gap: 6px;
  --board-pad: 7px;
  --page-pad: 15px;
  --col-w: min(calc(100vw - 2 * var(--page-pad)), calc(100dvh - 336px), 400px);

  /* Rewind Shimmer Token */
  --rewind-shimmer: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.15) 50%, transparent 100%);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, #332823 0%, var(--bg) 62%);
  color: var(--text);
  font-family: var(--font);
  font-synthesis: none;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: var(--font);
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Ensure board, tiles-layer, tiles, stones, and cells have no outline and are not tap-highlighted */
.board, .game-board, #game-board, #tiles-layer, .tile, .stone, .cell, .grid-cell {
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

/* Allow selection only on log export/textarea */
.run-log-text, textarea, input {
  user-select: text;
  -webkit-user-select: text;
}

/* Tabular numerals for stable widths */
.stat, .stat-card, .stat-value, .tile, .tile-face, #stone-countdown, #stat-score, #end-score, .end-score, .end-stat-value, .stat-num {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Full Viewport Mobile Shell Layout (100dvh)
   ========================================================================== */
.app-container {
  width: 100%;
  max-width: 430px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--shell);
  padding: 0 15px max(12px, env(safe-area-inset-bottom, 12px));
  box-sizing: border-box;
}

@media (max-width: 359px) {
  :root {
    --page-pad: 9px;
  }
  .app-container {
    padding-left: 9px;
    padding-right: 9px;
  }
}

/* ==========================================================================
   Three-Row Fixed Header (Constant Height Invariant)
   ========================================================================== */
.header, .game-header {
  width: 100%;
  max-width: calc(100vw - 2 * var(--page-pad));
  margin-left: auto;
  margin-right: auto;
  flex: none;
  padding-top: 23px;
  padding-bottom: 6px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

@media (max-width: 359px) {
  .header, .game-header {
    padding-top: 15px;
    padding-bottom: 6px;
  }
}

/* Row 1: Brand + Passives + Menu */
.headrow, .title-row {
  height: 31px;
  min-height: 31px;
  max-height: 31px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.brand, .game-title {
  font-weight: 900;
  font-size: clamp(18px, 5.6vw, 24px);
  letter-spacing: .1em;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text);
  line-height: 1;
}

.brand b {
  color: var(--accent);
}

.right {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex-shrink: 0;
}

/* Passive Relic Strip */
.passives, .passive-relics-container {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  flex-shrink: 0;
}

@media (max-width: 359px) {
  .passives, .passive-relics-container {
    gap: 3px;
  }
}

.relic-mini, .relic-passive-item {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  padding: 2px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #3b302b;
  border: 1px solid #6a5343;
  font-size: 9px;
  font-weight: 900;
  color: #fff1df;
  position: relative;
  overflow: visible;
  box-sizing: border-box;
}

/* Invisible hit-area padding >= 36px (26px + 2*5px = 36px) */
.relic-mini::before, .relic-passive-item::before {
  content: "";
  position: absolute;
  inset: -5px;
  pointer-events: auto;
}

/* Per-icon normalization variables computed from alpha bbox (scripts/icon_metrics.js) */
[data-relic="diagonal_charge"], [data-relic="diagonal_merge"] { --icon-scale: 0.88; --icon-x: 0.1%; --icon-y: 0.1%; }
[data-relic="eraser"] { --icon-scale: 1.048; --icon-x: 0.1%; --icon-y: 4.3%; }
[data-relic="fault_line"], [data-relic="fault"] { --icon-scale: 0.88; --icon-x: 0.1%; --icon-y: 0.1%; }
[data-relic="last_stand"], [data-relic="last"] { --icon-scale: 0.88; --icon-x: 0.2%; --icon-y: 0.1%; }
[data-relic="mason"] { --icon-scale: 0.88; --icon-x: 0.1%; --icon-y: 0.1%; }
[data-relic="rewind"], [data-relic="undo"] { --icon-scale: 1.186; --icon-x: 0.1%; --icon-y: 0.1%; }
[data-relic="shatter"] { --icon-scale: 1.453; --icon-x: 0.1%; --icon-y: 0.1%; }
[data-relic="siphon"] { --icon-scale: 0.88; --icon-x: 0.1%; --icon-y: 0.1%; }

.relic-svg, .relic-icon-img {
  display: block;
  width: 94%;
  height: 94%;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 1px 2px rgba(242, 199, 126, .16));
  pointer-events: none;
  margin: auto;
  transform: translate(var(--icon-x, 0%), var(--icon-y, 0%)) scale(var(--icon-scale, 1));
  transform-origin: center center;
}

.relic-monogram {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 950;
  color: #fff1df;
}

/* Menu Button: 32px visible, >= 36px hit-area */
.menu, #btn-pause-menu {
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  font-size: 17px;
  display: grid;
  place-items: center;
  color: var(--soft);
  position: relative;
}

.menu::before, #btn-pause-menu::before {
  content: "";
  position: absolute;
  inset: -3px;
  pointer-events: auto;
}

/* Row 2: Hazard Telegraph */
.telegraph, .hazard-row {
  width: var(--col-w);
  margin-left: auto;
  margin-right: auto;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  margin-top: 6px;
  border: 1px solid #493b36;
  background: #241e1d;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  overflow: hidden;
  box-sizing: border-box;
  flex-shrink: 0;
}

.telegraph-part {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 100%;
}

.telegraph-stone {
  flex: 1 1 auto;
  gap: 7px;
  cursor: pointer;
}

.telegraph-relic {
  flex: 0 0 auto;
  gap: 5px;
  padding-left: 8px;
  border-left: 1px solid #493b36;
  color: var(--accent);
}

.telegraph-relic.hidden {
  display: none !important;
}

.relic-cue-star {
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.relic-status {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--accent);
}

.relic-status strong, #relic-countdown {
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.haz {
  color: var(--warn);
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.haztext, .hazard-status {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  color: var(--text);
}

.haztext strong, #stone-countdown {
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.track {
  width: 42px;
  height: 4px;
  background: #554642;
  border-radius: 9px;
  overflow: hidden;
  flex: none;
}

.fill {
  height: 100%;
  width: 40%;
  background: var(--accent);
}

.telegraph.warning, .hazard-row.warning, .hazard-row.imminent {
  border-color: #9d5147;
  background: #352220;
}

.telegraph.warning .haz, .hazard-row.warning .haz, .hazard-row.imminent .haz {
  color: var(--warn);
  background: var(--warn);
}

.telegraph.warning .fill, .hazard-row.warning .fill, .hazard-row.imminent .fill {
  background: var(--warn);
}

/* Row 3: Stats */
.stats, .stats-row {
  width: var(--col-w);
  margin-left: auto;
  margin-right: auto;
  display: grid;
  grid-template-columns: 1.45fr .78fr .95fr;
  gap: 7px;
  margin-top: 8px;
  box-sizing: border-box;
  flex-shrink: 0;
}

@media (max-width: 359px) {
  .stats, .stats-row {
    gap: 4px;
  }
}

.stat, .stat-card {
  height: 56px;
  background: var(--panel);
  border: 1px solid #3c3437;
  border-radius: 10px;
  padding: 7px 9px;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 359px) {
  .stat, .stat-card {
    padding: 7px 6px;
  }
}

.stat label, .stat-label {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.1;
}

.value, .stat-value {
  font-size: 20px;
  line-height: 1.35;
  font-weight: 900;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.score .value, .score-card .stat-value {
  font-size: 22px;
  color: var(--accent);
}

.stat.small .value, .moves-card .stat-value, .tile-card .stat-value {
  font-size: 18px;
}

@media (max-width: 359px) {
  .value, .stat-value {
    font-size: 18px;
  }
  .score .value, .score-card .stat-value {
    font-size: 20px;
  }
}

/* ==========================================================================
   Game Space & 4x4 Board
   ========================================================================== */
.game-space {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 9px;
  padding: 12px 0 5px;
}

#stuck-banner, .stuck, .stuck-banner {
  display: none !important;
}

.boardwrap, .board-wrapper {
  width: var(--col-w);
  height: var(--col-w);
  aspect-ratio: 1;
  max-height: 100%;
  position: relative;
  flex: none;
  margin: 0 auto;
  perspective: 900px;
  perspective-origin: 50% 50%;
}

.board, .game-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 7px;
  background: var(--board);
  border: 1px solid #3c3336;
  border-radius: 17px;
  touch-action: none;
  box-sizing: border-box;
  position: relative;
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

.board.is-stuck {
  box-shadow: inset 0 0 0 1.5px #f27d70;
  border-color: #f27d70;
}

.board.is-stuck.targeting-dim,
.board.is-stuck.is-targeting {
  box-shadow: inset 0 0 0 1.5px #f27d7080;
  border-color: #f27d7080;
}

.board.is-stuck.brighten {
  box-shadow: inset 0 0 0 1.5px #ff9e93, 0 0 12px #f27d70aa;
  border-color: #ff9e93;
}

.stuck-impact-wave {
  position: absolute;
  inset: -1.5px;
  border-radius: 17px;
  border: 1.5px solid #f27d70;
  pointer-events: none;
  z-index: 25;
  animation: stuckWaveOut 450ms cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}

@keyframes stuckWaveOut {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.035);
    opacity: 0;
  }
}


.stone-impact-ring {
  position: absolute;
  border-radius: 9px;
  border: 2px solid #5b5052;
  box-shadow: 0 0 10px #282426;
  pointer-events: none;
  z-index: 20;
  animation: stoneRingPulse 280ms cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}

@keyframes stoneRingPulse {
  0% { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(1.4); opacity: 0; }
}

.stone-dust-speck {
  position: absolute;
  border-radius: 50%;
  background: #5b5052;
  pointer-events: none;
  z-index: 21;
}

/* Siphon feedback cues - Icon glow only (T4) */
@keyframes siphonGlowFade {
  0% {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(242, 199, 126, 0.65), inset 0 0 4px rgba(242, 199, 126, 0.35);
  }
  66.7% {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(242, 199, 126, 0.65), inset 0 0 4px rgba(242, 199, 126, 0.35);
  }
  100% {
    border-color: #6a5343;
    box-shadow: none;
  }
}

.relic-mini.siphon-glow {
  animation: siphonGlowFade 750ms ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  .relic-mini.siphon-glow {
    animation: none;
  }
}

@media (max-width: 359px) {
  .board, .game-board {
    gap: 4px;
    padding: 5px;
  }
}

.cell, .grid-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--well);
  border: 1px solid var(--wellLine);
  border-radius: 9px;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-sizing: border-box;
}

@media (max-width: 359px) {
  .cell, .grid-cell {
    border-radius: 7px;
  }
}

/* Tiles Layer positioning: positioned over grid, z-index 10 */
.tiles-layer {
  position: absolute;
  inset: var(--board-pad, 7px);
  pointer-events: none;
  overflow: visible;
  display: block;
  z-index: 10;
  transform-style: preserve-3d;
}

@media (max-width: 359px) {
  .tiles-layer {
    inset: var(--board-pad, 5px);
  }
}

.ghost-layer {
  position: absolute;
  inset: var(--board-pad, 7px);
  pointer-events: none;
}

/* Persistent Tile Structure: .tile (translation) > .tile-face (number, effects) */
.tile {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  pointer-events: auto;
  border-radius: 8px;
  user-select: none;
  -webkit-user-select: none;
  backface-visibility: hidden;
  background: transparent !important;
  border: none;
  box-shadow: none;
}

.tile-face {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: clamp(18px, 5vw, 29px);
  font-weight: 900;
  letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
  border: 1px solid #ffffff12;
  box-shadow: inset 0 0 0 1px #0000000a, 0 2px 4px #0002;
  color: #fff8ee;
  box-sizing: border-box;
  position: relative;
  pointer-events: none;
  transition: transform 140ms ease-out, box-shadow 140ms ease-out;
}

@media (max-width: 359px) {
  .tile {
    border-radius: 7px;
  }
  .tile-face {
    border-radius: 7px;
    font-size: 18px;
  }
}

.tile.tile-spawn .tile-face, .tile.spawn .tile-face {
  animation: spawnFade .11s ease-out forwards;
}

@keyframes spawnFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Tile Luminance Classes */
.v2 .tile-face, .tile-2 .tile-face { background: var(--t2); }
.v4 .tile-face, .tile-4 .tile-face { background: var(--t4); }
.v8 .tile-face, .tile-8 .tile-face { background: var(--t8); }
.v16 .tile-face, .tile-16 .tile-face { background: var(--t16); color: #211d1b; }
.v32 .tile-face, .tile-32 .tile-face { background: var(--t32); color: #211d1b; }
.v64 .tile-face, .tile-64 .tile-face { background: var(--t64); color: #211d1b; }
.v128 .tile-face, .tile-128 .tile-face { background: var(--t128); color: #2a2116; }
.v256 .tile-face, .tile-256 .tile-face { background: var(--t256); color: #2a2116; }
.v512 .tile-face, .tile-512 .tile-face { background: var(--t512); color: #2a2116; }
.v1024 .tile-face, .tile-1024 .tile-face { background: var(--t1024); color: #2a2116; }
.v2048 .tile-face, .tile-2048 .tile-face { background: var(--t2048); color: #2a2116; }
.v4096 .tile-face, .tile-4096 .tile-face, .tile-8192 .tile-face { background: var(--t4096); color: #2a2116; }

.compact .tile-face, .tile.compact .tile-face {
  font-size: clamp(14px, 3.9vw, 22px);
}

/* Stone Hazard */
.stone, .tile.stone, .tile-stone {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  pointer-events: auto;
  border-radius: 8px;
  background: transparent !important;
  border: none;
  box-shadow: none;
}

.stone .tile-face, .tile-stone .tile-face, .stone-face {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, #282426 0 4px, #171517 4px 8px);
  border: 2px solid #5b5052;
  color: #b5a7a4;
  box-shadow: inset 0 -4px 6px #0008;
  font-size: 23px;
  box-sizing: border-box;
  position: relative;
  pointer-events: none;
}

/* ==========================================================================
   Targeting Highlights
   ========================================================================== */
.tile.selected, .tile.target-selected {
  outline: none !important;
  box-shadow: none !important;
  opacity: 1 !important;
  z-index: 12;
}

.tile.selected:before, .tile.target-selected:before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  border: 2px dashed var(--accent);
  box-shadow: none;
  pointer-events: none;
  z-index: 14;
  opacity: 0;
  transition: opacity 140ms ease-out;
}

.tile.selected .tile-face, .tile.target-selected .tile-face {
  transform: scale(0.94);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.2);
}

.tile.candidate, .tile.target-candidate {
  outline: none !important;
  box-shadow: none !important;
  animation: none !important;
  opacity: 1 !important;
  z-index: 12;
}

.tile.candidate:before, .tile.target-candidate:before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  border: 2px dashed var(--accent);
  box-shadow: 0 0 0 1px rgba(16, 15, 17, 0.85);
  pointer-events: none;
  z-index: 14;
  opacity: 1;
  transition: opacity 140ms ease-out;
}

@media (max-width: 359px) {
  .tile.candidate:before, .tile.target-candidate:before,
  .tile.selected:before, .tile.target-selected:before {
    inset: -2px;
    border-radius: 9px;
  }
}

.tile.valid, .tile.target-partner {
  outline: none !important;
  box-shadow: none !important;
  animation: pulse 1s infinite;
  opacity: 1 !important;
  z-index: 12;
}

.tile.valid:before, .tile.target-partner:before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 1px #141315, 0 0 16px #f2c77e99;
  pointer-events: none;
  z-index: 14;
}

.tile.erasable {
  outline: none !important;
  box-shadow: none !important;
  opacity: 1 !important;
  z-index: 12;
}

.tile.erasable:after {
  display: none !important;
  content: none !important;
}

.tile.erasable:before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 3px solid #f27d70;
  box-shadow: 0 0 0 1px #141315, 0 0 14px #f27d7088;
  pointer-events: none;
  z-index: 15;
}

.cell.laser-target, .tile.laser-target {
  outline: 3px solid #f04438 !important;
  outline-offset: -4px;
  border-color: #ff594d !important;
  box-shadow: inset 0 0 0 2px #f0443855, 0 0 12px #f0443888 !important;
  opacity: 1 !important;
  position: relative;
  z-index: 3;
}

.cell.erasing {
  outline: 2px solid var(--warn);
  animation: eraseBurst .24s ease-out forwards;
  z-index: 4;
}

.cell.diag-persist {
  outline: 2px dashed #f2c77e !important;
  outline-offset: -4px;
  opacity: 1 !important;
  box-shadow: inset 0 0 0 1px #f2c77e35;
}

.cell.dim {
  opacity: .45 !important;
}

.tile.dim {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  opacity: 1 !important;
  filter: none !important;
  transition: opacity 120ms ease;
}

.tile.dim::before,
.tile.dim::after {
  display: none !important;
  content: none !important;
}

.tile.dim .tile-face {
  border: 1px solid transparent !important;
  box-shadow: none !important;
  outline: none !important;
  color: #e8dfd6 !important;
  filter: none !important;
  opacity: 1 !important;
  transition: background-color 120ms ease, color 120ms ease;
}

.tile.dim .tile-face::before,
.tile.dim .tile-face::after {
  display: none !important;
  content: none !important;
}

.tile.dim.v2 .tile-face, .tile.dim.tile-2 .tile-face { background: color-mix(in srgb, var(--t2) 35%, #141213 65%) !important; }
.tile.dim.v4 .tile-face, .tile.dim.tile-4 .tile-face { background: color-mix(in srgb, var(--t4) 35%, #141213 65%) !important; }
.tile.dim.v8 .tile-face, .tile.dim.tile-8 .tile-face { background: color-mix(in srgb, var(--t8) 35%, #141213 65%) !important; }
.tile.dim.v16 .tile-face, .tile.dim.tile-16 .tile-face { background: color-mix(in srgb, var(--t16) 35%, #141213 65%) !important; }
.tile.dim.v32 .tile-face, .tile.dim.tile-32 .tile-face { background: color-mix(in srgb, var(--t32) 35%, #141213 65%) !important; }
.tile.dim.v64 .tile-face, .tile.dim.tile-64 .tile-face { background: color-mix(in srgb, var(--t64) 35%, #141213 65%) !important; }
.tile.dim.v128 .tile-face, .tile.dim.tile-128 .tile-face { background: color-mix(in srgb, var(--t128) 35%, #141213 65%) !important; }
.tile.dim.v256 .tile-face, .tile.dim.tile-256 .tile-face { background: color-mix(in srgb, var(--t256) 35%, #141213 65%) !important; }
.tile.dim.v512 .tile-face, .tile.dim.tile-512 .tile-face { background: color-mix(in srgb, var(--t512) 35%, #141213 65%) !important; }
.tile.dim.v1024 .tile-face, .tile.dim.tile-1024 .tile-face { background: color-mix(in srgb, var(--t1024) 35%, #141213 65%) !important; }
.tile.dim.v2048 .tile-face, .tile.dim.tile-2048 .tile-face { background: color-mix(in srgb, var(--t2048) 35%, #141213 65%) !important; }
.tile.dim.v4096 .tile-face, .tile.dim.tile-4096 .tile-face,
.tile.dim.v8192 .tile-face, .tile.dim.tile-8192 .tile-face { background: color-mix(in srgb, var(--t4096) 35%, #141213 65%) !important; }
.tile.dim.stone .tile-face, .tile.dim.tile-stone .tile-face {
  background: color-mix(in srgb, #282426 35%, #141213 65%) !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
}

.cell.mason, .cell.mason-candidate {
  overflow: visible;
  background: #57452e !important;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(242, 199, 126, 0.3), 0 0 8px rgba(242, 199, 126, 0.35);
  z-index: 3;
  opacity: 1;
  animation: masonGlow 3s ease-in-out infinite;
}

.cell.mason:after, .cell.mason-candidate:after {
  content: none !important;
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .cell.mason, .cell.mason-candidate {
    animation: none !important;
    border-color: var(--accent) !important;
    box-shadow: inset 0 0 0 1.5px rgba(242, 199, 126, 0.6), 0 0 14px rgba(242, 199, 126, 0.55) !important;
    opacity: 0.92 !important;
  }
}

.board.draftdim .cell:not(.mason):not(.mason-candidate) {
  opacity: .22;
}

/* ==========================================================================
   Status Line & Cancel Bar
   ========================================================================== */
.status, .status-hint-bar {
  width: var(--col-w);
  margin-left: auto;
  margin-right: auto;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-size: 12px;
  line-height: 28px;
  color: var(--muted);
  flex-shrink: 0;
  border-radius: 0;
  position: relative;
  overflow: visible;
}

.status.stuck-warning, .status-hint-bar.stuck-warning {
  background: #492824 !important;
  border: 1px solid #a35449 !important;
  color: #ffe1d8 !important;
  font-weight: 900 !important;
}

.cancel, .btn-cancel-targeting {
  position: relative;
  height: 22px;
  max-height: 22px;
  line-height: 20px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--soft);
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.cancel::before, .btn-cancel-targeting::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% + 16px);
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  pointer-events: auto;
}

.cancel.hidden, .btn-cancel-targeting.hidden {
  display: none;
}

.targeting-bar {
  display: none;
}

.foresight-bar.hidden {
  display: none;
}

/* ==========================================================================
   Ability Bar verbatim from mock
   ========================================================================== */
.abilities, .ability-bar {
  width: var(--col-w);
  margin-left: auto;
  margin-right: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
  flex: none;
}

.abilities.hidden, .ability-bar.hidden {
  display: none;
}

.ability, .ability-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  height: 94px;
  min-width: 0;
  border: 1px solid #4b3b37;
  background: linear-gradient(145deg, #30272a, #211d20);
  border-radius: 13px;
  padding: 6px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: .15s;
  box-sizing: border-box;
}

@media (max-width: 359px) {
  .ability, .ability-btn {
    height: 91px;
  }
}

.ability.hidden, .ability-btn.hidden {
  display: none;
}

.ability .icon, .ability-btn-icon-wrap {
  height: 37px;
  width: 37px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #4b3931;
  border: 1px solid #775743;
  color: #fff2df;
  font-weight: 950;
  font-size: 10px;
  padding: 3px;
  overflow: hidden;
  box-sizing: border-box;
}

@media (max-width: 359px) {
  .ability .icon, .ability-btn-icon-wrap {
    height: 34px;
    width: 34px;
  }
}

.ability .name {
  font-size: clamp(11px, 3.2vw, 12px);
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--text);
}

.pips, .ability-pips {
  display: flex;
  gap: 3px;
  height: 4px;
}

.pip, .charge-pip {
  width: 11px;
  height: 4px;
  border-radius: 3px;
  background: #5a4b49;
}

.pip.on, .charge-pip.on, .charge-pip.filled {
  background: var(--accent);
}

.refill, .ability-btn-cooldown {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.ability.targeting, .ability.rescue, .ability.highlight-stuck, .ability.active-targeting {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #f2c77e33, 0 0 15px #f2c77e33;
}

.ability.rescue, .ability.highlight-stuck {
  animation: pulse 1s infinite;
}

.ability.dim, .ability:disabled, .ability-btn:disabled {
  opacity: .45;
}

.bottomhint {
  text-align: center;
  font-size: 11px;
  color: #84736b;
  letter-spacing: .09em;
  padding-top: 6px;
}

/* ==========================================================================
   Ability Card Micro-Interactions (H1 Icon Tilt & H2 Rewind Shimmer)
   ========================================================================== */

/* H1. Tactile Icon Tilt */
.ability-btn[data-relic="diagonal_charge"] .ability-btn-icon-wrap img,
.ability-btn[data-relic="diagonal_charge"] .ability-btn-icon-wrap svg,
.ability-btn[data-relic="diagonal_charge"] .relic-icon-img,
.ability-btn[data-relic="eraser"] .ability-btn-icon-wrap img,
.ability-btn[data-relic="eraser"] .ability-btn-icon-wrap svg,
.ability-btn[data-relic="eraser"] .relic-icon-img,
.ability-btn[data-relic="rewind"] .ability-btn-icon-wrap img,
.ability-btn[data-relic="rewind"] .ability-btn-icon-wrap svg,
.ability-btn[data-relic="rewind"] .relic-icon-img {
  transition: transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 50% 55%;
}

@media (hover: hover) and (pointer: fine) {
  .ability-btn[data-relic="diagonal_charge"]:not(:disabled):not([aria-disabled="true"]):not(.dim):hover .ability-btn-icon-wrap img,
  .ability-btn[data-relic="diagonal_charge"]:not(:disabled):not([aria-disabled="true"]):not(.dim):hover .relic-icon-img,
  .ability-btn[data-relic="eraser"]:not(:disabled):not([aria-disabled="true"]):not(.dim):hover .ability-btn-icon-wrap img,
  .ability-btn[data-relic="eraser"]:not(:disabled):not([aria-disabled="true"]):not(.dim):hover .relic-icon-img,
  .ability-btn[data-relic="rewind"]:not(:disabled):not([aria-disabled="true"]):not(.dim):hover .ability-btn-icon-wrap img,
  .ability-btn[data-relic="rewind"]:not(:disabled):not([aria-disabled="true"]):not(.dim):hover .relic-icon-img {
    transform: rotate(-11deg);
  }
}

@media (pointer: coarse) {
  .ability-btn[data-relic="diagonal_charge"]:not(:disabled):not([aria-disabled="true"]):not(.dim):active .ability-btn-icon-wrap img,
  .ability-btn[data-relic="diagonal_charge"]:not(:disabled):not([aria-disabled="true"]):not(.dim):active .relic-icon-img,
  .ability-btn[data-relic="eraser"]:not(:disabled):not([aria-disabled="true"]):not(.dim):active .ability-btn-icon-wrap img,
  .ability-btn[data-relic="eraser"]:not(:disabled):not([aria-disabled="true"]):not(.dim):active .relic-icon-img,
  .ability-btn[data-relic="rewind"]:not(:disabled):not([aria-disabled="true"]):not(.dim):active .ability-btn-icon-wrap img,
  .ability-btn[data-relic="rewind"]:not(:disabled):not([aria-disabled="true"]):not(.dim):active .relic-icon-img {
    transform: rotate(-11deg);
  }
}

/* Part C: Card Shine (Diagonal Merge, Eraser, Rewind) */
:root {
  --card-shine: rgba(255, 255, 255, 0.15);
}

.card-shine {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
  box-sizing: border-box;
}

.card-shine::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 55%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 0%, var(--card-shine, rgba(255, 255, 255, 0.15)) 50%, transparent 100%);
  opacity: 0;
  transform: translateX(-130%);
  animation: none;
}

@keyframes card-shine-sweep {
  0% {
    opacity: 0;
    transform: translateX(-130%);
  }
  30% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(240%);
  }
}

@media (hover: hover) and (pointer: fine) {
  .ability-btn:not(:disabled):not([aria-disabled="true"]):not(.dim):hover .card-shine::before {
    animation: card-shine-sweep 700ms ease-out 1;
    animation-fill-mode: none;
  }
}

.ability-btn.shimmer .card-shine::before {
  animation: card-shine-sweep 700ms ease-out 1;
  animation-fill-mode: none;
}

@media (prefers-reduced-motion: reduce) {
  .ability-btn[data-relic="diagonal_charge"] .ability-btn-icon-wrap img,
  .ability-btn[data-relic="diagonal_charge"] .relic-icon-img,
  .ability-btn[data-relic="eraser"] .ability-btn-icon-wrap img,
  .ability-btn[data-relic="eraser"] .relic-icon-img,
  .ability-btn[data-relic="rewind"] .ability-btn-icon-wrap img,
  .ability-btn[data-relic="rewind"] .relic-icon-img,
  .ability-btn[data-relic="diagonal_charge"]:hover .ability-btn-icon-wrap img,
  .ability-btn[data-relic="diagonal_charge"]:hover .relic-icon-img,
  .ability-btn[data-relic="eraser"]:hover .ability-btn-icon-wrap img,
  .ability-btn[data-relic="eraser"]:hover .relic-icon-img,
  .ability-btn[data-relic="rewind"]:hover .ability-btn-icon-wrap img,
  .ability-btn[data-relic="rewind"]:hover .relic-icon-img,
  .ability-btn[data-relic="diagonal_charge"]:active .ability-btn-icon-wrap img,
  .ability-btn[data-relic="diagonal_charge"]:active .relic-icon-img,
  .ability-btn[data-relic="eraser"]:active .ability-btn-icon-wrap img,
  .ability-btn[data-relic="eraser"]:active .relic-icon-img,
  .ability-btn[data-relic="rewind"]:active .ability-btn-icon-wrap img,
  .ability-btn[data-relic="rewind"]:active .relic-icon-img {
    transform: none !important;
    transition: none !important;
  }

  .card-shine,
  .card-shine::before,
  .ability-btn.shimmer .card-shine::before {
    animation: none !important;
    display: none !important;
  }
}

/* ==========================================================================
   Toasts & Tooltip Popovers
   ========================================================================== */
.toast-container {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
}

.toast, .toast-container .toast {
  position: absolute;
  z-index: 20;
  top: 72px;
  left: 50%;
  transform: translate(-50%, -5px);
  background: #f5e8d6;
  color: #302116;
  padding: 9px 13px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transition: .15s;
  white-space: nowrap;
  box-sizing: border-box;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tooltip, .relic-popover {
  position: absolute;
  z-index: 25;
  max-width: 210px;
  background: #f7ebda;
  color: #2b211b;
  border: 1px solid white;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 10px 30px #0008;
  box-sizing: border-box;
}

.tooltip strong, .popover-title {
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
  font-weight: 900;
  color: #2b211b;
}

.popover-desc {
  font-size: 11px;
  color: #2b211b;
}

.tooltip.hidden, .relic-popover.hidden {
  display: none;
}

/* ==========================================================================
   R14 Start-Screen Card Reveal Gate (Scrim present from first paint)
   ========================================================================== */
@keyframes startCardFallbackReveal {
  to {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

html.tutorial-active #start-overlay {
  display: none !important;
}

html.challenge-active #start-overlay {
  display: none !important;
}

html.tutorial-active #tutorial-overlay.hidden {
  display: flex !important;
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto !important;
}

html.challenge-active #challenge-overlay.hidden {
  display: flex !important;
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto !important;
}

html:not(.app-ready) #start-overlay .start-card {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: none !important;
  animation: startCardFallbackReveal 0.05s ease-out 1500ms forwards;
}

html.app-ready #start-overlay .start-card {
  animation: appear .2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  html.app-ready #start-overlay .start-card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ==========================================================================
   Modal Overlays (Start, Draft, Pause, Game Over)
   ========================================================================== */
.overlay, .modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: #0b090bea;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.overlay.hidden, .modal-overlay.hidden {
  display: none;
}

.modal, .start-card, .draft-card-container, .end-card, .challenge-card {
  position: relative;
  width: 100%;
  max-width: 370px;
  background: linear-gradient(145deg, #302729, #1c191b);
  border: 1px solid #574448;
  border-radius: 23px;
  padding: 21px 17px;
  box-shadow: 0 24px 70px #0009;
  animation: appear .2s ease-out;
  box-sizing: border-box;
  margin: auto;
}

.start-card {
  box-shadow: 0 24px 40px #0009;
}

.trophy-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #2b2220;
  border: 1px solid #4a3a37;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 10;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) {
  .trophy-btn:hover {
    background: #382c28;
    border-color: var(--accent);
    transform: scale(1.05);
  }
}

.trophy-btn:active {
  transform: scale(0.95);
}

.logo {
  height: 62px;
  width: 62px;
  display: grid;
  place-items: center;
  margin: 0 auto 13px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accentInk);
  font-size: 20px;
  font-weight: 950;
  transform: rotate(-4deg);
}

.eyebrow {
  text-align: center;
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 900;
}

.title {
  text-align: center;
  font-size: 35px;
  line-height: 1.03;
  letter-spacing: -.07em;
  margin: 8px 0;
  font-weight: 950;
}

.sub {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 auto 18px;
  max-width: 255px;
}

.primary, .btn-primary {
  width: 100%;
  min-height: 54px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .04em;
  background: var(--accent);
  color: var(--accentInk);
  border: 1px solid #f8d9a2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.secondary, .btn-secondary {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .04em;
  background: #2b2528;
  border: 1px solid #4b3d40;
  color: var(--soft);
  display: grid;
  place-items: center;
}

.best {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .13em;
  margin: 13px 0;
}

.best b, #start-best-score {
  color: var(--text);
  font-weight: 900;
}

.link {
  display: block;
  margin: auto;
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--soft);
  font-size: 11px;
  padding: 7px;
}

/* ==========================================================================
   Interactive Tutorial Overlay & Layout
   ========================================================================== */
#tutorial-overlay.tutorial-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #0b090bea;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 16px 16px;
  box-sizing: border-box;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.tutorial-overlay.hidden {
  display: none !important;
}

.tutorial-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.tutorial-progress-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tutorial-tag {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 14px;
  margin-left: 11px;
  text-transform: uppercase;
  color: var(--accent);
}

.btn-skip {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 14px;
  text-transform: uppercase;
  color: var(--muted);
  background: #251e20;
  border: 1px solid #45373a;
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 36px;
  min-width: 48px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-skip:hover {
  color: var(--text);
  border-color: var(--muted);
  background: #31272a;
}

.tutorial-stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  padding: 4px 0;
}

.step-view {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.step-view.active {
  display: flex;
  animation: tut-stepFadeIn 0.22s ease-out;
}

@keyframes tut-stepFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mini-boardwrap {
  width: min(280px, 72vw);
  height: min(280px, 72vw);
  aspect-ratio: 1;
  position: relative;
  margin: 0 auto;
  cursor: pointer;
}

.mini-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  padding: 7px;
  background: var(--board);
  border: 1px solid #3c3336;
  border-radius: 16px;
  box-sizing: border-box;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7);
}

.mini-cell {
  background: var(--well);
  border: 1px solid var(--wellLine);
  border-radius: 8px;
  position: relative;
  box-sizing: border-box;
}

.tiles-overlay-layer {
  position: absolute;
  inset: 7px;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.tiles-overlay-layer.tut-layer-fading-out {
  opacity: 0;
}

.tiles-overlay-layer.tut-layer-fading-in {
  animation: tut-layerFadeIn 240ms ease-out forwards;
}

@keyframes tut-layerFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.tut-demo-tile {
  position: absolute;
  width: calc((100% - 18px) / 4);
  height: calc((100% - 18px) / 4);
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
  border: 1px solid #ffffff12;
  box-shadow: inset 0 0 0 1px #0000000a, 0 2px 4px #0002;
  color: #fff8ee;
  box-sizing: border-box;
  transition: left 240ms cubic-bezier(0.2, 0.9, 0.25, 1), top 240ms cubic-bezier(0.2, 0.9, 0.25, 1), opacity 140ms ease, transform 240ms ease;
  will-change: left, top, opacity, transform;
  transform-origin: center center;
}

.tut-demo-tile.tile-2 { background: var(--t2); }
.tut-demo-tile.tile-4 { background: var(--t4); }
.tut-demo-tile.tile-8 { background: var(--t8); }
.tut-demo-tile.tile-16 { background: var(--t16); color: #211d1b; }
.tut-demo-tile.tile-32 { background: var(--t32); color: #211d1b; }
.tut-demo-tile.tile-64 { background: var(--t64); color: #211d1b; }
.tut-demo-tile.tile-128 { background: var(--t128); color: #2a2116; }
.tut-demo-tile.tile-256 { background: var(--t256); color: #2a2116; }
.tut-demo-tile.tile-512 { background: var(--t512); color: #2a2116; }
.tut-demo-tile.tile-1024 { background: var(--t1024); color: #2a2116; }
.tut-demo-tile.tile-2048 { background: var(--t2048); color: #2a2116; }

.tut-demo-stone {
  position: absolute;
  width: calc((100% - 18px) / 4);
  height: calc((100% - 18px) / 4);
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, #282426 0 4px, #171517 4px 8px);
  border: 2px solid #5b5052;
  color: #b5a7a4;
  box-shadow: inset 0 -4px 6px #0008;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  font-size: 23px;
  transition: transform 260ms cubic-bezier(0.18, 0.9, 0.32, 1.2), opacity 180ms ease;
  will-change: transform, opacity;
  pointer-events: none;
}

.pointer-indicator-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 58px;
  height: 58px;
  pointer-events: none;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.52s cubic-bezier(0.2, 0.9, 0.3, 1.0);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.7));
}

.pointer-indicator-wrap.visible {
  opacity: 1;
}

.pointer-indicator-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes tut-mergeScalePop {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1.0); }
}

.tut-tile-merge-pop {
  animation: tut-mergeScalePop 0.16s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.tut-stone-landing-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid #a38c86;
  box-shadow: 0 0 12px #f27d70;
  box-sizing: border-box;
  transform-origin: center center;
  animation: tut-stoneRingGrow 0.32s ease-out forwards;
  pointer-events: none;
  z-index: 15;
}

@keyframes tut-stoneRingGrow {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.demo-telegraph {
  width: min(280px, 72vw);
  height: 34px;
  margin-bottom: 8px;
  border: 1px solid #493b36;
  background: #241e1d;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.demo-telegraph.warning {
  border-color: #9d5147;
  background: #352220;
}

.demo-telegraph .haz {
  color: var(--warn);
  font-size: 14px;
  line-height: 1;
}

.demo-telegraph .haztext {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.demo-telegraph .haztext strong {
  font-weight: 900;
  color: #fff;
  font-size: 12px;
}

.demo-telegraph .track {
  width: 44px;
  height: 4px;
  background: #554642;
  border-radius: 9px;
  overflow: hidden;
}

.demo-telegraph .fill {
  height: 100%;
  width: 70%;
  background: var(--accent);
  transition: width 0.25s ease, background 0.25s ease;
}

.demo-telegraph.warning .fill {
  background: var(--warn);
}

.interactive-cue-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.85;
}

.step3-composite-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 370px;
}

.stage-section-label {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0 4px;
  text-align: center;
  opacity: 0;
  transform: scaleX(0.05);
  transform-origin: center center;
  clip-path: inset(0 50% 0 50%);
  transition: opacity 0.35s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), clip-path 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.stage-section-label.unfolded {
  opacity: 1;
  transform: scaleX(1);
  clip-path: inset(0 0% 0 0%);
}

.stage-section-label::before,
.stage-section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--line);
}

.relic-draft-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.demo-draft-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid #4c3c3f;
  border-radius: 11px;
  background: #272124;
  text-align: left;
  min-height: 48px;
  box-sizing: border-box;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  opacity: 0;
  transform: translateY(10px);
}

.demo-draft-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.demo-draft-card.selected,
.demo-draft-card.highlight {
  border-color: var(--accent);
  background: #3b2f28;
  box-shadow: 0 0 14px rgba(242, 199, 126, 0.22);
  transform: none;
}

.demo-draft-card.highlight::after,
.demo-draft-card.selected::after,
.demo-ability-card.highlight::after,
.tut-glass-shimmer::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -130%;
  width: 60%;
  height: 200%;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.05) 30%,
    rgba(255, 248, 230, 0.22) 50%,
    rgba(255, 255, 255, 0.05) 70%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(22deg);
  pointer-events: none;
  animation: tut-glassShinePeriodic 5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes tut-glassShine {
  0% { left: -80%; }
  100% { left: 150%; }
}

@keyframes tut-glassShinePeriodic {
  0% { left: -130%; }
  25% { left: 170%; }
  100% { left: 170%; }
}

.demo-draft-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #49352d;
  border: 1px solid #785846;
  box-sizing: border-box;
  flex-shrink: 0;
  padding: 4px;
}

.demo-draft-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.demo-draft-info { min-width: 0; }

.demo-draft-name {
  font-size: 11.5px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.demo-draft-desc {
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-draft-tag {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid #715b43;
  border-radius: 4px;
  padding: 3px 6px;
  text-transform: uppercase;
}

.demo-abilities-container {
  width: 100%;
  margin-top: 2px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.demo-abilities-container.visible {
  opacity: 1;
  transform: translateY(0);
}

.demo-ability-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.demo-ability-card {
  position: relative;
  overflow: hidden;
  height: 80px;
  border: 1px solid #4b3b37;
  background: linear-gradient(145deg, #30272a, #211d20);
  border-radius: 12px;
  padding: 6px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.demo-ability-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(242, 199, 126, 0.4), inset 0 0 0 1px rgba(242, 199, 126, 0.4);
  transform: none;
}

.demo-ability-icon {
  height: 32px;
  width: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #4b3931;
  border: 1px solid #775743;
  padding: 3px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.demo-ability-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.demo-ability-name {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  color: var(--text);
  flex-shrink: 0;
}

.demo-ability-pips {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 4px;
  flex-shrink: 0;
}

.demo-pip {
  width: 10px;
  height: 4px;
  border-radius: 2px;
  background: #5a4b49;
}

.demo-pip.on {
  background: var(--accent);
  box-shadow: 0 0 4px rgba(242, 199, 126, 0.6);
}

.demo-ability-refill {
  font-size: 10px;
  line-height: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.reduced-motion-annotation {
  display: none;
  width: 100%;
  background: #251d1e;
  border: 1px solid #5a4548;
  border-radius: 10px;
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--soft);
  box-sizing: border-box;
}

.reduced-motion-annotation strong { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .reduced-motion-annotation { display: block !important; }
  .tut-stone-landing-ring,
  .demo-telegraph-dot::before,
  .demo-draft-card.highlight::after,
  .demo-draft-card.selected::after,
  .demo-ability-card.highlight::after,
  .tut-glass-shimmer::after {
    animation: none !important;
    display: none !important;
  }
}

.tutorial-bottom-card {
  width: 100%;
  background: linear-gradient(145deg, #2a2225, #1d191c);
  border: 1px solid #4a3a3e;
  border-radius: 18px;
  padding: 14px 16px 12px;
  box-sizing: border-box;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.tutorial-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.tutorial-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-transform: uppercase;
}

.tutorial-step-counter {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.tutorial-caption {
  font-size: 12px;
  color: var(--soft);
  line-height: 1.4;
  margin-bottom: 12px;
  min-height: 34px;
}

.tutorial-action-row {
  display: flex;
  gap: 8px;
}

.btn-step-prev {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  background: #2b2326;
  border: 1px solid #4c3c3f;
  color: var(--soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
  box-sizing: border-box;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-step-prev:hover {
  background: #392d32;
  color: var(--text);
}

.btn-step-prev.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-tutorial-next {
  flex: 1;
  min-height: 44px;
  min-width: 80px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: var(--accentInk);
  border: 1px solid #f8d9a2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-transform: uppercase;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(242, 199, 126, 0.25);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn-tutorial-next:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-tutorial-next:active { transform: translateY(0); }

/* Responsive viewports: 320x568, 360x640 */
@media (max-height: 620px) {
  #tutorial-overlay.tutorial-overlay {
    padding: 12px 12px 8px;
  }
  .tutorial-header {
    height: 36px;
    margin-bottom: 2px;
  }
  .mini-boardwrap {
    width: min(200px, 58vw);
    height: min(200px, 58vw);
  }
  .demo-telegraph {
    width: min(200px, 58vw);
    height: 28px;
    margin-bottom: 4px;
    padding: 0 8px;
  }
  .interactive-cue-tag {
    margin-top: 3px;
  }
  .step3-composite-stage {
    gap: 4px;
  }
  .demo-draft-card {
    padding: 4px 8px;
    min-height: 40px;
    gap: 6px;
  }
  .demo-draft-icon {
    width: 30px;
    height: 30px;
    padding: 3px;
  }
  .demo-abilities-container {
    margin-top: 1px;
  }
  .demo-ability-card {
    height: 66px;
    padding: 4px 2px;
    gap: 2px;
  }
  .demo-ability-icon {
    height: 24px;
    width: 24px;
    padding: 2px;
  }
  .demo-ability-name,
  .demo-ability-refill {
    height: 11px;
    line-height: 11px;
  }
  .tutorial-bottom-card {
    padding: 8px 12px 8px;
    border-radius: 14px;
  }
  .tutorial-title {
    font-size: 13px;
  }
  .tutorial-caption {
    font-size: 11px;
    margin-bottom: 6px;
    min-height: 26px;
    line-height: 1.3;
  }
  .btn-step-prev {
    min-height: 38px;
    height: 38px;
  }
  .btn-tutorial-next {
    min-height: 38px;
    height: 38px;
    font-size: 12px;
  }
}

@media (max-width: 359px) {
  #tutorial-overlay.tutorial-overlay {
    padding: 12px 12px 8px;
  }
  .tutorial-progress-meta {
    gap: 6px;
  }
  .mini-boardwrap {
    width: min(190px, 58vw);
    height: min(190px, 58vw);
  }
  .demo-telegraph {
    width: min(190px, 58vw);
  }
  .tut-demo-tile {
    border-radius: 7px;
  }
}

.foot, .start-build-footer {
  text-align: center;
  color: #8d7b74;
  font-size: 11px;
  letter-spacing: .12em;
  margin-top: 15px;
}

/* Start Card Bottom Links Row */
.start-links-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.start-links-row .link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  padding: 0 8px;
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--soft);
  font-size: 11px;
  cursor: pointer;
  box-sizing: border-box;
  font-family: inherit;
  margin: 0;
}

.start-links-row .link:hover,
.start-links-row .link:focus-visible {
  color: var(--text);
  outline: none;
}

/* Daily Leaderboard Controls */
.daily-disclosure-container {
  height: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 8px 0 10px 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted);
  box-sizing: border-box;
  overflow: hidden;
}

.daily-disclosure-container.hidden {
  display: none;
}

.daily-disclosure-text {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
}

.daily-countdown-line {
  font-size: 10px;
  font-weight: 600;
  color: var(--soft);
}

.end-leaderboard-status,
#end-leaderboard-status {
  display: none !important;
}

/* Draft Modal Cards */
.draft-title {
  text-align: center;
  font-size: 26px;
  margin: 4px 0;
  font-weight: 950;
}

.draft-cards, .draft-offers-row {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.draftcard, .draft-offer-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid #4c3c3f;
  border-radius: 12px;
  background: #272124;
  text-align: left;
  min-height: 80px;
  box-sizing: border-box;
}

.draftcard.selected {
  border-color: var(--accent);
  background: #3b2f28;
}

.draftcard .art, .draft-offer-icon-wrap {
  height: 43px;
  width: 43px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: #49352d;
  border: 1px solid #785846;
  color: #fff1df;
  font-size: 11px;
  font-weight: 950;
  overflow: hidden;
  padding: 3px;
  box-sizing: border-box;
}

.dname, .draft-offer-name {
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 3px;
  color: var(--text);
}

.ddesc, .draft-offer-desc {
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.tag {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  color: var(--accent);
  border: 1px solid #715b43;
  border-radius: 5px;
  padding: 4px;
}

.owned, .draft-owned-section {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  margin-top: 10px;
}

.owned summary {
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}

.ownedicons, .draft-owned-chips {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.ownedicons .art, .ownedicons .relic-mini {
  height: 27px;
  width: 27px;
  font-size: 8px;
  opacity: .55;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #49352d;
  border: 1px solid #785846;
  padding: 2px;
  box-sizing: border-box;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.actions .primary {
  flex: 1;
}

.actions .secondary {
  width: 85px;
}

/* Pause Menu */
.sheetbutton {
  height: 43px;
  width: 100%;
  text-align: left;
  margin-top: 7px;
  padding: 0 11px;
  background: #292326;
  border: 1px solid #4a3a3e;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}

#pause-overlay .pause-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  box-sizing: border-box;
  background: linear-gradient(170deg, #2b2326 0%, #1e191b 60%, #171415 100%);
  border: 1px solid #4a3a3e;
  border-radius: 24px;
  padding: 22px 18px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(242, 199, 126, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

#pause-overlay .pause-card * {
  box-sizing: border-box;
}

#pause-overlay .pause-trophy-btn {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
}

.pause-header {
  text-align: center;
  margin-bottom: 6px;
}

.pause-badge-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.pause-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(242, 199, 126, 0.1);
  border: 1px solid rgba(242, 199, 126, 0.28);
  border-radius: 999px;
  padding: 4px 12px;
  line-height: 1;
}

.pause-badge-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: bestRunsDotPulse 2s infinite ease-in-out;
}

#pause-overlay .pause-title {
  display: block;
  width: fit-content;
  max-width: 100%;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.05em;
  color: var(--text);
  margin: 0 auto 4px;
  text-align: center;
}

#pause-overlay .pause-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
  margin: 0 auto;
  max-width: 250px;
  text-align: center;
}

#pause-overlay .pause-time-box {
  margin: 10px auto 14px;
  background: #1c1719;
  border: 1px solid #3c3235;
  border-radius: 12px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
  font-size: 11px;
}

.pause-time-icon {
  color: var(--accent);
  display: flex;
  align-items: center;
}

.pause-time-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pause-time-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.btn-action-icon-slot {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
}

#pause-overlay .btn-resume {
  margin-top: 0;
  width: 100%;
  height: 50px;
  min-height: 44px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accentInk);
  border: 1px solid #f8d9a2;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 0 18px rgba(242, 199, 126, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

#pause-overlay .btn-resume:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(242, 199, 126, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

#pause-overlay .btn-resume:active {
  transform: translateY(1px);
  filter: brightness(0.96);
}

#pause-overlay .btn-resume .btn-arrow {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(43, 29, 13, 0.15);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}

#pause-overlay .btn-secondary-action {
  margin-top: 0;
  width: 100%;
  height: 46px;
  min-height: 42px;
  border-radius: 12px;
  background: #272124;
  border: 1px solid #44373a;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

#pause-overlay .btn-secondary-action:hover {
  background: #332b2f;
  border-color: #5d4a4f;
  color: #fffbf5;
  transform: translateY(-1px);
}

#pause-overlay .btn-secondary-action:active {
  transform: translateY(1px);
  background: #221c1f;
}

#pause-overlay .btn-secondary-action.btn-danger:hover {
  border-color: rgba(242, 125, 112, 0.55);
  color: #ffd8d3;
}

#pause-overlay .btn-secondary-action .action-icon {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, transform 0.2s ease;
}

#pause-overlay .btn-secondary-action:hover .action-icon {
  color: var(--accent);
}

#pause-overlay .btn-secondary-action.btn-restart:hover .action-icon {
  transform: rotate(90deg);
}

.pause-utility-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(68, 55, 58, 0.5);
}

#pause-overlay .btn-utility {
  margin-top: 0;
  width: 100%;
  height: 38px;
  min-height: 36px;
  border-radius: 10px;
  background: #201a1c;
  border: 1px solid #3c3034;
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#pause-overlay .btn-utility:hover {
  background: #2c2427;
  border-color: #55444a;
  color: var(--text);
}

#pause-overlay .btn-utility.active-toggle {
  border-color: rgba(242, 199, 126, 0.45);
  color: var(--accent);
}

#pause-overlay #sound-icon svg {
  margin-left: 0 !important;
  display: block !important;
}

.card-confirm-view {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: linear-gradient(170deg, #2b2123 0%, #1e1719 50%, #161214 100%);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 12;
  box-sizing: border-box;
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-confirm-view.hidden {
  display: flex !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.96) translateY(6px);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0s linear 0.22s;
}

.confirm-warn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(242, 125, 112, 0.12);
  border: 1px solid rgba(242, 125, 112, 0.35);
  color: var(--warn);
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.confirm-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--warn);
  margin-bottom: 4px;
}

.confirm-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text);
  margin: 0 0 8px;
}

.confirm-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.5;
  max-width: 268px;
  margin: 0 0 20px;
}

.confirm-actions-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-confirm-action {
  width: 100%;
  height: 46px;
  min-height: 40px;
  border-radius: 12px;
  background: #261c1e;
  border: 1px solid rgba(242, 125, 112, 0.32);
  color: #ffd8d3;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.btn-confirm-action:hover {
  background: var(--warn);
  border-color: #ff9e93;
  color: #2b1412;
  box-shadow: 0 6px 20px rgba(242, 125, 112, 0.45);
  transform: translateY(-1px);
}

.btn-confirm-action:active {
  transform: translateY(1px);
}

.btn-cancel-action {
  width: 100%;
  height: 44px;
  min-height: 40px;
  border-radius: 12px;
  background: #231e20;
  border: 1px solid #44373a;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-cancel-action:hover {
  background: #2f272a;
  border-color: #5d4a4f;
  color: var(--text);
}

@media (max-height: 620px), (max-width: 359px) {
  #pause-overlay {
    padding: 12px;
  }
  #pause-overlay .pause-card {
    padding: 18px 14px 14px;
    border-radius: 20px;
  }
  #pause-overlay .pause-trophy-btn {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
  #pause-overlay .pause-title {
    font-size: 28px;
  }
  #pause-overlay .pause-time-box {
    margin: 8px auto 12px;
    padding: 6px 12px;
  }
  #pause-overlay .btn-resume {
    height: 46px;
  }
  #pause-overlay .btn-secondary-action {
    height: 42px;
  }
  #pause-overlay .card-confirm-view {
    padding: 16px 14px;
    border-radius: 20px;
  }
  #pause-overlay .confirm-desc {
    margin-bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pause-badge-pulse {
    animation: none !important;
  }
  #pause-overlay .btn-resume,
  #pause-overlay .btn-secondary-action,
  #pause-overlay .btn-utility,
  .card-confirm-view,
  .btn-confirm-action,
  .btn-cancel-action {
    transition: none !important;
  }
}

/* Game Over Modal */
.final, .end-score-val {
  font-size: 49px;
  letter-spacing: -.08em;
  text-align: center;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.newbest, .badge-new-best {
  display: inline-block;
  background: var(--accent);
  color: var(--accentInk);
  border-radius: 99px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .1em;
  margin-bottom: 8px;
}

.newbest.hidden, .badge-new-best.hidden {
  display: none;
}

.finalstats, .end-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 12px 0;
}

.finalstat, .end-summary-item {
  background: #292326;
  border: 1px solid #44373a;
  border-radius: 9px;
  padding: 8px;
  text-align: left;
}

.finalstat small, .summary-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .1em;
}

.finalstat strong, .summary-val {
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
}

.mini {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  width: 88px;
  height: 88px;
  padding: 4px;
  margin: 10px auto;
  background: #100e10;
  border-radius: 8px;
}

.mini span {
  display: grid;
  place-items: center;
  background: #2a2527;
  border-radius: 3px;
  font-size: 7px;
  font-weight: 900;
}

.mini .ms {
  position: static;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(135deg, #282426 0 2px, #171517 2px 4px);
}

.btn-sound-toggle {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ==========================================================================
   Last Stand Animation & Overlay
   ========================================================================== */
.stand, .last-stand-banner {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: radial-gradient(ellipse at center, #38261ff2 0%, #171214f7 60%, #080708fa 100%);
  display: block;
  text-align: center;
  overflow: hidden;
  pointer-events: none;
}

.stand:before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #f2c77e0b, transparent 45%, #f2c77e0b);
  pointer-events: none;
}

.stand.hidden, .last-stand-banner.hidden {
  display: none;
}

.stand-center-wrapper {
  position: absolute;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
  margin: 0;
}

.stand-center-wrapper .stand-copy {
  grid-area: 1 / 1;
  place-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
}

.stand-center-wrapper .stand-copy h2 {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: .78;
  letter-spacing: .1em;
}

.stand-center-wrapper .stand-copy .stand-subtitle {
  margin: 0;
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--soft);
}

.stand-center-wrapper .stand-dust-ring {
  grid-area: 1 / 1;
  place-self: center;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 25px var(--accent);
  animation: dustRingExpand 0.35s ease-out forwards;
  pointer-events: none;
  z-index: 1;
}

.stand h2 {
  font-size: clamp(37px, 11vw, 54px);
  letter-spacing: -.08em;
  color: var(--accent);
  margin: 0;
  text-shadow: 0 0 8px #f2c77e99, 0 0 34px #f2a84e77;
}

.stand p {
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--soft);
}

.stand .stand-last, .stand .stand-word {
  display: block;
  animation: none;
  will-change: transform;
}

.stand:not(.hidden) .stand-stamp {
  animation: standStampIn 0.24s cubic-bezier(0.1, 0.9, 0.2, 1) both;
  will-change: transform, opacity;
}

.stand:not(.hidden) .stand-last {
  animation: standExitRight 0.38s cubic-bezier(0.6, 0, 0.8, 0.25) 1.47s forwards;
}

.stand:not(.hidden) .stand-word {
  animation: standExitLeft 0.38s cubic-bezier(0.6, 0, 0.8, 0.25) 1.47s forwards;
}

@keyframes standStampIn {
  0% {
    transform: scale(3.4) rotate(-6deg);
    opacity: 0;
  }
  62.5% {
    transform: scale(0.94) rotate(-3deg);
    opacity: 1;
  }
  100% {
    transform: scale(1.0) rotate(0deg);
    opacity: 1;
  }
}

@keyframes standExitRight {
  to { transform: translateX(110vw); }
}

@keyframes standExitLeft {
  to { transform: translateX(-110vw); }
}

@keyframes boardShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 4px); }
}

.board-shake {
  animation: boardShake 0.14s ease-out;
}

@keyframes dustRingExpand {
  0% { transform: scale(0.1); opacity: 0.95; }
  100% { transform: scale(2.4); opacity: 0; }
}

.stand-dust-ring {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 25px var(--accent);
  animation: dustRingExpand 0.35s ease-out forwards;
  pointer-events: none;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .stand:not(.hidden) .stand-stamp {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  .stand:not(.hidden) .stand-last,
  .stand:not(.hidden) .stand-word {
    animation: none !important;
  }
  .board-shake {
    animation: none !important;
  }
}

/* T6: Shatter Break Animation */
@keyframes shatterFlash {
  0% { opacity: 0.95; transform: scale(1); filter: brightness(2); }
  50% { opacity: 1; transform: scale(1.05); filter: brightness(2.6); }
  100% { opacity: 0; transform: scale(1); filter: brightness(1); }
}

.shatter-flash {
  position: absolute;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 22;
  transform-origin: center center;
  animation: shatterFlash 0.12s ease-out forwards;
}

.shattering-stone {
  filter: brightness(2);
  transition: filter 0.06s ease;
}

.shatter-shard {
  position: absolute;
  width: 14px;
  height: 14px;
  background: repeating-linear-gradient(135deg, #282426 0 2px, #171517 2px 4px);
  border: 1px solid #5b5052;
  box-sizing: border-box;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  pointer-events: none;
  z-index: 25;
  transform-origin: center center;
  will-change: transform, opacity;
}

.shatter-pulse {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 16px var(--accent);
  transform-origin: center center;
  animation: dustRingExpand 0.28s ease-out forwards;
  pointer-events: none;
  z-index: 20;
}

/* T3: Eraser Dust Particles */
.eraser-dust {
  position: absolute;
  width: 5px;
  height: 5px;
  pointer-events: none;
  z-index: 25;
  will-change: transform, opacity;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes spawn {
  from { opacity: 0; transform: scale(.65); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  50% { opacity: .58; }
}

@keyframes appear {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes masonGlow {
  0%, 100% {
    border-color: rgba(242, 199, 126, 0.45);
    box-shadow: inset 0 0 0 1px rgba(242, 199, 126, 0.3), 0 0 8px rgba(242, 199, 126, 0.35);
    opacity: 0.85;
  }
  50% {
    border-color: rgba(242, 199, 126, 1);
    box-shadow: inset 0 0 0 2px rgba(242, 199, 126, 0.8), 0 0 20px rgba(242, 199, 126, 0.75);
    opacity: 1;
  }
}

@keyframes eraseBurst {
  0% { transform: scale(1); filter: brightness(1); }
  45% { transform: scale(1.12); filter: brightness(1.8); box-shadow: 0 0 22px #f27d70aa; }
  100% { transform: scale(.72); filter: brightness(1.4); opacity: .2; }
}

.cell.rewind-out .tile, .cell.rewind-out .stone {
  animation: rewindOut .18s ease-in both;
}

.cell.rewind-in .tile, .cell.rewind-in .stone {
  animation: rewindIn .28s cubic-bezier(.2, .9, .25, 1) both;
}

.cell.erasing .tile {
  animation: eraseTileOut .26s cubic-bezier(.3, .7, .4, 1) forwards;
}

@keyframes rewindOut {
  to { transform: translate(var(--rewind-x, 0), var(--rewind-y, 0)) scale(.94); opacity: .35; filter: brightness(1.45); }
}

@keyframes rewindIn {
  0% { transform: translate(var(--rewind-x, 0), var(--rewind-y, 0)) scale(.94); opacity: .45; filter: brightness(1.5); }
  72% { transform: translate(0, 0) scale(1.025); opacity: 1; }
  100% { transform: none; opacity: 1; filter: none; }
}

@keyframes eraseTileOut {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  45% { transform: scale(1.12) rotate(-3deg); filter: brightness(1.8); }
  100% { transform: scale(.15) rotate(12deg); opacity: 0; filter: brightness(2); }
}

.board.rewinding .cell {
  animation: rewindCell .38s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes rewindCell {
  0% { filter: brightness(1.6); }
  55% { filter: brightness(1.2); }
  100% { filter: none; }
}

/* Merge Pop Animation (120ms scale 1 -> 1.12 -> 1) */
@keyframes mergePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.tile.merge-pop {
  animation: mergePop 120ms ease-out forwards;
}

/* Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Debug Inspector (?debug=1)
   ========================================================================== */
.debug-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(16, 15, 17, 0.95);
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--font);
  z-index: 100;
  box-sizing: border-box;
}

.debug-panel.hidden {
  display: none;
}

.debug-header {
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 4px;
}

.debug-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.debug-label {
  color: var(--muted);
}

.debug-val {
  color: var(--text);
  font-weight: 700;
}

.debug-activations-title {
  margin-top: 4px;
  color: var(--muted);
}

.debug-activations {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.debug-badge {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--accent);
}

/* ==========================================================================
   Alternative Tile Ramp "v2" (Switched via URL parameter ?ramp=v2)
   Luminance strictly increasing from 2 to 4096; adjacent contrast ratio >= 1.15;
   Tile 2 vs empty cell >= 1.5; Stone vs tile 2 >= 1.5; Text contrast >= 4.5;
   Non-colour cue from 128 upward (strengthening inner ring and glow).
   ========================================================================== */
:root.ramp-v2, body.ramp-v2 {
  --t2: #423d3f;
  --t4: #4e4849;
  --t8: #5b5454;
  --t16: #69605e;
  --t32: #948375;
  --t64: #a69076;
  --t128: #be9f63;
  --t256: #d3b04c;
  --t512: #e4bf40;
  --t1024: #f2cd4b;
  --t2048: #fae16d;
  --t4096: #fff49e;
}

.ramp-v2 .v2 .tile-face, .ramp-v2 .tile-2 .tile-face,
.ramp-v2 .v4 .tile-face, .ramp-v2 .tile-4 .tile-face,
.ramp-v2 .v8 .tile-face, .ramp-v2 .tile-8 .tile-face,
.ramp-v2 .v16 .tile-face, .ramp-v2 .tile-16 .tile-face {
  color: #ffffff !important;
}

.ramp-v2 .v32 .tile-face, .ramp-v2 .tile-32 .tile-face,
.ramp-v2 .v64 .tile-face, .ramp-v2 .tile-64 .tile-face,
.ramp-v2 .v128 .tile-face, .ramp-v2 .tile-128 .tile-face,
.ramp-v2 .v256 .tile-face, .ramp-v2 .tile-256 .tile-face,
.ramp-v2 .v512 .tile-face, .ramp-v2 .tile-512 .tile-face,
.ramp-v2 .v1024 .tile-face, .ramp-v2 .tile-1024 .tile-face,
.ramp-v2 .v2048 .tile-face, .ramp-v2 .tile-2048 .tile-face,
.ramp-v2 .v4096 .tile-face, .ramp-v2 .tile-4096 .tile-face,
.ramp-v2 .tile-8192 .tile-face {
  color: #1e1715 !important;
}

/* Non-colour cue from 128 upward (strengthening inner ring and glow) */
.ramp-v2 .v128 .tile-face, .ramp-v2 .tile-128 .tile-face {
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4);
}
.ramp-v2 .v256 .tile-face, .ramp-v2 .tile-256 .tile-face {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55), inset 0 0 4px rgba(255, 255, 255, 0.15);
}
.ramp-v2 .v512 .tile-face, .ramp-v2 .tile-512 .tile-face {
  box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, 0.7), inset 0 0 7px rgba(255, 255, 255, 0.25);
}
.ramp-v2 .v1024 .tile-face, .ramp-v2 .tile-1024 .tile-face {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.85), inset 0 0 10px rgba(255, 255, 255, 0.35);
}
.ramp-v2 .v2048 .tile-face, .ramp-v2 .tile-2048 .tile-face {
  box-shadow: inset 0 0 0 3.5px #ffffff, inset 0 0 14px rgba(255, 255, 255, 0.5);
}
.ramp-v2 .v4096 .tile-face, .ramp-v2 .tile-4096 .tile-face,
.ramp-v2 .tile-8192 .tile-face {
  box-shadow: inset 0 0 0 4px #ffffff, inset 0 0 18px rgba(255, 255, 255, 0.65);
}

/* ==========================================================================
   Best Runs Trophy Button & Overlay Modal (S4)
   ========================================================================== */
.start-best-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

/* ==========================================================================
   Best Runs Redesign (T2 - Fidelity with design/best_runs_mock.html)
   Scoped CSS variables on #best-runs-overlay; pure vanilla CSS; zero external requests
   ========================================================================== */
#best-runs-overlay {
  --best-bg-modal: #241c19;
  --best-bg-card: #2b221f;
  --best-bg-card-hover: #342a26;
  --best-bg-chip: #221a17;
  --best-bg-close: #2f2521;
  --best-bg-footer: #1f1715;
  --best-accent-gold: #f2c779;
  --best-accent-gold-soft: rgba(242, 199, 121, 0.14);
  --best-text-cream: #fff5ed;
  --best-text-muted: #8e7f77;
  --best-border-subtle: #382c27;
  --best-border-chip: #3e3029;
  --best-border-close: #42332c;
  --best-border-divider: rgba(52, 40, 35, 0.6);
  --best-border-footer: rgba(52, 40, 35, 0.8);
  --best-scrollbar-thumb: #524037;
  --best-scrollbar-track: rgba(26, 20, 18, 0.6);
}

.best-runs-card {
  width: 100%;
  max-width: 440px;
  background: var(--best-bg-modal);
  border: 1px solid var(--best-border-subtle);
  border-radius: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

/* Header Section */
.best-runs-header {
  position: relative;
  text-align: center;
  padding: 26px 20px 15px;
  border-bottom: 1px solid var(--best-border-divider);
}

.best-runs-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--best-bg-close);
  border: 1px solid var(--best-border-close);
  color: var(--best-accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) {
  .best-runs-close-btn:hover {
    background: var(--best-accent-gold);
    color: var(--best-bg-modal);
    transform: scale(1.05);
  }
}

.best-runs-close-btn:active {
  transform: scale(0.95);
}

.best-runs-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--best-accent-gold);
  margin-bottom: 4px;
}

.best-runs-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--best-text-cream);
  letter-spacing: 0.025em;
  text-transform: uppercase;
  line-height: 1;
  margin: 0;
}

.best-runs-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--best-text-muted);
  letter-spacing: -0.01em;
  margin: 6px 0 0;
}

/* Records Scrollable List */
.best-runs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  margin: 0;
  max-height: min(460px, calc(100dvh - 180px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--best-scrollbar-thumb) var(--best-scrollbar-track);
}

.best-runs-list::-webkit-scrollbar {
  width: 6px;
}
.best-runs-list::-webkit-scrollbar-track {
  background: var(--best-scrollbar-track);
  border-radius: 9999px;
  margin: 8px 0;
}
.best-runs-list::-webkit-scrollbar-thumb {
  background: var(--best-scrollbar-thumb);
  border-radius: 9999px;
  border: 1px solid rgba(242, 199, 121, 0.15);
  transition: background-color 0.2s ease;
}
.best-runs-list::-webkit-scrollbar-thumb:hover {
  background: var(--best-accent-gold);
}

/* Record Item Card */
.record-card {
  background: var(--best-bg-card);
  border: 1px solid var(--best-border-subtle);
  border-radius: 16px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
              background-color 0.18s ease,
              border-color 0.18s ease,
              box-shadow 0.18s ease;
  box-sizing: border-box;
}

@media (hover: hover) {
  .record-card:hover {
    transform: translateY(-1px);
    background-color: var(--best-bg-card-hover);
    border-color: rgba(242, 199, 121, 0.35);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  }
}

.record-card.rank-top1 {
  border-color: rgba(242, 199, 121, 0.4);
  box-shadow: 0 0 10px rgba(242, 199, 121, 0.2);
}

.record-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.record-rank {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.record-rank.top-rank {
  background: var(--best-accent-gold-soft);
  color: var(--best-accent-gold);
  border: 1px solid rgba(242, 199, 121, 0.4);
  font-weight: 700;
}

.record-rank.muted-rank {
  background: var(--best-bg-chip);
  color: var(--best-text-muted);
  border: 1px solid var(--best-border-subtle);
  font-weight: 600;
}

.record-info {
  min-width: 0;
  overflow: hidden;
}

.record-score-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
}

.record-score {
  font-size: 17px;
  font-weight: 700;
  color: var(--best-text-cream);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.record-pts {
  font-size: 12px;
  font-weight: 600;
  color: var(--best-accent-gold);
}

.record-sub-row {
  font-size: 12px;
  font-weight: 500;
  color: var(--best-text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.record-dot-sep {
  color: #4d3f38;
}

.record-tile-label {
  color: #a4938a;
}

.record-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 5px;
}

.record-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--best-text-muted);
  letter-spacing: -0.01em;
}

.record-relics,
.record-relics-grid {
  display: grid;
  grid-template-columns: repeat(4, 20px);
  grid-template-rows: repeat(2, 20px);
  gap: 3px;
  justify-content: flex-end;
}

.record-relic-chip {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--best-bg-chip);
  border: 1px solid var(--best-border-chip);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.record-relic-chip.is-owned {
  opacity: 1;
  border-color: rgba(242, 199, 121, 0.45);
}

.record-relic-chip.is-unowned {
  opacity: 0.20;
  border-color: rgba(62, 48, 41, 0.4);
  filter: grayscale(0.85);
}

@media (hover: hover) {
  .record-relic-chip.is-owned:hover {
    border-color: var(--best-accent-gold);
    transform: scale(1.1);
  }
}

.record-relic-chip img,
.record-relic-chip svg,
.record-relic-chip .relic-monogram {
  width: 16px;
  height: 16px;
  max-width: 16px;
  max-height: 16px;
  display: block;
  transform: none;
}

/* Footer Section */
.best-runs-footer {
  padding: 12px 20px;
  background: var(--best-bg-footer);
  border-top: 1px solid var(--best-border-footer);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--best-text-muted);
  box-sizing: border-box;
}

.best-runs-footer-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.best-runs-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(242, 199, 121, 0.8);
  animation: bestRunsDotPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes bestRunsDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
}

@media (prefers-reduced-motion: reduce) {
  .best-runs-dot {
    animation: none;
  }
  .record-card {
    transition: none;
  }
}

.best-runs-footer-right {
  font-weight: 500;
  color: rgba(242, 199, 121, 0.9);
}

.best-runs-empty {
  padding: 32px 0;
  text-align: center;
  color: var(--best-text-muted);
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 380px) {
  .modal-overlay {
    padding: 8px;
  }
  .best-runs-card {
    width: min(calc(100vw - 16px), 440px);
  }
  .best-runs-header {
    padding: 20px 14px 12px;
  }
  .best-runs-close-btn {
    top: 14px;
    right: 14px;
  }
  .best-runs-list {
    padding: 10px;
    gap: 8px;
  }
  .record-card {
    padding: 8px 10px;
    gap: 6px;
  }
  .record-left {
    gap: 8px;
  }
  .record-score {
    font-size: 15px;
  }
}

.pause-time {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 6px 0 10px;
  font-variant-numeric: tabular-nums;
}

.pause-time strong {
  color: var(--text);
  font-weight: 900;
}

@media (prefers-reduced-motion: reduce) {
  .tile-face {
    transition: none !important;
  }
  .tile.candidate:before, .tile.target-candidate:before,
  .tile.selected:before, .tile.target-selected:before {
    transition: none !important;
  }
}

/* -------------------------------------------------------------
 * Clean Slate (Ascension) Sequence Visuals
 * Transform / Opacity / Box-shadow only - zero layout changes.
 * ------------------------------------------------------------- */
.clean-slate-banner,
.clean-slate-banner .stand-center-wrapper,
.clean-slate-banner .stand-copy {
  pointer-events: auto;
}

.clean-slate-banner:not(.hidden) .clean-slate-title {
  animation: standExitRight 0.38s cubic-bezier(0.6, 0, 0.8, 0.25) 1.47s forwards;
  will-change: transform;
}

.clean-slate-banner:not(.hidden) .stand-subtitle {
  animation: standExitLeft 0.38s cubic-bezier(0.6, 0, 0.8, 0.25) 1.47s forwards;
  will-change: transform;
}

.tile-clean-slate-charge,
.tile-clean-slate-charge .tile-face {
  z-index: 20 !important;
  box-shadow: 0 0 16px rgba(242, 199, 126, 0.58) !important;
  transition: box-shadow 0.45s ease-in-out;
}

.clean-slate-ring {
  position: absolute;
  border-radius: 50%;
  border: 3.5px solid var(--accent, #f2c77e);
  box-shadow: 0 0 20px rgba(242, 199, 126, 0.65), inset 0 0 12px rgba(242, 199, 126, 0.3);
  pointer-events: none;
  z-index: 15;
  will-change: transform, opacity;
}

.clean-slate-dust {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent, #f2c77e);
  box-shadow: 0 0 6px var(--accent, #f2c77e);
  pointer-events: none;
  z-index: 16;
  will-change: transform, opacity;
}

.clean-slate-popup {
  position: absolute;
  font-family: inherit;
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 800;
  color: var(--accent, #f2c77e);
  text-shadow: 0 0 12px rgba(242, 199, 126, 0.7), 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 25;
  transform: translate(-50%, -50%);
  animation: cleanSlatePopupFloat 1.2s cubic-bezier(0.15, 0.85, 0.3, 1) forwards;
}

@keyframes cleanSlatePopupFloat {
  0% {
    transform: translate(-50%, 0) scale(0.85);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -10px) scale(1.1);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -18px) scale(1.0);
    opacity: 1;
  }
  80% {
    transform: translate(-50%, -28px) scale(1.0);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -36px) scale(0.95);
    opacity: 0;
  }
}

.clean-slate-banner h2.clean-slate-title {
  font-size: clamp(48px, 14vw, 72px);
  letter-spacing: -0.04em;
  color: var(--accent, #f2c77e);
  margin: 0;
  text-shadow: 0 0 12px rgba(242, 199, 126, 0.8), 0 0 38px rgba(242, 168, 78, 0.6);
}

.clean-slate-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent, #f2c77e);
  background: rgba(242, 199, 126, 0.12);
  border: 1px solid rgba(242, 199, 126, 0.45);
  border-radius: 4px;
  padding: 2px 6px;
  text-transform: uppercase;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .clean-slate-banner:not(.hidden) .clean-slate-title,
  .clean-slate-banner:not(.hidden) .stand-subtitle {
    animation: none !important;
    transform: none !important;
  }
  .tile-clean-slate-charge,
  .tile-clean-slate-charge .tile-face {
    animation: none !important;
    box-shadow: none !important;
  }
  .clean-slate-ring {
    display: none !important;
  }
  .clean-slate-dust {
    display: none !important;
  }
}

/* ==========================================================================
   B4 Entry Point Button (Start Overlay)
   ========================================================================== */
.trophy-btn.leaderboard-btn {
  right: 60px;
}

/* ==========================================================================
   B1 Game-Over Ranking Card & Components
   ========================================================================== */
#end-overlay.modal-overlay {
  position: fixed;
  inset: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 12px;
  padding-top: max(0px, env(safe-area-inset-top));
  padding-bottom: max(0px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: none;
}
#end-overlay.modal-overlay::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.gameover-card, .modal.gameover-card {
  width: 100%;
  max-width: 400px;
  background: #261f22;
  border: 1.5px solid #3d3134;
  border-radius: clamp(16px, 2.8vh, 28px);
  padding: clamp(10px, 1.8vh, 22px) 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(0px, calc(0.8cqh - 2px), 8px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  position: relative;
  box-sizing: border-box;
  margin: auto;
  container-name: gameover-card;
  container-type: size;
  height: min(calc(100vh - 2 * clamp(12px, 2.5vh, 24px)), 860px);
  height: min(calc(100dvh - 2 * clamp(12px, 2.5dvh, 24px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)), 860px);
  max-height: 860px;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(2px, 0.4vh, 4px);
}

.run-complete-tag {
  font-size: clamp(10px, 1.5vh, 11px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
}

.modifier-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: 1px solid rgba(244, 199, 127, 0.4);
  background: rgba(244, 199, 127, 0.07);
  padding: 3px 8px;
  border-radius: 8px;
  text-transform: uppercase;
}

.score-display {
  font-size: clamp(30px, 4.8vh, 52px);
  font-size: clamp(30px, 4.8dvh, 52px);
  font-size: clamp(30px, 5.2cqh, 52px);
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  color: var(--text);
  margin: 0 0 clamp(4px, 0.8vh, 16px) 0;
  letter-spacing: -0.02em;
}

.mini-board-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: clamp(4px, 0.8vh, 16px);
}

.mini-board {
  width: clamp(80px, 15vh, 140px);
  width: clamp(80px, 15dvh, 140px);
  width: clamp(80px, 15cqh, 140px);
  height: clamp(80px, 15vh, 140px);
  height: clamp(80px, 15dvh, 140px);
  height: clamp(80px, 15cqh, 140px);
  margin: 0 auto;
  background: #141012;
  border-radius: 6px;
  padding: clamp(3px, 0.5vh, 5px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(2px, 0.4vh, 4px);
  border: 1px solid #33282b;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}

.mini-board span {
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(8px, 1.2vh, 10px);
  user-select: none;
  background: #2a2527;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(4px, 0.7vh, 7px);
  margin: 0 0 clamp(6px, 1vh, 14px) 0;
}

.stat-cell {
  background: #1c1618;
  border: 1px solid #3d3134;
  border-radius: 10px;
  padding: clamp(4px, 0.7vh, 8px) clamp(6px, 1.2vw, 12px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
}

.stat-cell.span-full {
  grid-column: span 2;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat-value {
  font-size: clamp(13px, 2vh, 16px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.relics-section {
  text-align: center;
  margin-bottom: clamp(6px, 1vh, 14px);
}

.relics-title {
  font-size: clamp(10px, 1.5vh, 11px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: clamp(3px, 0.5vh, 8px);
}

.relics-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.end-relics-list {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
  gap: clamp(3px, 0.8vw, 6px);
  margin: 0;
  padding: 1px 0;
}

.end-relics-list::-webkit-scrollbar {
  display: none;
}

.relic-slot {
  width: 44px;
  height: 44px;
  background: #2a2225;
  border: 1px solid #3d3134;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  box-sizing: border-box;
}

.relic-slot:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.relic-slot svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.relic-slot .relic-badge-sub {
  position: absolute;
  bottom: -4px;
  background: #171113;
  border: 1px solid #785a32;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 800;
  color: var(--accent);
  padding: 0 3px;
  line-height: 1.2;
}

/* Ranking Card Panel */
.global-ranking-panel {
  background: linear-gradient(175deg, #302629 0%, #1f181a 100%);
  border: 1px solid #785a32;
  border-radius: 14px;
  padding: 13px 14px 11px 14px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(244, 199, 127, 0.2);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  box-sizing: border-box;
}

.global-ranking-panel:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.global-ranking-panel::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(244, 199, 127, 0.18) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

.glass-shimmer {
  position: absolute;
  top: -50%;
  left: -160%;
  width: 60%;
  height: 200%;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(244, 199, 127, 0.16) 50%,
    rgba(255, 255, 255, 0.22) 53%,
    rgba(244, 199, 127, 0.16) 56%,
    rgba(255, 255, 255, 0.03) 75%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(25deg);
  pointer-events: none;
  display: none;
  z-index: 2;
}

.global-ranking-panel.shimmer-active .glass-shimmer {
  display: block;
  animation: glassSweep 5s ease-in-out infinite;
}

@keyframes glassSweep {
  0% { left: -160%; opacity: 0; }
  8% { opacity: 1; }
  38% { left: 200%; opacity: 1; }
  40% { opacity: 0; left: 200%; }
  100% { left: 200%; opacity: 0; }
}

.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(3px, 0.6vh, 8px);
  padding-bottom: clamp(2px, 0.4vh, 6px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 3;
}

.ranking-header-title {
  font-size: clamp(10px, 1.5vh, 11px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.ranking-header-title svg {
  fill: currentColor;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.ranking-meta-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ranking-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 8px;
  height: 24px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(244, 199, 127, 0.35);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.ranking-share-btn:hover {
  background: rgba(244, 199, 127, 0.15);
  border-color: var(--accent);
  color: #fcd99a;
  transform: translateY(-1px);
}

.ranking-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: clamp(36px, 5.5vh, 52px);
  position: relative;
  z-index: 3;
}

.rank-left {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.rank-number {
  font-size: clamp(24px, 3.8vh, 32px);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.01em;
  text-shadow: 0 2px 8px rgba(244, 199, 127, 0.25);
}

.rank-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.rank-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.percentile-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(244, 199, 127, 0.16);
  border: 1px solid rgba(244, 199, 127, 0.4);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  letter-spacing: 0.02em;
}

.percentile-badge.pill-btn {
  cursor: pointer;
  background: var(--accent);
  color: #171113;
  border-color: var(--accent);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.percentile-badge.pill-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.total-players-text {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 4px;
}

.ranking-footer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: clamp(4px, 0.7vh, 8px);
  padding-top: clamp(3px, 0.5vh, 6px);
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
  z-index: 3;
}

.status-ranked {
  color: #9fe29f;
}

.status-ranked svg {
  fill: #9fe29f;
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.status-pending {
  color: var(--accent);
}

.status-unranked {
  color: var(--muted);
}

.status-unranked svg {
  fill: var(--muted);
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.pending-loader {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(244, 199, 127, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.btn-play-again {
  width: 100%;
  background: var(--accent);
  color: #171113;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(244, 199, 127, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.action-buttons .btn-play-again {
  min-height: unset;
  height: 43px;
}

.action-buttons .btn-home,
.action-buttons .btn-copy-log-half {
  min-height: unset;
  height: 39px;
}

.btn-play-again:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.secondary-action-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-home,
.btn-copy-log-half {
  flex: 1;
  background: #362c30;
  color: var(--text);
  border: 1px solid #3d3134;
  border-radius: 12px;
  padding: 11px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.btn-home:hover,
.btn-copy-log-half:hover {
  background: #413539;
  border-color: #554448;
}

/* Compact Responsive Variants for Game-Over */
@media (max-width: 380px) {
  .gameover-card {
    padding: clamp(8px, 1.4vh, 14px) 14px;
    border-radius: 18px;
  }
  .score-display {
    font-size: clamp(30px, 4.8vh, 52px);
  }
  #global-ranking-panel .rank-number {
    font-size: 28px;
  }
  .mini-board {
    width: clamp(80px, 13vh, 100px);
    height: clamp(80px, 13vh, 100px);
  }
  .btn-home,
  .btn-copy-log-half {
    font-size: 11px;
    padding: 8px 6px;
  }
}

@media (max-height: 760px) {
  #end-overlay.modal-overlay {
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
  .gameover-card {
    padding: clamp(8px, 1.4vh, 16px) clamp(12px, 2.5vw, 18px);
    border-radius: 18px;
  }
  .score-display {
    font-size: clamp(30px, 4.8vh, 52px);
    font-size: clamp(30px, 4.8dvh, 52px);
    font-size: clamp(30px, 5.2cqh, 52px);
    margin: 0;
  }
  .mini-board-wrapper {
    margin: 0;
  }
  .mini-board {
    width: clamp(80px, 15vh, 140px);
    width: clamp(80px, 15dvh, 140px);
    width: clamp(80px, 15cqh, 140px);
    height: clamp(80px, 15vh, 140px);
    height: clamp(80px, 15dvh, 140px);
    height: clamp(80px, 15cqh, 140px);
    gap: 2px;
    padding: 3px;
  }
  .mini-board span {
    font-size: 8px;
  }
  .stats-grid {
    gap: clamp(3px, 0.5vh, 5px);
    margin: 0;
  }
  .stat-cell {
    padding: clamp(3px, 0.5vh, 6px) clamp(6px, 1.2vw, 10px);
  }
  .stat-seed-cell,
  #end-seed-cell {
    display: none !important;
  }
  .relics-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
  }
  .relics-title {
    display: none;
  }
  .end-relics-list {
    margin: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    gap: clamp(3px, 0.8vw, 6px);
  }
  .end-relics-list::-webkit-scrollbar {
    display: none;
  }
  .relic-chip {
    width: clamp(26px, 3.8vh, 32px);
    height: clamp(26px, 3.8vh, 32px);
    border-radius: 6px;
  }
  .relic-chip svg {
    width: clamp(14px, 2vh, 18px);
    height: clamp(14px, 2vh, 18px);
  }
  .global-ranking-panel {
    margin: 0;
    flex-shrink: 0;
    padding: clamp(6px, 1vh, 9px) clamp(8px, 1.5vw, 12px);
  }
  .action-buttons {
    margin: 0;
    flex-shrink: 0;
  }
}

@container gameover-card (min-height: 650px) {
  #end-seed-cell,
  .stat-seed-cell {
    display: flex !important;
  }
  .relics-title {
    display: block !important;
  }
  .relics-section {
    display: block !important;
  }
}

@media (max-height: 560px) {
  #end-overlay.modal-overlay {
    align-items: flex-start;
    padding-top: clamp(6px, 1.2vh, 16px);
    padding-bottom: clamp(6px, 1.2vh, 16px);
  }
  .gameover-card, .modal.gameover-card {
    height: auto;
    min-height: min-content;
    margin: auto 0;
  }
  .action-buttons {
    position: sticky;
    bottom: 0;
    background: #261f22;
    padding-top: 6px;
    z-index: 5;
  }
}

/* ==========================================================================
   B2 Global Leaderboard Overlay Modal
   ========================================================================== */
#leaderboard-overlay.leaderboard-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 8, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}

.leaderboard-modal, .modal.leaderboard-modal {
  width: 100%;
  height: 100%;
  max-height: 840px;
  max-width: 412px;
  background-color: #251e1c;
  border: 1px solid #44352f;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(244, 200, 121, 0.08);
  position: relative;
  margin: auto;
}

.modal-header {
  padding: 20px 20px 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  border-bottom: 1px solid rgba(68, 53, 47, 0.35);
}

.header-text-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}

.header-eyebrow {
  font-size: 11px;
  line-height: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.6px;
  color: var(--text);
  text-transform: uppercase;
  line-height: 1.1;
  margin: 0;
}

.shimmer-text {
  background: linear-gradient(90deg, #F4C879 0%, #FFFFFF 50%, #F4C879 100%);
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: shimmer 4s linear infinite;
}

@keyframes shimmer {
  to { background-position: 200% center; }
}

.header-subtitle {
  font-size: 12px;
  color: var(--soft);
  font-weight: 500;
  margin-top: 1px;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #302522;
  border: 1px solid #44352f;
  color: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.close-btn:hover {
  background: #3a2e2a;
  color: var(--text);
  border-color: var(--accent);
  transform: scale(1.05);
}

.category-tabs-wrapper {
  padding: 10px 18px 8px 18px;
  background: rgba(25, 22, 22, 0.4);
}

.category-tabs {
  display: flex;
  background: #1B1514;
  border: 1px solid #44352f;
  border-radius: 12px;
  padding: 3px;
  gap: 4px;
}

.category-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #766a64;
  font-family: inherit;
  font-size: 11px;
  line-height: 13px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 8px 6px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-transform: uppercase;
}

.category-tab-btn:hover:not(.active) {
  color: var(--soft);
  background: rgba(68, 53, 47, 0.25);
}

.category-tab-btn.active {
  background: #3a2e2a;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(244, 200, 121, 0.3);
}

/* Top 3 Podium */
.podium-section {
  padding: 16px 16px 8px 16px;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 8px;
  align-items: flex-end;
  position: relative;
}

.podium-card {
  background: #302522;
  border: 1px solid #44352f;
  border-radius: 14px;
  padding: 12px 8px 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.podium-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #44352f;
  z-index: 2;
}

.podium-slot-1 {
  position: relative;
  overflow: visible;
  transform: translateY(-4px);
}

.podium-card.rank-1 {
  background: linear-gradient(180deg, #372A24 0%, #291F1C 100%);
  border-color: rgba(244, 200, 121, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 20px rgba(244, 200, 121, 0.12);
  padding-top: 14px;
  padding-bottom: 12px;
}

.podium-card.rank-1::before {
  background: linear-gradient(90deg, #DDAA5E, #F4C879, #DDAA5E);
}

.trophy-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #F4C879, #C8923B);
  color: #19140C;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 10px rgba(244, 200, 121, 0.3);
  border: 1.5px solid #201A18;
  z-index: 10;
}

.trophy-badge svg {
  width: 12px;
  height: 12px;
  fill: #19140C;
}

.podium-card.rank-2::before {
  background: #D2D7DF;
}

.podium-card.rank-3::before {
  background: #E2A06E;
}

.podium-shimmer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  border-radius: 13px;
}

.podium-shimmer::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -130%;
  width: 60%;
  height: 200%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.04) 20%,
    rgba(255, 255, 255, 0.16) 50%,
    rgba(255, 255, 255, 0.04) 80%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(25deg);
  animation: glassShimmer 5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.podium-card.rank-1 .podium-shimmer::after {
  background: linear-gradient(
    90deg,
    rgba(244, 200, 121, 0) 0%,
    rgba(244, 200, 121, 0.06) 20%,
    rgba(255, 245, 215, 0.25) 50%,
    rgba(244, 200, 121, 0.06) 80%,
    rgba(244, 200, 121, 0) 100%
  );
  animation-delay: 0.2s;
}

.podium-card.rank-2 .podium-shimmer::after {
  animation-delay: 0.8s;
}

.podium-card.rank-3 .podium-shimmer::after {
  animation-delay: 1.4s;
}

@keyframes glassShimmer {
  0% { left: -130%; }
  25% { left: 170%; }
  100% { left: 170%; }
}

.avatar-wrapper {
  position: relative;
  margin-bottom: 6px;
  z-index: 3;
}

.podium-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #231C1A;
  border: 2px solid #44352f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
  box-sizing: border-box;
}

.rank-1 .podium-avatar {
  width: 48px;
  height: 48px;
  border-color: var(--accent);
  font-size: 15px;
  color: var(--accent);
  box-shadow: 0 0 12px rgba(244, 200, 121, 0.28);
}

.rank-2 .podium-avatar {
  border-color: #D2D7DF;
  color: #D2D7DF;
}

.rank-3 .podium-avatar {
  border-color: #E2A06E;
  color: #E2A06E;
}

.podium-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
  letter-spacing: -0.2px;
  margin-bottom: 2px;
  z-index: 3;
}

.podium-card.rank-1 .podium-name {
  color: #FFF6EC;
  max-width: 104px;
  font-size: 13px;
}

.podium-score {
  font-size: 15px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.3px;
  line-height: 1.1;
  margin-bottom: 4px;
  z-index: 3;
}

.podium-card.rank-1 .podium-score {
  font-size: 18px;
  text-shadow: 0 0 12px rgba(244, 200, 121, 0.4);
}

.podium-tile-pill {
  background: #231C1A;
  border: 1px solid #44352f;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  color: var(--soft);
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  z-index: 3;
}

.rank-1 .podium-tile-pill {
  background: rgba(244, 200, 121, 0.15);
  border-color: rgba(244, 200, 121, 0.35);
  color: var(--accent);
}

.podium-rank-tag {
  font-size: 10px;
  font-weight: 900;
  margin-top: 4px;
  color: var(--muted);
  letter-spacing: 0.5px;
  z-index: 3;
}

.rank-1 .podium-rank-tag { color: var(--accent); }
.rank-2 .podium-rank-tag { color: #D2D7DF; }
.rank-3 .podium-rank-tag { color: #E2A06E; }

/* Rankings List */
.list-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 18px;
  font-size: 10px;
  line-height: 12px;
  height: 26px;
  box-sizing: border-box;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  border-top: 1px solid rgba(68, 53, 47, 0.3);
  border-bottom: 1px solid rgba(68, 53, 47, 0.3);
  background: rgba(25, 22, 22, 0.6);
}

.rankings-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #44352f transparent;
  -webkit-overflow-scrolling: touch;
}

.rankings-scroll-area::-webkit-scrollbar {
  width: 5px;
}

.rankings-scroll-area::-webkit-scrollbar-thumb {
  background-color: #44352f;
  border-radius: 10px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 32px 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #302522;
  border: 1px solid #44352f;
  border-radius: 12px;
  text-align: left;
  transition: transform 0.15s ease, background-color 0.15s ease;
  box-sizing: border-box;
}

.ranking-row:hover {
  background: #3a2e2a;
  border-color: #5a473e;
}

.ranking-row.is-current-user {
  background: rgba(244, 200, 121, 0.08);
  border-color: rgba(244, 200, 121, 0.5);
}

.ranking-row .rank-number {
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  color: #766a64;
  letter-spacing: -0.3px;
  text-shadow: none;
  min-width: 32px;
  text-align: center;
  white-space: nowrap;
}

.row-avatar-box {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.row-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #251D1B;
  border: 1px solid #44352f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--soft);
  box-sizing: border-box;
}

.player-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-username {
  font-size: 13px;
  line-height: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.you-pill {
  font-size: 9px;
  line-height: 11px;
  font-weight: 900;
  background: var(--accent);
  color: #120F0D;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.player-subdetails {
  font-size: 11px;
  line-height: 13px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.sub-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
}

.player-score-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.player-score-val {
  font-size: 15px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.2px;
}

.player-tile-tag {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: #251D1A;
  color: var(--soft);
  border: 1px solid #44352f;
}

/* Pinned Bottom User Card */
.current-user-pinned {
  background: linear-gradient(180deg, #2D2320 0%, #251D1B 100%);
  border-top: 1px solid rgba(244, 200, 121, 0.28);
  padding: 10px 16px;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.45);
  z-index: 10;
  box-sizing: border-box;
}

.pinned-eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.pinned-label {
  font-size: 10px;
  line-height: 12px;
  font-weight: 900;
  letter-spacing: 1.2px;
  color: var(--accent);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lb-sync-bar {
  font-size: 10px;
  line-height: 12px;
  height: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-refresh-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--accent);
  padding: 0;
  width: 14px;
  height: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background-color 0.15s ease;
  position: relative;
}

.lb-refresh-btn::after {
  content: '';
  position: absolute;
  inset: -11px;
}

.lb-refresh-btn:hover {
  background: rgba(244, 199, 127, 0.15);
  transform: rotate(30deg);
}

.pinned-row-card {
  background: #342824;
  border: 1px solid rgba(244, 200, 121, 0.35);
  border-radius: 12px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 46px 32px 1fr auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  box-sizing: border-box;
}

@media (max-width: 370px) {
  .pinned-row-card {
    min-height: 63px;
  }
}



.pinned-rank-badge {
  font-size: 13px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.btn-name-edit {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  transition: transform 0.15s ease;
  vertical-align: middle;
}

.btn-name-edit:hover:not(:disabled) {
  transform: scale(1.2);
}

.btn-name-edit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.lb-state-msg {
  padding: 30px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.lb-retry-btn {
  background: var(--accent);
  color: #171113;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

/* ==========================================================================
   B3 Name Sheet Modal
   ========================================================================== */
.ns-overlay {
  z-index: 60;
  align-items: flex-end;
  padding: 0;
}

.ns-sheet {
  width: 100%;
  max-width: 412px;
  background: #251e1c;
  border: 1px solid #44352f;
  border-radius: 22px 22px 0 0;
  padding: 22px 20px 24px 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  margin: 0 auto;
  box-sizing: border-box;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.ns-header {
  text-align: center;
  margin-bottom: 16px;
}

.ns-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0 0 4px 0;
}

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

.ns-body {
  margin-bottom: 16px;
}

.ns-input {
  width: 100%;
  background: #1b1514;
  border: 1px solid #44352f;
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 14px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ns-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(244, 199, 127, 0.25);
}

.ns-error, .ns-error-box {
  color: #f87171;
  font-size: 11px;
  font-weight: 600;
  margin-top: 8px;
  text-align: center;
}

.ns-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ns-btn-save {
  min-height: 44px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ns-btn-generated {
  min-height: 40px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ns-btn-cancel {
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  border: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ns-btn-cancel:hover {
  color: var(--text);
}

/* ==========================================================================
   B4 Share Sheet & Outcome 8 Ranking Card Additions
   ========================================================================== */
.share-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 10, 0.68);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 60;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.share-sheet-backdrop.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.share-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: calc(100% - 24px);
  width: calc(100vw - 24px);
  max-width: 400px;
  z-index: 70;
  background: linear-gradient(180deg, #252124 0%, #191719 100%);
  border-top: 1px solid #4a3a3e;
  border-left: 1px solid #352c2f;
  border-right: 1px solid #352c2f;
  border-radius: 22px 22px 0 0;
  padding: 10px 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.75);
  box-sizing: border-box;
  transform: translate(-50%, 0);
  opacity: 1;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s ease;
}

.share-sheet.hidden {
  display: none !important;
  transform: translate(-50%, 105%);
  opacity: 0;
  pointer-events: none;
}

.share-sheet .grab-handle {
  width: 36px;
  height: 4px;
  background: #40393b;
  border-radius: 99px;
  margin: 0 auto 2px;
  flex-shrink: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
}

.sheet-header .header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sheet-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  margin: 0;
}

.mode-chip {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  background: #2c282a;
  border: 1px solid #40393b;
  color: var(--accent);
  white-space: nowrap;
}

.mode-chip.free {
  color: var(--soft);
}

.share-sheet .close-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  background: #2c282a;
  border: 1px solid #40393b;
  color: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  box-sizing: border-box;
}

.share-sheet .close-btn:active {
  transform: scale(0.96);
}

.preview-bubble {
  background: #242123;
  border: 1px solid #40393b;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}

.preview-msg {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.preview-name {
  font-weight: 700;
  color: var(--accent);
  display: inline-block;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.preview-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #141315;
  border: 1px solid #393336;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--soft);
  overflow: hidden;
  min-height: 36px;
  box-sizing: border-box;
}

.preview-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.status-box {
  background: #141315;
  border: 1px solid #393336;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--soft);
  box-sizing: border-box;
  min-height: 36px;
}

.status-box.error {
  border-color: rgba(242, 125, 112, 0.45);
  background: rgba(242, 125, 112, 0.08);
  color: var(--warn);
  justify-content: space-between;
}

.status-box.disabled-msg {
  color: var(--muted);
}

.share-sheet .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #40393b;
  border-top-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.8s linear infinite;
  box-sizing: border-box;
}

.share-sheet .meta-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0 16px;
}

.expiry-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.expiry-line.soon {
  color: var(--accent);
}

.free-note {
  font-size: 11px;
  color: var(--muted);
}

.actions-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

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

.share-sheet .btn-sheet {
  min-height: 44px;
  min-width: 36px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.share-sheet .btn-sheet:active:not(:disabled) {
  transform: scale(0.98);
}

.share-sheet .btn-sheet:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.share-sheet .btn-sheet-primary {
  background: var(--accent);
  color: #171113;
}

.share-sheet .btn-sheet-secondary {
  background: #2c282a;
  border-color: #40393b;
  color: var(--text);
}

.share-sheet .btn-copied {
  background: #28362a;
  border-color: #4c6e50;
  color: #b7e8bd;
}

.share-sheet .btn-retry {
  min-height: 36px;
  min-width: 36px;
  padding: 0 14px;
  width: auto;
  flex-shrink: 0;
  background: var(--warn);
  color: #260d0a;
  font-size: 12px;
  font-weight: 800;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-sizing: border-box;
}

/* Outcome 8 Specific Additions */
.ranking-share-btn-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  min-height: 36px;
  min-width: 36px;
  border-radius: 9999px;
  background: var(--accent);
  color: #171113;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.ranking-share-btn-gold:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.ranking-share-btn-gold:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ranking-share-btn-gold .spinner-sm {
  width: 12px;
  height: 12px;
  border: 2px solid #171113;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-sizing: border-box;
}

.free-run-muted-text {
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 500;
  display: block;
}

.play-daily-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  padding: 0 8px;
  color: var(--accent);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.play-daily-link:hover {
  text-decoration: underline;
}

.footer-left-unranked {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

@media (max-width: 340px) {
  .share-sheet {
    padding: 8px 12px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    gap: 9px;
  }
  .share-sheet .meta-stack {
    margin: 12px 0 12px;
  }
  .sheet-title {
    font-size: 14px;
  }
  .preview-bubble {
    padding: 10px 12px;
    gap: 6px;
  }
  .preview-msg {
    font-size: 13px;
  }
  .share-sheet .btn-sheet {
    min-height: 40px;
    font-size: 12px;
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .share-sheet,
  .share-sheet-backdrop,
  .share-sheet .btn-sheet {
    transition: none !important;
  }
  .share-sheet .spinner,
  .ranking-share-btn-gold .spinner-sm {
    animation: none !important;
  }
}

/* ==========================================================================
   Challenge Preview Card & In-Run Elements
   ========================================================================== */
#challenge-overlay.modal-overlay {
  position: fixed;
  inset: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 12px;
  padding-top: max(0px, env(safe-area-inset-top));
  padding-bottom: max(0px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 15;
}

#challenge-overlay.modal-overlay::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.challenge-overlay {
  z-index: 15;
}

.challenge-card {
  max-width: 370px;
  background: linear-gradient(145deg, #261f1c, #161311);
  border: 1px solid #3b322a;
  border-radius: 24px;
  padding: 16px 18px;
  box-sizing: border-box;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: Outfit, sans-serif;
  position: relative;
}

.challenge-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.challenge-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accentInk);
  font-family: Outfit, sans-serif;
  font-weight: 900;
  font-size: 13px;
  display: grid;
  place-items: center;
  letter-spacing: -0.05em;
  user-select: none;
}

.challenge-card-content {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Skeleton Loading Shimmer */
.challenge-skeleton-shimmer {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 8px 0;
  animation: pulse 1.8s ease-in-out infinite;
}

.challenge-skeleton-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #2a221b;
  margin-bottom: 10px;
}

.challenge-skeleton-line {
  height: 12px;
  background: #2b231d;
  border-radius: 6px;
  margin-bottom: 8px;
}

.challenge-skeleton-line.short { width: 90px; height: 10px; }
.challenge-skeleton-line.med { width: 140px; height: 16px; margin-bottom: 12px; }

.challenge-skeleton-score {
  width: 160px;
  height: 40px;
  background: #2b231d;
  border-radius: 8px;
  margin-bottom: 14px;
}

.challenge-skeleton-board {
  width: 116px;
  height: 116px;
  background: #14110f;
  border: 1px solid #2b241f;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
  padding: 3px;
  box-sizing: border-box;
  margin-bottom: 12px;
}

.challenge-skeleton-cell {
  background: #241e1a;
  border-radius: 3px;
}

.challenge-skeleton-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  margin-bottom: 14px;
}

.challenge-skeleton-stat {
  height: 42px;
  background: #171311;
  border: 1px solid #2f2722;
  border-radius: 10px;
}

.challenge-loading-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-top: 4px;
}

.challenge-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(242, 199, 126, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  box-sizing: border-box;
}

/* Sender Profile */
.challenge-sender-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 2px 0 8px 0;
}

.challenge-avatar-wrap {
  position: relative;
  margin-bottom: 8px;
}

.challenge-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(180deg, #2a221b, #14100d);
  border: 2px solid rgba(242, 199, 126, 0.6);
  box-shadow: 0 0 16px rgba(242, 199, 126, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
}

.challenge-avatar-initials {
  font-family: Outfit, sans-serif;
  font-size: 18px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  user-select: none;
}

.challenge-tagline {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(242, 199, 126, 0.85);
  margin-bottom: 2px;
}

.challenge-sender-name {
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  margin: 0 0 6px 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.challenge-badges-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.challenge-mode-badge {
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid rgba(242, 199, 126, 0.35);
  background: rgba(242, 199, 126, 0.12);
  color: var(--accent);
}

.challenge-mode-badge.free {
  background: #26201b;
  border-color: #3d332d;
  color: var(--text);
}

.challenge-mode-badge.expired {
  background: rgba(136, 19, 55, 0.25);
  border-color: rgba(225, 29, 72, 0.4);
  color: #fda4af;
}

.challenge-mode-badge.own {
  background: rgba(245, 186, 104, 0.2);
  border-color: rgba(245, 186, 104, 0.5);
  color: #fcd34d;
}

.challenge-mode-badge.completed {
  background: rgba(6, 78, 59, 0.35);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.challenge-mode-badge.completed.won {
  background: rgba(6, 78, 59, 0.35);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.challenge-mode-badge.completed.lost {
  background: rgba(242, 125, 112, 0.15);
  border: 1px solid var(--warn);
  color: var(--warn);
}

.challenge-mode-badge.completed.tied {
  background: #26201b;
  border: 1px solid #3d332d;
  color: var(--soft);
}

.challenge-expiry-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.challenge-expiry-tag.expiring-soon {
  color: #f5ba68;
  font-weight: 700;
}

/* Score Callout */
.challenge-score-callout {
  text-align: center;
  margin: 4px 0 8px 0;
}

.challenge-score-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.challenge-score-val {
  font-size: 38px;
  font-weight: 900;
  color: var(--text);
  font-family: Outfit, sans-serif;
  line-height: 1.1;
  margin: 2px 0;
  letter-spacing: -0.02em;
}

.challenge-score-val.dimmed {
  color: var(--muted);
}

/* Mini Board */
.challenge-mini-board-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px 0;
}

.challenge-mini-board {
  width: 116px;
  height: 116px;
  background: #14110f;
  border: 1px solid #2b241f;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2.5px;
  padding: 3px;
  box-sizing: border-box;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

.challenge-mini-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-weight: 800;
  font-size: 8px;
  line-height: 1;
  user-select: none;
  font-family: Outfit, sans-serif;
  box-sizing: border-box;
}

.challenge-mini-tile.tile-empty {
  background: #201c1a;
}

.challenge-mini-tile.tile-2 { background: var(--t2); color: #fbf8f3; }
.challenge-mini-tile.tile-4 { background: var(--t4); color: #d8cdbe; }
.challenge-mini-tile.tile-8 { background: var(--t8); color: #fbf8f3; }
.challenge-mini-tile.tile-16 { background: var(--t16); color: #211d1b; }
.challenge-mini-tile.tile-32 { background: var(--t32); color: #211d1b; }
.challenge-mini-tile.tile-64 { background: var(--t64); color: #211d1b; }
.challenge-mini-tile.tile-128 { background: var(--t128); color: #2a2116; }
.challenge-mini-tile.tile-256 { background: var(--t256); color: #2a2116; }
.challenge-mini-tile.tile-512 { background: var(--t512); color: #2a2116; }
.challenge-mini-tile.tile-1024 { background: var(--t1024); color: #2a2116; }
.challenge-mini-tile.tile-2048 { background: var(--t2048); color: #2a2116; }
.challenge-mini-tile.tile-4096 { background: var(--t4096); color: #2a2116; }

.challenge-mini-tile.stone-face,
.challenge-mini-tile.mini-stone {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: repeating-linear-gradient(135deg, #282426 0 3px, #171517 3px 6px);
  border: 1.5px solid #5b5052;
  color: #b5a7a4;
  box-shadow: inset 0 -2px 4px #0008;
  font-size: 8px;
  font-weight: 900;
  box-sizing: border-box;
}

.challenge-mini-board-placeholder {
  width: 100%;
  max-width: 260px;
  padding: 12px 14px;
  background: #171311;
  border: 1px dashed #3d332d;
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin: 6px auto;
  box-sizing: border-box;
}

/* Stats */
.challenge-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  margin-bottom: 6px;
}

.challenge-stat-box {
  background: #171311;
  border: 1px solid #2f2722;
  border-radius: 10px;
  padding: 6px 10px;
  text-align: left;
}

.challenge-stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.challenge-stat-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
}

.challenge-stat-val.gold {
  color: var(--accent);
}

.challenge-seed-box {
  background: #171311;
  border: 1px solid #2f2722;
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
}

.challenge-seed-val {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
}

/* Relics Row */
.challenge-relics-wrap {
  width: 100%;
  text-align: center;
  margin: 4px 0 8px 0;
}

.challenge-relics-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
}

.challenge-relics-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
  max-width: 100%;
}

.challenge-relic-chip {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #28211c;
  border: 1px solid #3d332c;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
}

.challenge-relic-chip img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.challenge-relic-chip .relic-monogram {
  font-size: 10px;
  font-weight: 900;
  color: var(--accent);
}

/* Banners & Cards */
.challenge-banner {
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
  margin-bottom: 8px;
  box-sizing: border-box;
  width: 100%;
}

.challenge-banner.gold {
  background: rgba(242, 199, 126, 0.12);
  border: 1px solid rgba(242, 199, 126, 0.3);
}

.challenge-banner.rose {
  background: rgba(136, 19, 55, 0.2);
  border: 1px solid rgba(225, 29, 72, 0.35);
}

.challenge-banner.dark,
.challenge-banner.tied {
  background: #171311;
  border: 1px solid #2f2722;
}

.challenge-banner.emerald,
.challenge-banner.won {
  background: rgba(6, 78, 59, 0.25);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.challenge-banner.warn,
.challenge-banner.lost {
  background: rgba(242, 125, 112, 0.15);
  border: 1px solid var(--warn);
}

.challenge-banner-title {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.challenge-banner.gold .challenge-banner-title { color: var(--accent); }
.challenge-banner.rose .challenge-banner-title { color: #fda4af; }
.challenge-banner.dark .challenge-banner-title { color: #f59e0b; }
.challenge-banner.tied .challenge-banner-title { color: var(--soft); }
.challenge-banner.emerald .challenge-banner-title,
.challenge-banner.won .challenge-banner-title { color: #6ee7b7; }
.challenge-banner.warn .challenge-banner-title,
.challenge-banner.lost .challenge-banner-title { color: var(--warn); }

.challenge-banner-text {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
  font-weight: 500;
}

.challenge-comparison-card {
  background: #171311;
  border: 1px solid #2f2722;
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 8px;
  width: 100%;
  box-sizing: border-box;
}

.challenge-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.challenge-comparison-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2px 6px;
}

.challenge-comparison-col:first-child {
  border-right: 1px solid #2f2722;
}

.challenge-comparison-score {
  font-size: 24px;
  font-weight: 900;
  margin: 2px 0;
  font-family: Outfit, sans-serif;
  line-height: 1.1;
}

.challenge-comparison-score.won { color: #4ade80; }
.challenge-comparison-score.lost { color: var(--warn); }
.challenge-comparison-score.tied { color: var(--soft); }

.challenge-comparison-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.challenge-comparison-sub.won { color: #4ade80; }
.challenge-comparison-sub.lost { color: var(--warn); }
.challenge-comparison-sub.tied { color: var(--soft); }

/* Actions */
.challenge-actions {
  width: 100%;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-challenge-primary {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accentInk);
  font-family: Outfit, sans-serif;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(242, 199, 126, 0.2);
  box-sizing: border-box;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.btn-challenge-primary:active {
  transform: scale(0.98);
}

.btn-challenge-secondary {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  background: #1f1a18;
  border: 1px solid #3d332d;
  color: var(--text);
  font-family: Outfit, sans-serif;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn-challenge-secondary:active {
  transform: scale(0.98);
}

.challenge-how-link {
  width: 100%;
  min-height: 36px;
  padding: 8px;
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: Outfit, sans-serif;
  box-sizing: border-box;
}

.challenge-how-link:hover {
  color: var(--text);
}

/* In-Run Challenge Strip (Pause and Game Over) */
.challenge-strip-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(242, 199, 126, 0.12);
  border: 1px solid rgba(242, 199, 126, 0.28);
  border-radius: 9999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin: 6px auto 2px auto;
  max-width: 90%;
  box-sizing: border-box;
}

.challenge-strip-inline.hidden {
  display: none !important;
}

.challenge-strip-bullet {
  font-size: 10px;
  color: #4ade80;
}

.challenge-strip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive & Viewport Adjustments */
@media (max-width: 350px), (max-height: 600px) {
  .challenge-card {
    padding: 12px 14px;
    border-radius: 20px;
  }
  .challenge-avatar {
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
  }
  .challenge-avatar-initials {
    font-size: 16px;
  }
  .challenge-sender-name {
    font-size: 18px;
    margin-bottom: 4px;
  }
  .challenge-score-val {
    font-size: 32px;
  }
  .challenge-mini-board {
    width: 104px;
    height: 104px;
  }
  .challenge-relic-chip {
    width: 24px;
    height: 24px;
  }
  .challenge-relic-chip img {
    width: 15px;
    height: 15px;
  }
  .btn-challenge-primary {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 11px;
  }
  .btn-challenge-secondary {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .challenge-skeleton-shimmer {
    animation: none !important;
  }
  .btn-challenge-primary,
  .btn-challenge-secondary {
    transition: none !important;
  }
  .challenge-spinner {
    animation: none !important;
  }
}

@media (max-height: 650px) {
  .challenge-comparison-card ~ div .challenge-mini-board {
    width: 24px;
    height: 24px;
  }
}


/* ==========================================================================
   Challenge Result Card (Post-Run Outcome & Comparison)
   ========================================================================== */
.challenge-result-card,
.modal.challenge-result-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, #231f22 0%, #171517 100%);
  border: 1.5px solid #4a3a3e;
  border-radius: clamp(16px, 2.8vh, 28px);
  padding: clamp(10px, 1.8vh, 22px) 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(0px, calc(0.8cqh - 2px), 8px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  box-sizing: border-box;
  margin: auto;
  container-name: challenge-result-card;
  container-type: size;
  height: min(calc(100vh - 2 * clamp(12px, 2.5vh, 24px)), 860px);
  height: min(calc(100dvh - 2 * clamp(12px, 2.5dvh, 24px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)), 860px);
  max-height: 860px;
  overflow: hidden;
}

.challenge-result-card.hidden {
  display: none !important;
}

.challenge-result-card .card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.challenge-result-card .kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.challenge-result-card .mode-chip {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--soft);
}

.challenge-result-card .expired-banner {
  background: var(--well);
  border: 1px solid var(--wellLine);
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.challenge-result-card .expired-banner.hidden {
  display: none !important;
}

.challenge-result-card .verdict-wrap {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.challenge-result-card .verdict-headline {
  font-size: clamp(24px, 4.2cqh, 32px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.05;
  text-transform: uppercase;
}

.challenge-result-card .verdict-win { color: var(--accent); }
.challenge-result-card .verdict-lose { color: var(--warn); }
.challenge-result-card .verdict-tie { color: var(--soft); }

.challenge-result-card .margin-line {
  font-size: clamp(11px, 1.8cqh, 13px);
  font-weight: 700;
  color: var(--soft);
}

.challenge-result-card .compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.challenge-result-card .player-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(7px, 1.4cqh, 10px);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1cqh, 8px);
  min-width: 0;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.challenge-result-card .player-col.winner {
  border-color: rgba(242, 199, 126, 0.55);
  background: linear-gradient(180deg, rgba(242, 199, 126, 0.09) 0%, var(--panel) 100%);
  box-shadow: inset 0 1px 0 rgba(242, 199, 126, 0.22);
}

.challenge-result-card .player-col.winner::after {
  content: "";
  position: absolute;
  top: -40%;
  left: -130%;
  width: 75%;
  height: 180%;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(245, 238, 229, 0.03) 35%,
    rgba(242, 199, 126, 0.14) 50%,
    rgba(255, 255, 255, 0.03) 65%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(18deg);
  pointer-events: none;
  animation: glassShimmer 3.8s ease-in-out infinite;
}

.challenge-result-card .player-id {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.challenge-result-card .avatar-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.challenge-result-card .player-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.challenge-result-card .score-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.challenge-result-card .score-val {
  font-size: clamp(16px, 2.8cqh, 20px);
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.challenge-result-card .player-col.winner .score-val {
  color: var(--accent);
}

.challenge-result-card .score-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.challenge-result-card .sub-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--wellLine);
}

.challenge-result-card .stat-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.challenge-result-card .stat-v {
  font-size: 12px;
  font-weight: 800;
  color: var(--soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.challenge-result-card .stat-k {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.challenge-result-card .boards-section {
  background: var(--well);
  border: 1px solid var(--wellLine);
  border-radius: 16px;
  padding: clamp(8px, 1.4cqh, 12px) 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.challenge-result-card .boards-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.challenge-result-card .boards-header::before,
.challenge-result-card .boards-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--wellLine);
}

.challenge-result-card .boards-lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.challenge-result-card .boards-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  justify-items: center;
  width: 100%;
  box-sizing: border-box;
}

.challenge-result-card .mini-board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.challenge-result-card .mini-board-wrap .mini-board {
  width: 100%;
  aspect-ratio: 1 / 1 !important;
  height: auto !important;
  max-height: none !important;
  background: var(--board);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  grid-template-rows: repeat(4, 1fr) !important;
  gap: 3px;
  box-sizing: border-box;
}

.challenge-result-card .mini-board-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1 !important;
  height: auto !important;
  max-height: none !important;
  background: var(--board);
  border: 1px dashed var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  box-sizing: border-box;
  line-height: 1.3;
}

.challenge-result-card .m-cell {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 4px;
  background: var(--panel);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-family: Outfit, sans-serif;
  font-weight: 900;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
  box-sizing: border-box;
}

.challenge-result-card .m-cell.stone {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  background: repeating-linear-gradient(135deg, #282426 0 4px, #171517 4px 8px) !important;
  border: 1.5px solid #5b5052;
  box-shadow: inset 0 -2px 4px #0008;
  color: transparent;
  pointer-events: auto;
}

.challenge-result-card .m-cell.t2 { background: var(--t2); color: var(--text); }
.challenge-result-card .m-cell.t4 { background: var(--t4); color: var(--text); }
.challenge-result-card .m-cell.t8 { background: var(--t8); color: var(--text); }
.challenge-result-card .m-cell.t16 { background: var(--t16); color: #211d1b; }
.challenge-result-card .m-cell.t32 { background: var(--t32); color: #211d1b; }
.challenge-result-card .m-cell.t64 { background: var(--t64); color: #211d1b; }
.challenge-result-card .m-cell.t128 { background: var(--t128); color: #2a2116; }
.challenge-result-card .m-cell.t256 { background: var(--t256); color: #2a2116; }
.challenge-result-card .m-cell.t512 { background: var(--t512); color: #2a2116; }
.challenge-result-card .m-cell.t1024 { background: var(--t1024); color: #2a2116; }
.challenge-result-card .m-cell.t2048 { background: var(--t2048); color: #2a2116; }
.challenge-result-card .m-cell.t4096 { background: var(--t4096); color: #2a2116; }

.challenge-result-card .m-cell.digits-4,
.challenge-result-card .m-cell.t1024,
.challenge-result-card .m-cell.t2048,
.challenge-result-card .m-cell.t4096 {
  font-size: 8px !important;
  letter-spacing: -0.06em;
}

.challenge-result-card .m-cell.digits-3,
.challenge-result-card .m-cell.t128,
.challenge-result-card .m-cell.t256,
.challenge-result-card .m-cell.t512 {
  font-size: 9px !important;
  letter-spacing: -0.05em;
}

.challenge-result-card .m-cell.digits-2,
.challenge-result-card .m-cell.t2,
.challenge-result-card .m-cell.t4,
.challenge-result-card .m-cell.t8,
.challenge-result-card .m-cell.t16,
.challenge-result-card .m-cell.t32,
.challenge-result-card .m-cell.t64 {
  font-size: 10.5px !important;
  letter-spacing: -0.04em;
}

.challenge-result-card .daily-rank {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--soft);
  background: #27211e;
  border: 1px solid rgba(242, 199, 126, 0.32);
  border-radius: 12px;
  padding: clamp(7px, 1.2cqh, 10px) 12px;
  box-shadow: inset 0 1px 0 rgba(255, 243, 216, 0.16);
  width: 100%;
  box-sizing: border-box;
}

.challenge-result-card .daily-rank.hidden {
  display: none !important;
}

.challenge-result-card .daily-rank-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.challenge-result-card .rank-emblem {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(242, 199, 126, 0.16);
  border: 1px solid rgba(242, 199, 126, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.challenge-result-card .rank-emblem svg {
  width: 13px;
  height: 13px;
}

.challenge-result-card .rank-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--soft);
}

.challenge-result-card .rank-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  flex-shrink: 0;
}

.challenge-result-card .rank-pill strong {
  color: var(--accent);
  font-weight: 900;
  font-size: 13px;
}

.challenge-result-card .btn-stack {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 1cqh, 7px);
  width: 100%;
}

.challenge-result-card .btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(5px, 1cqh, 7px);
  width: 100%;
}

.challenge-result-card .btn {
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: clamp(11px, 1.8cqh, 13px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  cursor: pointer;
  transition: transform 0.12s ease;
  width: 100%;
  box-sizing: border-box;
}

.challenge-result-card .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.challenge-result-card .btn:active:not(:disabled) {
  transform: scale(0.98);
}

.challenge-result-card .btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.challenge-result-card .btn-primary {
  background: var(--accent);
  color: var(--accentInk);
}

.challenge-result-card .btn-secondary {
  background: var(--panel2);
  border-color: var(--line);
  color: var(--text);
}

/* Compact Responsive Variants for Challenge-Result */
@media (max-width: 380px) {
  .challenge-result-card {
    padding: clamp(8px, 1.4vh, 14px) 14px;
    border-radius: 18px;
  }
}

@media (max-height: 760px) {
  .challenge-result-card {
    padding: clamp(8px, 1.4vh, 16px) clamp(12px, 2.5vw, 18px);
    border-radius: 18px;
  }
}

@media (max-width: 350px), (max-height: 600px) {
  .challenge-result-card .verdict-headline {
    font-size: 24px;
  }
  .challenge-result-card .margin-line {
    font-size: 11px;
  }
  .challenge-result-card .player-col {
    padding: 6px 8px;
    gap: 4px;
    border-radius: 12px;
  }
  .challenge-result-card .score-val {
    font-size: 16px;
  }
  .challenge-result-card .sub-stats {
    padding-top: 4px;
  }
  .challenge-result-card .boards-section {
    padding: 6px 8px;
    gap: 8px;
    border-radius: 12px;
  }
  .challenge-result-card .boards-pair {
    gap: 8px;
  }
  .challenge-result-card .mini-board-wrap .mini-board {
    width: 100%;
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    max-height: none !important;
    padding: 3px;
    gap: 2.5px;
    border-radius: 8px;
  }
  .challenge-result-card .mini-board-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 8px;
    font-size: 10px;
  }
  .challenge-result-card .m-cell {
    border-radius: 3px;
  }
  .challenge-result-card .daily-rank {
    padding: 6px 10px;
    border-radius: 10px;
  }
  .challenge-result-card .rank-emblem {
    width: 19px;
    height: 19px;
    border-radius: 6px;
  }
  .challenge-result-card .rank-label {
    font-size: 10px;
  }
  .challenge-result-card .rank-pill {
    font-size: 11px;
  }
  .challenge-result-card .rank-pill strong {
    font-size: 12px;
  }
  .challenge-result-card .expired-banner {
    padding: 3px 8px;
    font-size: 10px;
  }
  .challenge-result-card .btn-stack,
  .challenge-result-card .btn-row {
    gap: 5px;
  }
  .challenge-result-card .btn {
    min-height: 38px;
    border-radius: 10px;
    font-size: 11px;
    padding: 0 8px;
    gap: 5px;
  }
  .challenge-result-card .btn svg {
    width: 13px;
    height: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .challenge-result-card .btn {
    transition: none !important;
  }
  .challenge-result-card .player-col.winner::after {
    animation: none !important;
    display: none !important;
  }
}




