* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #d9e6ff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  position: fixed;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

:root {
  --accent:       #5ef0ff;
  --accent-warm: #ff9a50;
  --accent-warm-2:#ff7a3e;
  --accent-gold: #ffd24d;
  --token-green: #22C55E; /* Matches Sidebar's account-balance-wallet color */
  --accent-pink: #ff6aff;
  --danger:      #ff3b6b;
  --text:        #dfe9ff;
  --text-dim:    rgba(217,230,255,0.62);
  --text-muted:  rgba(217,230,255,0.38);

  /* Glassmorphism tokens */
  --glass-bg:    rgba(8, 12, 28, 0.42);
  --glass-bg-2:  rgba(255, 255, 255, 0.05);
  --glass-border:rgba(94, 240, 255, 0.22);
  --glass-blur:  18px;
  --radius:      12px;
  --radius-lg:   18px;
}

/* ====================================================================
   Hard 9:16 viewport lock. See earlier notes for why this is pure CSS.
   ==================================================================== */
#game-scaler {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #000;
  overflow: hidden;
}
#game-stage {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 0 60px rgba(94,240,255,0.10);
  contain: layout paint;
  clip-path: inset(0);
  max-height: 100vh;
  max-width: 100vw;
}
/* Canvas fills the whole WebView so the starfield pass can extend past the
 * 9:16 stage (into the RN safe-area insets). The game pass uses scissor +
 * viewport to keep gameplay constrained to the stage rect. */
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  pointer-events: none;
}

/* ============================== Loading ============================== */
#loading-splash {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: #03030a;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.45s ease;
}
#loading-splash.hidden {
  opacity: 0;
  pointer-events: none;
}
#splash-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#splash-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.8) 100%);
}
#splash-text {
  position: relative;
  z-index: 2;
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  letter-spacing: 4px;
  font-weight: 600;
  animation: splash-pulse 1.5s ease-in-out infinite;
}
@keyframes splash-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ============================== HUD ================================== */
#hud-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* Top bar — glass panel containing controls + score/timer + hull */
.hud-topbar {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-right { gap: 8px; }
.hud-kills-big {
  /* Reuses .hud-primary styling — same size/color/font as the level+timer. */
  padding-right: 2px;
}
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  line-height: 1;
}

.hud-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: var(--accent);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.18s ease, background 0.18s ease;
  flex-shrink: 0;
}
.hud-btn:active { transform: scale(0.9); }
.hud-btn:hover  { border-color: var(--accent); background: rgba(94,240,255,0.08); }

/* Hull indicator — remaining-lives readout. Neutral-glass panel so it reads as
 * a status meter, not an alarm. Dots glow red when healthy, dim out as lives
 * are lost. When the Invincibility upgrade is owned, the whole panel becomes
 * a cyan-tinted button.
 */
.hud-hull {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  cursor: default;
  transition: all 0.18s;
  height: 34px;
}
.hud-hull .hull-dots { display: inline-flex; gap: 4px; }
.hud-hull.actionable {
  cursor: pointer;
  background: rgba(94, 240, 255, 0.10);
  border-color: rgba(94, 240, 255, 0.45);
  box-shadow: 0 0 18px rgba(94,240,255,0.18);
}
.hud-hull.actionable:active { transform: scale(0.96); }
.hud-hull.shielded {
  background: rgba(94, 240, 255, 0.22);
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(94,240,255,0.45);
}
.hull-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5a7e;
  box-shadow: 0 0 5px rgba(255,90,126,0.7);
}
.hull-dot.dim {
  background: rgba(255,255,255,0.14);
  box-shadow: none;
}
.hud-hull .shield-icon {
  width: 14px;
  height: 14px;
  margin-left: 4px;
  color: var(--accent);
  display: none;
}
.hud-hull.actionable .shield-icon,
.hud-hull.shielded   .shield-icon {
  display: inline-flex;
  align-items: center;
}
.hud-hull .shield-timer {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--accent);
  margin-left: 4px;
  display: none;
}
.hud-hull.shielded .shield-timer { display: inline; }

