/* Snake Rush — Mind Boot Studios · © 2026 Mind Boot Studios */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  color-scheme: light dark;
  --bg: #0F172A;
  --card: #1E293B;
  --green: #4ADE80;
  --green-dark: #22C55E;
  --gold: #FFD700;
  --pink: #F472B6;
  --blue: #38BDF8;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --border: #334155;
  --border-strong: #475569;
  --surface: rgba(30, 41, 59, 0.88);
  --surface-chip: rgba(51, 65, 85, 0.85);
  --surface-subtle: rgba(15, 23, 42, 0.55);
  --surface-track: #334155;
  --surface-input: #0f172a;
  --card-gradient: linear-gradient(135deg, #243044 0%, #1e293b 100%);
  --card-gradient-alt: linear-gradient(135deg, #1e293b 0%, #172033 100%);
  --toggle-card-bg: linear-gradient(135deg, #1E293B 0%, #172033 100%);
  --toggle-card-checked: linear-gradient(135deg, #1a2e28 0%, #172033 100%);
  --toggle-icon-bg: rgba(255, 255, 255, 0.05);
  --overlay-bg: rgba(8, 12, 24, 0.78);
  --overlay-modal: rgba(8, 12, 24, 0.72);
  --modal-bg: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  --toast-bg: linear-gradient(135deg, #1e293b, #0f172a);
  --brand-bar: linear-gradient(90deg, #0F172A, #1a2744, #0F172A);
  --btn-primary-text: #0F172A;
  --shadow: rgba(0, 0, 0, 0.45);
  --shadow-soft: rgba(0, 0, 0, 0.35);
  --divider: #475569;
  --arena-bg: radial-gradient(ellipse at center, #1a1010 0%, #0f172a 70%);
  --ad-card-bg: linear-gradient(160deg, #1a2238 0%, #121a2c 100%);
  --toast-success-text: #bbf7d0;
  --toast-error-text: #fecaca;
  --toast-warn-text: #fde68a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --space: clamp(12px, 2vw, 24px);
  --font-base: clamp(14px, 1.6vw, 18px);
  --font-title: clamp(1.6rem, 4vw, 2.8rem);
  --canvas-max: min(92vw, 420px);
  --btn-radius: clamp(12px, 1.5vw, 18px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F1F5F9;
    --card: #FFFFFF;
    --green: #16A34A;
    --green-dark: #15803D;
    --gold: #CA8A04;
    --pink: #DB2777;
    --blue: #0284C7;
    --text: #0F172A;
    --muted: #64748B;
    --border: #CBD5E1;
    --border-strong: #94A3B8;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-chip: rgba(241, 245, 249, 0.95);
    --surface-subtle: rgba(255, 255, 255, 0.75);
    --surface-track: #E2E8F0;
    --surface-input: #F8FAFC;
    --card-gradient: linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 100%);
    --card-gradient-alt: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    --toggle-card-bg: linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 100%);
    --toggle-card-checked: linear-gradient(135deg, #ECFDF5 0%, #F0FDF4 100%);
    --toggle-icon-bg: rgba(15, 23, 42, 0.06);
    --overlay-bg: rgba(15, 23, 42, 0.35);
    --overlay-modal: rgba(15, 23, 42, 0.32);
    --modal-bg: linear-gradient(160deg, #FFFFFF 0%, #F8FAFC 100%);
    --toast-bg: linear-gradient(135deg, #FFFFFF, #F8FAFC);
    --brand-bar: linear-gradient(90deg, #F8FAFC, #E2E8F0, #F8FAFC);
    --btn-primary-text: #FFFFFF;
    --shadow: rgba(15, 23, 42, 0.12);
    --shadow-soft: rgba(15, 23, 42, 0.08);
    --divider: #CBD5E1;
    --arena-bg: radial-gradient(ellipse at center, #E2E8F0 0%, #F1F5F9 70%);
    --ad-card-bg: linear-gradient(160deg, #FFFFFF 0%, #F8FAFC 100%);
    --toast-success-text: #166534;
    --toast-error-text: #B91C1C;
    --toast-warn-text: #B45309;
  }
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--font-base);
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.hidden { display: none !important; }

/* ── Mind Boot Studios animated brand bar ── */
.mbg-brand-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 16px);
  padding: 6px var(--space);
  background: var(--brand-bar);
  background-size: 200% 100%;
  animation: mbgShimmer 6s ease infinite;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

@keyframes mbgShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.mbg-logo-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  font-weight: 800;
  font-size: clamp(0.85rem, 2.2vw, 1.1rem);
  letter-spacing: 0.04em;
}

.mbg-mark {
  width: clamp(30px, 5.5vw, 38px);
  height: clamp(30px, 5.5vw, 38px);
  flex-shrink: 0;
  margin: 0 clamp(6px, 1.5vw, 10px);
  display: block;
  filter: drop-shadow(0 0 10px rgba(62, 207, 182, 0.38)) drop-shadow(0 0 14px rgba(124, 156, 255, 0.22));
  animation: mbgFloat 3.2s ease-in-out infinite;
}

.reduced-motion .mbg-mark {
  animation: none !important;
}

/* ── Mind Boot Studios letter animations ── */
.grs-word {
  display: inline-flex;
  align-items: baseline;
}
.grs-char {
  display: inline-block;
  animation: grsLetterWave 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.07s);
  will-change: transform;
}
.grs-boot .grs-char {
  color: var(--blue);
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}
.grs-mind {
  position: relative;
  animation: grsRespawnPulse 3.5s ease-in-out infinite;
}
.grs-boot {
  position: relative;
  margin-left: 2px;
}
.grs-mind .grs-char {
  color: var(--green);
  animation-name: grsLetterWave, grsRespawnFlash;
  animation-duration: 2.4s, 3.5s;
  animation-timing-function: ease-in-out, ease-in-out;
  animation-iteration-count: infinite, infinite;
  animation-delay: calc(var(--i, 0) * 0.07s), calc(var(--i, 0) * 0.05s);
}
.grs-mind::after {
  content: "";
  position: absolute;
  inset: -2px -4px;
  border-radius: 6px;
  background: radial-gradient(ellipse at center, rgba(74, 222, 128, 0.22), transparent 70%);
  opacity: 0;
  z-index: -1;
  animation: grsRespawnAura 3.5s ease-in-out infinite;
  pointer-events: none;
}
.grs-studios,
.mbg-games {
  margin-left: 6px;
  font-weight: 500;
  font-size: 0.75em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  animation: grsStudiosFade 4s ease-in-out infinite;
}
.grs-login-brand {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0;
  font-weight: 800;
  font-size: 1.08em;
}
.grs-login-brand .grs-char {
  animation-duration: 2.8s;
}
.grs-login-brand .grs-mind .grs-char {
  animation-duration: 2.8s, 4s;
}

@keyframes grsLetterWave {
  0%, 100% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-3px) scale(1.06); }
  50% { transform: translateY(0) scale(1); }
  75% { transform: translateY(-1px) scale(1.02); }
}
@keyframes grsRespawnFlash {
  0%, 78%, 100% {
    text-shadow: 0 0 0 transparent;
    filter: brightness(1);
  }
  82% {
    text-shadow: 0 0 14px rgba(74, 222, 128, 0.9), 0 0 28px rgba(74, 222, 128, 0.45);
    filter: brightness(1.35);
  }
  88% {
    text-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
    filter: brightness(1.1);
  }
}
@keyframes grsRespawnPulse {
  0%, 78%, 100% { transform: scale(1); }
  84% { transform: scale(1.03); }
}
@keyframes grsRespawnAura {
  0%, 75%, 100% { opacity: 0; transform: scale(0.92); }
  82% { opacity: 1; transform: scale(1.08); }
  90% { opacity: 0; transform: scale(1.15); }
}
@keyframes grsStudiosFade {
  0%, 100% { opacity: 0.65; letter-spacing: 0.1em; }
  50% { opacity: 1; letter-spacing: 0.14em; }
}
@keyframes mbgFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes mbgPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.reduced-motion .mbg-brand-bar,
.reduced-motion .mbg-games,
.reduced-motion .mbg-mark,
.reduced-motion .brand-logo-mark,
.reduced-motion .grs-char,
.reduced-motion .grs-mind,
.reduced-motion .grs-mind::after,
.reduced-motion .grs-studios,
.reduced-motion .pulse-glow {
  animation: none !important;
}

/* Pause decorative animations during gameplay (saves GPU / battery) */
body:has(#screen-game.active) .mbg-brand-bar .grs-char,
body:has(#screen-game.active) .mbg-brand-bar .grs-mind::after,
body:has(#screen-game.active) .mbg-brand-bar .grs-studios {
  animation-play-state: paused;
}

body.device-phone .top-bar {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--surface);
}

body.device-phone .game-pause-menu,
body.device-phone .game-overlay {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.device-phone .grs-char {
  will-change: auto;
}

/* ── App shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
}

.screen-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  align-items: stretch;
}

.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 10px var(--space) max(12px, calc(var(--safe-bottom) + 8px));
  font-size: clamp(0.72rem, 1.8vw, 0.82rem);
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  flex-shrink: 0;
  min-height: 2.5rem;
}
/* ── HUD ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--space) 8px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  font-size: clamp(13px, 1.8vw, 16px);
  flex-wrap: wrap;
  flex-shrink: 0;
  row-gap: 6px;
}
.hud-item {
  background: var(--surface-chip);
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  min-width: 0;
  line-height: 1.25;
}
.hud-item.rank {
  flex: 1 1 120px;
  min-width: 0;
  text-align: center;
  color: var(--gold);
  font-weight: 700;
  font-size: clamp(0.82rem, 1.7vw, 1rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hud-item.auth {
  flex: 0 1 auto;
  max-width: min(46%, 220px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(12px, 1.7vw, 15px);
  font-weight: 600;
  opacity: 1;
}

.xp-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--space) 10px;
  min-height: 2.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.xp-track {
  flex: 1;
  min-width: 0;
  height: 8px;
  background: var(--surface-track);
  border-radius: 999px;
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
  width: 0%;
  transition: width 0.4s ease;
  will-change: width;
  border-radius: 999px;
}
.xp-text {
  flex: 0 0 auto;
  font-size: clamp(12px, 1.9vw, 15px);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.35;
  letter-spacing: 0.01em;
  padding: 2px 0 3px;
}

/* ── Screens ── */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: var(--space);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.25s ease;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  flex-shrink: 0;
}
.screen-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  line-height: 1.25;
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.01em;
}

/* ── Login ── */
.login-screen {
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding-top: clamp(8px, 2vh, 24px);
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
}

body:has(#screen-login.active) {
  overflow: hidden;
}

#screen-login.login-screen.active {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.btn-new-guest {
  width: 100%;
  margin-top: 4px;
  font-size: 0.9rem;
}

.login-card .btn-new-guest:not(.hidden) + .login-divider,
.login-card .btn-guest + .btn-new-guest:not(.hidden) {
  margin-top: 0;
}

body.web-silent-auth .login-card-web {
  gap: 16px;
}

body.web-silent-auth #btn-guest-play {
  font-size: 1.1rem;
  padding: 16px 20px;
}

body.web-silent-auth .login-sub.web-sync-note {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}
.login-brand { margin-bottom: 8px; }
.login-brand.login-brand-compact { margin-bottom: 4px; }
.login-brand.login-brand-compact .tagline,
.login-brand.login-brand-compact .mbg-sub { display: none; }
body.android-native-login .login-screen { justify-content: center; }
.brand-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
}

.brand-logo-mark {
  width: clamp(64px, 18vw, 88px);
  height: clamp(64px, 18vw, 88px);
  display: block;
  filter: drop-shadow(0 4px 18px rgba(62, 207, 182, 0.32)) drop-shadow(0 2px 10px rgba(124, 156, 255, 0.2));
  animation: mbgFloat 3.5s ease-in-out infinite;
}

.menu-brand .brand-logo-mark {
  width: clamp(56px, 16vw, 76px);
  height: clamp(56px, 16vw, 76px);
}
.login-brand h1 { font-size: var(--font-title); }
.mbg-sub { color: var(--muted); margin: 4px 0 8px; }
.tagline { color: var(--muted); font-size: 0.9em; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: clamp(20px, 4vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.btn-play-games.btn-primary {
  width: 100%;
  margin-top: 0;
  padding: 14px 20px;
  font-size: 1.05rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78em;
  margin: 4px 0;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.login-sub { color: var(--muted); font-size: 0.85em; line-height: 1.5; text-align: center; }
.login-sub small { font-size: 0.85em; opacity: 0.8; }

/* OAuth pill buttons — same footprint as former Sign in with Apple */
.btn-oauth-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 14px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: clamp(0.95rem, 2.1vw, 1.05rem);
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-oauth-pill svg {
  flex-shrink: 0;
}
.btn-oauth-pill:active {
  transform: scale(0.985);
}
body.show-focus .btn-oauth-pill:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.btn-google {
  border: 1.5px solid #747775;
  background: #fff;
  color: #1f1f1f;
  box-shadow:
    0 1px 2px rgba(60, 64, 67, 0.12),
    0 2px 6px rgba(60, 64, 67, 0.08);
}
.btn-google:hover {
  background: #f8f9fa;
  box-shadow:
    0 1px 3px rgba(60, 64, 67, 0.16),
    0 4px 10px rgba(60, 64, 67, 0.1);
}
.btn-google:active {
  background: #f1f3f4;
  border-color: #5f6368;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.1);
}

.btn-apple {
  border: none;
  background: #000;
  color: #fff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 2px 6px rgba(0, 0, 0, 0.15);
}
.btn-apple:hover {
  background: #1a1a1a;
}
.btn-apple:active {
  background: #2a2a2a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-play-games {
  border: none;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #e2e8f0;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.2), 0 2px 6px rgba(15, 23, 42, 0.35);
}
.btn-play-games:hover {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
}
.btn-play-games:active {
  transform: scale(0.98);
}

@media (prefers-color-scheme: dark) {
  .login-card .btn-google {
    background: #fff;
    color: #1f1f1f;
    border-color: #dadce0;
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.35),
      0 1px 2px rgba(0, 0, 0, 0.2);
  }
}

.login-error { color: #f87171; font-size: 0.85em; line-height: 1.4; }
.login-loading { color: var(--green); font-size: 0.9em; }

/* ── App-wide loading overlay (centered game board) ── */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space);
  background: var(--bg);
  transition: opacity 0.25s ease;
}
.app-loading-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3vw, 20px);
  width: min(100%, calc(var(--canvas-max) + 48px));
}
.app-loading-board {
  width: min(92vw, var(--canvas-max));
  max-width: var(--canvas-max);
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 36px var(--shadow);
  flex-shrink: 0;
}
.app-loading-snake {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
}
.app-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  pointer-events: none;
}
.app-loading-title {
  font-weight: 800;
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  letter-spacing: 0.04em;
  color: var(--text);
}
.app-loading-text {
  color: var(--muted);
  font-size: 0.92em;
  min-height: 1.4em;
}

.reduced-motion .app-loading-snake {
  opacity: 0.98;
}
.login-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  width: 100%;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.settings-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.setting-toggle {
  cursor: pointer;
  display: block;
}
.setting-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.setting-toggle-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--toggle-card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.setting-toggle-input:focus-visible + .setting-toggle-card {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.setting-toggle-input:checked + .setting-toggle-card {
  border-color: rgba(74, 222, 128, 0.45);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.12), 0 4px 16px rgba(74, 222, 128, 0.08);
  background: var(--toggle-card-checked);
}

.setting-icon {
  font-size: 1.35rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--toggle-icon-bg);
  border-radius: 10px;
  flex-shrink: 0;
}
.setting-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.setting-label {
  font-size: 0.92em;
  font-weight: 600;
  color: var(--text);
}
.setting-hint {
  font-size: 0.72em;
  color: var(--muted);
}

