/* ================================================================
   QUIZCRAFT — Pipe Puzzle
   Fonts: loaded via Google Fonts CDN (see index.html <head>)
     - Barlow Condensed: display/heading typeface
     - DM Sans: body/UI typeface
     - JetBrains Mono: monospace/numeric typeface
   Palette: Deep Obsidian · Electric Cyan · Hot Coral
================================================================ */

/* ═══════════════════════════════════════════════════════════════
   ROOT DESIGN TOKENS
═══════════════════════════════════════════════════════════════ */
:root {
  --bg: #070810;
  --bg2: #0a0b15;
  --surface: #0e0d22;
  --panel: #11102a;
  --panel2: #0c0f20;
  --border: #1c1840;
  --border2: #252050;
  --accent: #c060ff;
  --accent-dim: rgba(192, 96, 255, 0.5);
  --accent-glow: rgba(192, 96, 255, 0.18);
  --accent-deep: rgba(192, 96, 255, 0.06);
  --accent2: #ff4d8a;
  --accent2-dim: rgba(255, 77, 138, 0.5);
  --accent2-glow: rgba(255, 77, 138, 0.18);
  --accent2-deep: rgba(255, 77, 138, 0.06);
  --gold: #ffcc44;
  --gold-glow: rgba(255, 204, 68, 0.22);
  --green: #00e899;
  --text: #d0c8f4;
  --text-dim: #5040a0;
  --text-muted: #16123a;
  --r: 8px;
  --r2: 14px;
  --t: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-deep: 0 32px 80px rgba(0, 0, 0, 0.9);
  --overlay-bg: rgba(4, 6, 14, 0.88);
  --btn-fg: #ffffff;
  --btn2-fg: #ffffff;
  --ff-head: "Barlow Condensed", sans-serif;
  --ff-body: "DM Sans", sans-serif;
  --ff-mono: "JetBrains Mono", monospace;
}

/* ── Theme overrides (4 lobby themes — lobby/popups only) ───── */
body[data-theme="purple"] {
  --bg: #070810;
  --bg2: #0a0b15;
  --surface: #0e0d22;
  --panel: #11102a;
  --panel2: #0c0f20;
  --border: #1c1840;
  --border2: #252050;
  --accent: #c060ff;
  --accent-dim: rgba(192, 96, 255, 0.5);
  --accent-glow: rgba(192, 96, 255, 0.18);
  --accent-deep: rgba(192, 96, 255, 0.06);
  --accent2: #ff4d8a;
  --accent2-dim: rgba(255, 77, 138, 0.5);
  --accent2-glow: rgba(255, 77, 138, 0.18);
  --accent2-deep: rgba(255, 77, 138, 0.06);
  --text: #d0c8f4;
  --text-dim: #5040a0;
  --text-muted: #16123a;
}
body[data-theme="black"] {
  --bg: #080808;
  --bg2: #0c0c0c;
  --surface: #111111;
  --panel: #141414;
  --panel2: #0e0e0e;
  --border: #1e1e1e;
  --border2: #282828;
  --accent: #e0e0e0;
  --accent-dim: rgba(224, 224, 224, 0.5);
  --accent-glow: rgba(224, 224, 224, 0.18);
  --accent-deep: rgba(224, 224, 224, 0.06);
  --accent2: #a0a0b0;
  --accent2-dim: rgba(160, 160, 176, 0.5);
  --accent2-glow: rgba(160, 160, 176, 0.18);
  --accent2-deep: rgba(160, 160, 176, 0.06);
  --text: #d8d8d8;
  --text-dim: #505050;
  --text-muted: #1a1a1a;
}
body[data-theme="parrot"] {
  --bg: #040e06;
  --bg2: #050f07;
  --surface: #071408;
  --panel: #091608;
  --panel2: #060e06;
  --border: #0c2010;
  --border2: #103018;
  --accent: #00ff88;
  --accent-dim: rgba(0, 255, 136, 0.5);
  --accent-glow: rgba(0, 255, 136, 0.18);
  --accent-deep: rgba(0, 255, 136, 0.06);
  --accent2: #aaff00;
  --accent2-dim: rgba(170, 255, 0, 0.5);
  --accent2-glow: rgba(170, 255, 0, 0.18);
  --accent2-deep: rgba(170, 255, 0, 0.06);
  --text: #b0f0c0;
  --text-dim: #288040;
  --text-muted: #0a1c0c;
}
body[data-theme="pink"] {
  --bg: #110810;
  --bg2: #140a12;
  --surface: #1c0e1a;
  --panel: #1e101c;
  --panel2: #180c16;
  --border: #2e1228;
  --border2: #3e1a38;
  --accent: #ff60b0;
  --accent-dim: rgba(255, 96, 176, 0.5);
  --accent-glow: rgba(255, 96, 176, 0.18);
  --accent-deep: rgba(255, 96, 176, 0.06);
  --accent2: #ff90d0;
  --accent2-dim: rgba(255, 144, 208, 0.5);
  --accent2-glow: rgba(255, 144, 208, 0.18);
  --accent2-deep: rgba(255, 144, 208, 0.06);
  --text: #f0c8e8;
  --text-dim: #883068;
  --text-muted: #1e0c1a;
}

/* ═══════════════════════════════════════════════════════════════
   RESET + BASE
═══════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

/* Marble theme — contrast overrides */

/* ═══════════════════════════════════════════════════════════════
   PARTICLES
═══════════════════════════════════════════════════════════════ */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  will-change: transform;
  contain: strict;
}

/* ═══════════════════════════════════════════════════════════════
   SCREENS
═══════════════════════════════════════════════════════════════ */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 16px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.97);
  display: none;
}

#s-game {
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  align-items: stretch;
  overscroll-behavior: contain;
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.78) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.68) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.82) 100%
    ),
    var(--thm-bg-url-css) center center / cover no-repeat;
}

#s-game * {
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════════════════════════
   LOADING SCREEN
═══════════════════════════════════════════════════════════════ */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition:
    opacity 0.65s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.65s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.65s;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.03);
  visibility: hidden;
}

#loading-screen.gone {
  display: none;
  visibility: hidden;
}

.load-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.load-bg-hex {
  position: absolute;
  width: 60px;
  height: 60px;
  opacity: 0;
  animation: hexFloat 6s ease-in-out infinite;
}

.load-bg-hex::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent-deep);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  border: 1px solid var(--accent-dim);
}

@keyframes hexFloat {
  0% {
    opacity: 0;
    transform: scale(0.6) rotate(0deg);
  }
  30% {
    opacity: 0.4;
  }
  70% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
    transform: scale(1.2) rotate(30deg);
  }
}

.load-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  z-index: 2;
}

.load-eyebrow {
  font-family: var(--ff-mono);
  font-size: 0.58rem;
  letter-spacing: 0.6em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.6;
  margin-bottom: 6px;
  animation: fadeSlideUp 0.6s ease both;
}

.load-logo-wrap {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 14px;
  animation: fadeSlideUp 0.6s 0.1s ease both;
}

.load-logo-flow {
  font-family: var(--ff-head);
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-weight: 900;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.01em;
}

.load-logo-line {
  font-family: var(--ff-head);
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px var(--accent-glow));
  letter-spacing: -0.01em;
}

.load-subtitle {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.5em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 36px;
  animation: fadeSlideUp 0.6s 0.2s ease both;
}

.load-bar-wrap {
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: fadeSlideUp 0.6s 0.3s ease both;
}

.load-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.load-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--accent-glow);
  position: relative;
}

.load-bar-fill::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 10px var(--accent),
    0 0 20px var(--accent-glow);
  transform: translateX(4px);
}

.load-percent {
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.load-ad-slot,
.load-ad-label,
.load-ad-dot {
  display: none !important;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════
   LOBBY SCREEN
═══════════════════════════════════════════════════════════════ */
#lobby-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 200;
  transition:
    opacity 0.55s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.55s;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#lobby-screen.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(14px) scale(0.985);
  display: none;
}

/* Applied right after display:none is removed, before rAF kicks in */
#lobby-screen.lobby-pre-enter {
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.985);
  pointer-events: none;
  transition: none;
}

/* Triggered one frame later — animates in smoothly */
#lobby-screen.lobby-entering {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition:
    opacity 0.55s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.55s;
}

.lobby-bg-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.lobby-pipe-line {
  position: absolute;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent-deep),
    transparent
  );
  animation: pipeSweep 8s ease-in-out infinite;
}

.lobby-pipe-line:nth-child(2) {
  animation-delay: -2.5s;
  animation-duration: 11s;
}
.lobby-pipe-line:nth-child(3) {
  animation-delay: -5s;
  animation-duration: 9s;
}

@keyframes pipeSweep {
  0% {
    left: -100%;
    width: 40%;
  }
  100% {
    left: 110%;
    width: 60%;
  }
}

.lobby-ambient {
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 300px;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: ambientPulse 4s ease-in-out infinite alternate;
}

@keyframes ambientPulse {
  0% {
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}

.lobby-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 900px;
  padding: 44px 24px 32px;
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  margin: auto;
}

/* Left panel */
.lobby-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  max-width: 420px;
}

.lobby-brand {
  margin-bottom: 28px;
  text-align: left !important;
}

.lobby-eyebrow {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.55em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.65;
  display: block;
  margin-bottom: 10px;
}

.lobby-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 10px;
}

.lobby-title-flow {
  font-family: var(--ff-head);
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  font-weight: 900;
  line-height: 0.95;
  color: #fff;
  letter-spacing: -0.02em;
}

.lobby-title-line {
  font-family: var(--ff-head);
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 16px var(--accent-glow));
}

.lobby-tagline {
  font-family: var(--ff-body);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 8px;
  display: block;
}

.lobby-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    var(--accent-dim),
    var(--accent2-dim),
    transparent
  );
  margin: 20px 0;
  opacity: 0.35;
}

.lb-sec-label {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: block;
}

/* Difficulty selector */
.diff-cards-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 20px;
}

.diff-card {
  flex: 1;
  padding: 14px 12px 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1.5px solid var(--border2);
  border-radius: var(--r2);
  cursor: pointer;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.diff-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-deep), transparent);
  opacity: 0;
  transition: opacity var(--t);
}

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

.diff-card:hover::before {
  opacity: 1;
}

.diff-card.active {
  border-color: var(--accent);
  background: var(--accent-deep);
  box-shadow:
    0 0 24px var(--accent-glow),
    0 8px 32px rgba(0, 0, 0, 0.3);
}

.diff-card.active::before {
  opacity: 1;
}

.diff-card-grid-icon {
  display: grid;
  gap: 2px;
  position: relative;
  z-index: 1;
  margin-bottom: 2px;
}

.diff-card-dot {
  border-radius: 2px;
  background: var(--text-muted);
  transition: background var(--t);
}

.diff-card.active .diff-card-dot {
  background: var(--accent);
}
.diff-card:hover:not(.active) .diff-card-dot {
  background: var(--accent-dim);
}

.diff-card-name {
  font-family: var(--ff-head);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  transition: color var(--t);
  position: relative;
  z-index: 1;
}

.diff-card.active .diff-card-name {
  color: var(--accent);
}

.diff-card-size {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  position: relative;
  z-index: 1;
}

.diff-card-active-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: scaleX(0);
  transition: transform var(--t);
}

.diff-card.active .diff-card-active-bar {
  transform: scaleX(1);
}

/* Selection badge */
.lobby-sel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 18px;
}

.lobby-sel-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-deep);
  border: 1px solid var(--accent-dim);
  border-radius: 100px;
  padding: 5px 14px;
  font-family: var(--ff-mono);
  font-size: 0.56rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.lobby-sel-arrow {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.lobby-sel-hint {
  font-family: var(--ff-body);
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Play button */
.lobby-play-btn {
  width: 100%;
  padding: 13px 20px;
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: var(--r2);
  color: var(--accent);
  font-family: var(--ff-head);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color var(--t);
  box-shadow:
    0 0 30px var(--accent-glow),
    inset 0 0 40px var(--accent-deep);
}

.lobby-play-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: translateX(-101%);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.lobby-play-btn:hover {
  color: var(--bg);
}

.lobby-play-btn:hover::before {
  transform: translateX(0);
}

.lobby-play-btn span {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.lobby-play-arrow {
  font-size: 1.2rem;
  transition: transform var(--t);
}

.lobby-play-btn:hover .lobby-play-arrow {
  transform: translateX(4px);
}

/* Right panel */
.lobby-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 220px;
  flex-shrink: 0;
}

.lobby-stat-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  padding: 16px;
  overflow: hidden;
  position: relative;
}

.lobby-stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent-dim),
    transparent
  );
}

/* Hall of fame */
.lobby-hof-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.lobby-hof-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color var(--t);
}

.lobby-hof-row:hover {
  border-color: var(--border2);
}

.lobby-hof-pos {
  font-family: var(--ff-mono);
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 22px;
}

.lobby-hof-row:nth-child(1) .lobby-hof-pos {
  color: var(--gold);
}
.lobby-hof-row:nth-child(2) .lobby-hof-pos {
  color: #b0bec5;
}
.lobby-hof-row:nth-child(3) .lobby-hof-pos {
  color: #a07860;
}

.lobby-hof-name {
  flex: 1;
  font-family: var(--ff-body);
  font-size: 1rem;
  color: var(--text);
}

.lobby-hof-wins {
  font-family: var(--ff-mono);
  font-size: 0.84rem;
  color: var(--gold);
}

.lobby-hof-empty {
  font-family: var(--ff-body);
  font-style: italic;
  font-size: 1rem;
  color: var(--text);
  opacity: 0.4;
  text-align: center;
  padding: 4px 0;
}

/* Theme swatches */
.lobby-theme-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

#theme-dots-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lobby-theme-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.lobby-theme-dot:hover {
  transform: scale(1.2);
  outline-color: var(--accent);
}

.lobby-theme-dot.selected {
  outline-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.lobby-theme-dot.selected::before {
  content: "\2714";
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.48rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  background: rgba(0, 0, 0, 0.32);
  border-radius: 6px;
}

.theme-dot-inner {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  border-radius: 6px;
  overflow: hidden;
}

.theme-dot-inner span {
  display: block;
}

.custom-theme-dot {
  background: var(--panel);
  border: 1.5px solid var(--border2) !important;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-dot-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.custom-dot-inner svg {
  width: 16px;
  height: 16px;
  transition: color var(--t);
}

.custom-theme-dot:hover .custom-dot-inner svg {
  color: var(--accent);
  animation: spinOnce 0.5s ease;
}

@keyframes spinOnce {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Top-right action buttons */
.lobby-top-actions {
  position: sticky;
  top: 0;
  right: 0;
  align-self: flex-end;
  display: flex;
  gap: 8px;
  z-index: 10;
  align-items: center;
  padding: 14px 20px 8px;
  margin-left: auto;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  pointer-events: auto;
}

.lobby-icon-btn {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid var(--border2);
  border-radius: var(--r);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: all var(--t);
}

.lobby-icon-btn svg {
  width: 20px;
  height: 20px;
}

.lobby-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-deep);
}

/* Coin row */
.lobby-coin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border2);
  border-radius: var(--r);
}

.lobby-coin-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lobby-coin-label {
  font-family: var(--ff-body);
  font-size: 1rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

.lobby-coin-val {
  font-family: var(--ff-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
}

.lobby-coin-earn {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent2);
  border: 1.5px solid var(--accent2-dim);
  background: var(--accent2-deep);
  padding: 6px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--t);
}

.lobby-coin-earn:hover {
  background: var(--accent2);
  color: var(--btn2-fg, #ffffff);
}

/* Hide legacy/unused lobby sections */
.lobby-mode-section,
.lobby-diff-section,
.lobby-series-section,
.lobby-theme-section,
.lobby-hof,
.lobby-selection-row,
.lobby-inner {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   LEVEL SELECT POPUP
═══════════════════════════════════════════════════════════════ */
.level-select-dialog {
  max-width: 520px;
  width: 100%;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px !important;
  border: 1.5px solid var(--border2) !important;
  background: var(--surface) !important;
  flex-shrink: 0;
}

.lvl-dlg-inner {
  padding: 24px 22px 20px;
}

.lvl-dlg-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.lvl-dlg-title {
  font-family: var(--ff-head);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: block;
}

.lvl-dlg-sub {
  font-family: var(--ff-body);
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 2px;
  display: block;
}

.lvl-dlg-badge {
  font-family: var(--ff-mono);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent2-deep);
  border: 1px solid var(--accent2-dim);
  color: var(--accent2);
}

/* Progress bar */
.lvl-dlg-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.lvl-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.lvl-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.4s;
  box-shadow: 0 0 6px var(--accent-glow);
}

.lvl-progress-label {
  font-family: var(--ff-mono);
  font-size: 0.5rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Level grid */
#overlay-levels .level-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  width: 100%;
  margin-bottom: 14px;
  contain: layout style;
}

#overlay-levels .level-cell {
  aspect-ratio: 1;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
  font-family: var(--ff-mono);
  font-size: 0.54rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
}

#overlay-levels .level-cell:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-deep);
  transform: scale(1.12);
  box-shadow: 0 0 10px var(--accent-glow);
  z-index: 2;
}

#overlay-levels .level-cell.done {
  background: rgba(0, 232, 153, 0.07);
  border-color: rgba(0, 232, 153, 0.4);
  color: var(--green);
}

#overlay-levels .level-cell.done::after {
  content: "\2713";
  position: absolute;
  font-size: 0.36rem;
  bottom: 1px;
  right: 2px;
  opacity: 0.6;
  color: var(--green);
}

#overlay-levels .level-cell.next {
  border-color: var(--accent2);
  color: var(--accent2);
  background: var(--accent2-deep);
  box-shadow: 0 0 10px var(--accent2-glow);
  animation: glowBlink 0.9s ease-in-out infinite;
}

#overlay-levels .level-cell.picked {
  border-color: var(--gold) !important;
  color: var(--gold) !important;
  background: rgba(255, 204, 68, 0.08) !important;
  box-shadow: 0 0 10px rgba(255, 204, 68, 0.3) !important;
  animation: none !important;
}

#overlay-levels .level-cell.locked {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.38;
  pointer-events: none;
}

#overlay-levels .level-cell.locked::before {
  content: "\1F512";
  font-size: 0.5rem;
  position: absolute;
}

/* Difficulty tabs inside popup */
.lvl-diff-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.lvl-diff-tab {
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  font-family: var(--ff-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all var(--t);
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  position: relative;
}

.lvl-diff-tab:hover {
  color: var(--text);
}

.lvl-diff-tab.active {
  color: var(--accent);
  border-color: var(--border2);
  background: var(--surface);
}

.lvl-diff-tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

/* ═══════════════════════════════════════════════════════════════
   GAME SCREEN — topbar, score, board
═══════════════════════════════════════════════════════════════ */
.board-wrap {
  position: relative;
  flex-shrink: 0;
  margin: 6px auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-wrap::before,
.board-wrap::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.9;
  z-index: 2;
  pointer-events: none;
}

.board-wrap::before {
  top: -5px;
  left: -5px;
  border-width: 2.5px 0 0 2.5px;
}

.board-wrap::after {
  top: -5px;
  right: -5px;
  border-width: 2.5px 2.5px 0 0;
}

.board-corner-br {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--accent);
  border-width: 0 2.5px 2.5px 0;
  opacity: 0.9;
  z-index: 2;
  pointer-events: none;
}

.board-corner-bl {
  position: absolute;
  bottom: -5px;
  left: -5px;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--accent);
  border-width: 0 0 2.5px 2.5px;
  opacity: 0.9;
  z-index: 2;
  pointer-events: none;
}

/* Board SVG — GPU-accelerated, zero-lag pipe rendering */
#board-svg {
  display: block;
  cursor: crosshair;
  will-change: contents;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  shape-rendering: optimizeSpeed;
  isolation: isolate;
}

#board-svg path {
  will-change: d;
  vector-effect: non-scaling-stroke;
}

#board-svg rect {
  will-change: fill;
}

