/* =========================================================================
   GLOW PATH — style.css
   Design tokens live as CSS custom properties on :root. app.js overwrites a
   handful of them (--tg-*) from Telegram.WebApp.themeParams at boot, so the
   chrome adapts to the user's Telegram theme while the game scene itself
   (the canvas) keeps its own deliberate night-sky palette — that palette IS
   the game's identity and shouldn't flatten to a generic light theme.
   ========================================================================= */

:root {
  /* --- Core palette -------------------------------------------------- */
  --bg-deep: #0B0F1A;        /* base night sky */
  --bg-panel: #131A2B;       /* raised glass panels */
  --bg-panel-2: #1A2338;     /* slightly lighter panel / rows */
  --accent-glow: #7FE7DC;    /* soft teal — primary trail / CTA glow */
  --accent-violet: #B79CFF;  /* secondary glow / combo accent */
  --star-gold: #FFD873;      /* stars + currency */
  --text-primary: #EAF2FF;
  --text-muted: #8A94AC;
  --danger: #FF7A7A;

  /* --- Telegram theme overrides (set by app.js when available) -------- */
  --tg-bg: var(--bg-deep);
  --tg-text: var(--text-primary);
  --tg-hint: var(--text-muted);
  --tg-button: var(--accent-glow);
  --tg-button-text: #08131A;

  /* --- Type ------------------------------------------------------------ */
  --font-display: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* --- Layout ----------------------------------------------------------- */
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-family: var(--font-body);
  /* Prevent iOS/Android rubber-banding and text selection during drawing */
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button { font-family: inherit; }

/* =========================== Screen system ============================ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding-top: calc(var(--safe-top) + 14px);
  padding-bottom: calc(var(--safe-bottom) + 14px);
  background: radial-gradient(120% 90% at 50% -10%, #1B2540 0%, var(--bg-deep) 60%);
}
.screen.active { display: flex; }

/* ============================ Loading ================================== */
#screen-loading {
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.loader-orb {
  width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFFFF, var(--accent-glow) 40%, transparent 72%);
  box-shadow: 0 0 40px 10px rgba(127, 231, 220, 0.45);
  animation: orb-pulse 1.6s ease-in-out infinite;
}
@keyframes orb-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.75; }
  50% { transform: scale(1.05); opacity: 1; }
}
.loader-text { color: var(--tg-hint); font-size: 14px; letter-spacing: 0.02em; }

/* ============================ Buttons =================================== */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 22px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-glow), #57C7BC);
  color: #06181A;
  box-shadow: 0 6px 24px rgba(127, 231, 220, 0.28);
}
.btn-secondary {
  background: var(--bg-panel-2);
  color: var(--text-primary);
  border: 1px solid rgba(234, 242, 255, 0.08);
}
.btn-ghost {
  background: transparent;
  color: var(--accent-glow);
  border: 1px solid rgba(127, 231, 220, 0.35);
}
.btn-ghost.danger { color: var(--danger); border-color: rgba(255, 122, 122, 0.35); }
.btn-large { width: 100%; padding: 17px; font-size: 18px; }
.btn-small { padding: 10px 16px; font-size: 13px; }
.btn-icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--bg-panel-2);
  color: var(--text-primary);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(234, 242, 255, 0.08);
}
.btn[hidden] { display: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:disabled:active { transform: none; }

/* ============================ Menu screen =============================== */
.menu-top {
  display: flex; justify-content: space-between; padding: 0 18px;
}
.pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-panel);
  border: 1px solid rgba(234, 242, 255, 0.08);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
}
.pill-compact { padding: 6px 12px; font-size: 13px; }
.pill-icon { font-size: 13px; }
.pill-stars .pill-icon { color: var(--star-gold); }
.pill-energy .pill-icon { color: var(--accent-glow); }
.pill-sub { color: var(--text-muted); font-weight: 500; }

.menu-center {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 0 24px;
}
.game-title {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  text-shadow: 0 0 30px rgba(127, 231, 220, 0.35);
}
.game-title span { color: var(--accent-glow); }
.game-subtitle { color: var(--text-muted); margin: 0; font-size: 15px; }

.energy-timer-wrap {
  margin-top: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.energy-timer-label { font-size: 12px; color: var(--text-muted); }
.energy-timer { font-family: var(--font-display); font-size: 20px; color: var(--accent-violet); font-weight: 600; }

.menu-actions {
  display: flex; flex-direction: column; gap: 12px;
  padding: 0 24px 6px;
}
.menu-row { display: flex; gap: 12px; justify-content: center; }
.badge {
  background: var(--star-gold);
  color: #3A2A00;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 6px;
  margin-left: 8px; letter-spacing: 0.03em;
}
#btnGetEnergy { align-self: center; margin-top: 4px; }

/* ============================ Onboarding ================================ */
.onboard-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 24px 30px; gap: 16px;
  position: relative;
}
.onboard-slide { display: none; flex-direction: column; align-items: center; gap: 14px; }
.onboard-slide.active { display: flex; }
.onboard-glyph {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9), var(--accent-glow) 35%, transparent 72%);
  box-shadow: 0 0 50px 12px rgba(127, 231, 220, 0.3);
}
#onboardGlyphStars { background: radial-gradient(circle at 40% 35%, #FFFFFF, var(--star-gold) 35%, transparent 72%); box-shadow: 0 0 50px 12px rgba(255, 216, 115, 0.3); }
#onboardGlyphFade { background: radial-gradient(circle at 40% 35%, #FFFFFF, var(--accent-violet) 35%, transparent 72%); box-shadow: 0 0 50px 12px rgba(183, 156, 255, 0.3); opacity: 0.7; }
.onboard-slide h2 { font-family: var(--font-display); font-size: 22px; margin: 0; }
.onboard-slide p { color: var(--text-muted); font-size: 14px; line-height: 1.5; margin: 0; max-width: 300px; }
.onboard-dots { display: flex; gap: 8px; margin-top: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(234,242,255,0.2); transition: background 0.2s; }
.dot.active { background: var(--accent-glow); }
#btnOnboardNext { position: absolute; bottom: 28px; left: 30px; right: 30px; }

