:root {
  --bg-0: #07091a;
  --bg-1: #0f1230;
  --bg-2: #181b48;
  --accent: #6cf3ff;
  --accent-2: #b96bff;
  --warn: #ff5b6e;
  --text: #f1f4ff;
  --text-dim: #8b91c4;
  --gold: #ffd166;
  --shadow: 0 10px 40px rgba(0,0,0,0.45);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background:
    radial-gradient(circle at 20% 10%, rgba(108,243,255,0.10), transparent 50%),
    radial-gradient(circle at 85% 90%, rgba(185,107,255,0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100vw, 440px);
  padding: 12px;
  gap: 10px;
}

#hud {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: rgba(15, 18, 48, 0.65);
  border: 1px solid rgba(108, 243, 255, 0.15);
  border-radius: var(--radius);
  padding: 10px 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hud-cell { display: flex; flex-direction: column; gap: 2px; }
.hud-center { align-items: center; }
.hud-right { align-items: flex-end; }

.hud-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}

.hud-value {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(108,243,255,0.35);
}

#nextCanvas {
  width: 56px;
  height: 56px;
  display: block;
}

#stage {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 400 / 600;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(108,243,255,0.12);
  background:
    radial-gradient(circle at 50% 110%, rgba(185,107,255,0.18), transparent 60%),
    linear-gradient(180deg, rgba(7,9,26,0.6), rgba(15,18,48,0.6));
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

.combo-badge {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) scale(0.7);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07091a;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(.2,1.4,.4,1);
  box-shadow: 0 8px 28px rgba(108,243,255,0.45);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}
.combo-badge.show { opacity: 1; transform: translateX(-50%) scale(1); }

.mode-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(108,243,255,0.3);
  background: rgba(15,18,48,0.7);
  color: var(--text);
  backdrop-filter: blur(8px);
  transition: transform 120ms ease, background 200ms ease;
}
.mode-chip:hover { transform: scale(1.04); }
.mode-chip.daily {
  background: linear-gradient(135deg, rgba(108,243,255,0.25), rgba(255,209,102,0.25));
  border-color: rgba(255,209,102,0.6);
  color: #ffe28a;
}
.mode-chip.zen {
  background: linear-gradient(135deg, rgba(91,235,143,0.25), rgba(122,243,255,0.18));
  border-color: rgba(91,235,143,0.6);
  color: #c5f5d6;
}

.mode-toggle {
  display: inline-flex;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(108,243,255,0.2);
  border-radius: 12px;
  padding: 4px;
  margin: 10px auto 14px;
  gap: 4px;
}
.mode-tab {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.mode-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07091a;
  box-shadow: 0 4px 16px rgba(108,243,255,0.3);
}

.daily-info {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 14px;
  padding: 10px;
  background: rgba(255,209,102,0.08);
  border: 1px solid rgba(255,209,102,0.25);
  border-radius: 10px;
}
.daily-info.hidden { display: none; }
.daily-info strong { color: var(--gold); }

.skin-row {
  display: flex; align-items: center; gap: 12px;
  justify-content: center;
  margin-bottom: 14px;
}
.skin-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}
.skin-picker { display: flex; gap: 8px; }
.skin-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  cursor: pointer;
  position: relative;
  transition: transform 120ms ease, border-color 200ms ease;
  background-size: cover;
}
.skin-swatch:hover { transform: scale(1.1); border-color: rgba(108,243,255,0.6); }
.skin-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108,243,255,0.35);
}
.skin-swatch.locked {
  cursor: not-allowed;
  filter: grayscale(0.7) brightness(0.5);
}
.skin-swatch.locked::after {
  content: '🔒';
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.skin-swatch[title] { /* tooltip hint */ }

.evo-chart {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  opacity: 0.85;
}
.evo-chart .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 0 6px rgba(0,0,0,0.35);
  transition: transform 200ms ease, opacity 200ms ease;
  opacity: 0.45;
}
.evo-chart .dot.unlocked { opacity: 1; transform: scale(1.08); }

#controls {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.ctrl-btn {
  background: rgba(15, 18, 48, 0.7);
  color: var(--text);
  border: 1px solid rgba(108,243,255,0.18);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 18px;
  cursor: pointer;
  transition: transform 120ms ease, background 200ms ease, border-color 200ms ease;
  min-width: 56px;
}
.ctrl-btn:hover { background: rgba(24, 27, 72, 0.9); border-color: rgba(108,243,255,0.4); }
.ctrl-btn:active { transform: scale(0.94); }