.game-topbar {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 8px;
  border-bottom: 1px solid var(--border2);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.game-logo {
  font-family: var(--ff-head);
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

.game-logo-sub {
  font-family: var(--ff-mono);
  font-size: 0.58rem;
  letter-spacing: 0.28em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 1px;
}

.series-label {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  opacity: 0.9;
}

.header-controls {
  display: flex;
  gap: 5px;
  align-items: center;
}

.icon-btn {
  width: 36px;
  height: 36px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: all var(--t);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-deep);
  box-shadow: 0 0 10px var(--accent-glow);
}

.icon-btn:active {
  transform: scale(0.92);
  transition: transform 0.08s ease;
}

/* Score panel */
.score-panel {
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 5px;
  align-items: center;
  margin-bottom: 7px;
  flex-shrink: 0;
}

.score-side {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
  position: relative;
  overflow: hidden;
}

.score-side.ax {
  border-color: var(--accent2);
  box-shadow: 0 0 10px var(--accent2-glow);
}
.score-side.ao {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.score-player {
  font-family: var(--ff-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text);
  opacity: 0.85;
  text-transform: uppercase;
}

.score-num {
  font-family: var(--ff-mono);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
  will-change: contents;
  font-variant-numeric: tabular-nums;
}

.sx .score-num {
  color: var(--accent2);
  text-shadow: 0 0 10px var(--accent2-dim);
}
.so .score-num {
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-dim);
}
.st .score-num {
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.score-name {
  font-family: var(--ff-body);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text);
  opacity: 0.7;
  text-align: center;
}

.score-vs {
  font-family: var(--ff-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-align: center;
}

/* Fill/progress bar */
.series-progress {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-shrink: 0;
}

.fill-track-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  contain: layout;
}

.fill-track-label {
  font-family: var(--ff-mono);
  font-size: 0.38rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.fill-track {
  height: 5px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 3px;
  overflow: hidden;
}

.fill-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 0 6px var(--accent-glow);
  will-change: width;
}

.fill-pct {
  font-family: var(--ff-mono);
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}

/* Round log */
.round-log-wrap {
  width: 100%;
  max-width: 520px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.round-log-label {
  font-family: var(--ff-mono);
  font-size: 0.38rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.round-log {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 16px;
}

.round-chip {
  padding: 1px 7px;
  border-radius: 3px;
  font-family: var(--ff-mono);
  font-size: 0.44rem;
  letter-spacing: 0.04em;
}

.round-chip.rc {
  background: var(--accent-deep);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}
.round-chip.rp {
  background: var(--accent2-deep);
  color: var(--accent2);
  border: 1px solid var(--accent2-dim);
}

/* Status/turn bar */
.turn-bar {
  width: 100%;
  max-width: 520px;
  text-align: center;
  margin-bottom: 6px;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.turn-text {
  font-family: "Bebas Neue", "Orbitron", sans-serif;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  transition: color 0.2s;
  will-change: contents;
  contain: content;
}

.turn-text.xt {
  color: var(--accent2);
  text-shadow: 0 0 10px var(--accent2-dim);
}
.turn-text.ot {
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-dim);
}
.turn-text.dt {
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
}

@keyframes glowBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.blink {
  animation: glowBlink 0.7s ease-in-out infinite;
}

/* Action buttons */
.btn-row {
  width: 100%;
  max-width: 520px;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 4px;
}

.abtn {
  flex: 1;
  padding: 10px 6px;
  background: var(--panel);
  border: 1.5px solid var(--border2);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.abtn::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--t);
}

.abtn span {
  position: relative;
  z-index: 1;
}

.abtn svg {
  color: currentColor;
  width: 13px;
  height: 13px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.abtn:active {
  transform: scale(0.96);
  transition: transform 0.08s ease;
}

.abtn.undo-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.abtn.undo-btn:hover::before {
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
}
.abtn.hint-btn {
  border-color: var(--accent2);
  color: var(--accent2);
}
.abtn.hint-btn:hover {
  color: var(--btn2-fg, #ffffff);
  border-color: var(--accent2);
}
.abtn.hint-btn::before {
  background: var(--accent2);
}
.abtn.hint-btn:hover::before {
  opacity: 1;
}
.abtn.reset-btn {
  border-color: rgba(255, 80, 80, 0.5);
  color: rgba(240, 100, 100, 0.9);
}
.abtn.reset-btn:hover {
  color: #ffffff;
}
.abtn.reset-btn::before {
  background: #e05050;
}
.abtn.reset-btn:hover::before {
  opacity: 1;
}

.abtn.hint-btn-ad {
  border-color: var(--gold) !important;
  color: var(--gold) !important;
  animation: glowBlink 0.8s ease-in-out infinite;
}

.abtn.hint-btn-ad::before {
  background: var(--gold) !important;
}
.abtn.hint-btn-ad:hover {
  color: #ffffff !important;
}
.abtn.hint-btn-ad:hover::before {
  opacity: 1 !important;
}

/* ═══════════════════════════════════════════════════════════════
   OVERLAYS
═══════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg, rgba(4, 6, 14, 0.88));
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 300;
  backdrop-filter: var(--backdrop-blur, blur(12px) saturate(0.7));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  will-change: opacity;
  transform: translateZ(0);
}

.overlay.show {
  opacity: 1;
  pointer-events: all;
}

/* On tall screens, center dialogs vertically */
@media (min-height: 600px) {
  .overlay {
    align-items: center;
  }
}

.dialog {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 32px 36px 28px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-deep);
  transform: translate3d(0, 14px, 0) scale(0.96);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
  flex-shrink: 0;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.overlay.show .dialog {
  transform: translate3d(0, 0, 0) scale(1);
}

.dialog::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border2);
  border-width: 1px 0 0 1px;
}

.dialog::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border2);
  border-width: 1px 1px 0 0;
}

.d-corner-br {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border2);
  border-width: 0 1px 1px 0;
}

.d-corner-bl {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border2);
  border-width: 0 0 1px 1px;
}

.dialog-title {
  font-family: var(--ff-head);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 5px;
  text-shadow: 0 0 20px var(--accent-glow);
}

.dialog-subtitle {
  font-family: var(--ff-body);
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  font-style: italic;
}

.primary-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--r);
  color: var(--btn-fg, #ffffff);
  font-family: var(--ff-mono);
  font-size: 0.48rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 8px;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
}

.primary-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity var(--t);
}

.primary-btn:hover {
  color: var(--btn-fg, #ffffff);
}
.primary-btn:hover::before {
  opacity: 1;
}

.primary-btn span {
  position: relative;
  z-index: 1;
}

.go-lobby-btn {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
}
.go-lobby-btn:hover {
  color: #ffffff !important;
}
.go-lobby-btn::before {
  background: rgba(0, 0, 0, 0.15) !important;
}

.quit-danger-btn {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
}
.quit-danger-btn::before {
  background: rgba(0, 0, 0, 0.15) !important;
}
.quit-danger-btn:hover {
  color: #ffffff !important;
}
.quit-dialog-title {
  color: #c05050 !important;
  text-shadow: 0 0 20px rgba(180, 50, 50, 0.4) !important;
}
.quit-confirm-btn {
  background: #c05050 !important;
  border-color: #a03030 !important;
  color: #ffffff !important;
}
.quit-confirm-btn::before {
  background: rgba(0, 0, 0, 0.15) !important;
}
.quit-confirm-btn:hover {
  color: #ffffff !important;
}

.pause-icon-wrap {
  margin: 14px auto 20px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-icon-wrap svg {
  width: 52px;
  height: 52px;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════
   WIN OVERLAY
═══════════════════════════════════════════════════════════════ */
#result-overlay {
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.92) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.86) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.94) 100%
    ),
    var(--thm-bg-url-css) center center / cover no-repeat;
  backdrop-filter: none;
  z-index: 400;
}

#result-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.result-box {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 16px;
  padding: 36px 40px 30px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-deep);
  animation: popIn 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  flex-shrink: 0;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.result-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

@keyframes popIn {
  from {
    transform: scale(0.65);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

#res-sym {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.res-title {
  font-family: var(--ff-head);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.res-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-style: italic;
}

.res-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.res-star {
  color: var(--text-muted);
  font-size: 1.5rem;
  transition:
    color 0.3s,
    filter 0.3s;
}

.res-star.on {
  color: var(--gold);
  filter: drop-shadow(0 0 8px var(--gold-glow));
}

.res-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.rs-box {
  flex: 1;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 6px;
  text-align: center;
}

.rs-val {
  font-family: var(--ff-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.rs-lbl {
  font-family: var(--ff-mono);
  font-size: 0.4rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 2px;
}

.res-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.res-btns .rbtn.pri {
  flex: 1 1 100%;
}

.res-btns .rbtn.sec {
  flex: 1 1 calc(50% - 4px);
}

.rbtn {
  flex: 1;
  padding: 11px;
  border-radius: var(--r);
  cursor: pointer;
  font-family: var(--ff-mono);
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
}

.rbtn.pri {
  background: var(--accent);
  border: 1.5px solid var(--accent);
  color: var(--btn-fg, #ffffff);
}

.rbtn.pri::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity var(--t);
}

.rbtn.pri:hover {
  color: var(--btn-fg, #ffffff);
}
.rbtn.pri:hover::before {
  opacity: 1;
}
.rbtn.pri span {
  position: relative;
  z-index: 1;
}

.rbtn.sec {
  background: var(--panel);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
}

.rbtn.sec:hover {
  border-color: var(--border2);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   CHAMPION SCREEN
═══════════════════════════════════════════════════════════════ */
#s-champ {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 20px;
  padding-bottom: 24px;
}

.champ-header {
  text-align: center;
  margin-bottom: 14px;
  width: 100%;
  max-width: 440px;
  border-bottom: 1px solid var(--border2);
  padding-bottom: 12px;
}

#champ-trophy {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.champ-title {
  font-family: var(--ff-head);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.champ-sub {
  font-family: var(--ff-body);
  font-size: 0.88rem;
  color: var(--text-dim);
  font-style: italic;
}

.final-scores {
  width: 100%;
  max-width: 440px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.fs-side {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 13px 10px;
  text-align: center;
}

.fs-side-x {
  border-color: var(--accent2-dim);
}
.fs-side-o {
  border-color: var(--accent-dim);
}
.fs-side-t {
  border-color: rgba(255, 215, 0, 0.3);
}

.fs-player {
  font-family: var(--ff-mono);
  font-size: 0.44rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.fs-num {
  font-family: var(--ff-mono);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}

.fs-side-x .fs-num {
  color: var(--accent2);
  text-shadow: 0 0 12px var(--accent2-dim);
}
.fs-side-o .fs-num {
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-dim);
}
.fs-side-t .fs-num {
  color: var(--gold);
  text-shadow: 0 0 12px var(--gold-glow);
}

.fs-name {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.fs-vs {
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-align: center;
}

.stats-strip {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 440px;
  margin-bottom: 10px;
}

.stat-box {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 8px;
  text-align: center;
}

.stat-num {
  font-family: var(--ff-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.stat-lbl {
  font-family: var(--ff-mono);
  font-size: 0.42rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.replay-log {
  width: 100%;
  max-width: 440px;
  margin-bottom: 10px;
}

.replay-label {
  font-family: var(--ff-mono);
  font-size: 0.44rem;
  letter-spacing: 0.28em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.replay-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 96px;
  overflow-y: auto;
}

.replay-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  background: var(--panel);
  border: 1px solid var(--border);
}

.rn {
  font-family: var(--ff-mono);
  font-size: 0.44rem;
  color: var(--text-dim);
  min-width: 24px;
}
.rx {
  color: var(--accent);
  font-weight: 600;
}
.ro {
  color: var(--accent2);
  font-weight: 600;
}

.replay-moves {
  margin-left: auto;
  font-size: 0.56rem;
  color: var(--text-dim);
}

/* Leaderboard list (champion screen) */
.lb-list {
  width: 100%;
  max-width: 440px;
  margin-bottom: 10px;
}

.lb-title {
  font-family: var(--ff-mono);
  font-size: 0.44rem;
  letter-spacing: 0.28em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.lb-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  margin-bottom: 3px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.lbe-rank {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 26px;
}

.lbe-name {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text);
}
.lbe-score {
  font-family: var(--ff-mono);
  font-size: 0.58rem;
  color: var(--gold);
}
.lb-empty {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  padding: 8px 0;
}

/* Champion action buttons */
.champ-btns {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 440px;
}

.cbtn {
  flex: 1;
  padding: 12px;
  border-radius: var(--r);
  cursor: pointer;
  font-family: var(--ff-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: all var(--t);
  position: relative;
  overflow: hidden;
}

.cbtn.filled {
  background: var(--accent);
  border: 1.5px solid var(--accent);
  color: var(--btn-fg, #ffffff);
}

.cbtn.filled::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity var(--t);
}

.cbtn.filled:hover {
  color: var(--btn-fg, #ffffff);
}
.cbtn.filled:hover::before {
  opacity: 1;
}
.cbtn.filled span {
  position: relative;
  z-index: 1;
}

.cbtn.ghost {
  background: var(--panel);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
}

.cbtn.ghost:hover {
  border-color: var(--border2);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 100px;
  padding: 8px 20px;
  font-family: var(--ff-mono);
  font-size: 0.54rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 500;
  transition: all 0.24s;
  box-shadow: 0 0 20px var(--accent-glow);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════════
   AD OVERLAY
═══════════════════════════════════════════════════════════════ */
#overlay-ad {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg, rgba(4, 6, 14, 0.88));
  backdrop-filter: var(--backdrop-blur, blur(8px) saturate(0.6));
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s;
  padding: 20px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-height: 500px) {
  #overlay-ad {
    align-items: center;
  }
}

#overlay-ad.show {
  opacity: 1;
  pointer-events: all;
}

.ad-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-deep);
  display: flex;
  flex-direction: column;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.ad-card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
}

.ad-topbar-adlabel {
  font-family: var(--ff-mono);
  font-size: 0.55rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.ad-topbar-skip {
  font-family: var(--ff-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 5px 14px;
  border-radius: 3px;
  border: 1.5px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: default;
  transition: all 0.2s;
  white-space: nowrap;
  opacity: 0.7;
  pointer-events: none;
}

.ad-topbar-skip.visible {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-deep);
  opacity: 1;
  cursor: pointer;
  pointer-events: all;
}

.ad-topbar-skip.visible:hover {
  background: var(--accent-glow);
  color: var(--accent);
}

.ad-content-box {
  width: calc(100% - 20px);
  min-height: 250px;
  position: relative;
  background: var(--bg2);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 10px;
  border-radius: 2px;
  box-sizing: border-box;
}

.ad-content-box::before,
.ad-content-box::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--border2);
  border-style: solid;
  z-index: 2;
  pointer-events: none;
}

.ad-content-box::before {
  top: 6px;
  left: 6px;
  border-width: 1.5px 0 0 1.5px;
}

.ad-content-box::after {
  bottom: 6px;
  right: 6px;
  border-width: 0 1.5px 1.5px 0;
}

.ad-content-box iframe {
  width: 100%;
  height: 100%;
  min-height: 250px;
  border: none;
  display: block;
}

.ad-card-footer {
  font-family: var(--ff-body);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: center;
  padding: 10px 16px;
  font-style: italic;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ad-footer-dot {
  font-size: 0.5rem;
  color: var(--text-dim);
}

/* Hide legacy ad elements */
.ad-popup-wrap,
.ad-popup-label,
.ad-popup-reward,
.ad-iframe-wrap,
.ad-timer-bar-wrap,
.ad-timer-label,
.ad-skip-btn,
#level-select-panel,
.ad-card::before,
.ad-timer-track,
.ad-timer-fill,
.ad-content-badge,
.ad-topbar-title {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   COINS + SHOP
═══════════════════════════════════════════════════════════════ */
.coin-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 100px;
  padding: 6px 13px 6px 9px;
  cursor: pointer;
  transition: all var(--t);
  flex-shrink: 0;
}

.coin-display:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.04);
}

.coin-icon {
  font-size: 15px;
  line-height: 1;
}
.coin-icon-svg {
  display: block;
  flex-shrink: 0;
}

.lobby-coin-svg {
  display: block;
}

.coin-count {
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  min-width: 26px;
  text-align: center;
}

.coin-earn-pop {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1.5px solid var(--gold);
  border-radius: 100px;
  padding: 6px 16px;
  font-family: var(--ff-mono);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--gold);
  box-shadow: 0 0 16px var(--gold-glow);
  pointer-events: none;
  z-index: 600;
  animation: coinPop 0.95s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  will-change: transform, opacity;
}

@keyframes coinPop {
  0% {
    bottom: 80px;
    opacity: 0;
    transform: translateX(-50%) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) scale(1.1);
  }
  70% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    bottom: 140px;
    opacity: 0;
    transform: translateX(-50%) scale(0.9);
  }
}

#overlay-shop .dialog {
  max-width: 400px;
  text-align: left;
  padding: 22px 20px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex-shrink: 0;
}

.shop-title {
  font-family: var(--ff-head);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  text-align: center;
  text-shadow: 0 0 16px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.shop-balance-row {
  font-family: var(--ff-body);
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.shop-section-label {
  font-family: var(--ff-mono);
  font-size: 0.42rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 7px;
  margin-top: 13px;
}

.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 10px 14px;
  transition: all var(--t);
  cursor: pointer;
}

.shop-item:hover {
  border-color: var(--accent);
  transform: translateX(3px);
}

.shop-item-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.shop-item-info {
  flex: 1;
}

.shop-item-name {
  font-family: var(--ff-mono);
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.shop-item-desc {
  font-family: var(--ff-body);
  font-size: 0.66rem;
  color: var(--text-dim);
}

.shop-item-price {
  font-family: var(--ff-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}

.shop-item-price.free {
  color: var(--accent2);
}
.shop-item.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Enhanced shop layout */
.shop-header-bar {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border2);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
}

.shop-scroll {
  max-height: 60vh;
  overflow-y: auto;
  padding: 8px 20px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.shop-balance-val {
  color: var(--accent);
  font-family: var(--ff-mono);
  font-weight: 700;
  font-size: 1rem;
}

/* Owned / active states */
.shop-item-price.owned {
  color: #4caf50;
  font-weight: 700;
}
.shop-item-price.active-boost {
  color: var(--accent);
  font-weight: 700;
}
.shop-item.shop-item-owned {
  opacity: 0.75;
  border-color: #4caf5055;
}
.shop-item.shop-item-unaffordable {
  opacity: 0.55;
}
.shop-item.shop-item-unaffordable .shop-item-price {
  color: #888;
}

/* Theme swatch in shop */
.shop-theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid var(--border2);
}

/* Theme dot lock state */
.lobby-theme-dot.locked-theme {
  opacity: 0.7;
  position: relative;
}

.theme-lock-badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 0.55rem;
  font-family: var(--ff-mono);
  color: var(--accent);
  padding: 2px 4px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 2px;
}

.lobby-theme-dot {
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════
   DAILY STREAK
═══════════════════════════════════════════════════════════════ */
#overlay-streak .dialog {
  text-align: center;
  max-width: 340px;
}

.streak-days {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin: 14px 0;
}

.streak-day {
  width: 34px;
  height: 44px;
  border-radius: 8px;
  border: 1.5px solid var(--border2);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.streak-day-label {
  font-family: var(--ff-mono);
  font-size: 0.36rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.streak-day-coin {
  font-family: var(--ff-mono);
  font-size: 0.46rem;
  font-weight: 700;
  color: var(--text-dim);
}

.streak-day.done {
  border-color: var(--gold);
  background: rgba(255, 204, 68, 0.08);
}
.streak-day.done .streak-day-coin {
  color: var(--gold);
}
.streak-day.today {
  border-color: var(--accent);
  background: var(--accent-deep);
  animation: glowBlink 0.7s ease-in-out infinite;
}
.streak-day.today .streak-day-coin {
  color: var(--accent);
}

.streak-reward-big {
  font-family: var(--ff-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 16px var(--gold-glow);
  margin: 6px 0;
}

.streak-claim-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1.5px solid var(--gold);
  border-radius: var(--r);
  color: var(--gold);
  font-family: var(--ff-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 4px;
  position: relative;
  overflow: hidden;
  transition: color var(--t);
  box-shadow: 0 0 14px var(--gold-glow);
}

.streak-claim-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gold);
  opacity: 0;
  transition: opacity var(--t);
}

.streak-claim-btn:hover {
  color: #1a0a00;
}
.streak-claim-btn:hover::before {
  opacity: 1;
}
.streak-claim-btn span {
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS
═══════════════════════════════════════════════════════════════ */
.settings-dialog {
  max-width: 380px;
  text-align: left;
  padding: 28px 24px 22px;
}

.settings-group {
  margin-bottom: 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row-info {
  flex: 1;
}

.settings-row-label {
  font-family: var(--ff-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.settings-row-sub {
  font-family: var(--ff-body);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.settings-section-label {
  font-family: var(--ff-mono);
  font-size: 0.5rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
  margin-top: 4px;
}

.settings-danger-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1.5px solid rgba(180, 50, 50, 0.5);
  border-radius: var(--r);
  color: rgba(200, 80, 80, 0.8);
  font-family: var(--ff-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--t);
}

.settings-danger-btn:hover {
  border-color: #e05050;
  color: #e05050;
  background: rgba(180, 50, 50, 0.1);
}

.toggle-btn {
  width: 44px;
  height: 24px;
  border-radius: 100px;
  background: var(--border2);
  border: 1.5px solid var(--border2);
  cursor: pointer;
  transition: all 0.22s;
  position: relative;
  flex-shrink: 0;
}

.toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.22s;
}

.toggle-btn.active .toggle-knob {
  left: 22px;
  background: var(--bg);
}

/* ═══════════════════════════════════════════════════════════════
   THEME BUILDER
═══════════════════════════════════════════════════════════════ */
#overlay-theme-builder {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.tb-dialog {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 12px;
  padding: 0;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-deep);
  flex-shrink: 0;
}

.tb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border2);
}

.tb-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tb-header-icon {
  font-size: 1rem;
  color: var(--accent);
  opacity: 0.7;
}
.tb-header-title {
  font-family: var(--ff-head);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
}

.tb-close-btn {
  font-family: var(--ff-mono);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 6px 13px;
  border-radius: 4px;
  background: transparent;
  border: 1.5px solid var(--border2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.18s;
}

.tb-close-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tb-section-label {
  font-family: var(--ff-mono);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 14px 22px 6px;
}

.tb-section-sub {
  font-family: var(--ff-body);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text-dim);
}

.tb-sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 22px 14px;
  border-bottom: 1px solid var(--border2);
}