.setting-switch {
  position: relative;
  width: 46px;
  height: 26px;
  background: var(--border-strong);
  border-radius: 20px;
  flex-shrink: 0;
  transition: background 0.25s ease;
}
.setting-toggle-input:checked + .setting-toggle-card .setting-switch {
  background: var(--green);
}
.setting-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.setting-toggle-input:checked + .setting-toggle-card .setting-knob {
  transform: translateX(20px);
}

/* Hide vibration on TV — no haptic hardware */
body.device-tv .haptics-setting-wrap {
  display: none !important;
}

.legal { width: 100%; text-align: center; font-size: 0.72rem; color: var(--muted); }

/* ── Menu (home screen — matches login layout) ── */
.app-shell:has(#screen-menu.active) .top-bar,
.app-shell:has(#screen-menu.active) .xp-strip,
.app-shell:has(#screen-coop.active) .top-bar,
.app-shell:has(#screen-coop.active) .xp-strip {
  display: none;
}

.menu-screen.active {
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 10px var(--space) 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.menu-home {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-top: 4px;
}

.menu-brand {
  margin-bottom: 4px;
  text-align: center;
  flex-shrink: 0;
}

.menu-brand .brand-logo {
  margin-bottom: 6px;
  line-height: 1;
}

.menu-brand .brand-logo-mark {
  width: clamp(56px, 16vw, 76px);
  height: clamp(56px, 16vw, 76px);
}

.menu-brand h1 {
  font-size: var(--font-title);
  margin: 0 0 6px;
  line-height: 1.1;
}

.menu-brand .player-greeting {
  color: var(--green);
  margin: 0;
  font-weight: 600;
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  line-height: 1.45;
  max-width: 100%;
  padding: 0 4px;
  overflow-wrap: anywhere;
}

.menu-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 10px 40px var(--shadow-soft);
  padding: clamp(18px, 3.5vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.menu-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.menu-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 0;
  height: auto;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-gradient);
  color: var(--text);
  font-size: clamp(0.76rem, 1.8vw, 0.85rem);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.menu-chip:active {
  transform: scale(0.97);
  border-color: rgba(74, 222, 128, 0.45);
}

.menu-chip-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.menu-chip-muted {
  opacity: 0.9;
}

.menu-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  text-align: center;
  min-width: 0;
}

.stat-chip span {
  color: var(--muted);
  font-size: clamp(0.68rem, 1.5vw, 0.78rem);
  white-space: nowrap;
  line-height: 1.2;
}

.stat-chip strong {
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  color: var(--green);
  font-weight: 800;
}

.menu-arenas {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-section-label {
  margin: 0;
  font-size: clamp(0.78rem, 1.8vw, 0.88rem);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}

.menu-screen .difficulty-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-screen .diff-btn {
  width: 100%;
  min-height: 0;
  height: auto;
  padding: 12px 14px;
  border-radius: var(--btn-radius);
  border: 1px solid var(--border);
  background: var(--card-gradient-alt);
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.diff-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  min-height: 1.5rem;
}

.menu-screen .diff-btn span.diff-emoji {
  font-size: 1.35rem;
  line-height: 1;
}

.menu-screen .diff-btn .diff-heading {
  font-size: clamp(0.92rem, 2vw, 1rem);
  font-weight: 700;
  line-height: 1.35;
  width: 100%;
}

.menu-screen .diff-btn .diff-trait-inline {
  font-weight: 600;
  color: var(--green);
}

.menu-screen .diff-btn small {
  font-size: clamp(0.8rem, 1.8vw, 0.88rem);
  width: 100%;
  order: unset;
  line-height: 1.45;
  color: var(--muted);
}

.menu-screen .diff-btn.active {
  border-color: var(--green);
  background: rgba(74, 222, 128, 0.08);
}

.menu-screen .diff-btn.active[data-mode="very_easy"] {
  border-color: var(--blue);
  background: rgba(56, 189, 248, 0.1);
}

.menu-play-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 0;
}

.menu-action-btn {
  width: 100%;
  max-width: none;
  margin: 0 !important;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 14px 16px !important;
  font-size: 1rem !important;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--btn-radius);
}

.menu-play-row .btn-primary.menu-action-btn {
  box-shadow: 0 6px 20px rgba(74, 222, 128, 0.22);
}

.menu-play-row .coop-menu-btn {
  border: 1px solid var(--border-strong);
  background: var(--card-gradient-alt);
  color: var(--text);
}

.player-greeting { color: var(--green); margin-top: 2px; font-weight: 600; font-size: 0.88em; }

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.diff-btn span.diff-emoji { font-size: 1.2em; }
.diff-btn .diff-heading { font-size: 0.9em; line-height: 1.35; }
.diff-btn .diff-trait-inline {
  font-weight: 600;
  color: var(--green);
}
.diff-btn small { font-size: 0.68em; color: var(--muted); line-height: 1.25; }
.diff-btn.active { border-color: var(--green); background: rgba(74,222,128,0.08); }
.diff-btn.active[data-mode="very_easy"] { border-color: var(--blue); background: rgba(56,189,248,0.1); }
.diff-btn.active[data-mode="easy"] { border-color: #F87171; background: rgba(248,113,113,0.1); }
.diff-btn.active[data-mode="medium"] { border-color: #F87171; background: rgba(248,113,113,0.1); }
.diff-btn.active[data-mode="hard"] { border-color: #F87171; background: rgba(248,113,113,0.1); }
.diff-btn:active { transform: scale(0.97); }
.menu-screen .diff-btn.active[data-mode="easy"],
.menu-screen .diff-btn.active[data-mode="medium"],
.menu-screen .diff-btn.active[data-mode="hard"] {
  border-color: #F87171;
  background: rgba(248, 113, 113, 0.1);
}

/* Mode visuals on game board */
body.mode-very-easy #game-canvas {
  border-color: var(--blue);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.15);
}
body.mode-medium #game-canvas,
body.mode-hard #game-canvas {
  border-color: #F87171;
  box-shadow: 0 0 28px rgba(248, 113, 113, 0.2);
}
/* Pulse only on menu — static shadow during gameplay saves GPU */
body.mode-medium:not(:has(#screen-game.active)) #game-canvas,
body.mode-hard:not(:has(#screen-game.active)) #game-canvas {
  animation: infernoPulse 1.8s ease-in-out infinite;
}
body.mode-medium .canvas-wrap,
body.mode-hard .canvas-wrap {
  background: var(--arena-bg);
  border-radius: 16px;
}
body.mode-easy #game-canvas {
  border-color: #F87171;
  box-shadow: 0 0 20px rgba(248, 113, 113, 0.15);
}
@keyframes infernoPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(248, 113, 113, 0.15); }
  50% { box-shadow: 0 0 32px rgba(248, 113, 113, 0.35); }
}

/* ── Buttons ── */
button, .btn-primary, .btn-secondary, .btn-sm, .btn-icon, .dpad-btn {
  font-family: inherit;
}
button:focus-visible, .btn-primary:focus-visible, .btn-secondary:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}
body:not(.show-focus) button:focus { outline: none; }

.btn-primary {
  width: 100%;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  padding: clamp(14px, 2.5vw, 20px);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 700;
  border: none;
  border-radius: var(--btn-radius);
  background: linear-gradient(135deg, var(--green), #22C55E);
  color: var(--btn-primary-text);
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 8px 24px rgba(74, 222, 128, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 4px 14px rgba(74, 222, 128, 0.18);
}
.btn-secondary {
  padding: clamp(12px, 2vw, 16px) 8px;
  border: 1px solid var(--border);
  border-radius: var(--btn-radius);
  background: var(--card-gradient);
  color: var(--text);
  font-size: clamp(0.8rem, 1.6vw, 0.95rem);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--shadow-soft);
}
.btn-sm { padding: 8px 14px; border: none; border-radius: 10px; background: var(--green); color: var(--btn-primary-text); font-weight: 600; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  width: clamp(40px, 6vw, 44px);
  height: clamp(40px, 6vw, 44px);
  border-radius: 12px;
  font-size: clamp(18px, 2.5vw, 22px);
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.pulse-glow { animation: pulseGlow 2.5s infinite; }
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4); }
  50% { box-shadow: 0 0 20px 4px rgba(74, 222, 128, 0.25); }
}