.pwr-btn { position: relative; padding: 8px 12px; }
.pwr-icon { font-size: 22px; }
.pwr-tag {
  position: absolute;
  top: -6px; right: -6px;
  background: linear-gradient(135deg, #ff6bd7, #b96bff);
  color: #07091a;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(185,107,255,0.5);
}
.pwr-btn.armed {
  background: linear-gradient(135deg, rgba(255,107,215,0.25), rgba(108,243,255,0.25));
  border-color: rgba(255,107,215,0.6);
  animation: pulse 1.2s ease-in-out infinite;
}
.pwr-btn.armed .pwr-tag {
  background: linear-gradient(135deg, #6cf3ff, #5beb8f);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,215,0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(255,107,215,0); }
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 18, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.overlay.hidden { display: none; }

.overlay-card {
  width: min(360px, 100%);
  background: linear-gradient(160deg, rgba(24,27,72,0.95), rgba(15,18,48,0.95));
  border: 1px solid rgba(108,243,255,0.25);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  text-align: center;
  animation: pop 280ms cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.overlay-card h2 {
  font-size: 22px;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.go-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
  font-size: 15px;
}
.go-row span { color: var(--text-dim); }
.go-row strong { font-variant-numeric: tabular-nums; }

.go-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

button.primary, button.ghost {
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform 120ms ease, filter 200ms ease;
}
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07091a;
  box-shadow: 0 8px 22px rgba(108,243,255,0.4);
}
button.primary:hover { filter: brightness(1.1); }
button.primary:active { transform: scale(0.97); }

button.ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(108,243,255,0.25);
}
button.ghost:hover { background: rgba(255,255,255,0.1); }

.go-hint { margin-top: 12px; color: var(--text-dim); font-size: 12px; }

.lb-panel {
  margin: 14px 0 6px;
  padding: 12px;
  background: rgba(108,243,255,0.06);
  border: 1px solid rgba(108,243,255,0.2);
  border-radius: 12px;
}
.lb-panel.hidden { display: none; }
.lb-title {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-align: center;
}
.lb-list { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }
.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.02);
}
.lb-row.me {
  background: linear-gradient(90deg, rgba(108,243,255,0.18), rgba(185,107,255,0.18));
  border: 1px solid rgba(108,243,255,0.4);
}
.lb-rank { color: var(--text-dim); font-weight: 700; }
.lb-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--accent); }
.lb-loading, .lb-empty { text-align: center; color: var(--text-dim); font-style: italic; }
.lb-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}
.lb-name-row label { color: var(--text-dim); letter-spacing: 0.08em; }
.lb-name-row input {
  flex: 1;
  background: rgba(15,18,48,0.7);
  border: 1px solid rgba(108,243,255,0.25);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font: inherit;
  outline: none;
}
.lb-name-row input:focus { border-color: var(--accent); }

.intro-card { padding: 32px 24px; }
.intro-logo {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.18em;
  background: linear-gradient(135deg, #ff6bd7 0%, #6cf3ff 50%, #ffd166 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(108,243,255,0.3);
  margin-bottom: 6px;
}
.intro-tag {
  font-size: 13px;
  letter-spacing: 0.35em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 22px;
}
.intro-orbs {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 6px;
  margin-bottom: 20px;
  height: 44px;
}
.intro-orbs .o {
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  animation: floaty 2.4s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

.help-list { text-align: left; padding-left: 18px; }
.help-list li { padding: 6px 0; color: var(--text); font-size: 14px; }

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
  font-size: 14px;
}
.setting-row:last-of-type { border-bottom: none; }
.setting-row label { color: var(--text-dim); }
.setting-row select,
.setting-row input[type="checkbox"] {
  background: rgba(15,18,48,0.7);
  border: 1px solid rgba(108,243,255,0.25);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.setting-row input[type="checkbox"] {
  appearance: none;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  position: relative;
  padding: 0;
  transition: background 200ms ease;
}
.setting-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  transition: left 200ms ease;
}
.setting-row input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.setting-row input[type="checkbox"]:checked::after { left: 18px; }
.setting-val { font-variant-numeric: tabular-nums; color: var(--gold); }

.ach-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -120%) scale(0.9);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(108,243,255,0.95), rgba(185,107,255,0.95));
  color: #07091a;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  z-index: 100;
  opacity: 0;
  transition: opacity 200ms ease, transform 320ms cubic-bezier(.2,1.4,.4,1);
  max-width: 340px;
  font-weight: 600;
}
.ach-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.ach-icon { font-size: 32px; line-height: 1; }
.ach-name { font-size: 14px; font-weight: 800; letter-spacing: 0.04em; }
.ach-desc { font-size: 12px; opacity: 0.85; }

.ad-slot {
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-height: 800px) {
  .ad-slot { min-height: 50px; }
}

/* Legal links inside the intro overlay (About / Privacy / Terms + hub) */
.legal-links {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}
.legal-links a { color: var(--text-dim); text-decoration: none; }
.legal-links a:hover { color: var(--accent); text-decoration: underline; }

/* Cookie banner (Consent Mode v2 control).
   NOTE: the modifier class is `cookie-ghost`, NOT `ghost` — `.ghost` is already
   the secondary-button style here, and reusing it caused a layout collision in
   Drop Double (see its README). z-index sits above overlays (50) and toasts (100). */
.cookie-banner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(7,9,26,0.96); backdrop-filter: blur(10px);
  padding: 14px calc(20px + env(safe-area-inset-right))
           calc(14px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
  border-top: 1px solid rgba(108,243,255,0.25);
  display: flex; align-items: center; justify-content: center; gap: 16px;
  z-index: 200; flex-wrap: wrap; font-size: 13px; color: var(--text);
}
.cookie-banner[hidden] { display: none !important; }
.cookie-banner a { color: var(--accent); }
.cookie-banner button {
  padding: 8px 18px; border-radius: 8px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07091a; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn.cookie-ghost {
  background: transparent; border: 1px solid rgba(139,145,196,0.5); color: var(--text-dim);
}
.cookie-btn.cookie-ghost:hover { background: rgba(139,145,196,0.15); }


/* --- Ad slot: hidden in the self-hosted build ------------------------------
   #adSlotTop/#adSlotBottom are empty containers for a banner injected by a
   portal SDK (CrazyGames / Poki / GameDistribution). In this build those SDKs
   are commented out in index.html and AdSense is not approved yet, so nothing
   ever fills them — but the media query above still reserves 50px, leaving a
   blank gap. Delete this when a real ad source is wired up. */
.ad-slot { display: none !important; }