.tb-row-label {
  font-family: var(--ff-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
}

.tb-sound-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tb-toggle {
  width: 40px;
  height: 22px;
  border-radius: 100px;
  background: var(--border2);
  border: 1.5px solid var(--border2);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tb-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
}

.tb-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}

.tb-toggle.active .tb-knob {
  left: 20px;
}

.tb-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 2px;
  background: var(--border2);
  outline: none;
  cursor: pointer;
}

.tb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.tb-vol-label {
  font-family: var(--ff-mono);
  font-size: 0.5rem;
  color: var(--text-dim);
  min-width: 30px;
}

.tb-swatches-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 6px 22px 16px;
  border-bottom: 1px solid var(--border2);
}

.tb-swatch {
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.18s;
  position: relative;
}

.tb-swatch:hover {
  border-color: var(--accent);
  transform: scale(1.04);
}
.tb-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

.tb-swatch-board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
  height: 52px;
  width: 100%;
}

.tb-swatch-cell {
  display: block;
}

.tb-swatch-label {
  display: block;
  text-align: center;
  font-family: var(--ff-mono);
  font-size: 0.44rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 4px 4px 5px;
  text-transform: uppercase;
}

.tb-color-preview-bar {
  display: flex;
  height: 18px;
  margin: 0 22px 10px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border2);
}

.tb-cpb-seg {
  flex: 1;
}

.tb-color-grid {
  padding: 0 22px 8px;
}

.tb-color-row {
  display: grid;
  grid-template-columns: 100px 1fr 100px 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.tb-color-row:last-child {
  border-bottom: none;
}

.tb-color-label {
  font-family: var(--ff-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.tb-color-pick-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tb-color-pick {
  width: 28px;
  height: 22px;
  border-radius: 4px;
  border: 1.5px solid var(--border2);
  cursor: pointer;
  padding: 0;
  background: none;
  flex-shrink: 0;
}

.tb-color-pick::-webkit-color-swatch-wrapper {
  padding: 1px;
}
.tb-color-pick::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.tb-color-hex {
  font-family: var(--ff-mono);
  font-size: 0.48rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.tb-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border2);
}

.tb-btn-reset {
  font-family: var(--ff-mono);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 9px 18px;
  border-radius: 4px;
  background: transparent;
  border: 1.5px solid var(--border2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.18s;
}

.tb-btn-reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tb-btn-apply {
  font-family: var(--ff-mono);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: 4px;
  background: var(--accent);
  border: 1.5px solid var(--accent);
  color: var(--btn-fg, #ffffff);
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.tb-btn-apply:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Graphics Quality Selector */
/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — 5 mandatory breakpoints
   Laptop: 1281–1440px | Small Laptop: 1025–1280px
   Tablet: 769–1024px  | Mobile: 481–768px
   Small Mobile: ≤480px
   Each step reduces all scalable values by ~20–30%
═══════════════════════════════════════════════════════════════ */

/* ================================================================
   LAPTOP — 1281px to 1440px  (~10% reduction from base)
   ================================================================ */
@media (min-width: 1281px) and (max-width: 1440px) {
  /* Lobby brand / title */
  .lobby-title-flow {
    font-size: clamp(2rem, 3.6vw, 3.2rem);
  }
  .lobby-title-line {
    font-size: clamp(2rem, 3.6vw, 3.2rem);
  }
  .lobby-tagline {
    font-size: 0.82rem;
  }
  .lobby-eyebrow {
    font-size: 0.6rem;
  }
  .lobby-play-btn {
    font-size: 0.98rem;
    padding: 12px 18px;
  }
  .lobby-play-arrow {
    font-size: 1.1rem;
  }
  .lobby-sel-hint {
    font-size: 0.66rem;
  }
  .lobby-coin-val {
    font-size: 1.28rem;
  }
  .lobby-coin-earn {
    font-size: 0.66rem;
    padding: 5px 13px;
  }
  .lobby-coin-label {
    font-size: 0.92rem;
  }
  .lobby-icon-btn {
    width: 40px;
    height: 40px;
  }
  .lobby-icon-btn svg {
    width: 19px;
    height: 19px;
  }
  .lobby-top-actions {
    padding: 13px 19px 8px;
    gap: 7px;
  }
  .lobby-brand {
    margin-bottom: 25px;
  }
  .lobby-layout {
    padding-top: 42px;
  }
  .lobby-stat-num {
    font-size: 1.05rem;
  }
  .lobby-stat-lbl {
    font-size: 0.62rem;
  }
  .lobby-hof-name {
    font-size: 0.96rem;
  }
  .lobby-hof-pos {
    font-size: 0.8rem;
  }
  .lobby-hof-wins {
    font-size: 0.82rem;
  }
  .lobby-hof-empty {
    font-size: 0.96rem;
  }
  .diff-card-name {
    font-size: 1.02rem;
  }
  .diff-card-size {
    font-size: 0.64rem;
  }
  .lb-empty {
    font-size: 0.66rem;
  }
  .lb-sec-label {
    font-size: 0.6rem;
  }

  /* Game screen */
  .game-logo {
    font-size: 1.3rem;
  }
  .game-logo-sub {
    font-size: 0.54rem;
  }
  .series-label {
    font-size: 0.63rem;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
  }
  .icon-btn svg {
    width: 15px;
    height: 15px;
  }
  .coin-count {
    font-size: 0.66rem;
  }
  .score-num {
    font-size: 1.34rem;
  }
  .score-player {
    font-size: 0.54rem;
  }
  .score-name {
    font-size: 0.64rem;
  }
  .score-vs {
    font-size: 0.57rem;
  }
  .fill-track-label {
    font-size: 0.54rem;
  }
  .fill-pct {
    font-size: 0.57rem;
  }
  .round-log-label {
    font-size: 0.54rem;
  }
  .turn-text {
    font-size: 0.87rem;
  }
  .abtn {
    font-size: 0.52rem;
    padding: 10px 6px;
  }
  .ro {
    font-size: 0.42rem;
  }

  /* Popups / dialogs */
  .dialog {
    max-width: 293px;
    padding: 30px 34px 26px;
  }
  .result-box {
    max-width: 293px;
    padding: 33px 37px 27px;
  }
  .dialog-title {
    font-size: 1.32rem;
  }
  .dialog-subtitle {
    font-size: 0.84rem;
  }
  .primary-btn {
    font-size: 0.46rem;
    padding: 11px;
  }
  .rbtn {
    font-size: 0.54rem;
    padding: 10px;
  }
  .res-title {
    font-size: 1.72rem;
  }
  .res-sub {
    font-size: 0.78rem;
  }
  .rs-val {
    font-size: 1.05rem;
  }
  .rs-lbl {
    font-size: 0.38rem;
  }
  .cbtn {
    font-size: 0.58rem;
    padding: 11px;
  }
  .champ-title {
    font-size: 1.72rem;
  }
  .champ-sub {
    font-size: 0.84rem;
  }
  .stat-num {
    font-size: 1.15rem;
  }
  .stat-lbl {
    font-size: 0.4rem;
  }
  .fs-num {
    font-size: 2.1rem;
  }
  .fs-player {
    font-size: 0.42rem;
  }
  .fs-name {
    font-size: 0.69rem;
  }
  .replay-row {
    font-size: 0.67rem;
  }
  .replay-moves {
    font-size: 0.54rem;
  }
  .rn {
    font-size: 0.42rem;
  }
  .lbe-name {
    font-size: 0.77rem;
  }
  .lbe-score {
    font-size: 0.56rem;
  }
  .lb-title {
    font-size: 0.42rem;
  }
  .settings-row-label {
    font-size: 0.87rem;
  }
  .settings-row-sub {
    font-size: 0.69rem;
  }
  .settings-section-label {
    font-size: 0.48rem;
  }
  .settings-danger-btn {
    font-size: 0.52rem;
  }

  /* Shop */
  .shop-title {
    font-size: 1.25rem;
  }
  .shop-balance-row {
    font-size: 0.69rem;
  }
  .shop-balance-val {
    font-size: 0.96rem;
  }
  .shop-section-label {
    font-size: 0.4rem;
  }
  .shop-item-name {
    font-size: 0.56rem;
  }
  .shop-item-desc {
    font-size: 0.63rem;
  }
  .shop-item-price {
    font-size: 0.79rem;
  }

  /* Level select popup */
  .level-select-dialog {
    max-width: 423px;
  }
  .lvl-dlg-inner {
    padding: 22px 20px 18px;
  }
  .lvl-dlg-title {
    font-size: 1.44rem;
  }
  .lvl-dlg-sub {
    font-size: 0.75rem;
  }
  .lvl-dlg-badge {
    font-size: 0.46rem;
  }

  /* Theme builder */
  .tb-dialog {
    max-width: 423px;
  }
  .tb-header-title {
    font-size: 1.25rem;
  }
  .tb-header-icon {
    font-size: 0.96rem;
  }
  .tb-close-btn {
    font-size: 0.48rem;
    padding: 5px 12px;
  }
  .tb-section-label {
    font-size: 0.48rem;
  }
  .tb-section-sub {
    font-size: 0.67rem;
  }
  .tb-section-title {
    font-size: 0.51rem;
  }
  .tb-row-label {
    font-size: 0.52rem;
  }
  .tb-color-label {
    font-size: 0.77rem;
  }
  .tb-color-hex {
    font-size: 0.46rem;
  }
  .tb-color-name {
    font-size: 0.46rem;
  }
  .tb-vol-label {
    font-size: 0.48rem;
  }
  .tb-swatch-label {
    font-size: 0.42rem;
  }
  .tb-btn-apply {
    font-size: 0.5rem;
    padding: 9px 19px;
  }
  .tb-btn-reset {
    font-size: 0.5rem;
    padding: 8px 17px;
  }

  /* Streak */
  .streak-day-coin {
    font-size: 0.44rem;
  }
  .streak-reward-big {
    font-size: 1.25rem;
  }
  .streak-claim-btn {
    font-size: 0.58rem;
  }

  /* Notifications */
  .notification {
    font-size: 0.62rem;
  }
  .tooltip {
    font-size: 0.56rem;
  }
  .coin-earn-pop {
    font-size: 0.63rem;
  }

  /* Ad overlay */
  .ad-card {
    max-width: 300px;
  }
  .ad-card-topbar {
    padding: 9px 13px;
  }
  .ad-topbar-adlabel {
    font-size: 0.53rem;
  }
  .ad-topbar-skip {
    font-size: 0.56rem;
    padding: 5px 13px;
  }
  .ad-content-box {
    margin: 9px;
    min-height: 210px;
  }
  .ad-content-box iframe {
    min-height: 210px;
  }
  .ad-card-footer {
    font-size: 0.65rem;
    padding: 9px 14px;
  }

  /* Loading screen */
  .load-logo-flow {
    font-size: clamp(3.2rem, 9vw, 5.5rem);
  }
  .load-logo-line {
    font-size: clamp(3.2rem, 9vw, 5.5rem);
  }
  .load-subtitle {
    font-size: 0.6rem;
    letter-spacing: 0.48em;
  }
  .load-percent {
    font-size: 0.68rem;
  }
  .load-bar-wrap {
    width: 268px;
  }
}

/* ================================================================
   LARGE DESKTOP — 1441px and above  (scale down lobby to prevent scroll)
   ================================================================ */
@media (min-width: 1441px) {
  #lobby-screen {
    justify-content: center;
    overflow-y: hidden;
  }
  .lobby-layout {
    padding: 32px 24px 24px;
  }
  .lobby-brand {
    margin-bottom: 20px;
  }
  .lobby-title-flow {
    font-size: clamp(1.9rem, 3vw, 3rem);
  }
  .lobby-title-line {
    font-size: clamp(1.9rem, 3vw, 3rem);
  }
  .lobby-tagline {
    font-size: 0.8rem;
  }
  .lobby-play-btn {
    font-size: 0.95rem;
    padding: 11px 18px;
  }
  .lobby-play-arrow {
    font-size: 0.88rem;
  }
  .lobby-divider {
    margin: 14px 0;
  }
  .diff-card {
    padding: 11px 10px 10px;
  }
  .lobby-sel-row {
    margin-bottom: 14px;
  }
  .lobby-coin-row {
    margin-bottom: 10px;
  }
}

/* Custom scrollbar for lobby — replaces default system scrollbar */
#lobby-screen::-webkit-scrollbar {
  width: 5px;
}
#lobby-screen::-webkit-scrollbar-track {
  background: transparent;
}
#lobby-screen::-webkit-scrollbar-thumb {
  background: var(--accent-dim, rgba(255,255,255,0.18));
  border-radius: 100px;
}
#lobby-screen::-webkit-scrollbar-thumb:hover {
  background: var(--accent, rgba(255,255,255,0.35));
}
#lobby-screen {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim, rgba(255,255,255,0.18)) transparent;
}

/* ================================================================
   SMALL LAPTOP — 1025px to 1280px  (~25% reduction from Laptop)
   ================================================================ */
@media (min-width: 1025px) and (max-width: 1280px) {
  /* Lobby layout — stack to column, centered */
  #lobby-screen {
    align-items: center;
    justify-content: center;
  }
  .lobby-layout {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 28px 20px 24px;
    max-width: 560px;
  }
  .lobby-left {
    max-width: 100%;
    align-items: center;
    text-align: center;
  }
  .lobby-right {
    width: 100%;
    max-width: 480px;
  }
  .lobby-brand {
    text-align: center !important;
    margin-bottom: 14px;
  }
  .lobby-stat-card {
    display: none;
  }
  .lobby-themes-card {
    display: block;
    padding: 12px 14px;
    margin: auto;
    width: fit-content;
  }
  .lobby-themes-card .lobby-theme-dot {
    width: 28px;
    height: 28px;
  }
  .lobby-divider {
    margin: 12px 0;
  }

  /* Lobby brand / title */
  .lobby-title-flow {
    font-size: clamp(1.6rem, 3.2vw, 2.5rem);
  }
  .lobby-title-line {
    font-size: clamp(1.6rem, 3.2vw, 2.5rem);
  }
  .lobby-tagline {
    font-size: 0.66rem;
  }
  .lobby-eyebrow {
    font-size: 0.48rem;
  }
  .lobby-play-btn {
    font-size: 0.8rem;
    padding: 10px 15px;
  }
  .lobby-play-arrow {
    font-size: 0.88rem;
  }
  .lobby-sel-hint {
    font-size: 0.53rem;
  }
  .lobby-coin-val {
    font-size: 1.02rem;
  }
  .lobby-coin-earn {
    font-size: 0.53rem;
    padding: 4px 10px;
  }
  .lobby-coin-label {
    font-size: 0.74rem;
  }
  .lobby-icon-btn {
    width: 32px;
    height: 32px;
  }
  .lobby-icon-btn svg {
    width: 15px;
    height: 15px;
  }
  .lobby-top-actions {
    padding: 10px 15px 6px;
    gap: 6px;
  }
  .lobby-brand {
    margin-bottom: 19px;
  }
  .lobby-stat-num {
    font-size: 0.84rem;
  }
  .lobby-stat-lbl {
    font-size: 0.5rem;
  }
  .lobby-hof-name {
    font-size: 0.77rem;
  }
  .lobby-hof-pos {
    font-size: 0.64rem;
  }
  .lobby-hof-wins {
    font-size: 0.66rem;
  }
  .lobby-hof-empty {
    font-size: 0.77rem;
  }
  .diff-card-name {
    font-size: 0.82rem;
  }
  .diff-card-size {
    font-size: 0.51rem;
  }
  .lb-empty {
    font-size: 0.53rem;
  }
  .lb-sec-label {
    font-size: 0.48rem;
  }

  /* Game screen */
  .game-logo {
    font-size: 1.04rem;
  }
  .game-logo-sub {
    font-size: 0.43rem;
  }
  .series-label {
    font-size: 0.5rem;
  }
  .icon-btn {
    width: 27px;
    height: 27px;
  }
  .icon-btn svg {
    width: 12px;
    height: 12px;
  }
  .coin-count {
    font-size: 0.53rem;
  }
  .score-num {
    font-size: 1.07rem;
  }
  .score-player {
    font-size: 0.43rem;
  }
  .score-name {
    font-size: 0.51rem;
  }
  .score-vs {
    font-size: 0.46rem;
  }
  .fill-track-label {
    font-size: 0.43rem;
  }
  .fill-pct {
    font-size: 0.46rem;
  }
  .round-log-label {
    font-size: 0.43rem;
  }
  .turn-text {
    font-size: 0.7rem;
  }
  .abtn {
    font-size: 0.42rem;
    padding: 8px 5px;
  }
  .ro {
    font-size: 0.34rem;
  }

  /* Popups / dialogs */
  .dialog {
    max-width: 276px;
    padding: 24px 27px 21px;
  }
  .result-box {
    max-width: 276px;
    padding: 26px 30px 22px;
  }
  .dialog-title {
    font-size: 1.06rem;
  }
  .dialog-subtitle {
    font-size: 0.67rem;
  }
  .primary-btn {
    font-size: 0.37rem;
    padding: 9px;
  }
  .rbtn {
    font-size: 0.43rem;
    padding: 8px;
  }
  .res-title {
    font-size: 1.37rem;
  }
  .res-sub {
    font-size: 0.62rem;
  }
  .rs-val {
    font-size: 0.84rem;
  }
  .rs-lbl {
    font-size: 0.3rem;
  }
  .cbtn {
    font-size: 0.46rem;
    padding: 9px;
  }
  .champ-title {
    font-size: 1.37rem;
  }
  .champ-sub {
    font-size: 0.67rem;
  }
  .stat-num {
    font-size: 0.92rem;
  }
  .stat-lbl {
    font-size: 0.32rem;
  }
  .fs-num {
    font-size: 1.68rem;
  }
  .fs-player {
    font-size: 0.34rem;
  }
  .fs-name {
    font-size: 0.55rem;
  }
  .replay-row {
    font-size: 0.54rem;
  }
  .replay-moves {
    font-size: 0.43rem;
  }
  .rn {
    font-size: 0.34rem;
  }
  .lbe-name {
    font-size: 0.61rem;
  }
  .lbe-score {
    font-size: 0.45rem;
  }
  .lb-title {
    font-size: 0.34rem;
  }
  .settings-row-label {
    font-size: 0.7rem;
  }
  .settings-row-sub {
    font-size: 0.55rem;
  }
  .settings-section-label {
    font-size: 0.38rem;
  }
  .settings-danger-btn {
    font-size: 0.42rem;
  }

  /* Shop */
  .shop-title {
    font-size: 1rem;
  }
  .shop-balance-row {
    font-size: 0.55rem;
  }
  .shop-balance-val {
    font-size: 0.77rem;
  }
  .shop-section-label {
    font-size: 0.32rem;
  }
  .shop-item-name {
    font-size: 0.45rem;
  }
  .shop-item-desc {
    font-size: 0.5rem;
  }
  .shop-item-price {
    font-size: 0.63rem;
  }

  /* Level select popup */
  .level-select-dialog {
    max-width: 390px;
  }
  .lvl-dlg-inner {
    padding: 18px 16px 14px;
  }
  .lvl-dlg-title {
    font-size: 1.15rem;
  }
  .lvl-dlg-sub {
    font-size: 0.6rem;
  }
  .lvl-dlg-badge {
    font-size: 0.37rem;
  }

  /* Theme builder */
  .tb-dialog {
    max-width: 390px;
  }
  .tb-header-title {
    font-size: 1rem;
  }
  .tb-header-icon {
    font-size: 0.77rem;
  }
  .tb-close-btn {
    font-size: 0.38rem;
    padding: 4px 10px;
  }
  .tb-section-label {
    font-size: 0.38rem;
  }
  .tb-section-sub {
    font-size: 0.54rem;
  }
  .tb-section-title {
    font-size: 0.41rem;
  }
  .tb-row-label {
    font-size: 0.42rem;
  }
  .tb-color-label {
    font-size: 0.61rem;
  }
  .tb-color-hex {
    font-size: 0.37rem;
  }
  .tb-color-name {
    font-size: 0.37rem;
  }
  .tb-vol-label {
    font-size: 0.38rem;
  }
  .tb-swatch-label {
    font-size: 0.34rem;
  }
  .tb-btn-apply {
    font-size: 0.4rem;
    padding: 7px 15px;
  }
  .tb-btn-reset {
    font-size: 0.4rem;
    padding: 6px 13px;
  }

  /* Streak */
  .streak-day-coin {
    font-size: 0.35rem;
  }
  .streak-reward-big {
    font-size: 1rem;
  }
  .streak-claim-btn {
    font-size: 0.46rem;
  }

  /* Notifications */
  .notification {
    font-size: 0.5rem;
  }
  .tooltip {
    font-size: 0.45rem;
  }
  .coin-earn-pop {
    font-size: 0.5rem;
  }

  /* Ad overlay */
  .ad-card {
    max-width: 260px;
  }
  .ad-card-topbar {
    padding: 8px 11px;
  }
  .ad-topbar-adlabel {
    font-size: 0.42rem;
  }
  .ad-topbar-skip {
    font-size: 0.45rem;
    padding: 4px 10px;
  }
  .ad-content-box {
    margin: 8px;
    min-height: 178px;
  }
  .ad-content-box iframe {
    min-height: 178px;
  }
  .ad-card-footer {
    font-size: 0.52rem;
    padding: 8px 12px;
  }

  /* Loading screen */
  .load-logo-flow {
    font-size: clamp(2.6rem, 8vw, 4.4rem);
  }
  .load-logo-line {
    font-size: clamp(2.6rem, 8vw, 4.4rem);
  }
  .load-subtitle {
    font-size: 0.48rem;
    letter-spacing: 0.38em;
  }
  .load-percent {
    font-size: 0.54rem;
  }
  .load-bar-wrap {
    width: 214px;
  }
}