/* ── Co-op menu button ── */
.coop-menu-btn {
  width: 100%;
  max-width: none;
  margin: 0;
  display: inline-flex;
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
}

/* ── Co-op lobby (matches menu pill layout) ── */
.coop-screen.active {
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 10px var(--space) 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.coop-home {
  gap: 14px;
}

.coop-brand {
  position: relative;
  width: 100%;
  padding: 0 44px;
}

.coop-back-btn {
  position: absolute;
  left: 0;
  top: 2px;
}

.coop-card-main {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.coop-duo-hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
  font-size: 0.92rem;
}

.coop-duo-legend {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0;
}

.coop-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
}

.coop-legend-sep {
  color: var(--muted);
  opacity: 0.5;
  user-select: none;
}

.coop-room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 360px) {
  .coop-room-actions {
    grid-template-columns: 1fr;
  }
}

.coop-room-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.coop-room-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.coop-room-code {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.75rem, 8vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-align: center;
  color: var(--text);
}

.coop-room-wait {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.coop-room-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  color: var(--text);
}

.coop-online-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coop-online-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.coop-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(74, 222, 128, 0.15);
  color: var(--green);
}

.coop-step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.coop-step-body strong {
  font-size: 0.88rem;
  color: var(--text);
}

.coop-step-body span {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.coop-online-shared {
  margin-bottom: 0 !important;
}

body.coop-online-mode .coop-controls-panel .coop-ctrl-toggle {
  display: none;
}

.coop-card-main .menu-action-btn {
  width: 100%;
  margin: 0 !important;
}

.duo-p1,
.duo-p1 .duo-player-label { color: #38BDF8; }
.duo-p2,
.duo-p2 .duo-player-label { color: #4ADE80; }

.duo-player-label {
  font-weight: 700;
}

.duo-hud-scores {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex: 0 1 auto;
}

body.duo-active .duo-hud-scores {
  display: inline-flex !important;
}

.duo-hud-score .duo-player-label {
  margin-right: 2px;
}

.duo-lives-chip .duo-player-label {
  font-size: 0.72rem;
  margin-right: 2px;
}

@media (max-width: 380px) {
  .duo-lives-chip .duo-player-label {
    font-size: 0.65rem;
  }
  .duo-hud-score {
    font-size: 0.8rem;
  }
}

.board-hint .duo-p1 { color: #38BDF8; font-weight: 700; }
.board-hint .duo-p2 { color: #4ADE80; font-weight: 700; }

.coop-ctrl-player.duo-p1 .duo-player-label { color: #38BDF8; }
.coop-ctrl-player.duo-p2 .duo-player-label { color: #4ADE80; }

.duo-color-swatch {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
  border: 3px solid rgba(255, 255, 255, 0.55);
}

.duo-color-swatch.duo-p1 { background: #38BDF8; }
.duo-color-swatch.duo-p2 { background: #4ADE80; }

.duo-color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
  flex-shrink: 0;
}

.duo-p1 .duo-color-dot { background: #38BDF8; }
.duo-p2 .duo-color-dot { background: #4ADE80; }

.duo-lives-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.duo-lives-sep {
  margin: 0 6px;
  color: var(--muted);
}

body.duo-active .solo-only { display: none !important; }
body.duo-active .duo-only { display: inline !important; }
body.duo-active .duo-only.hidden { display: inline !important; }

.duo-hud-score {
  display: inline-flex;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
}

.duo-hud-score.duo-p1 { color: #38BDF8; }
.duo-hud-score.duo-p2 { color: #4ADE80; }

.game-pause-coop {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: -4px 0 12px;
}

.duo-pause-score {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 1.05rem;
}

.duo-pause-score.duo-p1 { color: #38BDF8; }
.duo-pause-score.duo-p2 { color: #4ADE80; }

body.duo-active .game-main { width: 100%; }
body.duo-active #game-dpad { display: none !important; }
body.duo-active .board-hint { display: none; }

/* Co-op control settings panel */
.coop-controls-panel,
.duo-controls-panel {
  width: 100%;
  text-align: left;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--border);
}

.duo-controls-panel {
  margin-bottom: 0;
  padding: 10px 12px max(10px, calc(var(--safe-bottom) * 0.25 + 8px));
  flex-shrink: 0;
}

.coop-ctrl-heading {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.coop-ctrl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin-bottom: 10px;
}

.coop-ctrl-col-head {
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}

.coop-ctrl-col-head.duo-p1 {
  color: #38BDF8;
  border-bottom-color: rgba(56, 189, 248, 0.35);
}

.coop-ctrl-col-head.duo-p2 {
  color: #4ADE80;
  border-bottom-color: rgba(74, 222, 128, 0.35);
}

.coop-ctrl-cell {
  min-height: 0;
}

.coop-ctrl-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

@media (max-width: 420px) {
  .coop-ctrl-grid {
    gap: 8px 10px;
  }
}

.coop-ctrl-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coop-ctrl-player {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  margin-bottom: 2px;
}

.coop-ctrl-player strong {
  font-weight: 700;
}

.coop-ctrl-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
}

@media (prefers-color-scheme: dark) {
  .coop-ctrl-row {
    background: rgba(255, 255, 255, 0.04);
  }
}

.coop-ctrl-keys {
  font-size: 0.8rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  line-height: 1.3;
}

.coop-ctrl-detail {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.coop-ctrl-shared {
  padding-top: 10px;
  margin-bottom: 12px;
  border-top: 1px solid var(--border);
}

.coop-controls-panel .coop-ctrl-toggle {
  margin: 0;
}

.coop-controls-panel .setting-toggle-card {
  align-items: center;
}

.coop-ctrl-pad-status {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.2em;
}

body.duo-active .duo-controls-panel:not(.hidden) {
  display: block !important;
}
body.duo-active #duo-controls-ingame.hidden {
  display: none !important;
}

/* ── Game layout ── */
#screen-game {
  padding: clamp(8px, 1.4vw, 14px) var(--space);
  padding-bottom: max(8px, var(--safe-bottom));
  overflow: hidden;
  align-items: center;
}

.app-shell:has(#screen-game.active) .app-footer {
  display: none;
}

.game-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  gap: 6px;
  width: 100%;
  max-width: min(100%, calc(var(--canvas-max) + 48px));
}

.game-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  gap: 6px;
  width: min(100%, var(--canvas-max));
  max-width: var(--canvas-max);
}

.game-hud {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  flex-shrink: 0;
  font-size: clamp(0.82rem, 1.8vw, 1rem);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.game-hud-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 2rem;
}

.game-hud-top {
  justify-content: space-between;
  gap: 8px;
}

.game-hud-score {
  flex: 0 1 auto;
  white-space: nowrap;
  line-height: 1.25;
}

.game-hud-stats {
  justify-content: center;
  flex-wrap: wrap;
  row-gap: 4px;
  column-gap: 12px;
}

.game-hud-row > span {
  white-space: nowrap;
  line-height: 1.25;
}

.game-hud .btn-icon,
.game-hud-pause {
  width: clamp(36px, 5vw, 42px);
  height: clamp(36px, 5vw, 42px);
  flex-shrink: 0;
  margin-left: auto;
}

.game-hud .combo { color: var(--gold); font-weight: 800; flex: 1 1 auto; text-align: center; min-width: 0; }
.game-hud .lives-hud { font-weight: 600; }
.diff-badge { font-size: 1.1em; }

.canvas-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}
.board-hint {
  flex-shrink: 0;
  font-size: clamp(0.82rem, 2.2vw, 0.98rem);
  font-weight: 600;
  color: var(--text);
  opacity: 0.88;
  text-align: center;
  margin: 0;
  padding: 6px 8px max(8px, calc(var(--safe-bottom) * 0.25 + 6px));
  line-height: 1.4;
  width: 100%;
}
body.device-tv .board-hint { display: none; }
#game-canvas {
  width: 100%;
  height: auto;
  max-width: var(--canvas-max);
  max-height: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  border: 2px solid var(--border);
  touch-action: none;
  cursor: pointer;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 8px 24px var(--shadow-soft);
}

body.device-phone #game-dpad,
body.device-tablet #game-dpad {
  display: none;
}
body.device-phone .game-main,
body.device-tablet .game-main {
  flex: 1 1 auto;
  width: min(100%, var(--canvas-max));
  max-width: var(--canvas-max);
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  flex-shrink: 0;
}
.dpad-label {
  font-size: clamp(0.72rem, 1.6vw, 0.82rem);
  color: var(--text);
  opacity: 0.75;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.dpad-mid { display: flex; gap: clamp(36px, 8vw, 56px); }
.dpad-btn {
  width: clamp(56px, 12vw, 80px);
  height: clamp(56px, 12vw, 80px);
  border: none;
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  font-size: clamp(18px, 3vw, 26px);
  cursor: pointer;
}
.dpad-btn:active { background: var(--surface-track); transform: scale(0.94); }
.device-tv .dpad-btn { width: 88px; height: 88px; font-size: 28px; }

/* ── Rewards ── */
.big-score { text-align: center; font-size: clamp(1.2rem, 3vw, 1.6rem); margin: 12px 0 20px; color: var(--gold); }
.reward-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.reward-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  padding: 14px 16px;
  border-radius: 14px;
  animation: slideUp 0.35s ease both;
}
.reward-card.gold { border: 1px solid var(--gold); background: linear-gradient(135deg, #1E293B, #2D2410); }
.reward-card.pulse { animation: slideUp 0.35s ease both, pulse 1.5s infinite 0.35s; }
.rc-icon { font-size: 1.5em; }
.rc-label { flex: 1; color: var(--muted); font-size: 0.9em; }
.rc-value { font-weight: 800; color: var(--green); }

@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.015); } }

/* ── Shop / Leaderboard ── */
.shop-list, .leaderboard-list {
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}
.shop-balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), var(--card));
  border: 1px solid rgba(255, 215, 0, 0.45);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 22px var(--shadow-soft);
}
.shop-balance-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.shop-balance-card span { color: var(--muted); font-size: clamp(0.84rem, 1.8vw, 0.92rem); }
.shop-balance-note {
  color: var(--text);
  opacity: 0.78;
  font-size: clamp(0.78rem, 1.7vw, 0.86rem);
  line-height: 1.35;
  font-weight: 600;
}
.shop-balance-card strong {
  color: var(--gold);
  font-size: clamp(1.15rem, 2.6vw, 1.35rem);
  flex-shrink: 0;
}
.shop-section-title {
  margin: 16px 0 4px;
  font-size: 1rem;
  text-align: left;
}
.shop-section-hint {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
  line-height: 1.4;
}
.shop-price {
  color: var(--gold);
  font-weight: 700;
}
.btn-sm.btn-buy-coin {
  background: linear-gradient(180deg, #3d3010 0%, #2a2208 100%);
  border-color: rgba(255, 215, 0, 0.55);
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}
.diff-btn.locked {
  opacity: 0.82;
  border-style: dashed;
}
.diff-btn .diff-lock {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  color: var(--gold);
  font-style: normal;
  font-weight: 700;
  margin: 0;
  margin-left: auto;
  white-space: nowrap;
}
.shop-support-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
}
.shop-support-toggles .setting-toggle {
  width: 100%;
}
.shop-support-toggles .setting-toggle-card {
  border-radius: 14px;
}
.shop-coffee-wrap {
  margin-bottom: 14px;
}
.shop-coffee-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--card);
}
.shop-coffee-emoji {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}
.shop-coffee-copy {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.shop-coffee-copy strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}
.shop-coffee-copy small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}
.shop-coffee-btn {
  flex-shrink: 0;
  white-space: nowrap;
  min-width: 5.5rem;
  width: auto;
  max-width: none;
  margin: 0;
  border-color: rgba(180, 83, 9, 0.45);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.18) 0%, rgba(245, 158, 11, 0.08) 100%);
  color: var(--text);
  font-weight: 800;
}
.shop-coffee-btn:disabled {
  opacity: 1;
  cursor: default;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.1);
  color: var(--green);
}
.shop-remove-ads { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.shop-remove-ads-offer {
  border-color: rgba(56, 189, 248, 0.5);
  background: var(--card);
  padding: 16px 14px;
  align-items: stretch;
  gap: 14px;
}
.shop-remove-ads-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}
.shop-remove-ads-offer .shop-offer-name {
  display: block;
  color: var(--text);
  font-size: clamp(1rem, 2.2vw, 1.12rem);
  font-weight: 800;
  line-height: 1.25;
}
.shop-remove-ads-offer .shop-offer-desc {
  display: block;
  color: var(--muted);
  font-size: clamp(0.86rem, 1.9vw, 0.96rem);
  font-weight: 600;
  line-height: 1.35;
}
.shop-remove-ads-offer .shop-offer-price {
  display: block;
  color: var(--muted);
  font-size: clamp(0.86rem, 1.9vw, 0.96rem);
  font-weight: 600;
  line-height: 1.35;
}
.btn-sm.btn-buy-iap {
  align-self: center;
  background: linear-gradient(180deg, var(--blue) 0%, #0369a1 100%);
  border-color: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.86rem, 1.9vw, 0.96rem);
  min-width: 5.75rem;
  min-height: 2.75rem;
  padding: 10px 14px;
  white-space: nowrap;
  flex-shrink: 0;
}
.shop-remove-ads-offer .btn-buy-iap:disabled {
  opacity: 0.72;
  background: var(--surface-chip);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}
