/* =========================================================================
   CyberStakeRush — Design System
   Palette sampled from the supplied brand logo assets (see PRD Section 6.2)
   ========================================================================= */

:root {
  /* Brand palette */
  --navy: #001e50;
  --navy-deep: #010a1c;
  --void: #05070c;
  --gold: #ffd200;
  --gold-deep: #c79a00;
  --magenta: #e64aff;
  --magenta-deep: #9b1fc9;
  --cyan: #6fd8ff;
  --cyan-deep: #1aa6d8;
  --green: #39ff88;
  --red: #ff4d5e;

  /* Surfaces */
  --bg-0: #05070c;
  --bg-1: #0a1224;
  --bg-2: #0f1a35;
  --bg-card: rgba(15, 26, 53, 0.86);
  --bg-card-solid: #0f1a35;
  --border-soft: rgba(111, 216, 255, 0.18);

  /* Text */
  --ink-0: #f4f8ff;
  --ink-1: #c7d3ea;
  --ink-2: #8b9bc2;
  --ink-3: #5c6a8c;

  /* Type */
  --font-display: "Orbitron", "Rajdhani", "Segoe UI", sans-serif;
  --font-body: "Rajdhani", "Segoe UI", Roboto, Arial, sans-serif;

  /* Radii / spacing */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Shadows / glow */
  --glow-cyan: 0 0 0 1px rgba(111, 216, 255, 0.35), 0 0 24px rgba(111, 216, 255, 0.25);
  --glow-magenta: 0 0 0 1px rgba(230, 74, 255, 0.4), 0 0 24px rgba(230, 74, 255, 0.28);
  --glow-gold: 0 0 0 1px rgba(255, 210, 0, 0.4), 0 0 24px rgba(255, 210, 0, 0.22);
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.45);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@font-face {
  font-family: "GameFont";
  src: local("Arial");
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(111, 216, 255, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(230, 74, 255, 0.08), transparent 60%),
    var(--bg-0);
  min-height: 100%;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  margin: 0 0 var(--space-3);
  color: var(--ink-0);
  text-transform: uppercase;
}
h1 { font-size: clamp(1.6rem, 4vw + 0.4rem, 2.4rem); }
h2 { font-size: clamp(1.2rem, 2.4vw + 0.4rem, 1.6rem); }
h3 { font-size: 1.05rem; letter-spacing: 0.06em; color: var(--cyan); }
p { line-height: 1.5; color: var(--ink-1); margin: 0 0 var(--space-3); }
a { color: var(--cyan); text-decoration: none; }
small.muted, .muted { color: var(--ink-2); font-size: 0.85rem; }

button, input, select { font-family: var(--font-body); }

::selection { background: var(--magenta); color: #fff; }

/* -------------------------------------------------------------------------
   Layout helpers
   ------------------------------------------------------------------------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-8);
}
.screen--wide { max-width: 880px; }
.screen--full { max-width: none; padding: 0; }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

/* -------------------------------------------------------------------------
   Brand header / mascot
   ------------------------------------------------------------------------- */
.brand-badge {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: center;
}
.brand-badge img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(111, 216, 255, 0.45));
}
.brand-wordmark {
  max-width: 260px;
  width: 70%;
  display: block;
  margin: 0 auto var(--space-4);
  filter: drop-shadow(0 0 20px rgba(255, 210, 0, 0.25));
}
.mascot-hero {
  width: min(220px, 60vw);
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.5));
}

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(6px);
}
.card--cyan { box-shadow: var(--shadow-card), var(--glow-cyan); border-color: rgba(111, 216, 255, 0.4); }
.card--magenta { box-shadow: var(--shadow-card), var(--glow-magenta); border-color: rgba(230, 74, 255, 0.4); }
.card--gold { box-shadow: var(--shadow-card), var(--glow-gold); border-color: rgba(255, 210, 0, 0.4); }
.card--flat { background: var(--bg-2); box-shadow: none; }

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  padding: 14px 22px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(135deg, var(--gold), #ffb000);
  color: #241900;
  box-shadow: 0 6px 18px rgba(255, 210, 0, 0.35);
}
.btn--secondary {
  background: transparent;
  color: var(--cyan);
  border: 1.5px solid var(--cyan);
}
.btn--magenta {
  background: linear-gradient(135deg, var(--magenta), var(--magenta-deep));
  color: #fff;
  box-shadow: 0 6px 18px rgba(230, 74, 255, 0.35);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: normal;
  min-height: 40px;
}
.btn--sm { padding: 8px 16px; min-height: 36px; font-size: 0.8rem; width: auto; }
.btn--block { width: 100%; }