/* ================================================================
   TABLET — 769px to 1024px  (~25% reduction from Small Laptop)
   Lobby: single-column layout, game screen adjustments
   ================================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Lobby layout — stack to column, centered */
  #lobby-screen {
    align-items: center;
    justify-content: center;
  }
  .lobby-layout {
    flex-direction: column;
    align-items: center;
    max-width: 520px;
    gap: 12px;
    padding: 24px 18px 20px;
    margin: auto;
  }
  .lobby-left {
    max-width: 100%;
    align-items: center;
    text-align: center;
  }
  .lobby-right {
    width: 100%;
    max-width: 480px;
  }
  .lobby-brand {
    text-align: center !important;
    margin-bottom: 10px;
  }
  .lobby-stat-card {
    display: none;
  }
  .lobby-themes-card {
    display: block;
    padding: 10px 12px;
    margin: auto;
    width: fit-content;
  }
  .lobby-themes-card .lobby-theme-dot {
    width: 26px;
    height: 26px;
  }
  .lobby-divider {
    margin: 10px 0;
  }

  /* Lobby brand / title */
  .lobby-title-flow {
    font-size: clamp(1.3rem, 3vw, 2rem);
  }
  .lobby-title-line {
    font-size: clamp(1.3rem, 3vw, 2rem);
  }
  .lobby-tagline {
    font-size: 0.52rem;
  }
  .lobby-eyebrow {
    font-size: 0.38rem;
  }
  .lobby-play-btn {
    font-size: 0.62rem;
    padding: 8px 12px;
  }
  .lobby-play-arrow {
    font-size: 0.7rem;
  }
  .lobby-sel-hint {
    font-size: 0.42rem;
  }
  .lobby-coin-val {
    font-size: 0.82rem;
  }
  .lobby-coin-earn {
    font-size: 0.42rem;
    padding: 3px 8px;
  }
  .lobby-coin-label {
    font-size: 0.59rem;
  }
  .lobby-icon-btn {
    width: 26px;
    height: 26px;
  }
  .lobby-icon-btn svg {
    width: 12px;
    height: 12px;
  }
  .lobby-top-actions {
    padding: 8px 12px 5px;
    gap: 5px;
  }
  .lobby-stat-num {
    font-size: 0.67rem;
  }
  .lobby-stat-lbl {
    font-size: 0.4rem;
  }
  .lobby-hof-name {
    font-size: 0.61rem;
  }
  .lobby-hof-pos {
    font-size: 0.51rem;
  }
  .lobby-hof-wins {
    font-size: 0.53rem;
  }
  .lobby-hof-empty {
    font-size: 0.61rem;
  }
  .diff-card-name {
    font-size: 0.65rem;
  }
  .diff-card-size {
    font-size: 0.41rem;
  }
  .lb-empty {
    font-size: 0.42rem;
  }
  .lb-sec-label {
    font-size: 0.38rem;
  }

  /* Game screen */
  .game-logo {
    font-size: 0.83rem;
  }
  .game-logo-sub {
    font-size: 0.34rem;
  }
  .series-label {
    font-size: 0.4rem;
  }
  .icon-btn {
    width: 22px;
    height: 22px;
  }
  .icon-btn svg {
    width: 10px;
    height: 10px;
  }
  .coin-count {
    font-size: 0.42rem;
  }
  .score-num {
    font-size: 0.86rem;
  }
  .score-player {
    font-size: 0.34rem;
  }
  .score-name {
    font-size: 0.41rem;
  }
  .score-vs {
    font-size: 0.37rem;
  }
  .fill-track-label {
    font-size: 0.34rem;
  }
  .fill-pct {
    font-size: 0.37rem;
  }
  .round-log-label {
    font-size: 0.34rem;
  }
  .turn-text {
    font-size: 0.56rem;
  }
  .abtn {
    font-size: 0.34rem;
    padding: 6px 4px;
  }
  .ro {
    font-size: 0.27rem;
  }

  /* Popups / dialogs */
  .dialog {
    max-width: 220px;
    padding: 19px 21px 17px;
  }
  .result-box {
    max-width: 220px;
    padding: 21px 24px 17px;
  }
  .dialog-title {
    font-size: 0.85rem;
  }
  .dialog-subtitle {
    font-size: 0.54rem;
  }
  .primary-btn {
    font-size: 0.3rem;
    padding: 7px;
  }
  .rbtn {
    font-size: 0.34rem;
    padding: 6px;
  }
  .res-title {
    font-size: 1.1rem;
  }
  .res-sub {
    font-size: 0.5rem;
  }
  .rs-val {
    font-size: 0.67rem;
  }
  .rs-lbl {
    font-size: 0.24rem;
  }
  .cbtn {
    font-size: 0.37rem;
    padding: 7px;
  }
  .champ-title {
    font-size: 1.1rem;
  }
  .champ-sub {
    font-size: 0.54rem;
  }
  .stat-num {
    font-size: 0.74rem;
  }
  .stat-lbl {
    font-size: 0.26rem;
  }
  .fs-num {
    font-size: 1.34rem;
  }
  .fs-player {
    font-size: 0.27rem;
  }
  .fs-name {
    font-size: 0.44rem;
  }
  .replay-row {
    font-size: 0.43rem;
  }
  .replay-moves {
    font-size: 0.34rem;
  }
  .rn {
    font-size: 0.27rem;
  }
  .lbe-name {
    font-size: 0.49rem;
  }
  .lbe-score {
    font-size: 0.36rem;
  }
  .lb-title {
    font-size: 0.27rem;
  }
  .settings-row-label {
    font-size: 0.56rem;
  }
  .settings-row-sub {
    font-size: 0.44rem;
  }
  .settings-section-label {
    font-size: 0.3rem;
  }
  .settings-danger-btn {
    font-size: 0.34rem;
  }

  /* Shop */
  .shop-title {
    font-size: 0.8rem;
  }
  .shop-balance-row {
    font-size: 0.44rem;
  }
  .shop-balance-val {
    font-size: 0.61rem;
  }
  .shop-section-label {
    font-size: 0.26rem;
  }
  .shop-item-name {
    font-size: 0.36rem;
  }
  .shop-item-desc {
    font-size: 0.4rem;
  }
  .shop-item-price {
    font-size: 0.5rem;
  }

  /* Level select popup */
  .level-select-dialog {
    max-width: 300px;
  }
  .lvl-dlg-inner {
    padding: 14px 12px 11px;
  }
  .lvl-dlg-title {
    font-size: 0.92rem;
  }
  .lvl-dlg-sub {
    font-size: 0.48rem;
  }
  .lvl-dlg-badge {
    font-size: 0.3rem;
  }

  /* Theme builder */
  .tb-dialog {
    max-width: 300px;
  }
  .tb-header-title {
    font-size: 0.8rem;
  }
  .tb-header-icon {
    font-size: 0.61rem;
  }
  .tb-close-btn {
    font-size: 0.3rem;
    padding: 3px 8px;
  }
  .tb-section-label {
    font-size: 0.3rem;
  }
  .tb-section-sub {
    font-size: 0.43rem;
  }
  .tb-section-title {
    font-size: 0.33rem;
  }
  .tb-row-label {
    font-size: 0.34rem;
  }
  .tb-color-label {
    font-size: 0.49rem;
  }
  .tb-color-hex {
    font-size: 0.3rem;
  }
  .tb-color-name {
    font-size: 0.3rem;
  }
  .tb-vol-label {
    font-size: 0.3rem;
  }
  .tb-swatch-label {
    font-size: 0.27rem;
  }
  .tb-btn-apply {
    font-size: 0.32rem;
    padding: 6px 12px;
  }
  .tb-btn-reset {
    font-size: 0.32rem;
    padding: 5px 10px;
  }

  /* Streak */
  .streak-day-coin {
    font-size: 0.28rem;
  }
  .streak-reward-big {
    font-size: 0.8rem;
  }
  .streak-claim-btn {
    font-size: 0.37rem;
  }

  /* Notifications */
  .notification {
    font-size: 0.4rem;
  }
  .tooltip {
    font-size: 0.36rem;
  }
  .coin-earn-pop {
    font-size: 0.4rem;
  }

  /* Ad overlay */
  .ad-card {
    max-width: 220px;
  }
  .ad-card-topbar {
    padding: 7px 9px;
  }
  .ad-topbar-adlabel {
    font-size: 0.34rem;
  }
  .ad-topbar-skip {
    font-size: 0.36rem;
    padding: 3px 8px;
  }
  .ad-content-box {
    margin: 7px;
    min-height: 150px;
  }
  .ad-content-box iframe {
    min-height: 150px;
  }
  .ad-card-footer {
    font-size: 0.42rem;
    padding: 7px 10px;
  }

  /* Loading screen */
  .load-logo-flow {
    font-size: clamp(2rem, 7vw, 3.5rem);
  }
  .load-logo-line {
    font-size: clamp(2rem, 7vw, 3.5rem);
  }
  .load-subtitle {
    font-size: 0.38rem;
    letter-spacing: 0.3em;
  }
  .load-percent {
    font-size: 0.43rem;
  }
  .load-bar-wrap {
    width: 170px;
  }
}

/* ================================================================
   MOBILE — 481px to 768px  (~25% reduction from Tablet)
   Lobby: stacked single-column, game: compact layout
   ================================================================ */
@media (min-width: 481px) and (max-width: 768px) {
  /* Lobby — stack to column, aligned to bottom */
  #lobby-screen {
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .lobby-top-actions {
    position: sticky;
    top: 0;
    align-self: stretch;
    justify-content: center;
    z-index: 10;
  }
  .lobby-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 14px max(24px, env(safe-area-inset-bottom, 24px));
    width: 100%;
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 18px;
  }
  .lobby-left {
    max-width: 100%;
  }
  .lobby-right {
    width: 100%;
  }
  .lobby-stat-card {
    display: none;
  }
  .lobby-themes-card {
    display: block;
    padding: 10px 12px;
  }
  .lobby-themes-card .lobby-theme-dot {
    width: 26px;
    height: 26px;
  }
  .lobby-brand {
    margin-bottom: 10px;
  }
  .lobby-divider {
    margin: 10px 0;
  }

  /* Game screen */
  #s-game {
    justify-content: flex-start;
    align-items: center;
    padding: 6px 8px 6px;
  }
  #s-game .game-topbar,
  #s-game .score-panel,
  #s-game .series-progress,
  #s-game .round-log-wrap,
  #s-game .turn-bar {
    flex-shrink: 0;
    width: 100%;
  }
  #s-game .board-wrap {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px auto;
    width: 100%;
    min-height: 0;
  }
  #s-game .btn-row {
    flex-shrink: 0;
    margin-top: auto;
    padding-bottom: env(safe-area-inset-bottom, 4px);
    width: 100%;
  }
  .game-topbar {
    flex-wrap: nowrap;
    gap: 0;
    padding: 0 2px 5px;
    width: 100%;
    min-width: 0;
  }

  /* Lobby brand / title */
  .lobby-title-flow {
    font-size: clamp(1.05rem, 4vw, 1.6rem);
  }
  .lobby-title-line {
    font-size: clamp(1.05rem, 4vw, 1.6rem);
  }
  .lobby-tagline {
    font-size: 0.41rem;
  }
  .lobby-eyebrow {
    font-size: 0.3rem;
  }
  .lobby-play-btn {
    font-size: 0.5rem;
    padding: 6px 10px;
  }
  .lobby-play-arrow {
    font-size: 0.56rem;
  }
  .lobby-sel-hint {
    font-size: 0.34rem;
  }
  .lobby-coin-val {
    font-size: 0.65rem;
  }
  .lobby-coin-earn {
    font-size: 0.34rem;
    padding: 3px 6px;
  }
  .lobby-coin-label {
    font-size: 0.47rem;
  }
  .lobby-icon-btn {
    width: 21px;
    height: 21px;
  }
  .lobby-icon-btn svg {
    width: 10px;
    height: 10px;
  }
  .lobby-top-actions {
    padding: 6px 10px 4px;
    gap: 4px;
  }
  .lobby-stat-num {
    font-size: 0.54rem;
  }
  .lobby-stat-lbl {
    font-size: 0.32rem;
  }
  .lobby-hof-name {
    font-size: 0.49rem;
  }
  .lobby-hof-pos {
    font-size: 0.41rem;
  }
  .lobby-hof-wins {
    font-size: 0.42rem;
  }
  .lobby-hof-empty {
    font-size: 0.49rem;
  }
  .diff-card-name {
    font-size: 0.52rem;
  }
  .diff-card-size {
    font-size: 0.33rem;
  }
  .lb-empty {
    font-size: 0.34rem;
  }
  .lb-sec-label {
    font-size: 0.3rem;
  }

  /* Game screen text */
  .game-logo {
    font-size: clamp(0.6rem, 2.8vw, 0.78rem);
  }
  .game-logo-sub {
    font-size: 0.28rem;
  }
  .series-label {
    font-size: clamp(0.3rem, 1.4vw, 0.38rem);
  }
  .icon-btn {
    width: 18px;
    height: 18px;
  }
  .icon-btn svg {
    width: 8px;
    height: 8px;
  }
  .coin-display {
    padding: 3px 6px 3px 4px;
    gap: 3px;
  }
  .coin-count {
    font-size: 0.34rem;
  }
  .score-num {
    font-size: 0.69rem;
  }
  .score-player {
    font-size: 0.27rem;
  }
  .score-name {
    font-size: 0.33rem;
  }
  .score-vs {
    font-size: 0.3rem;
  }
  .fill-track-label {
    font-size: 0.27rem;
  }
  .fill-pct {
    font-size: 0.3rem;
  }
  .round-log-label {
    font-size: 0.27rem;
  }
  .turn-text {
    font-size: 0.45rem;
  }
  .abtn {
    font-size: 0.27rem;
    padding: 5px 3px;
  }
  .ro {
    font-size: 0.22rem;
  }

  /* Popups / dialogs */
  .dialog {
    max-width: 88vw;
    padding: 15px 17px 13px;
  }
  .result-box {
    max-width: 88vw;
    padding: 17px 19px 14px;
  }
  .dialog-title {
    font-size: 0.68rem;
  }
  .dialog-subtitle {
    font-size: 0.43rem;
  }
  .primary-btn {
    font-size: 0.24rem;
    padding: 6px;
  }
  .rbtn {
    font-size: 0.27rem;
    padding: 5px;
  }
  .res-title {
    font-size: 0.88rem;
  }
  .res-sub {
    font-size: 0.4rem;
  }
  .rs-val {
    font-size: 0.54rem;
  }
  .rs-lbl {
    font-size: 0.19rem;
  }
  .cbtn {
    font-size: 0.3rem;
    padding: 6px;
  }
  .champ-title {
    font-size: 0.88rem;
  }
  .champ-sub {
    font-size: 0.43rem;
  }
  .stat-num {
    font-size: 0.59rem;
  }
  .stat-lbl {
    font-size: 0.21rem;
  }
  .fs-num {
    font-size: 1.07rem;
  }
  .fs-player {
    font-size: 0.22rem;
  }
  .fs-name {
    font-size: 0.35rem;
  }
  .replay-row {
    font-size: 0.34rem;
  }
  .replay-moves {
    font-size: 0.27rem;
  }
  .rn {
    font-size: 0.22rem;
  }
  .lbe-name {
    font-size: 0.39rem;
  }
  .lbe-score {
    font-size: 0.29rem;
  }
  .lb-title {
    font-size: 0.22rem;
  }
  .settings-row-label {
    font-size: 0.45rem;
  }
  .settings-row-sub {
    font-size: 0.35rem;
  }
  .settings-section-label {
    font-size: 0.24rem;
  }
  .settings-danger-btn {
    font-size: 0.27rem;
  }

  /* Shop */
  .shop-title {
    font-size: 0.64rem;
  }
  .shop-balance-row {
    font-size: 0.35rem;
  }
  .shop-balance-val {
    font-size: 0.49rem;
  }
  .shop-section-label {
    font-size: 0.21rem;
  }
  .shop-item-name {
    font-size: 0.29rem;
  }
  .shop-item-desc {
    font-size: 0.32rem;
  }
  .shop-item-price {
    font-size: 0.4rem;
  }

  /* Level select popup */
  .level-select-dialog {
    max-width: 88vw;
  }
  .lvl-dlg-inner {
    padding: 11px 10px 9px;
  }
  .lvl-dlg-title {
    font-size: 0.74rem;
  }
  .lvl-dlg-sub {
    font-size: 0.38rem;
  }
  .lvl-dlg-badge {
    font-size: 0.24rem;
  }

  /* Theme builder */
  .tb-dialog {
    max-width: 88vw;
  }
  .tb-header-title {
    font-size: 0.64rem;
  }
  .tb-header-icon {
    font-size: 0.49rem;
  }
  .tb-close-btn {
    font-size: 0.24rem;
    padding: 3px 6px;
  }
  .tb-section-label {
    font-size: 0.24rem;
  }
  .tb-section-sub {
    font-size: 0.34rem;
  }
  .tb-section-title {
    font-size: 0.26rem;
  }
  .tb-row-label {
    font-size: 0.27rem;
  }
  .tb-color-label {
    font-size: 0.39rem;
  }
  .tb-color-hex {
    font-size: 0.24rem;
  }
  .tb-color-name {
    font-size: 0.24rem;
  }
  .tb-vol-label {
    font-size: 0.24rem;
  }
  .tb-swatch-label {
    font-size: 0.22rem;
  }
  .tb-btn-apply {
    font-size: 0.26rem;
    padding: 5px 10px;
  }
  .tb-btn-reset {
    font-size: 0.26rem;
    padding: 4px 8px;
  }

  /* Streak */
  .streak-day-coin {
    font-size: 0.22rem;
  }
  .streak-reward-big {
    font-size: 0.64rem;
  }
  .streak-claim-btn {
    font-size: 0.3rem;
  }

  /* Notifications */
  .notification {
    font-size: 0.32rem;
  }
  .tooltip {
    font-size: 0.29rem;
  }
  .coin-earn-pop {
    font-size: 0.32rem;
  }

  /* Ad overlay */
  .ad-card {
    max-width: 185px;
  }
  .ad-card-topbar {
    padding: 6px 7px;
  }
  .ad-topbar-adlabel {
    font-size: 0.27rem;
  }
  .ad-topbar-skip {
    font-size: 0.29rem;
    padding: 2px 6px;
  }
  .ad-content-box {
    margin: 6px;
    min-height: 126px;
  }
  .ad-content-box iframe {
    min-height: 126px;
  }
  .ad-card-footer {
    font-size: 0.34rem;
    padding: 6px 8px;
  }

  /* Loading screen */
  .load-logo-flow {
    font-size: clamp(1.6rem, 6vw, 2.8rem);
  }
  .load-logo-line {
    font-size: clamp(1.6rem, 6vw, 2.8rem);
  }
  .load-subtitle {
    font-size: 0.3rem;
    letter-spacing: 0.24em;
  }
  .load-percent {
    font-size: 0.34rem;
  }
  .load-bar-wrap {
    width: 136px;
  }
}