.shop-iap-legal {
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.shop-iap-legal a { color: var(--blue); font-weight: 600; }
.shop-iap-legal a.hidden { display: none; }
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-gradient);
  padding: 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.shop-item:active { transform: scale(0.99); }
.shop-item.selected { border-color: var(--green); }
.shop-item.shake { animation: shake 0.4s ease; }
.shop-emoji { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.shop-info { flex: 1; min-width: 0; }
.shop-info strong { color: var(--text); font-weight: 700; }
.shop-info small { color: var(--muted); font-size: clamp(0.82rem, 1.8vw, 0.9rem); }
.shop-list { display: flex; flex-direction: column; gap: 10px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ── Shop / Leaderboard ── */
.shop-screen,
.leaderboard-screen {
  padding-top: clamp(8px, 1.5vw, 16px);
}
.screen-panel {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.leaderboard-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}
.lb-heading {
  margin: 0 0 4px;
  font-size: clamp(1rem, 2.2vw, 1.12rem);
  font-weight: 800;
  color: var(--text);
  text-align: left;
}
.lb-subheading {
  margin: 0 0 12px;
  font-size: clamp(0.82rem, 1.8vw, 0.92rem);
  color: var(--muted);
  text-align: left;
  line-height: 1.4;
}
.my-rank-card {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.14), var(--card));
  border: 1px solid rgba(74, 222, 128, 0.45);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 8px 22px var(--shadow-soft);
}
.my-rank-card.hidden { display: none; }
.my-rank-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.my-rank-position {
  font-size: clamp(1.2rem, 2.8vw, 1.45rem);
  font-weight: 800;
  color: var(--gold);
}
.my-rank-tier {
  font-weight: 700;
  color: var(--text);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
}
.my-rank-meta {
  font-size: clamp(0.82rem, 1.8vw, 0.9rem);
  color: var(--muted);
  line-height: 1.45;
}
.rank-shared-hint {
  font-size: clamp(0.78rem, 1.7vw, 0.88rem);
  color: var(--muted);
  text-align: left;
  line-height: 1.45;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-gradient);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.lb-row.me {
  border-color: var(--green);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), var(--card));
  box-shadow: 0 4px 14px rgba(74, 222, 128, 0.12);
}
.lb-row.lb-top-1 { border-color: rgba(255, 215, 0, 0.55); }
.lb-row.lb-top-2 { border-color: rgba(148, 163, 184, 0.65); }
.lb-row.lb-top-3 { border-color: rgba(180, 83, 9, 0.45); }
.lb-rank {
  width: 36px;
  color: var(--gold);
  font-weight: 800;
  flex-shrink: 0;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
}
.lb-badge { flex-shrink: 0; font-size: 1.15em; }
.lb-main { flex: 1; min-width: 0; }
.lb-name {
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(0.92rem, 2vw, 1rem);
}
.lb-sub {
  font-size: clamp(0.78rem, 1.7vw, 0.86rem);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.lb-score {
  font-weight: 800;
  color: var(--green);
  flex-shrink: 0;
  text-align: right;
  font-size: clamp(0.95rem, 2.1vw, 1.08rem);
}
.lb-empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 16px;
  background: var(--card-gradient);
  border: 2px dashed var(--border);
  border-radius: 14px;
  font-size: clamp(0.9rem, 2vw, 1rem);
}
.muted {
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

/* ── Daily ── */
.daily-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1E293B, #2D1F4E);
  border-radius: 24px;
  margin: 20px auto;
  padding: clamp(28px, 6vw, 48px);
  max-width: 480px;
  width: 100%;
}
.daily-amount { font-size: clamp(2.2rem, 6vw, 3.2rem); font-weight: 800; color: var(--gold); margin-bottom: 12px; }