/* -------------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); text-align: left; }
.field label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.field input, .field select {
  background: #0b1428;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--ink-0);
  padding: 13px 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
.field input::placeholder { color: var(--ink-3); }
.field input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(111, 216, 255, 0.18); }
.field .hint { font-size: 0.75rem; color: var(--ink-3); }
.field-error { color: var(--red); font-size: 0.78rem; min-height: 1em; }

/* -------------------------------------------------------------------------
   HUD (battery + subscription + wallet)
   ------------------------------------------------------------------------- */
.hud {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + var(--safe-top));
  background: linear-gradient(180deg, rgba(5, 7, 12, 0.96), rgba(5, 7, 12, 0.7));
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(8px);
}
.hud__logo { height: 28px; }
.hud__spacer { flex: 1; min-width: var(--space-2); }
.hud__brand {
  font-family: var(--font-display);
  font-size: clamp(0.7rem, 2.6vw + 0.2rem, 1.2rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
  cursor: pointer;
  text-shadow: 0 0 16px rgba(111, 216, 255, 0.35);
}
.hud__brand span { color: var(--gold); }
.hud > .music-toggle,
.hud > .battery-meter,
.hud > .sub-badge {
  flex-shrink: 0;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-1);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.is-on { color: var(--cyan); border-color: rgba(111, 216, 255, 0.5); background: rgba(111, 216, 255, 0.1); }

.battery-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(57, 255, 136, 0.08);
  border: 1px solid rgba(57, 255, 136, 0.35);
  border-radius: var(--radius-pill);
  padding: 6px 12px 6px 8px;
  cursor: pointer;
  color: var(--ink-0);
}
.battery-meter__icon { width: 18px; height: 18px; flex-shrink: 0; }
.battery-meter__bar {
  width: 32px;
  height: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.battery-meter__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #16d97a);
  transition: width 0.3s ease;
}
.battery-meter--low .battery-meter__fill { background: linear-gradient(90deg, var(--red), #ff8a4d); }
.battery-meter--low { border-color: rgba(255, 77, 94, 0.5); background: rgba(255, 77, 94, 0.08); }
.battery-meter__count { font-family: var(--font-display); font-size: 0.85rem; color: var(--ink-0); font-weight: 700; }

.sub-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 210, 0, 0.4);
  background: rgba(255, 210, 0, 0.08);
  color: var(--gold);
  cursor: pointer;
  white-space: nowrap;
}
.sub-badge--expired { border-color: var(--ink-3); background: transparent; color: var(--ink-3); }

.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--cyan);
  overflow: hidden; padding: 0; cursor: pointer; background: var(--bg-2);
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* -------------------------------------------------------------------------
   Nav (bottom tab bar, mobile-first)
   ------------------------------------------------------------------------- */
.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  padding: var(--space-2) var(--space-2) calc(var(--space-2) + var(--safe-bottom));
  background: rgba(5, 7, 12, 0.96);
  border-top: 1px solid var(--border-soft);
  backdrop-filter: blur(8px);
}
.tabbar__item {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--ink-3); font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 6px 14px; border-radius: var(--radius-md);
  min-width: 64px;
}
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item.is-active { color: var(--cyan); background: rgba(111, 216, 255, 0.08); }

/* -------------------------------------------------------------------------
   Store
   ------------------------------------------------------------------------- */
.pack-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
.pack-card {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.pack-card:active { transform: scale(0.98); }
.pack-card.is-best::before {
  content: "BEST VALUE";
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--magenta); color: #fff; font-size: 0.6rem; font-family: var(--font-display);
  padding: 3px 10px; border-radius: var(--radius-pill); letter-spacing: 0.06em;
}
.pack-card__icon { font-size: 1.8rem; }
.pack-card__title { font-family: var(--font-display); margin: var(--space-2) 0 2px; }
.pack-card__price { color: var(--gold); font-weight: 700; }

.tier-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.tier-row.is-active { border-color: var(--gold); box-shadow: var(--glow-gold); }