/* ================================================================
   SMALL MOBILE — ≤ 480px  (~25% reduction from Mobile)
   Lobby: compact stacked, game: minimal footprint
   ================================================================ */
@media (max-width: 480px) {
  /* Lobby — stack to column */
  #lobby-screen {
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .lobby-top-actions {
    position: sticky;
    top: 0;
    align-self: stretch;
    justify-content: center;
    z-index: 10;
  }
  .lobby-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 10px max(18px, env(safe-area-inset-bottom, 18px));
    width: 100%;
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 14px;
  }
  .lobby-left {
    max-width: 100%;
  }
  .lobby-right {
    width: 100%;
  }
  .lobby-stat-card {
    display: none;
  }
  .lobby-themes-card {
    display: block;
    padding: 8px 10px;
  }
  .lobby-themes-card .lobby-theme-dot {
    width: 22px;
    height: 22px;
  }
  .lobby-brand {
    margin-bottom: 7px;
  }
  .lobby-divider {
    margin: 8px 0;
  }
  .diff-cards-row {
    gap: 5px;
  }
  .diff-card {
    padding: 8px 7px 7px;
  }

  /* Game screen */
  #s-game {
    justify-content: flex-start;
    align-items: center;
    padding: 4px 6px 4px;
  }
  #s-game .game-topbar,
  #s-game .score-panel,
  #s-game .series-progress,
  #s-game .round-log-wrap,
  #s-game .turn-bar {
    flex-shrink: 0;
    width: 100%;
  }
  #s-game .board-wrap {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 3px auto;
    width: 100%;
    min-height: 0;
  }
  #s-game .btn-row {
    flex-shrink: 0;
    margin-top: auto;
    padding-bottom: env(safe-area-inset-bottom, 3px);
    width: 100%;
  }
  .game-topbar {
    flex-wrap: nowrap;
    gap: 0;
    padding: 0 1px 4px;
    width: 100%;
    min-width: 0;
  }

  /* Lobby brand / title */
  .lobby-title-flow {
    font-size: clamp(0.8rem, 3.5vw, 1.2rem);
  }
  .lobby-title-line {
    font-size: clamp(0.8rem, 3.5vw, 1.2rem);
  }
  .lobby-tagline {
    font-size: 0.33rem;
  }
  .lobby-eyebrow {
    font-size: 0.24rem;
  }
  .lobby-play-btn {
    font-size: 0.4rem;
    padding: 5px 8px;
  }
  .lobby-play-arrow {
    font-size: 0.45rem;
  }
  .lobby-sel-hint {
    font-size: 0.27rem;
  }
  .lobby-coin-val {
    font-size: 0.52rem;
  }
  .lobby-coin-earn {
    font-size: 0.27rem;
    padding: 2px 5px;
  }
  .lobby-coin-label {
    font-size: 0.38rem;
  }
  .lobby-icon-btn {
    width: 17px;
    height: 17px;
  }
  .lobby-icon-btn svg {
    width: 8px;
    height: 8px;
  }
  .lobby-top-actions {
    padding: 5px 8px 3px;
    gap: 3px;
  }
  .lobby-stat-num {
    font-size: 0.43rem;
  }
  .lobby-stat-lbl {
    font-size: 0.26rem;
  }
  .lobby-hof-name {
    font-size: 0.39rem;
  }
  .lobby-hof-pos {
    font-size: 0.33rem;
  }
  .lobby-hof-wins {
    font-size: 0.34rem;
  }
  .lobby-hof-empty {
    font-size: 0.39rem;
  }
  .diff-card-name {
    font-size: 0.42rem;
  }
  .diff-card-size {
    font-size: 0.26rem;
  }
  .lb-empty {
    font-size: 0.27rem;
  }
  .lb-sec-label {
    font-size: 0.24rem;
  }

  /* Game screen text */
  .game-logo {
    font-size: clamp(0.46rem, 2.2vw, 0.6rem);
  }
  .game-logo-sub {
    display: none;
  }
  .series-label {
    font-size: clamp(0.24rem, 1.1vw, 0.3rem);
  }
  .icon-btn {
    width: 14px;
    height: 14px;
  }
  .icon-btn svg {
    width: 6px;
    height: 6px;
  }
  .coin-display {
    padding: 2px 5px 2px 3px;
    gap: 2px;
  }
  .coin-count {
    font-size: 0.27rem;
  }
  .score-num {
    font-size: 0.55rem;
  }
  .score-player {
    font-size: 0.22rem;
  }
  .score-name {
    font-size: 0.26rem;
  }
  .score-vs {
    font-size: 0.24rem;
  }
  .fill-track-label {
    font-size: 0.22rem;
  }
  .fill-pct {
    font-size: 0.24rem;
  }
  .round-log-label {
    font-size: 0.22rem;
  }
  .turn-text {
    font-size: 0.36rem;
  }
  .abtn {
    font-size: 0.22rem;
    padding: 4px 3px;
  }
  .ro {
    font-size: 0.18rem;
  }

  /* Popups / dialogs */
  .dialog {
    max-width: 94vw;
    padding: 12px 13px 10px;
  }
  .result-box {
    max-width: 94vw;
    padding: 13px 15px 11px;
  }
  .dialog-title {
    font-size: 0.54rem;
  }
  .dialog-subtitle {
    font-size: 0.34rem;
  }
  .primary-btn {
    font-size: 0.19rem;
    padding: 5px;
  }
  .rbtn {
    font-size: 0.22rem;
    padding: 4px;
  }
  .res-title {
    font-size: 0.7rem;
  }
  .res-sub {
    font-size: 0.32rem;
  }
  .rs-val {
    font-size: 0.43rem;
  }
  .rs-lbl {
    font-size: 0.15rem;
  }
  .cbtn {
    font-size: 0.24rem;
    padding: 5px;
  }
  .champ-title {
    font-size: 0.7rem;
  }
  .champ-sub {
    font-size: 0.34rem;
  }
  .stat-num {
    font-size: 0.47rem;
  }
  .stat-lbl {
    font-size: 0.17rem;
  }
  .fs-num {
    font-size: 0.86rem;
  }
  .fs-player {
    font-size: 0.18rem;
  }
  .fs-name {
    font-size: 0.28rem;
  }
  .replay-row {
    font-size: 0.27rem;
  }
  .replay-moves {
    font-size: 0.22rem;
  }
  .rn {
    font-size: 0.18rem;
  }
  .lbe-name {
    font-size: 0.31rem;
  }
  .lbe-score {
    font-size: 0.23rem;
  }
  .lb-title {
    font-size: 0.18rem;
  }
  .settings-row-label {
    font-size: 0.36rem;
  }
  .settings-row-sub {
    font-size: 0.28rem;
  }
  .settings-section-label {
    font-size: 0.19rem;
  }
  .settings-danger-btn {
    font-size: 0.22rem;
  }

  /* Shop */
  .shop-title {
    font-size: 0.51rem;
  }
  .shop-balance-row {
    font-size: 0.28rem;
  }
  .shop-balance-val {
    font-size: 0.39rem;
  }
  .shop-section-label {
    font-size: 0.17rem;
  }
  .shop-item-name {
    font-size: 0.23rem;
  }
  .shop-item-desc {
    font-size: 0.26rem;
  }
  .shop-item-price {
    font-size: 0.32rem;
  }

  /* Level select popup */
  .level-select-dialog {
    max-width: 94vw;
  }
  .lvl-dlg-inner {
    padding: 9px 8px 7px;
  }
  .lvl-dlg-title {
    font-size: 0.59rem;
  }
  .lvl-dlg-sub {
    font-size: 0.3rem;
  }
  .lvl-dlg-badge {
    font-size: 0.19rem;
  }

  /* Theme builder */
  .tb-dialog {
    max-width: 94vw;
  }
  .tb-header-title {
    font-size: 0.51rem;
  }
  .tb-header-icon {
    font-size: 0.39rem;
  }
  .tb-close-btn {
    font-size: 0.19rem;
    padding: 2px 5px;
  }
  .tb-section-label {
    font-size: 0.19rem;
  }
  .tb-section-sub {
    font-size: 0.27rem;
  }
  .tb-section-title {
    font-size: 0.21rem;
  }
  .tb-row-label {
    font-size: 0.22rem;
  }
  .tb-color-label {
    font-size: 0.31rem;
  }
  .tb-color-hex {
    font-size: 0.19rem;
  }
  .tb-color-name {
    font-size: 0.19rem;
  }
  .tb-vol-label {
    font-size: 0.19rem;
  }
  .tb-swatch-label {
    font-size: 0.17rem;
  }
  .tb-btn-apply {
    font-size: 0.21rem;
    padding: 4px 8px;
  }
  .tb-btn-reset {
    font-size: 0.21rem;
    padding: 3px 6px;
  }

  /* Streak */
  .streak-day-coin {
    font-size: 0.18rem;
  }
  .streak-reward-big {
    font-size: 0.51rem;
  }
  .streak-claim-btn {
    font-size: 0.24rem;
  }

  /* Notifications */
  .notification {
    font-size: 0.26rem;
  }
  .tooltip {
    font-size: 0.23rem;
  }
  .coin-earn-pop {
    font-size: 0.26rem;
  }

  /* Ad overlay */
  .ad-card {
    max-width: 155px;
  }
  .ad-card-topbar {
    padding: 5px 6px;
  }
  .ad-topbar-adlabel {
    font-size: 0.22rem;
  }
  .ad-topbar-skip {
    font-size: 0.23rem;
    padding: 2px 5px;
  }
  .ad-content-box {
    margin: 5px;
    min-height: 105px;
  }
  .ad-content-box iframe {
    min-height: 105px;
  }
  .ad-card-footer {
    font-size: 0.27rem;
    padding: 5px 6px;
  }

  /* Loading screen */
  .load-logo-flow {
    font-size: clamp(1.3rem, 5vw, 2.2rem);
  }
  .load-logo-line {
    font-size: clamp(1.3rem, 5vw, 2.2rem);
  }
  .load-subtitle {
    font-size: 0.24rem;
    letter-spacing: 0.19em;
  }
  .load-percent {
    font-size: 0.27rem;
  }
  .load-bar-wrap {
    width: 108px;
  }
}

/* ================================================================
   HEIGHT-BASED ADJUSTMENTS (preserved — width-independent)
   ================================================================ */
@media (max-height: 700px) {
  .load-ad-slot {
    display: none;
  }
  .placeholder {
    gap: 4px;
    padding: 8px;
  }
  .ad-size {
    font-size: 13px;
  }
  .ad-size span {
    font-size: 10px;
  }
  .ad-label {
    font-size: 5.5px;
  }
  .ad-subtitle {
    font-size: 6.5px;
  }
  .ad-desc {
    display: none;
  }
}

@media (max-height: 640px) {
  .game-topbar {
    padding-bottom: 6px;
    margin-bottom: 6px;
  }
  .score-panel {
    margin-bottom: 4px;
  }
  .score-num {
    font-size: 1.2rem;
  }
  .series-progress {
    margin-bottom: 4px;
  }
  .round-log-wrap {
    margin-bottom: 4px;
  }
  .turn-bar {
    margin-bottom: 6px;
    min-height: 20px;
  }
  .turn-text {
    font-size: 0.6rem;
  }
  .ad-topbar-adlabel {
    font-size: 0.374rem;
  }
  .ad-topbar-skip {
    font-size: 0.398rem;
    padding: 4px 11px;
  }
  .ad-card-footer {
    font-size: 0.437rem;
  }
  .ad-card-topbar {
    padding: 8px 12px;
  }
}

@media (max-height: 580px) {
  .round-log-wrap {
    display: none;
  }
  .score-num {
    font-size: 1rem;
  }
  .ad-topbar-adlabel {
    font-size: 0.359rem;
  }
  .ad-topbar-skip {
    font-size: 0.382rem;
    padding: 4px 10px;
  }
  .ad-card-footer {
    font-size: 0.421rem;
  }
  .ad-card-topbar {
    padding: 7px 11px;
  }
}

/* ================================================================
   LANDSCAPE ORIENTATION (mobile/tablet landscape)
   ================================================================ */
@media (orientation: landscape) and (max-height: 520px) {
  #lobby-screen {
    overflow-y: auto;
  }
  .lobby-brand {
    margin-bottom: 8px;
  }
  .lobby-title-flow {
    font-size: clamp(1.1rem, 3.5vw, 1.9rem);
  }
  .lobby-title-line {
    font-size: clamp(1.1rem, 3.5vw, 1.9rem);
  }
  .lobby-tagline {
    display: none;
  }
  .lobby-divider {
    margin: 6px 0;
  }
  .lobby-play-btn {
    padding: 6px 13px;
    font-size: 0.58rem;
  }
  .lobby-coin-val {
    font-size: 0.88rem;
  }
  .lobby-coin-earn {
    font-size: 0.56rem;
    padding: 4px 8px;
  }
  .lobby-coin-label {
    font-size: 0.72rem;
  }
  .lobby-icon-btn {
    width: 30px;
    height: 30px;
  }
  .lobby-icon-btn svg {
    width: 13px;
    height: 13px;
  }
  .lobby-top-actions {
    padding: 7px 12px 4px;
    gap: 4px;
  }

  #s-game {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 5px 8px;
    overflow-y: auto;
  }
  .game-topbar {
    width: 100%;
    flex-shrink: 0;
    padding-bottom: 4px;
    margin-bottom: 4px;
    flex-wrap: nowrap;
  }
  .game-logo {
    font-size: 0.82rem;
  }
  .game-logo-sub {
    display: none;
  }
  .series-label {
    font-size: 0.46rem;
  }
  .score-panel,
  .series-progress,
  .round-log-wrap,
  .turn-bar,
  .btn-row {
    flex-shrink: 0;
    width: 100%;
  }
  .score-num {
    font-size: 0.9rem;
  }
  .score-player {
    font-size: 0.38rem;
  }
  .score-name {
    font-size: 0.35rem;
  }
  .turn-text {
    font-size: 0.5rem;
  }
  .btn-row {
    flex-direction: row;
    justify-content: center;
    gap: 5px;
  }
  .abtn {
    font-size: 0.55rem;
    padding: 5px 8px;
  }
  .ad-topbar-adlabel {
    font-size: 0.359rem;
  }
  .ad-topbar-skip {
    font-size: 0.382rem;
    padding: 4px 10px;
  }
  .ad-card-footer {
    font-size: 0.421rem;
  }
  .ad-card-topbar {
    padding: 7px 11px;
  }
}

/* ================================================================
   CENTER GAME ON WIDE + TALL SCREENS
   ================================================================ */