/* ── Install banner ── */
.install-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px var(--space);
  background: linear-gradient(90deg, var(--green), var(--blue));
  color: var(--btn-primary-text);
  font-weight: 600;
  font-size: 0.88em;
  flex-shrink: 0;
}

/* ── Confetti (lightweight) ── */
#screen-rewards, #screen-daily { position: relative; overflow: hidden; }
.confetti {
  position: absolute;
  top: -8px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  pointer-events: none;
  z-index: 10;
  will-change: transform, opacity;
}
@keyframes confettiFall {
  0% { transform: translate3d(0,0,0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(0, 100vh, 0) rotate(540deg); opacity: 0; }
}

/* ══════════════════════════════════════
   TABLET — portrait & landscape
   ══════════════════════════════════════ */
@media (min-width: 600px) {
  :root {
    --canvas-max: min(55vh, 520px);
  }

  .menu-home,
  .menu-card,
  .coop-screen .menu-home,
  .coop-screen .menu-card {
    max-width: 420px;
  }
}

@media (min-width: 600px) and (orientation: landscape) {
  :root { --canvas-max: min(72vh, 580px); }

  /* Side-by-side d-pad only on phone landscape — tablets/desktop stay centered column */
  body.device-phone .game-layout {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 3vw, 40px);
    max-width: min(100%, calc(var(--canvas-max) + 220px));
  }
  body.device-phone .game-layout .game-main {
    flex: 0 1 auto;
    width: min(100%, var(--canvas-max));
    max-width: var(--canvas-max);
  }
  body.device-phone .game-layout .dpad {
    flex: 0 0 auto;
    justify-content: center;
    padding: 0;
  }
  :root { --canvas-max: min(78vh, 640px); }
}