/* Primary center readout — level + time, in the same treatment the score used. */
.hud-primary {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 17px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(94,240,255,0.45);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.hud-primary .sep {
  color: rgba(94,240,255,0.45);
  font-weight: 400;
}

/* Secondary HUD row (mode + kills) */
.hud-sub {
  position: absolute;
  top: 62px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.hud-pill {
  padding: 5px 10px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 2px;
  border-radius: 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  color: var(--accent);
}
.hud-pill.warm {
  border-color: rgba(255,154,80,0.4);
  color: var(--accent-warm);
  background: rgba(255, 154, 80, 0.1);
}
.hud-kv {
  display: flex; gap: 5px;
}
.hud-kv .k { color: var(--text-muted); }
.hud-kv .v { color: var(--text); font-weight: 700; }

/* Powerup/event banner — center of screen for 2s */
#banner {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 20;
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  padding: 18px 30px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 40px rgba(0,0,0,0.55), 0 0 40px rgba(94,240,255,0.15);
}
#banner.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
#banner .eyebrow {
  font-size: 10px;
  letter-spacing: 6px;
  color: var(--accent);
  font-weight: 600;
  text-shadow: 0 0 10px rgba(94,240,255,0.6);
}
#banner .main {
  font-size: 28px;
  letter-spacing: 3px;
  font-weight: 800;
  margin-top: 6px;
  color: #fff;
  text-shadow: 0 0 22px rgba(94,240,255,0.7);
}
#banner .sub {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ============================== Overlays ============================= */
#overlay-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: radial-gradient(ellipse at center, rgba(6,10,28,0.45) 0%, rgba(3,3,10,0.88) 100%);
  overflow: hidden;
}
.overlay.hidden { display: none; }

/* Title / game-over share a hero poster that fades into the glass menu. */
.overlay-hero {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.overlay-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  filter: brightness(0.78) saturate(1.05);
}
.overlay-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(3, 3, 10, 0.0) 0%,
    rgba(3, 3, 10, 0.25) 42%,
    rgba(3, 3, 10, 0.78) 70%,
    rgba(3, 3, 10, 0.96) 100%);
}
.overlay-inner { position: relative; z-index: 2; }

.overlay-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 24px;
  text-align: center;
  overflow-y: auto;
}

/* Title */
.si-logo {
  margin-bottom: 32px;
}
.si-logo .title {
  font-size: 44px;
  letter-spacing: 6px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 22px rgba(94,240,255,0.9), 0 0 48px rgba(94,240,255,0.35);
}
.si-logo .subtitle {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--accent);
  text-transform: uppercase;
}

/* Primary buttons — glass with gradient fill */
/* Vertical menu stack — every overlay's button column uses .si-menu. */
.si-menu {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.si-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 28px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--accent);
  background: linear-gradient(180deg, rgba(10, 30, 50, 0.55) 0%, rgba(4, 8, 24, 0.88) 100%);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
}
.si-btn:hover { border-color: var(--accent); }
.si-btn:active { transform: scale(0.97); box-shadow: 0 2px 10px rgba(0,0,0,0.5); }

.si-btn-primary {
  color: #051325;
  background: linear-gradient(135deg, #8aefff 0%, #5ef0ff 50%, #a7b8ff 100%);
  border-color: transparent;
  box-shadow: 0 8px 28px rgba(94,240,255,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
  text-shadow: none;
}
.si-btn-primary:hover { border-color: transparent; }
.si-btn-ghost {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.16);
  min-width: 0;
  padding: 10px 20px;
  font-size: 11px;
}
.si-btn-danger {
  color: var(--danger);
  border-color: rgba(255,59,107,0.4);
  background: linear-gradient(180deg, rgba(50, 10, 20, 0.6) 0%, rgba(20, 4, 10, 0.85) 100%);
}

/* Instructions block */
.instr {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.75;
  letter-spacing: 0.5px;
  max-width: 300px;
  margin: 0 auto 30px;
}
.instr strong { color: var(--accent); font-weight: 600; }

/* Wallet chip — uses the app's green Material icon ("account-balance-wallet"). */
.wallet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.40);
  border-radius: 999px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--token-green);
}
.wallet-chip svg { color: var(--token-green); }