@media (min-width: 769px) and (min-height: 751px) {
  #s-game {
    justify-content: center;
  }
  .ad-size {
    font-size: 26px;
  }
  .ad-size span {
    font-size: 20px;
  }
  .ad-label {
    font-size: 9px;
  }
  .ad-subtitle {
    font-size: 10px;
  }
  .ad-desc {
    font-size: 9px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   AD PLACEHOLDER (iframe: script/ads/ad.html)
   Uses CSS vars — adapts to every theme automatically.
═══════════════════════════════════════════════════════════════ */
/* Ad placeholder page base — scoped to avoid overriding game styles */
.placeholder-page html,
.placeholder-page body {
  width: 100%;
  height: 100%;
  background: var(--bg, #141c0a);
  font-family: "Georgia", serif;
}

.placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg, #141c0a);
  border: 1px dashed var(--border2, #3a4a28);
  gap: 10px;
  padding: 20px;
  text-align: center;
  position: relative;
}

.placeholder::before,
.placeholder::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--border, #4a5a30);
  border-style: solid;
}

.placeholder::before {
  top: 10px;
  left: 10px;
  border-width: 1.5px 0 0 1.5px;
}
.placeholder::after {
  bottom: 10px;
  right: 10px;
  border-width: 0 1.5px 1.5px 0;
}

.ad-label {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted, #6a7a50);
  font-family: "Courier New", monospace;
}

.ad-size {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent, #b8c878);
  font-family: "Georgia", serif;
  letter-spacing: 0.02em;
  line-height: 1;
}

.ad-size span {
  font-size: 22px;
  color: var(--accent2, #8a9a6a);
  margin: 0 4px;
}

.ad-subtitle {
  font-size: 11px;
  color: var(--text-dim, #6a7a50);
  font-family: "Georgia", serif;
  font-style: italic;
}

.ad-desc {
  font-size: 10px;
  color: var(--text-muted, #4a5a30);
  line-height: 1.5;
  max-width: 200px;
  font-family: "Courier New", monospace;
}

@media (max-width: 1400px) {
  .ad-size {
    font-size: 26px;
  }
  .ad-size span {
    font-size: 20px;
  }
  .ad-label {
    font-size: 9px;
  }
  .ad-subtitle {
    font-size: 10px;
  }
  .ad-desc {
    font-size: 9px;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  .ad-size {
    font-size: 22px;
  }
  .ad-size span {
    font-size: 17px;
  }
  .ad-label {
    font-size: 8px;
  }
  .ad-subtitle {
    font-size: 9px;
  }
  .ad-desc {
    font-size: 8px;
  }
}

@media (max-width: 700px) {
  .placeholder {
    gap: 8px;
    padding: 16px;
  }
  .ad-size {
    font-size: 20px;
  }
  .ad-size span {
    font-size: 15px;
  }
  .ad-label {
    font-size: 8px;
  }
  .ad-subtitle {
    font-size: 9px;
  }
  .ad-desc {
    font-size: 8px;
    max-width: 170px;
  }
}

@media (max-width: 600px) {
  .placeholder {
    gap: 7px;
    padding: 14px;
  }
  .ad-size {
    font-size: 18px;
  }
  .ad-size span {
    font-size: 14px;
  }
  .ad-label {
    font-size: 7px;
  }
  .ad-subtitle {
    font-size: 8px;
  }
  .ad-desc {
    font-size: 7px;
    max-width: 150px;
  }
}

@media (max-width: 520px) {
  .placeholder {
    gap: 6px;
    padding: 12px;
  }
  .ad-size {
    font-size: 16px;
  }
  .ad-size span {
    font-size: 12px;
  }
  .ad-label {
    font-size: 6.5px;
  }
  .ad-subtitle {
    font-size: 7.5px;
  }
  .ad-desc {
    font-size: 6.5px;
    max-width: 130px;
  }
}

@media (max-width: 420px) {
  .placeholder {
    gap: 5px;
    padding: 10px;
  }
  .ad-size {
    font-size: 14px;
  }
  .ad-size span {
    font-size: 11px;
  }
  .ad-label {
    font-size: 6px;
  }
  .ad-subtitle {
    font-size: 7px;
  }
  .ad-desc {
    font-size: 6px;
    max-width: 110px;
  }
}

@media (max-width: 380px) {
  .placeholder {
    gap: 4px;
    padding: 8px;
  }
  .ad-size {
    font-size: 13px;
  }
  .ad-size span {
    font-size: 10px;
  }
  .ad-label {
    font-size: 5.5px;
  }
  .ad-subtitle {
    font-size: 6.5px;
  }
  .ad-desc {
    display: none;
  }
}

@media (max-width: 360px) {
  .ad-size {
    font-size: 11px;
  }
  .ad-size span {
    font-size: 9px;
  }
  .ad-label {
    font-size: 5px;
  }
  .ad-subtitle {
    font-size: 6px;
  }
}

/* ================================================================
   FLAPPY ROCKET DESIGN SYSTEM — Lobby & Overlay Styles
   (moved from inline <style> block in index.html)
================================================================ */
/* ================================================================
   FLAPPY ROCKET DESIGN SYSTEM — applied to QuizCraft lobby
   All lobby/popup screens use these full-page patterns.
   The in-game board (#s-game) is NEVER touched.
================================================================ */

/* ── ROOT VARIABLES ── */
:root {
  --fr-bg: var(--fr-bg);
  --fr-orange: var(--fr-accent);
  --fr-gold: var(--fr-gold);
  --fr-gold-dim: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
  --fr-border: rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  --fr-border-hover: rgba(var(--th-r), var(--th-g), var(--th-b), 0.65);
  --fr-surface: rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.85);
  --fr-accent: var(--fr-accent);
  --fr-accent2: var(--fr-accent2);
  /* Theme RGB channels — updated by ThemeSystem._applyVars() */
  --th-r: 192;
  --th-g: 96;
  --th-b: 255; /* accent (default purple) */
  --th-r2: 255;
  --th-g2: 77;
  --th-b2: 184; /* accent2 */
  --th-bg-r: 7;
  --th-bg-g: 4;
  --th-bg-b: 15; /* bg */
  --fr-font-display: "Bebas Neue", "Orbitron", sans-serif;
  --fr-font-body: "Rajdhani", sans-serif;
  --fr-font-mono: "Share Tech Mono", monospace;
  --fr-font-ui: "Space Grotesk", "Rajdhani", sans-serif;
}

/* ================================================================
   GLOBAL RESET (Flappy Rocket base)
================================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: var(--fr-bg);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--fr-font-body);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: var(--fr-font-body);
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

/* ================================================================
   BACKGROUND IMAGE MIXIN — used by lobby, loading, all full-page overlays
   Overlay is lighter so the bg.jpg shows through clearly,
   with theme color tint via th-bg-r/g/b vars
================================================================ */
.fr-bg-page {
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.72) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.6) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.78) 100%
    ),
    var(--thm-bg-url) center center / cover no-repeat;
}

/* ================================================================
   LOADING SCREEN
================================================================ */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.8) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.68) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.84) 100%
    ),
    var(--thm-bg-url) center center / cover no-repeat;
  transition: opacity 0.5s ease;
}
#loading-screen.fade-out {
  opacity: 0;
}
#loading-screen.gone {
  display: none !important;
}

.ld-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.5vh, 20px);
  width: min(460px, calc(100vw - 40px));
  text-align: center;
}
.ld-bar-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.ld-bar-track {
  position: relative;
  width: 100%;
  height: 28px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 3px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.4),
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    0 4px 0 rgba(0, 0, 0, 0.35);
  overflow: visible;
}
.ld-bar-fill {
  position: relative;
  height: 100%;
  width: 0%;
  min-width: 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe566 0%, #ffb800 40%, #ff8c00 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow:
    0 0 16px rgba(255, 180, 0, 0.7),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2);
  transition: width 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
/* Glossy shine stripe */
.ld-bar-shine {
  position: absolute;
  top: 3px;
  left: 6px;
  right: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}
/* Animated bubbles inside bar */
.ld-bar-bubbles {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  pointer-events: none;
}
.ld-bar-bubbles span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: ldBubble 1.1s ease-in-out infinite;
  flex-shrink: 0;
}
.ld-bar-bubbles span:nth-child(2) {
  animation-delay: 0.22s;
  width: 5px;
  height: 5px;
}
.ld-bar-bubbles span:nth-child(3) {
  animation-delay: 0.44s;
  width: 4px;
  height: 4px;
}
@keyframes ldBubble {
  0%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-3px) scale(1.2);
    opacity: 1;
  }
}
/* Star emoji that rides the bar tip */
.ld-bar-star {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) translateX(-50%);
  left: 0%;
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
  transition: left 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 6px rgba(255, 200, 0, 0.8));
  animation: ldStarSpin 2s linear infinite;
  z-index: 2;
}
@keyframes ldStarSpin {
  0% {
    transform: translateY(-50%) translateX(-50%) rotate(0deg) scale(1);
  }
  50% {
    transform: translateY(-50%) translateX(-50%) rotate(180deg) scale(1.15);
  }
  100% {
    transform: translateY(-50%) translateX(-50%) rotate(360deg) scale(1);
  }
}
.ld-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ld-bar-label {
  font-family: var(--fr-font-ui);
  font-size: clamp(0.56rem, 1.1vw, 0.68rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 600;
}
.ld-bar-pct {
  font-family: var(--fr-font-ui);
  font-size: clamp(0.62rem, 1.3vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffcc00;
  text-shadow: 0 0 8px rgba(255, 200, 0, 0.6);
}

/* ── SHARED TYPOGRAPHY ── */
.lb-ew {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}
.lb-ew-line {
  flex: 1;
  max-width: 44px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(52, 211, 153, 0.3));
}
.lb-ew-line:last-child {
  background: linear-gradient(
    to left,
    transparent,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.3)
  );
}
.lb-ew-txt {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.55rem, 1.2vw, 0.8rem);
  letter-spacing: 0.8em;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
}
.lb-title {
  font-family: var(--fr-font-display);
  font-size: clamp(2.4rem, 7vw, 5.5rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  background: linear-gradient(
    135deg,
    var(--fr-accent) 0%,
    #ffffff 35%,
    #fff7e6 65%,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.7) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}
.lb-title span.lb-title-hi {
  -webkit-text-fill-color: var(--fr-accent);
  color: var(--fr-accent);
}
.lb-tag {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.55rem, 1.2vw, 0.8rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #fff;
}

/* ── COINS DISPLAY ── */
.lb-lobby-coins {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--fr-font-mono);
  font-size: clamp(0.72rem, 1.4vw, 0.9rem);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.85);
  letter-spacing: 0.1em;
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.07);
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  border-radius: 20px;
  padding: 5px 14px;
  margin-top: 4px;
}
.lb-lobby-coins svg {
  fill: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
}

/* ================================================================
   MAIN LOBBY — 3-section full-page layout
================================================================ */
#lobby-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.94) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.88) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.96) 100%
    ),
    var(--thm-bg-url) center center / cover no-repeat;
  opacity: 1;
  transition: opacity 0.4s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
#lobby-screen.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  display: none;
}
#lobby-screen.lobby-pre-enter {
  opacity: 0;
  transition: none !important;
}
#lobby-screen.lobby-entering {
  opacity: 1;
  transition: opacity 0.4s ease;
}

.lb-fullpage {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(40px, 8vh, 100px) 20px clamp(40px, 8vh, 100px);
  box-sizing: border-box;
}

/* Section 1 — Logo */
.lb-section-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  width: 100%;
}

/* Section 2 — Big Play Button */
.lb-section-play {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 2.5vh, 28px) 0;
}

/* Section 3 — Bottom (Store + Difficulty + Icon buttons) */
.lb-section-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 2.8vh, 32px);
}

/* Top action buttons row (Store + Difficulty selector) */
.lb-section-select-btns {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2.5vw, 24px);
}

/* Icon buttons row */
.lb-section-icons {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 32px);
}

/* ── BIG PLAY BUTTON ── */
.lb-big-play {
  width: clamp(130px, 22vw, 190px);
  height: clamp(130px, 22vw, 190px);
  border-radius: 50%;
  border: 3px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
  background: radial-gradient(
    circle at 38% 38%,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.35) 0%,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.25) 60%,
    rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.5) 100%
  );
  box-shadow:
    0 0 40px rgba(var(--th-r), var(--th-g), var(--th-b), 0.35),
    0 0 80px rgba(var(--th-r), var(--th-g), var(--th-b), 0.15),
    inset 0 2px 0 rgba(255, 200, 100, 0.25),
    inset 0 -2px 0 rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition:
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}
.lb-big-play::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  animation: lbPlayPulse 2.4s ease-in-out infinite;
}
@keyframes lbPlayPulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.1;
    transform: scale(1.08);
  }
}
.lb-big-play svg {
  width: clamp(48px, 9vw, 76px);
  height: clamp(48px, 9vw, 76px);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.9);
  fill: rgba(var(--th-r), var(--th-g), var(--th-b), 0.9);
  margin-left: 6%;
  filter: drop-shadow(0 0 8px rgba(var(--th-r), var(--th-g), var(--th-b), 0.5));
}
.lb-big-play:hover {
  transform: scale(1.07);
  border-color: var(--fr-accent);
  box-shadow:
    0 0 60px rgba(var(--th-r), var(--th-g), var(--th-b), 0.55),
    0 0 120px rgba(var(--th-r), var(--th-g), var(--th-b), 0.25),
    inset 0 2px 0 rgba(255, 200, 100, 0.35),
    inset 0 -2px 0 rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.6);
}
.lb-big-play:active {
  transform: scale(0.97);
}

/* ── SELECT BUTTONS (Store / Difficulty) ── */
.lb-select-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: clamp(10px, 1.8vh, 14px) clamp(20px, 4vw, 36px);
  border-radius: 10px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.08);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.85);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.72rem, 1.6vw, 0.92rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  transition:
    transform 0.16s ease,
    border-color 0.2s,
    background 0.2s,
    box-shadow 0.2s,
    color 0.2s;
}
.lb-select-btn svg {
  width: clamp(14px, 2.2vw, 18px);
  height: clamp(14px, 2.2vw, 18px);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.lb-select-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.75);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.16);
  box-shadow: 0 0 24px rgba(var(--th-r), var(--th-g), var(--th-b), 0.22);
  color: #fff;
}
.lb-select-btn:active {
  transform: translateY(0);
}

/* ── ICON BUTTONS (Sound / Info / Settings) ── */
.lb-icon-btn {
  width: clamp(52px, 9vw, 72px);
  height: clamp(52px, 9vw, 72px);
  border-radius: 50%;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.35);
  background: rgba(255, 120, 0, 0.08);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.2s,
    background 0.2s,
    box-shadow 0.2s;
  backdrop-filter: blur(6px);
}
.lb-icon-btn svg {
  width: clamp(20px, 3.5vw, 28px);
  height: clamp(20px, 3.5vw, 28px);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lb-icon-btn:hover {
  transform: scale(1.1);
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.16);
  box-shadow: 0 0 20px rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  color: #fff;
}
.lb-icon-btn:active {
  transform: scale(0.95);
}

/* DIFFICULTY quick-select pill in lobby (replaces old diff cards for lobby) */
.lb-diff-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--fr-font-mono);
  font-size: clamp(0.52rem, 1.1vw, 0.66rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
}
.lb-diff-pill {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  background: rgba(255, 100, 0, 0.05);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.55);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 0.16s,
    color 0.16s,
    background 0.16s;
}
.lb-diff-pill.active {
  border-color: var(--fr-accent);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.15);
  color: var(--fr-gold);
  box-shadow: 0 0 10px rgba(var(--th-r), var(--th-g), var(--th-b), 0.18);
}
.lb-diff-pill:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.5);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
}

/* ================================================================
   FULL-PAGE OVERLAY SYSTEM (all lobby sub-pages)
================================================================ */
.fr-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.92) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.86) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.94) 100%
    ),
    var(--thm-bg-url) center center / cover no-repeat;
  opacity: 1;
  transition: opacity 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.fr-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Hides lobby/game screen while an overlay is open — does NOT use display:none to avoid reflow */
.fr-screen-hidden {
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* old overlay class redirect */
.overlay {
  display: none !important;
}

/* Inner containers */
.fr-overlay-inner {
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.fr-overlay-inner--narrow {
  max-width: min(560px, 100vw);
  margin: 0 auto;
}
.fr-overlay-inner--wide {
  max-width: min(860px, 100vw);
  margin: 0 auto;
}

/* ── Overlay Header ── */
.fr-ov-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(14px, 2.5vh, 24px) clamp(16px, 3vw, 32px);
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
  flex-shrink: 0;
}
.fr-ov-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.7rem, 1.5vw, 0.88rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.06);
  transition:
    border-color 0.18s,
    background 0.18s,
    color 0.18s;
}
.fr-ov-back svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fr-ov-back:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.6);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.12);
  color: #fff;
}

.fr-ov-coins {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--fr-font-mono);
  font-size: clamp(0.65rem, 1.3vw, 0.82rem);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.85);
  letter-spacing: 0.1em;
}
.fr-ov-coins svg {
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
  fill: currentColor;
}

/* ── Overlay Body ── */
.fr-ov-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(16px, 3vh, 28px) clamp(20px, 4vw, 40px) clamp(20px, 4vh, 40px);
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vh, 24px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.fr-ov-body--centered {
  align-items: center;
  justify-content: center;
}
.fr-ov-body--gap {
  gap: clamp(12px, 2vh, 20px);
}

/* ── Game Logo inside overlay ── */
.fr-game-logo {
  text-align: center;
}
.fr-game-logo .lb-title {
  font-size: clamp(1.8rem, 5vw, 3.2rem);
}
.fr-game-logo--stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ── Divider ── */
.fr-divider {
  width: 60%;
  height: 1px;
  margin: 0 auto;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.3),
    transparent
  );
  flex-shrink: 0;
}

/* ── Section title ── */
.fr-section-title {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.55rem, 1.3vw, 0.72rem);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
  margin-bottom: 4px;
}

/* ── Info rows (How to Play) ── */
.fr-info-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fr-info-section--centered-280 {
  width: min(280px, 92vw);
  margin: 0 auto;
}
.fr-info-section--grow {
  flex: 1;
}

.fr-info-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.fr-info-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
}
.fr-info-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  stroke-width: 2;
  stroke-linecap: round;
}
.fr-info-icon svg[fill="currentColor"] {
  fill: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  stroke: none;
}

.fr-info-text {
  font-family: var(--fr-font-body);
  font-size: clamp(0.78rem, 1.5vw, 0.95rem);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.5;
  padding-top: 6px;
}
.fr-info-text strong {
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.9);
  font-weight: 700;
}

.fr-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.fr-ctrl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--fr-font-body);
  font-size: clamp(0.72rem, 1.3vw, 0.88rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
}
.fr-ctrl-row kbd {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  font-family: var(--fr-font-mono);
  font-size: clamp(0.58rem, 1.1vw, 0.72rem);
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Footer ── */
.fr-footer {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.46rem, 1vw, 0.58rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.15);
  text-align: center;
  padding-top: 8px;
  flex-shrink: 0;
}

/* ── Full-width action buttons ── */
.fr-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: clamp(12px, 1.8vh, 16px) clamp(16px, 3vw, 24px);
  border-radius: 10px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.08);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.85);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.72rem, 1.5vw, 0.9rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition:
    border-color 0.18s,
    background 0.18s,
    color 0.18s,
    box-shadow 0.18s,
    transform 0.14s;
}
.fr-action-btn svg {
  width: clamp(13px, 2vw, 16px);
  height: clamp(13px, 2vw, 16px);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.fr-action-btn:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.75);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.16);
  color: #fff;
  box-shadow: 0 0 24px rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  transform: translateY(-1px);
}
.fr-action-btn:active {
  transform: translateY(0);
}

.fr-action-btn--primary {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.18);
  border-color: var(--fr-accent);
  box-shadow: 0 0 20px rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
}
.fr-action-btn--primary svg {
  fill: currentColor;
  stroke: none;
}

.fr-action-btn--danger {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.06);
  color: rgba(239, 100, 100, 0.8);
}
.fr-action-btn--danger:hover {
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.18);
}

/* ── Panel Icon (big centered icon for Pause/Quit) ── */
.fr-panel-icon {
  width: clamp(52px, 9vw, 72px);
  height: clamp(52px, 9vw, 72px);
  border-radius: 50%;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.fr-panel-icon svg {
  width: clamp(24px, 4.5vw, 36px);
  height: clamp(24px, 4.5vw, 36px);
  fill: none;
  stroke: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fr-panel-icon--pause {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.35);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
}
.fr-panel-icon--danger {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.07);
}
.fr-panel-icon--danger svg {
  stroke: rgba(239, 100, 100, 0.8);
}
.fr-panel-icon--success {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
}
.fr-panel-icon--success svg {
  stroke: rgba(var(--th-r), var(--th-g), var(--th-b), 0.9);
  fill: none;
}

.fr-panel-title {
  font-family: var(--fr-font-display);
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--fr-gold);
  text-align: center;
  text-shadow: 0 0 30px rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
}
.fr-panel-title--danger {
  color: #f87171;
  text-shadow: 0 0 24px rgba(239, 68, 68, 0.35);
}
.fr-panel-title--success {
  color: var(--fr-accent);
  text-shadow: 0 0 28px rgba(var(--th-r), var(--th-g), var(--th-b), 0.5);
}

/* Result overlay — stars */
.fr-res-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.res-star {
  color: rgba(255, 255, 255, 0.15);
  font-size: 1.8rem;
  transition:
    color 0.3s,
    filter 0.3s;
}
.res-star.on {
  color: #f5c518;
  filter: drop-shadow(0 0 10px rgba(245, 197, 24, 0.6));
}