/* ============================ Gameplay =================================== */
#screen-game { padding: 0; background: var(--bg-deep); }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud-top {
  position: absolute; top: calc(var(--safe-top) + 10px); left: 14px; right: 14px;
  display: flex; align-items: flex-start; justify-content: space-between;
  z-index: 5; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(19, 26, 43, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(234, 242, 255, 0.1);
  color: var(--text-primary);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-score {
  font-family: var(--font-display); font-weight: 700; font-size: 30px;
  color: var(--text-primary); text-shadow: 0 0 18px rgba(127,231,220,0.35);
}
.hud-combo {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  color: var(--star-gold);
  background: rgba(255, 216, 115, 0.12);
  padding: 2px 10px; border-radius: 999px;
}
.hud-timer-wrap { position: relative; width: 44px; height: 44px; }
.hud-timer-ring { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(234,242,255,0.12); stroke-width: 4; }
.ring-progress {
  fill: none; stroke: var(--accent-glow); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 119.4; stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}
.hud-timer-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-primary);
}

.pause-overlay {
  position: absolute; inset: 0; background: rgba(11, 15, 26, 0.78);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.pause-overlay[hidden] { display: none; }
.pause-card {
  background: var(--bg-panel); border-radius: var(--radius-lg);
  padding: 26px; width: 240px; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
  border: 1px solid rgba(234,242,255,0.08);
}
.pause-card h2 { font-family: var(--font-display); margin: 0 0 6px; }

/* ============================ Results =================================== */
#screen-results { align-items: center; justify-content: center; padding: 24px; }
.results-card {
  width: 100%; max-width: 340px;
  background: var(--bg-panel);
  border: 1px solid rgba(234,242,255,0.08);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.results-eyebrow { color: var(--text-muted); font-size: 13px; margin: 0; }
.results-score {
  font-family: var(--font-display); font-size: 54px; margin: 0;
  color: var(--accent-glow); text-shadow: 0 0 30px rgba(127,231,220,0.4);
}
.results-sub { margin: 0; color: var(--text-muted); font-size: 13px; }
.results-stats { display: flex; justify-content: center; gap: 34px; margin: 6px 0; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat span { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--star-gold); }
.stat label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ad-offers { display: flex; flex-direction: column; gap: 8px; }
.results-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* ============================ Sub-header (settings/collection) ========== */
.sub-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px 14px;
}
.sub-header h2 { font-family: var(--font-display); font-size: 18px; margin: 0; }
.sub-header-spacer { width: 40px; }

/* ============================ Settings =================================== */
.settings-list { padding: 6px 20px; display: flex; flex-direction: column; gap: 4px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 4px; border-bottom: 1px solid rgba(234,242,255,0.06);
  font-size: 15px;
}
.setting-row input[type="checkbox"] {
  appearance: none; width: 42px; height: 24px; border-radius: 999px;
  background: var(--bg-panel-2); position: relative; cursor: pointer;
  border: 1px solid rgba(234,242,255,0.1);
  transition: background 0.2s;
}
.setting-row input[type="checkbox"]::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}
.setting-row input[type="checkbox"]:checked { background: rgba(127,231,220,0.25); }
.setting-row input[type="checkbox"]:checked::after { transform: translateX(18px); background: var(--accent-glow); }
#btnResetProgress { margin-top: 18px; align-self: flex-start; }
.settings-version { color: var(--text-muted); font-size: 11px; margin-top: 24px; text-align: center; }

/* ============================ Collection =================================== */
.collection-section { padding: 4px 20px 18px; }
.collection-section h3 { font-family: var(--font-display); font-size: 14px; color: var(--text-muted); margin: 0 0 10px; font-weight: 600; }
.swatch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; overflow-y: auto; }
.swatch {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  background: var(--bg-panel-2); border: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  position: relative; cursor: pointer;
}
.swatch .dot-preview { width: 26px; height: 26px; border-radius: 50%; }
.swatch .cost { font-size: 10px; color: var(--text-muted); }
.swatch.locked { opacity: 0.55; }
.swatch.equipped { border-color: var(--accent-glow); }
.swatch .lock-icon { position: absolute; top: 4px; right: 6px; font-size: 10px; }

/* ============================ Toast =================================== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 26px);
  transform: translateX(-50%);
  background: var(--bg-panel-2);
  border: 1px solid rgba(234,242,255,0.1);
  color: var(--text-primary);
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 100;
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Respect reduced-motion preference (also toggle-able in Settings via a JS class) */
@media (prefers-reduced-motion: reduce) {
  .loader-orb { animation: none; }
}
body.reduce-motion .loader-orb { animation: none; }