/* ══════════════════════════════════════
   LARGE TABLET / SMALL DESKTOP
   ══════════════════════════════════════ */
@media (min-width: 900px) {
  .screen-container {
    max-width: 100%;
    margin: 0;
    width: 100%;
  }

  .menu-home,
  .menu-card,
  .coop-screen .menu-home,
  .coop-screen .menu-card {
    max-width: 440px;
  }

  :root { --canvas-max: min(70vh, 680px); }
}

/* ══════════════════════════════════════
   TV & Android TV (large screen, no touch)
   ══════════════════════════════════════ */
body.device-tv {
  --font-base: 20px;
  --canvas-max: min(62vh, 780px);
}

body.device-tv .mbg-brand-bar {
  padding: 10px var(--space);
}
body.device-tv .mbg-logo-wrap {
  font-size: 1.35rem;
}
body.device-tv .top-bar {
  font-size: 16px;
  padding: 12px 24px;
}
body.device-tv .btn-primary:not(.menu-action-btn) {
  padding: 22px;
  font-size: 1.4rem;
  max-width: 600px;
}
body.device-tv .menu-action-btn {
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0 18px !important;
  font-size: 1.1rem !important;
}
body.device-tv .btn-secondary {
  padding: 18px;
  font-size: 1.1rem;
}
body.device-tv .btn-icon,
body.device-tv .dpad-btn {
  width: 96px;
  height: 96px;
  font-size: 32px;
  border-radius: 20px;
}
body.device-tv .dpad-mid { gap: 72px; }
body.device-tv .diff-btn { padding: 16px; }
body.device-tv .diff-btn .diff-heading { font-size: 1.1em; }
body.device-tv .game-layout {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 48px;
  max-width: min(100%, calc(var(--canvas-max) + 280px));
}
body.device-tv .game-main {
  width: min(100%, var(--canvas-max));
  max-width: var(--canvas-max);
}
body.device-tv #screen-menu.active {
  gap: 12px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding-left: 4%;
  padding-right: 4%;
}