/* Result overlay — stat boxes */
.fr-res-stats {
  display: flex;
  gap: 8px;
  width: min(280px, 92vw);
  margin: 0 auto;
}
.fr-rs-box {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.fr-rs-val {
  font-family: var(--fr-font-mono);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 700;
  color: var(--fr-gold);
  letter-spacing: 0.04em;
}
.fr-rs-lbl {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.42rem, 1vw, 0.54rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 3px;
}

.fr-panel-sub {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.5rem, 1.2vw, 0.68rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
}

/* ── Settings inside overlay ── */
.fr-settings-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.fr-settings-label {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.5rem, 1.1vw, 0.62rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.65);
  padding-bottom: clamp(3px, 0.4vh, 5px);
  margin-bottom: clamp(4px, 0.6vh, 7px);
  margin-top: clamp(8px, 1.2vh, 14px);
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
}
.fr-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(5px, 0.8vh, 8px) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.fr-settings-row:last-child {
  border-bottom: none;
}
.fr-settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.fr-settings-row-lbl {
  font-family: var(--fr-font-body);
  font-size: clamp(0.78rem, 1.5vw, 0.95rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}
.fr-settings-row-sub {
  font-family: var(--fr-font-body);
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  color: rgba(255, 255, 255, 0.28);
}
.fr-toggle {
  width: clamp(36px, 5.5vw, 44px);
  height: clamp(19px, 2.8vw, 23px);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
  cursor: pointer;
}
.fr-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: clamp(13px, 2vw, 17px);
  height: clamp(13px, 2vw, 17px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition:
    transform 0.2s,
    background 0.2s;
}
.fr-toggle.active {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.55);
}
.fr-toggle.active::after {
  transform: translateX(clamp(16px, 2.4vw, 21px));
  background: var(--fr-gold);
}

.fr-danger-btn {
  width: 100%;
  padding: clamp(8px, 1.2vh, 11px);
  border-radius: 7px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.05);
  color: rgba(239, 68, 68, 0.6);
  font-family: var(--fr-font-body);
  font-size: clamp(0.68rem, 1.3vw, 0.84rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.fr-danger-btn:hover {
  border-color: rgba(239, 68, 68, 0.6);
  color: #f87171;
  background: rgba(239, 68, 68, 0.08);
}

/* ── Custom scrollbar — all overlay scrollable areas ── */
.fr-overlay::-webkit-scrollbar,
.fr-overlay-inner::-webkit-scrollbar,
.fr-ov-body::-webkit-scrollbar,
.fr-grid-wrap::-webkit-scrollbar,
#overlay-ad .fr-ov-body::-webkit-scrollbar {
  width: 4px;
}
.fr-overlay::-webkit-scrollbar-track,
.fr-overlay-inner::-webkit-scrollbar-track,
.fr-ov-body::-webkit-scrollbar-track,
.fr-grid-wrap::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 2px;
}
.fr-overlay::-webkit-scrollbar-thumb,
.fr-overlay-inner::-webkit-scrollbar-thumb,
.fr-ov-body::-webkit-scrollbar-thumb,
.fr-grid-wrap::-webkit-scrollbar-thumb {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.35);
  border-radius: 2px;
}
.fr-overlay::-webkit-scrollbar-thumb:hover,
.fr-overlay-inner::-webkit-scrollbar-thumb:hover,
.fr-ov-body::-webkit-scrollbar-thumb:hover,
.fr-grid-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.6);
}
.fr-overlay,
.fr-overlay-inner,
.fr-ov-body,
.fr-grid-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.35)
    rgba(255, 255, 255, 0.03);
}

/* ── Grid scrollable wrap ── */
.fr-grid-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(14px, 2.5vh, 24px) clamp(14px, 2.5vw, 28px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Level section headers ── */
.level-section-label {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.44rem, 0.9vw, 0.56rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.6);
  padding: 6px 0 4px;
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
  margin-bottom: 4px;
  margin-top: 12px;
}
.level-section-label:first-child {
  margin-top: 0;
}
.level-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

/* ── Shop Grid ── */
.fr-shop-section-label {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.5rem, 1.1vw, 0.62rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.65);
  margin: clamp(16px, 2.5vh, 24px) 0 clamp(8px, 1.2vh, 12px);
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
  padding-bottom: 6px;
}
.fr-shop-section-label:first-child {
  margin-top: 0;
}
.fr-shop-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fr-shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: clamp(8px, 1.2vh, 12px) clamp(10px, 2vw, 16px);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition:
    border-color 0.16s,
    background 0.16s;
}
.fr-shop-item:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.06);
}
.fr-shop-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.fr-shop-theme-swatch {
  border-radius: 6px;
}
.fr-shop-item-info {
  flex: 1;
  min-width: 0;
}
.fr-shop-item-name {
  font-family: var(--fr-font-body);
  font-size: clamp(0.78rem, 1.5vw, 0.92rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}
.fr-shop-item-desc {
  font-family: var(--fr-font-body);
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  color: rgba(255, 255, 255, 0.3);
}
.fr-shop-item-price {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-family: var(--fr-font-mono);
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.fr-shop-balance-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(8px, 1.2vh, 12px) clamp(10px, 2vw, 16px);
  border-radius: 8px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  background: rgba(255, 200, 0, 0.05);
  margin-bottom: 4px;
  font-family: var(--fr-font-mono);
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.1em;
}
.fr-shop-balance-val {
  color: rgba(253, 224, 71, 0.9);
  font-size: clamp(0.72rem, 1.4vw, 0.9rem);
  font-weight: 700;
}

/* ── Ad page ── */
.fr-ad-frame-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 2.5vh, 28px) clamp(16px, 3vw, 32px);
}
.fr-ad-frame-box {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 300/250;
  border: 1px dashed rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.fr-ad-frame-box iframe {
  width: 100%;
  height: 100%;
  border: none;
}
.fr-ad-placeholder {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.5rem, 1vw, 0.62rem);
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.15);
  text-transform: uppercase;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.95);
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  border-radius: 8px;
  padding: 10px 20px;
  font-family: var(--fr-font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.9);
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
  z-index: 9000;
  opacity: 0;
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Particles ── */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* ── Coin inline SVG ── */
.coin-svg-inline {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Earn Ad button ── */
.lb-earn-ad-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.35);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.08);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.6rem, 1.2vw, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.16s;
  white-space: nowrap;
}
.lb-earn-ad-btn:hover {
  border-color: var(--fr-accent);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.16);
  color: #fff;
}

/* hidden helper for JS-only IDs that must exist in DOM */
.js-hidden {
  display: none !important;
}

/* ================================================================
   LEVEL CELL — inside overlay-difficulty
================================================================ */
#overlay-difficulty .level-cell,
#overlay-levels-page .level-cell {
  aspect-ratio: 1;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.45);
  font-family: var(--fr-font-mono);
  font-size: 0.54rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
}
#overlay-difficulty .level-cell:hover,
#overlay-levels-page .level-cell:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
  color: var(--fr-gold);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
  transform: scale(1.1);
  box-shadow: 0 0 12px rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  z-index: 2;
}
#overlay-difficulty .level-cell.done,
#overlay-levels-page .level-cell.done {
  background: rgba(80, 200, 160, 0.07);
  border-color: rgba(80, 200, 160, 0.4);
  color: #50c8a0;
}
#overlay-difficulty .level-cell.done::after,
#overlay-levels-page .level-cell.done::after {
  content: "✓";
  position: absolute;
  font-size: 0.36rem;
  bottom: 1px;
  right: 2px;
  opacity: 0.6;
  color: #50c8a0;
}
#overlay-difficulty .level-cell.next,
#overlay-levels-page .level-cell.next {
  border-color: var(--fr-accent2);
  color: var(--fr-accent2);
  background: rgba(255, 77, 184, 0.08);
  box-shadow: 0 0 10px rgba(255, 77, 184, 0.3);
  animation: glowBlinkPurple 0.9s ease-in-out infinite;
}
@keyframes glowBlinkPurple {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(255, 77, 184, 0.3);
  }
  50% {
    box-shadow: 0 0 18px rgba(255, 77, 184, 0.6);
  }
}
#overlay-difficulty .level-cell.picked,
#overlay-levels-page .level-cell.picked {
  border-color: var(--fr-gold) !important;
  color: var(--fr-gold) !important;
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.1) !important;
  box-shadow: 0 0 12px rgba(var(--th-r), var(--th-g), var(--th-b), 0.35) !important;
  animation: none !important;
}
#overlay-difficulty .level-cell.locked,
#overlay-levels-page .level-cell.locked {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.25);
  cursor: not-allowed;
  opacity: 0.75;
  pointer-events: none;
}
#overlay-difficulty .level-cell.locked::before,
#overlay-levels-page .level-cell.locked::before {
  content: "🔒";
  font-size: 0.5rem;
  position: absolute;
}

/* ================================================================
   AD MODAL — panel-style popup
================================================================ */
.ad-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 4, 20, 0.82);
  backdrop-filter: blur(10px) saturate(0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  padding: 20px;
}
.ad-modal-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

.ad-modal-panel {
  background: linear-gradient(145deg, var(--fr-bg), var(--fr-bg));
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  border-radius: 10px;
  padding: clamp(16px, 3vh, 28px) clamp(16px, 3vw, 28px)
    clamp(14px, 2.5vh, 24px);
  width: min(440px, 92vw);
  max-height: 90dvh;
  overflow-y: auto;
  position: relative;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.75),
    0 0 60px rgba(var(--th-r), var(--th-g), var(--th-b), 0.08);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ad-modal-overlay:not(.hidden) .ad-modal-panel {
  transform: translateY(0) scale(1);
}

/* corner accents */
.ad-modal-panel::before,
.ad-modal-panel::after,
.ad-modal-corner {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  border-style: solid;
}
.ad-modal-panel::before {
  top: 9px;
  left: 9px;
  border-width: 1px 0 0 1px;
}
.ad-modal-panel::after {
  top: 9px;
  right: 9px;
  border-width: 1px 1px 0 0;
}
.ad-modal-corner.p-br {
  bottom: 9px;
  right: 9px;
  border-width: 0 1px 1px 0;
}
.ad-modal-corner.p-bl {
  bottom: 9px;
  left: 9px;
  border-width: 0 0 1px 1px;
}

.ad-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(10px, 1.8vh, 16px);
  padding-bottom: clamp(8px, 1.2vh, 12px);
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.12);
}
.ad-modal-title {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.52rem, 1.2vw, 0.68rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.65);
}
.ad-modal-skip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.07);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.6rem, 1.2vw, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.ad-modal-skip:not(:disabled):hover {
  border-color: var(--fr-accent);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.15);
  color: var(--fr-gold);
}
.ad-modal-skip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ad-modal-frame-wrap {
  width: 100%;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.12);
  background: rgba(255, 255, 255, 0.02);
  aspect-ratio: 300/250;
  margin-bottom: clamp(10px, 1.8vh, 16px);
}
.ad-modal-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.ad-modal-footer {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.44rem, 0.9vw, 0.55rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.13);
  text-align: center;
}

/* ================================================================
   THEME BUILDER MODAL — panel-style popup
================================================================ */
.tb-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 4, 20, 0.82);
  backdrop-filter: blur(10px) saturate(0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  padding: 20px;
  overflow-y: auto;
}
.tb-modal-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

.tb-modal-panel {
  background: linear-gradient(145deg, var(--fr-bg), var(--fr-bg));
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.22);
  border-radius: 10px;
  padding: clamp(16px, 3vh, 28px) clamp(16px, 3vw, 28px)
    clamp(14px, 2.5vh, 24px);
  width: min(400px, 92vw);
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.75),
    0 0 50px rgba(var(--th-r), var(--th-g), var(--th-b), 0.07);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tb-modal-overlay:not(.hidden) .tb-modal-panel {
  transform: translateY(0) scale(1);
}

/* corner accents */
.tb-modal-panel::before,
.tb-modal-panel::after,
.tb-modal-corner {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.28);
  border-style: solid;
}
.tb-modal-panel::before {
  top: 9px;
  left: 9px;
  border-width: 1px 0 0 1px;
}
.tb-modal-panel::after {
  top: 9px;
  right: 9px;
  border-width: 1px 1px 0 0;
}
.tb-modal-corner.tb-p-br {
  bottom: 9px;
  right: 9px;
  border-width: 0 1px 1px 0;
}
.tb-modal-corner.tb-p-bl {
  bottom: 9px;
  left: 9px;
  border-width: 0 0 1px 1px;
}

.tb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(10px, 1.8vh, 16px);
  padding-bottom: clamp(8px, 1.2vh, 12px);
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.12);
}
.tb-modal-title {
  font-family: var(--fr-font-display);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  letter-spacing: 0.06em;
  color: var(--fr-gold);
  text-shadow: 0 0 20px rgba(var(--th-r), var(--th-g), var(--th-b), 0.35);
}
.tb-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s;
}
.tb-modal-close:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
  color: var(--fr-gold);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
}

.tb-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tb-section-label {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.48rem, 1vw, 0.6rem);
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.6);
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
  margin-bottom: 8px;
}
.tb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.tb-row-lbl {
  font-family: var(--fr-font-body);
  font-size: clamp(0.76rem, 1.4vw, 0.9rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}
.tb-vol-lbl {
  font-family: var(--fr-font-mono);
  font-size: 0.62rem;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
}
.tb-swatches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 7px;
  margin-bottom: 4px;
}
.tb-preview-bar {
  height: 7px;
  border-radius: 3px;
  margin-bottom: 10px;
}
.tb-colors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.tb-color-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tb-color-lbl {
  font-family: var(--fr-font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.38);
  text-transform: uppercase;
  min-width: 36px;
}
.tb-color-input {
  width: 28px;
  height: 22px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
.tb-color-hex {
  font-family: var(--fr-font-mono);
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.28);
}

.tb-modal-footer {
  display: flex;
  gap: 8px;
  margin-top: clamp(14px, 2vh, 20px);
  padding-top: clamp(10px, 1.5vh, 14px);
  border-top: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
}
.tb-btn-primary {
  flex: 1;
  padding: clamp(9px, 1.4vh, 13px);
  border-radius: 7px;
  border: 1px solid var(--fr-accent);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.18);
  color: var(--fr-gold);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.68rem, 1.3vw, 0.84rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 0 16px rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
}
.tb-btn-primary:hover {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  color: #fff;
  box-shadow: 0 0 28px rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
}
.tb-btn-ghost {
  padding: clamp(9px, 1.4vh, 13px) clamp(14px, 2.5vw, 20px);
  border-radius: 7px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.05);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.65);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.68rem, 1.3vw, 0.84rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.tb-btn-ghost:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.5);
  color: var(--fr-gold);
}

/* ================================================================
   FULL-SCREEN THEME OVERLAY
================================================================ */
.thm-dot-row {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}
.thm-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 4px 6px;
  cursor: pointer;
  transition: all 0.16s;
}
.thm-dot-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: conic-gradient(
    var(--dot-a) 0deg 180deg,
    var(--dot-b) 180deg 360deg
  );
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  display: block;
  transition: transform 0.16s;
}
.thm-dot:hover .thm-dot-swatch {
  transform: scale(1.15);
}
.thm-dot--active .thm-dot-swatch {
  border-color: var(--dot-a);
  box-shadow: 0 0 8px var(--dot-a);
}
.thm-dot-label {
  font-family: var(--ff-mono, monospace);
  font-size: 0.44rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.28);
  white-space: nowrap;
}
.thm-dot--active .thm-dot-label {
  color: rgba(255, 255, 255, 0.7);
}
.thm-dot--active {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.thm-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 450;
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.92) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.86) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.94) 100%
    ),
    var(--thm-bg-url) center center / cover no-repeat;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  opacity: 1;
  transition: opacity 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.35)
    rgba(255, 255, 255, 0.03);
}
.thm-fullscreen.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.thm-fullscreen::-webkit-scrollbar {
  width: 4px;
}
.thm-fullscreen::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 2px;
}
.thm-fullscreen::-webkit-scrollbar-thumb {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.35);
  border-radius: 2px;
}
.thm-fullscreen::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.6);
}

.thm-inner {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 3vh, 28px) clamp(16px, 3vw, 40px) clamp(30px, 5vh, 56px);
  box-sizing: border-box;
  max-width: 1200px;
  margin: 0 auto;
}

/* Top bar */
.thm-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(14px, 2.5vh, 28px);
  flex-shrink: 0;
}
.thm-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.35);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.07);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.85);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.65rem, 1.3vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.thm-back-btn:hover {
  border-color: var(--fr-accent);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.15);
  color: #fff;
}

.thm-topbar-coins {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--fr-font-mono);
  font-size: clamp(0.65rem, 1.3vw, 0.82rem);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.85);
  letter-spacing: 0.1em;
}

/* Title block */
.thm-title-block {
  text-align: center;
  margin-bottom: clamp(12px, 2vh, 24px);
  flex-shrink: 0;
}
.thm-game-title {
  font-family: var(--fr-font-display);
  font-size: clamp(2.4rem, 7vw, 5.5rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  background: linear-gradient(
    135deg,
    var(--fr-accent) 0%,
    #ffffff 40%,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.2) 65%,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.7) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.thm-hi {
  -webkit-text-fill-color: var(--fr-accent);
  color: var(--fr-accent);
}
.thm-subtitle {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.52rem, 1.1vw, 0.68rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 12px;
}
.thm-section-tag {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.6rem, 1.2vw, 0.76rem);
  letter-spacing: 0.6em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.18);
}

/* Theme card grid */
.thm-card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(10px, 1.8vw, 18px);
  width: 100%;
  margin-bottom: clamp(16px, 2.5vh, 28px);
}
@media (max-width: 700px) {
  .thm-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 380px) {
  .thm-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Individual theme card */
.thm-card {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition:
    border-color 0.2s,
    transform 0.18s,
    box-shadow 0.2s;
}
.thm-card:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.45);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
}
.thm-card--active {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.75) !important;
  box-shadow: 0 0 24px rgba(var(--th-r), var(--th-g), var(--th-b), 0.3) !important;
}
.thm-card--locked {
  opacity: 0.72;
}

/* Card preview (mini pipe scene) */
.thm-card-preview {
  width: 100%;
  aspect-ratio: 16/9;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.thm-card-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  padding-bottom: 0;
}
.thm-card-bar {
  position: absolute;
  bottom: 0;
  width: 14%;
  border-radius: 3px 3px 0 0;
}
.thm-card-connector {
  position: absolute;
  top: 35%;
  left: 14%;
  right: 14%;
  height: 5%;
  border-radius: 3px;
}
.thm-card-tick {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.9rem;
  color: var(--fr-accent);
  text-shadow: 0 0 10px rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  font-weight: 900;
}
.thm-card-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 2, 14, 0.62);
  backdrop-filter: blur(2px);
  font-family: var(--fr-font-mono);
  font-size: clamp(0.48rem, 0.9vw, 0.6rem);
  letter-spacing: 0.15em;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.9);
  text-transform: uppercase;
}

/* Card body */
.thm-card-body {
  padding: clamp(8px, 1.2vh, 12px) clamp(8px, 1.5vw, 12px)
    clamp(8px, 1.2vh, 12px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.thm-card-name {
  font-family: var(--fr-font-body);
  font-size: clamp(0.75rem, 1.5vw, 0.9rem);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.02em;
}
.thm-card-desc {
  font-family: var(--fr-font-body);
  font-size: clamp(0.58rem, 1vw, 0.7rem);
  color: rgba(255, 255, 255, 0.35);
  line-height: 1.4;
  flex: 1;
}
.thm-card-btn {
  margin-top: clamp(6px, 1vh, 10px);
  width: 100%;
  padding: clamp(5px, 0.8vh, 8px) 0;
  border-radius: 4px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.05);
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.75);
  font-family: var(--fr-font-mono);
  font-size: clamp(0.48rem, 0.9vw, 0.6rem);
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.thm-card-btn:hover {
  border-color: var(--fr-accent);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.15);
  color: var(--fr-gold);
}
.thm-card-btn--active {
  border-color: var(--fr-accent) !important;
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.2) !important;
  color: var(--fr-gold) !important;
}