/* -------------------------------------------------------------------------
   Modal / overlay
   ------------------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2, 4, 10, 0.78);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-card), var(--glow-cyan);
  max-height: 90vh;
  overflow-y: auto;
}
.modal__icon { font-size: 2.6rem; margin-bottom: var(--space-2); }

/* -------------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card-solid);
  border: 1px solid var(--cyan);
  color: var(--ink-0);
  padding: 12px 20px; border-radius: var(--radius-pill);
  font-size: 0.85rem; z-index: 200; box-shadow: var(--glow-cyan);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* -------------------------------------------------------------------------
   Misc components
   ------------------------------------------------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 0.7rem; }
.badge--free { background: rgba(111, 216, 255, 0.15); color: var(--cyan); }
.badge--mtn { background: rgba(255, 210, 0, 0.15); color: var(--gold); font-family: var(--font-display); letter-spacing: 0.04em; }

.divider { height: 1px; background: var(--border-soft); border: none; margin: var(--space-4) 0; }

/* -------------------------------------------------------------------------
   Developer credit
   ------------------------------------------------------------------------- */
.dev-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  opacity: 0.85;
}
.dev-credit img { height: 22px; width: auto; }

/* -------------------------------------------------------------------------
   Leaderboard
   ------------------------------------------------------------------------- */
.podium {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  gap: var(--space-3);
}
.podium__spot {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-2);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.podium__spot--1 { order: 2; padding-top: var(--space-6); border-color: rgba(255, 210, 0, 0.5); box-shadow: var(--glow-gold); }
.podium__spot--2 { order: 1; }
.podium__spot--3 { order: 3; }
.podium__spot.is-me { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.podium__medal { font-size: 1.6rem; }
.podium__avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: #06101f;
}
.podium__name { font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.02em; }
.podium__score { color: var(--gold); font-weight: 700; font-size: 0.85rem; }

.rank-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-soft);
}
.rank-row:last-child { border-bottom: none; }
.rank-row.is-me { background: rgba(111, 216, 255, 0.06); margin: 0 calc(var(--space-4) * -1); padding-left: var(--space-4); padding-right: var(--space-4); border-radius: var(--radius-sm); }
.rank-row__rank { width: 28px; color: var(--ink-2); font-family: var(--font-display); font-size: 0.8rem; }
.rank-row__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-card-solid); border: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 0.7rem; color: var(--cyan);
}
.rank-row__name { font-size: 0.9rem; }
.rank-row__score { color: var(--gold); font-weight: 700; font-size: 0.85rem; }

.level-tile {
  width: 100%; aspect-ratio: 1; border-radius: var(--radius-md);
  border: 1px solid var(--border-soft); background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.1rem; color: var(--ink-1);
  cursor: pointer; position: relative;
}
.level-tile.is-locked { color: var(--ink-3); cursor: not-allowed; }
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); }

.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(111, 216, 255, 0.25); border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
  width: 100%; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); transition: width 0.4s ease; }

/* -------------------------------------------------------------------------
   Game frame
   ------------------------------------------------------------------------- */
.game-frame-wrap {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: flex; flex-direction: column;
}
.game-frame-wrap iframe { flex: 1; width: 100%; height: 100%; border: none; }
.game-frame__bar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px 14px; padding-top: calc(10px + var(--safe-top));
  background: rgba(5, 7, 12, 0.92); border-bottom: 1px solid var(--border-soft);
}

/* -------------------------------------------------------------------------
   Responsive breakpoints
   ------------------------------------------------------------------------- */
@media (min-width: 376px) {
  .pack-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 769px) {
  .screen { max-width: 640px; padding-top: var(--space-7); }
  .screen--wide { max-width: 960px; }
  .level-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (min-width: 1025px) {
  body::before {
    content: "";
    position: fixed; inset: 0;
    background: radial-gradient(1400px 800px at 50% -20%, rgba(111, 216, 255, 0.06), transparent 60%);
    pointer-events: none;
  }
  .screen { max-width: 720px; }
  .tabbar { max-width: 720px; margin: 0 auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-left: 1px solid var(--border-soft); border-right: 1px solid var(--border-soft); }
}
@media (orientation: landscape) and (max-height: 480px) {
  .screen { padding-top: var(--space-3); padding-bottom: var(--space-4); }
  .mascot-hero { width: 120px; }
}