body.device-tv #screen-menu .menu-brand { margin: 0; }

body.device-tv .menu-home {
  max-width: 520px;
}

/* TV safe overscan margin */
@media (min-width: 1280px) {
  body.device-tv {
    padding-left: 5%;
    padding-right: 5%;
  }
}

/* Hide install banner on TV */
body.device-tv #install-banner { display: none !important; }

/* Small phones */
@media (max-width: 360px) {
  .menu-nav { grid-template-columns: repeat(2, 1fr); }
  .menu-chip { font-size: 0.65rem; }
  .dpad-btn { width: 52px; height: 52px; }
}

@media (max-width: 479px) {
  .menu-home,
  .menu-card {
    max-width: 100%;
  }
}

/* Very short screens */
@media (max-height: 500px) and (orientation: landscape) {
  .mbg-brand-bar { display: none; }
  .login-brand .brand-logo-mark {
    width: 48px;
    height: 48px;
  }
  :root { --canvas-max: 85vh; }
  .dpad { flex-direction: row; gap: 12px; }
  .dpad-mid { flex-direction: column; gap: 8px; }
}

/* ── In-game modal & toasts ── */
body.game-modal-open {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space);
  background: var(--overlay-modal);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: overlayFadeIn 0.2s ease;
  touch-action: none;
}