/* Custom color editor row */
.thm-custom-row {
  display: none !important;
  width: 100%;
  margin-bottom: clamp(12px, 2vh, 20px);
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.15);
  border-radius: 8px;
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.04);
  padding: clamp(12px, 2vh, 18px) clamp(14px, 2.5vw, 22px);
}
.thm-custom-header {
  margin-bottom: 10px;
}
.thm-custom-label {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.52rem, 1vw, 0.66rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
}
.thm-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 7px;
  margin-bottom: 12px;
}
.thm-custom-preview-wrap {
  margin-bottom: 10px;
}
.thm-custom-sublabel {
  font-family: var(--fr-font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.25);
  display: block;
  margin-bottom: 4px;
}
.thm-preview-bar {
  display: flex;
  height: 7px;
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
}
.thm-color-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}
.thm-color-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.thm-clbl {
  font-family: var(--fr-font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.38);
  text-transform: uppercase;
  min-width: 40px;
}
.thm-cinput {
  width: 26px;
  height: 22px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
.thm-chex {
  font-family: var(--fr-font-mono);
  font-size: 0.52rem;
  color: rgba(255, 255, 255, 0.28);
}
.thm-apply-btn {
  padding: 7px 18px;
  border-radius: 6px;
  border: 1px solid var(--fr-accent);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.18);
  color: var(--fr-gold);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.66rem, 1.2vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.thm-apply-btn:hover {
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.32);
  color: #fff;
}
.thm-reset-btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.25);
  background: none;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.55);
  font-family: var(--fr-font-ui);
  font-size: clamp(0.66rem, 1.2vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.thm-reset-btn:hover {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.5);
  color: var(--fr-gold);
}

/* Footer */
.thm-footer {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.44rem, 0.9vw, 0.56rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.12);
  text-align: center;
  padding-top: 6px;
  flex-shrink: 0;
}

/* AD OVERLAY FIX — ensure it shows properly when hidden class removed */
#overlay-ad:not(.hidden) {
  opacity: 1 !important;
  pointer-events: all !important;
  visibility: visible !important;
  display: flex !important;
}

/* ================================================================
   GAME SCREEN — lobby-style 3-section vertical layout
   .game-fullpage mirrors .lb-fullpage from the lobby design
================================================================ */

/* Full-page wrapper — fills the #s-game fixed container */
.game-fullpage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* ── SECTION 1: TOP BAR ── */
.gfp-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(6px, 1.2vw, 14px);
  padding: clamp(6px, 1vh, 12px) clamp(12px, 2.5vw, 28px);
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.18);
  flex-shrink: 0;
}

.gfp-topbar-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex-shrink: 0;
}

/* Logo — same Bebas Neue font as lobby .lb-title, scaled to fit topbar */
.gfp-logo {
  font-family: var(--fr-font-display);
  font-size: clamp(1.1rem, 2.8vw, 1.8rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  background: linear-gradient(
    135deg,
    var(--fr-accent) 0%,
    #ffffff 40%,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.7) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}
.gfp-logo-hi {
  -webkit-text-fill-color: var(--fr-accent);
  color: var(--fr-accent);
}

/* Sub-label under logo — same Share Tech Mono as lb-tag */
.gfp-logo-sub {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.42rem, 0.9vw, 0.58rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.55);
  white-space: nowrap;
}

/* Stats strip in the top bar */
.gfp-topbar-stats {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.2vw, 14px);
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.gfp-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
}

.gfp-stat--fill {
  flex-direction: row;
  align-items: center;
  gap: 5px;
}

/* Label — Space Grotesk matching bottom buttons */
.gfp-stat-lbl {
  font-family: var(--fr-font-ui);
  font-size: clamp(0.38rem, 0.7vw, 0.5rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.5);
  white-space: nowrap;
}

/* Value — Space Grotesk bold, sized to read clearly */
.gfp-stat-val {
  font-family: var(--fr-font-ui);
  font-size: clamp(0.75rem, 1.5vw, 1.05rem);
  font-weight: 700;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.92);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.gfp-stat-sep {
  width: 1px;
  height: clamp(24px, 3vh, 36px);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.15);
  flex-shrink: 0;
}

.gfp-fill-track {
  width: clamp(40px, 6vw, 80px);
  height: 5px;
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.2);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
/* fill-pct hidden inside in-game topbar — bar alone shows progress clearly */
#s-game .fill-pct {
  display: none;
}

/* Widen the fill track now that % text is gone */
#s-game .gfp-fill-track {
  width: clamp(55px, 8vw, 110px);
}

/* Icon buttons in topbar — compact version of lb-icon-btn */
.gfp-icon-btn {
  width: clamp(34px, 5vw, 44px) !important;
  height: clamp(34px, 5vw, 44px) !important;
}
.gfp-icon-btn svg {
  width: clamp(15px, 2.5vw, 20px) !important;
  height: clamp(15px, 2.5vw, 20px) !important;
}
/* Home icon uses fill — don't force it to none */
#btn-lobby svg path,
#btn-lobby svg polyline {
  fill: inherit;
  stroke: currentColor;
}
#btn-lobby svg path[fill="currentColor"] {
  fill: currentColor;
  stroke: none;
}
/* Pause icon rects use fill */
#btn-pause svg rect {
  fill: currentColor;
  stroke: none;
}
/* Sound icon polygon uses fill */
#btn-sound svg polygon,
#lb-btn-sound svg polygon {
  fill: currentColor;
  stroke: none;
}

/* ── SECTION 2: BOARD CENTER ── */
.gfp-board-section {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 1.5vh, 18px) clamp(12px, 2vw, 20px);
  min-height: 0;
  width: 100%;
  gap: clamp(6px, 1vh, 12px);
}

/* turn-text already styled in style.css */

/* board-wrap already styled in style.css — corner accents use --accent which is theme-aware */

/* ── SECTION 3: BOTTOM BUTTONS ── */
.gfp-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1vh, 10px);
  padding: clamp(10px, 1.8vh, 18px) clamp(12px, 2.5vw, 28px);
  border-top: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.18);
  flex-shrink: 0;
}

.gfp-action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 20px);
}

/* Reuse .lb-select-btn from lobby for action buttons */
.gfp-action-btn {
  min-width: clamp(90px, 14vw, 140px);
  padding: clamp(10px, 1.5vh, 14px) clamp(16px, 2.5vw, 24px) !important;
  justify-content: center;
}

.gfp-action-btn--danger {
  border-color: rgba(239, 100, 100, 0.4) !important;
  color: rgba(239, 100, 100, 0.85) !important;
  background: rgba(239, 100, 100, 0.05) !important;
}
.gfp-action-btn--danger:hover {
  border-color: rgba(239, 100, 100, 0.75) !important;
  background: rgba(239, 100, 100, 0.14) !important;
  color: #fff !important;
  box-shadow: 0 0 20px rgba(239, 100, 100, 0.2) !important;
}

/* hint-btn-ad on new lobby-style buttons */
#btn-hint.hint-btn-ad {
  border-color: var(--gold) !important;
  color: var(--gold) !important;
  background: rgba(255, 204, 68, 0.06) !important;
  animation: glowBlink 0.8s ease-in-out infinite !important;
}

/* round-log already styled in style.css */

/* ================================================================
   EXTRACTED INLINE STYLE CLASSES
   (moved from style="" attributes in index.html)
================================================================ */

/* Sound icon visibility — on shown by default, off hidden */
.lb-sound-on {
  display: block;
}
.lb-sound-off {
  display: none;
}
/* When button has muted class, swap icons */
#lb-btn-sound.muted .lb-sound-on {
  display: none;
}
#lb-btn-sound.muted .lb-sound-off {
  display: block;
}

/* Champion screen stat items */
.champ-stats {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin: 12px 0;
}
.stat-item {
  text-align: center;
}

/* Overlay z-index assignments */
#result-overlay {
  z-index: 400;
}
#overlay-confirm {
  z-index: 600;
}
#overlay-streak {
  z-index: 400;
}
#overlay-levels-page {
  z-index: 360;
}
#overlay-levels {
  z-index: 360;
}

/* Lobby title smaller variant (used in overlays) */
.lb-title-overlay {
  font-size: clamp(1.8rem, 5vw, 3rem) !important;
}

/* Settings volume row */
.settings-vol-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-sound-range {
  width: 90px;
  accent-color: var(--fr-accent);
}
.settings-vol-label-span {
  font-size: 0.75rem;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.8);
  min-width: 32px;
  text-align: right;
}

/* Difficulty selector */
.diff-btn-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diff-card-layout {
  justify-content: space-between;
  padding: clamp(14px, 2.5vh, 20px) clamp(16px, 3vw, 24px) !important;
}
.diff-card-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.diff-dots {
  font-size: 1.1rem;
}
.diff-size-badge {
  font-family: var(--fr-font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  opacity: 0.5;
}

/* Levels section (hidden on init via js-hidden) */
/* .js-hidden already handles display:none */

/* Levels diff header row */
.lvl-diff-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.lvl-section-title-inline {
  margin-bottom: 0;
}
.lvl-back-btn-sm {
  font-size: clamp(0.58rem, 1.1vw, 0.7rem);
  padding: 5px 10px;
}
.lvl-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.lvl-progress-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(160, 70, 255, 0.15);
  overflow: hidden;
  margin-bottom: 4px;
}
.lvl-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.8),
    var(--fr-accent),
    var(--fr-gold)
  );
  transition: width 0.3s;
}
.lvl-progress-label {
  margin-bottom: 14px;
}

/* Shop earn ad wrapper */
.shop-earn-ad-wrap {
  margin-top: 16px;
}

/* ================================================================
   AD OVERLAY — full-page layout classes
================================================================ */
#overlay-ad {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  flex-direction: column;
  background:
    linear-gradient(
      to bottom,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.92) 0%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.86) 50%,
      rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.94) 100%
    ),
    var(--thm-bg-url) center center / cover no-repeat;
}
#overlay-ad:not(.hidden) {
  display: flex;
}

.ad-inner-wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: clamp(16px, 3vh, 28px) clamp(16px, 3vw, 32px);
}
.ad-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: clamp(10px, 1.8vh, 16px);
  border-bottom: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.1);
  flex-shrink: 0;
}
.ad-header-label {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.5rem, 1.1vw, 0.64rem);
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.65);
}
.ad-body-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.5vh, 24px);
  padding: clamp(16px, 3vh, 28px) 0;
}
.ad-title-block {
  text-align: center;
}
.lb-title-ad {
  font-size: clamp(2rem, 6vw, 4rem) !important;
  margin-bottom: 4px;
}
.lb-tag-sm {
  font-size: clamp(0.5rem, 1.1vw, 0.66rem);
}
.ad-label-text {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.52rem, 1.1vw, 0.66rem);
  letter-spacing: 0.55em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.7);
}
.ad-frame-outer {
  width: 100%;
  max-width: 440px;
  position: relative;
}
.ad-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
  border-style: solid;
}
.ad-corner-tl {
  top: -1px;
  left: -1px;
  border-width: 1px 0 0 1px;
}
.ad-corner-tr {
  top: -1px;
  right: -1px;
  border-width: 1px 1px 0 0;
}
.ad-corner-bl {
  bottom: -1px;
  left: -1px;
  border-width: 0 0 1px 1px;
}
.ad-corner-br {
  bottom: -1px;
  right: -1px;
  border-width: 0 1px 1px 0;
}
.ad-dashed-frame {
  border: 1px dashed rgba(var(--th-r), var(--th-g), var(--th-b), 0.3);
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: 300 / 250;
  background: rgba(255, 255, 255, 0.015);
}
.ad-iframe-el {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.ad-footer-label {
  font-family: var(--fr-font-mono);
  font-size: clamp(0.44rem, 0.9vw, 0.56rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.12);
  text-align: center;
  padding-top: 8px;
  flex-shrink: 0;
}

/* Streak overlay */
.streak-days-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.streak-reward-big {
  font-size: clamp(1.4rem, 4vw, 2rem) !important;
  margin-top: 12px;
}
.streak-claim-btn {
  margin-top: 8px;
}

/* ================================================================
   QUIZ ENGINE — in-game question card & answer options
   Replaces the old pipe board. Built from the same FR design
   tokens (--th-r/g/b, --fr-accent, --green) used everywhere else
   in the lobby/overlay system, so it themes automatically across
   all four palettes without any extra wiring.
================================================================ */

.quiz-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(10px, 2vh, 18px);
  width: 100%;
  max-width: 420px;
  margin: 6px auto 0;
  position: relative;
}

.quiz-card {
  position: relative;
  background: linear-gradient(
    160deg,
    rgba(var(--th-bg-r), var(--th-bg-g), var(--th-bg-b), 0.92) 0%,
    rgba(var(--th-r), var(--th-g), var(--th-b), 0.07) 100%
  );
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.32);
  border-radius: 16px;
  padding: clamp(18px, 4vh, 28px) clamp(16px, 4vw, 24px);
  text-align: center;
  box-shadow:
    0 0 30px rgba(var(--th-r), var(--th-g), var(--th-b), 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.quiz-card-badge {
  font-family: var(--fr-font-ui);
  font-size: clamp(0.6rem, 1.3vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.75);
}

.quiz-question {
  font-family: "Rajdhani", sans-serif;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
}

@keyframes quizCardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes quizCardOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
}
.quiz-card-enter {
  animation: quizCardIn 0.36s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.quiz-card-exit {
  animation: quizCardOut 0.2s ease-in both;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vh, 12px);
}
.quiz-options-exit {
  animation: quizCardOut 0.2s ease-in both;
}

.quiz-opt {
  justify-content: flex-start !important;
  text-align: left;
  text-transform: none !important;
  letter-spacing: 0.01em !important;
  gap: 12px;
}
.quiz-opt-letter {
  flex-shrink: 0;
  width: clamp(22px, 4vw, 26px);
  height: clamp(22px, 4vw, 26px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fr-font-ui);
  font-weight: 700;
  font-size: clamp(0.7rem, 1.6vw, 0.8rem);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.16);
  border: 1px solid rgba(var(--th-r), var(--th-g), var(--th-b), 0.4);
  color: inherit;
  transition:
    background 0.18s,
    border-color 0.18s,
    color 0.18s;
}
.quiz-opt-text {
  flex: 1;
  font-weight: 600;
  text-transform: none;
}

@keyframes quizOptIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.quiz-opt-enter {
  animation: quizOptIn 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.quiz-opt--selected {
  border-color: rgba(var(--th-r), var(--th-g), var(--th-b), 0.85);
  background: rgba(var(--th-r), var(--th-g), var(--th-b), 0.22);
}

.quiz-opt--correct {
  border-color: var(--green) !important;
  background: rgba(0, 232, 153, 0.16) !important;
  color: var(--green) !important;
  box-shadow: 0 0 22px rgba(0, 232, 153, 0.35) !important;
  animation: quizPulse 0.5s ease;
}
.quiz-opt--correct .quiz-opt-letter {
  background: var(--green);
  border-color: var(--green);
  color: #04261b;
}

.quiz-opt--wrong {
  border-color: rgba(239, 68, 68, 0.85) !important;
  background: rgba(239, 68, 68, 0.14) !important;
  color: #f87171 !important;
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.3) !important;
}
.quiz-opt--wrong .quiz-opt-letter {
  background: #ef4444;
  border-color: #ef4444;
  color: #2a0a0a;
}

.quiz-opt--dim {
  opacity: 0.28;
  filter: grayscale(0.4);
  pointer-events: none;
}

@keyframes quizPulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes quizShake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  80% {
    transform: translateX(3px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-5px);
  }
  40%,
  60% {
    transform: translateX(5px);
  }
}
.quiz-shake {
  animation: quizShake 0.45s;
}

.quiz-mini-result {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translate(-50%, 12px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  font-family: var(--fr-font-ui);
  font-weight: 700;
  font-size: clamp(0.72rem, 1.6vw, 0.86rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(10px);
  z-index: 5;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}
.quiz-mini-result.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.quiz-mini-result .quiz-mini-icon {
  width: 16px;
  height: 16px;
}
.quiz-mini-result .quiz-mini-icon svg {
  width: 100%;
  height: 100%;
}
.quiz-mini-result.result-correct {
  background: rgba(0, 232, 153, 0.18);
  border: 1px solid var(--green);
  color: var(--green);
  box-shadow: 0 0 24px rgba(0, 232, 153, 0.3);
}
.quiz-mini-result.result-wrong {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid #ef4444;
  color: #f87171;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.25);
}

.round-chip.rc-correct {
  background: rgba(0, 232, 153, 0.14);
  color: var(--green);
  border: 1px solid rgba(0, 232, 153, 0.45);
}
.round-chip.rc-wrong {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

@media (max-width: 480px) {
  .quiz-wrap {
    max-width: 100%;
  }
  .quiz-question {
    font-size: clamp(0.92rem, 4vw, 1.1rem);
  }
}

/* ================================================================
   IMAGE ASSETS — Logo, Play Button, Background
================================================================ */

/* ── Logo image replaces text logo everywhere ── */
.lb-logo-img {
  display: block;
  width: clamp(185px, 48vw, 270px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.55));
  image-rendering: -webkit-optimize-contrast;
}

/* Loader screen logo — slightly larger than lobby */
#loading-screen .lb-logo-img {
  width: clamp(210px, 56vw, 310px);
}
.lb-logo-img--sm {
  width: clamp(100px, 28vw, 160px);
}
.lb-logo-img--md {
  width: clamp(140px, 38vw, 120px);
}
.lb-title {
  line-height: 1;
  padding: 0;
  background: none;
  -webkit-text-fill-color: unset;
}

/* In-game topbar logo */
.gfp-logo-img {
  display: block;
  height: clamp(28px, 6vw, 40px);
  width: auto;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}
.gfp-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* ── Play button image replaces HTML SVG button ── */
.lb-big-play--img {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: clamp(140px, 36vw, 200px);
  height: auto;
  border-radius: 0 !important;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}
.lb-big-play--img:hover,
.lb-big-play--img:focus {
  transform: scale(1.06);
  filter: brightness(1.1) drop-shadow(0 6px 20px rgba(255, 200, 0, 0.5));
}
.lb-big-play--img:active {
  transform: scale(0.96);
}
.lb-play-img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

/* ── Theme builder preview card — logo size ── */
.thm-game-title .lb-logo-img--sm {
  width: clamp(70px, 18vw, 110px);
}
.thm-game-title .lb-logo-img--md {
  width: clamp(120px, 30vw, 100px);
}

/* ================================================================
   IMAGE BUTTONS — sprite-based buttons replacing SVG/HTML buttons
================================================================ */

/* ── Icon-only buttons (lobby + in-game topbar) ── */
.img-icon-btn {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 2px !important;
  width: clamp(38px, 8vw, 52px) !important;
  height: clamp(38px, 8vw, 52px) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}
.img-icon-btn:hover {
  transform: scale(1.1);
  filter: brightness(1.1);
}
.img-icon-btn:active {
  transform: scale(0.93);
}
.img-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

/* ── Select buttons with icon (Store, Difficulty) ── */
.img-btn .img-btn-icon {
  width: clamp(22px, 4.5vw, 30px);
  height: clamp(22px, 4.5vw, 30px);
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Full image text buttons (Next, Resume, Home, etc.) ── */
/* The button keeps its existing fr-action-btn padding/sizing
   but adds the image as an absolute background layer */
.img-text-btn {
  position: relative;
  overflow: visible;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  isolation: isolate;
}
.img-text-btn-bg {
  position: absolute;
  inset: -6px -10px;
  width: calc(100% + 20px);
  height: calc(100% + 12px);
  object-fit: fill;
  pointer-events: none;
  z-index: 0;
  opacity: 0.92;
  border-radius: 12px;
}
.img-text-btn > *:not(.img-text-btn-bg) {
  position: relative;
  z-index: 1;
}
.img-text-btn:hover .img-text-btn-bg {
  opacity: 1;
  filter: brightness(1.08);
}
.img-text-btn:active .img-text-btn-bg {
  filter: brightness(0.92);
  transform: scale(0.97);
}