/* Upgrade screen */
.upgrade-hdr {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 0 4px;
}
.upgrade-title {
  font-size: 18px;
  letter-spacing: 4px;
  font-weight: 700;
  color: #fff;
}
.upgrade-note {
  max-width: 340px;
  margin: 0 auto 18px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent-warm);
  background: rgba(255,154,80,0.08);
  border: 1px solid rgba(255,154,80,0.28);
  border-radius: 10px;
  padding: 8px 14px;
  line-height: 1.5;
}

.upgrade-list {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}
.upgrade-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 14px 14px 16px;
  background: var(--glass-bg-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  text-align: left;
}
.upgrade-card.owned {
  border-color: rgba(94,240,255,0.55);
  background: rgba(94,240,255,0.08);
  box-shadow: inset 0 0 14px rgba(94,240,255,0.14);
}
.upgrade-card.locked { opacity: 0.55; }
.upgrade-cost {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--token-green);
}
.upgrade-cost svg { color: var(--token-green); }
.upgrade-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #fff;
  padding-right: 70px;
}
.upgrade-tag {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
  margin-top: 2px;
}
.upgrade-desc {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  margin-top: 6px;
  padding-right: 70px;
}
.upgrade-buy {
  align-self: flex-start;
  margin-top: 10px;
  padding: 7px 16px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(94,240,255,0.1);
  border: 1px solid rgba(94,240,255,0.4);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.upgrade-buy:active { transform: scale(0.95); }
.upgrade-buy:disabled {
  color: var(--text-muted);
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  cursor: not-allowed;
}
.upgrade-buy.owned {
  color: #051325;
  background: linear-gradient(135deg, #8aefff, #5ef0ff);
  border-color: transparent;
  cursor: default;
}

/* Game over stats */
.go-stats {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 auto 30px;
  width: 260px;
  padding: 14px 16px;
  background: var(--glass-bg-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
}
.go-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(94,240,255,0.1);
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
}
.go-stat:last-child { border-bottom: none; }
.go-stat .k { color: var(--text-muted); letter-spacing: 2px; font-size: 11px; }
.go-stat .v { color: var(--accent); font-weight: 700; }

/* SVG button icons inherit color from parent */
.hud-btn svg, .hud-hull svg { stroke: currentColor; }

/* ============================== Ads ================================== */
/* Banner-ad slot. The placeholder content is visible in dev / on hosts that
 * don't implement show_banner_ad. In the app, the RN host overlays its real
 * AdMob / IronSource banner on top of this region.
 */
/* Inline between the stats and the menu — the RN host overlays its real
 * AdMob banner on top of this rect using the coordinates sent via the bridge. */
.ad-slot {
  width: 100%;
  max-width: 320px;
  margin: 18px auto 16px;
  height: 50px; /* AdMob BANNER standard size (320x50) */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 10px;
  pointer-events: none;
}
.ad-slot-label {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--text-muted);
}
.ad-slot-placeholder { display: none; }
.ad-slot-label::after {
  content: '· AdMob banner';
  margin-left: 6px;
  color: var(--text-dim);
  letter-spacing: 2px;
  font-size: 9px;
}
.ad-slot-label {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--text-muted);
}
.ad-slot-placeholder {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.ad-note {
  margin-top: 14px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* Loading overlay while the RN host plays rewarded ads between runs. */
.ad-loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(94,240,255,0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ad-spin 0.9s linear infinite;
  margin-bottom: 18px;
}
@keyframes ad-spin { to { transform: rotate(360deg); } }
.ad-loading-label {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(94,240,255,0.45);
}
.ad-loading-sub {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