.game-overlay.hidden {
  display: none !important;
}

.game-modal {
  width: min(100%, 380px);
  max-height: min(85vh, 520px);
  overflow-y: auto;
  background: var(--modal-bg);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: clamp(18px, 4vw, 24px);
  text-align: center;
  box-shadow: 0 24px 48px var(--shadow);
  animation: modalPopIn 0.25s ease;
}

.game-modal-success { border-color: rgba(74, 222, 128, 0.55); }
.game-modal-danger { border-color: rgba(248, 113, 113, 0.55); }

.game-modal-icon {
  font-size: clamp(2rem, 6vw, 2.6rem);
  line-height: 1;
  margin-bottom: 8px;
}

.game-modal-title {
  margin: 0 0 8px;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  font-weight: 800;
}

.game-modal-message {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-line;
}

.game-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.game-modal-btn {
  flex: 1 1 120px;
  min-width: 120px;
  max-width: 200px;
  margin: 0 !important;
}

.game-toast-stack {
  position: fixed;
  top: calc(var(--safe-top, 0px) + 52px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9700;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.game-toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  background: var(--toast-bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: 0 8px 24px var(--shadow-soft);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  cursor: pointer;
}

.game-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.game-toast-info { border-color: rgba(56, 189, 248, 0.45); }
.game-toast-success { border-color: rgba(74, 222, 128, 0.5); color: var(--toast-success-text); }
.game-toast-error { border-color: rgba(248, 113, 113, 0.55); color: var(--toast-error-text); }
.game-toast-warn { border-color: rgba(251, 191, 36, 0.55); color: var(--toast-warn-text); }

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: none; }
}

.reduced-motion .game-overlay,
.reduced-motion .game-modal,
.reduced-motion .game-toast,
.reduced-motion .game-pause-menu,
.reduced-motion .game-pause-card {
  animation: none !important;
  transition: none !important;
}

/* ── Pause menu (in-game) ── */
.game-pause-menu {
  position: fixed;
  inset: 0;
  z-index: 9200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space);
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlayFadeIn 0.2s ease;
  touch-action: none;
}

.game-pause-menu.hidden {
  display: none !important;
}

.game-pause-card {
  width: min(100%, 380px);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: clamp(20px, 4vw, 28px);
  text-align: center;
  box-shadow: 0 24px 48px var(--shadow);
  animation: modalPopIn 0.25s ease;
}

.game-pause-icon {
  font-size: clamp(2rem, 6vw, 2.6rem);
  margin: 0 0 6px;
  line-height: 1;
}

.game-pause-title {
  margin: 0 0 8px;
  font-size: clamp(1.1rem, 2.4vw, 1.3rem);
  font-weight: 800;
}

.game-pause-score {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.game-pause-score strong {
  color: var(--green);
  font-size: 1.15rem;
}

.game-pause-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.game-pause-stats strong {
  color: var(--text);
  font-weight: 700;
}

.pause-diff-badge {
  color: var(--text);
  font-weight: 600;
}

.game-pause-settings {
  margin: 0 0 18px;
  text-align: left;
}

.game-pause-settings-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.game-pause-settings .settings-toggles {
  gap: 8px;
}

.game-pause-settings .setting-toggle-card {
  padding: 10px 12px;
}

.game-pause-speed {
  margin: 0 0 12px;
}

.game-pause-speed-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.speed-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.speed-btn {
  padding: 10px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.speed-btn:hover {
  border-color: rgba(74, 222, 128, 0.45);
}

.speed-btn.active {
  border-color: var(--green);
  background: rgba(74, 222, 128, 0.12);
  color: var(--green);
}

.speed-btn:active {
  transform: scale(0.97);
}

.speed-btn[data-comfort="true"] {
  box-shadow: inset 0 0 0 1px rgba(94, 184, 255, 0.35);
}

.pause-speed-comfort-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

.game-pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── In-run lives HUD ── */
.lives-hud strong {
  color: #fb7185;
}

/* ── Ad overlay (level-up + rewarded continue) ── */
body.ad-open {
  overflow: hidden;
}

.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 9400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space);
  background: var(--overlay-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
}

.ad-overlay.hidden {
  display: none !important;
}

.ad-card {
  width: min(100%, 360px);
  background: var(--ad-card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
  box-shadow: 0 24px 48px var(--shadow);
}

.ad-sponsor {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ad-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 800;
}

.ad-subtitle {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.ad-progress {
  height: 8px;
  background: var(--surface-track);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.ad-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), #86efac);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.ad-timer {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.ad-timer strong {
  color: var(--text);
}

.ad-skip-btn {
  margin-top: 14px;
  width: 100%;
}
