/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=Space+Grotesk:wght@500;700;900&display=swap');

:root {
  --bg-dark: #070a0f;
  --bg-card: rgba(15, 23, 38, 0.92);
  --bg-card-border: rgba(255, 255, 255, 0.1);
  --primary-green: #22c55e;
  --primary-green-glow: rgba(34, 197, 94, 0.4);
  --accent-gold: #fbbf24;
  --accent-gold-glow: rgba(251, 191, 36, 0.4);
  --debt-red: #ef4444;
  --debt-red-glow: rgba(239, 68, 68, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none !important;
  outline: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none !important;
  touch-action: manipulation;
  outline: none;
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 50% 10%, rgba(34, 197, 94, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 10% 90%, rgba(251, 191, 36, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(239, 68, 68, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 1;
}

#app-container {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100%;
  max-height: 840px;
  background: #080d14;
  border-radius: 24px;
  box-shadow: 0 30px 70px -15px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 2;
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none !important;
}

@media (max-width: 500px) {
  #app-container {
    max-width: 100vw;
    width: 100vw;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #080d14;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none !important;
}

/* ================= TOP HUD ================= */
#top-hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 20;
  gap: 6px;
}

.hud-group-left {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 1;
  min-width: 0;
}

.hud-group-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0; /* Guaranteed NEVER to push buttons off-screen */
}

.hud-pill {
  background: rgba(13, 20, 32, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 4px 8px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
  font-weight: 700;
  font-size: 0.80rem;
  white-space: nowrap;
}

.hud-pill.vault {
  border-color: var(--accent-gold-glow);
  color: var(--accent-gold);
}

.hud-pill.stage-pill {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 3px 7px;
  border-color: rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.15);
  white-space: nowrap;
}

.hud-pill.score-pill {
  font-size: 0.95rem;
  font-family: var(--font-mono);
  font-weight: 900;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  flex-shrink: 0;
}

.hud-pill.wallet-cash {
  color: var(--primary-green);
  border-color: var(--primary-green-glow);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 900;
  flex-shrink: 0;
}

/* Header Buttons (Sound & Pause) */
#sound-toggle, #btn-pause-game {
  width: 32px;
  height: 32px;
  flex-shrink: 0; /* Never shrink or get pushed out */
  border-radius: 50%;
  background: rgba(13, 20, 32, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  font-size: 0.85rem;
  transition: transform 0.15s ease, background 0.15s ease;
}

#sound-toggle:hover, #btn-pause-game:hover {
  transform: scale(1.08);
  background: rgba(255, 255, 255, 0.15);
}

/* Market Weather FinTech Alert Banner (Semi-Transparent & Fully Responsive) */
.market-ticker-banner {
  position: absolute;
  top: max(48px, calc(env(safe-area-inset-top) + 42px));
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border-radius: 9999px;
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 800;
  color: #fff;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  max-width: min(92vw, 390px);
  width: max-content;
  box-sizing: border-box;
}

.market-ticker-banner.active {
  opacity: 0.95;
  transform: translateX(-50%) translateY(0);
}

.ticker-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: pulseTickerDot 0.8s infinite alternate;
  flex-shrink: 0;
}

.ticker-icon {
  flex-shrink: 0;
  font-size: 0.82rem;
}

.ticker-title {
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.ticker-sep {
  flex-shrink: 0;
  opacity: 0.5;
}

.ticker-text {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
  opacity: 0.9;
}

@keyframes pulseTickerDot {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1.0; }
}

.ticker-timer-badge {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 800;
  color: #f8fafc;
  flex-shrink: 0;
  margin-left: 2px;
}

/* Active Power-Ups Dock (Sleek Horizontal Status Shelf, placed below top ticker) */
.active-powerups-dock {
  position: absolute;
  top: max(84px, calc(env(safe-area-inset-top) + 78px));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 25;
  pointer-events: none;
}

.powerup-pill {
  background: rgba(10, 16, 28, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 900;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

.powerup-timer-text {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 900;
  background: rgba(255, 255, 255, 0.16);
  padding: 1px 6px;
  border-radius: 6px;
  color: #ffffff;
}

.powerup-pill.shield { border-color: #10b981; color: #6ee7b7; box-shadow: 0 0 12px rgba(16, 185, 129, 0.4); }
.powerup-pill.shield .powerup-timer-text { background: rgba(16, 185, 129, 0.25); color: #a7f3d0; }
.powerup-pill.magnet { border-color: #38bdf8; color: #7dd3fc; box-shadow: 0 0 12px rgba(56, 189, 248, 0.4); }
.powerup-pill.magnet .powerup-timer-text { background: rgba(56, 189, 248, 0.25); color: #bae6fd; }
.powerup-pill.mult2 { border-color: #f59e0b; color: #fde047; box-shadow: 0 0 12px rgba(245, 158, 11, 0.4); }
.powerup-pill.mult2 .powerup-timer-text { background: rgba(245, 158, 11, 0.25); color: #fef08a; }
.powerup-pill.mult5 { border-color: #ec4899; color: #f472b6; box-shadow: 0 0 14px rgba(236, 72, 153, 0.5); }
.powerup-pill.mult5 .powerup-timer-text { background: rgba(236, 72, 153, 0.25); color: #fbcfe8; }
.powerup-pill.hypercombo { border-color: #f43f5e; color: #fef08a; box-shadow: 0 0 16px rgba(244, 63, 94, 0.6); animation: pulseHyperCombo 0.8s infinite alternate; }
.powerup-pill.hypercombo .powerup-timer-text { background: rgba(244, 63, 94, 0.3); color: #ffe4e6; }

@keyframes pulseHyperCombo {
  0% { transform: scale(1); filter: brightness(1); }
  100% { transform: scale(1.05); filter: brightness(1.2); }
}

/* Unified Streak Status Container */
#hud-streak-container {
  position: absolute;
  top: max(86px, calc(env(safe-area-inset-top) + 78px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Debt Penalty Streak Badge */
#hud-debt-streak {
  background: rgba(220, 38, 38, 0.4);
  border: 1px solid #ef4444;
  padding: 4px 14px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: #ffffff;
  display: none;
  animation: pulseDebt 0.6s infinite alternate;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.45);
}

@keyframes pulseDebt {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); }
}

#hud-solvency-streak {
  background: rgba(245, 158, 11, 0.35);
  border: 1px solid #fbbf24;
  padding: 4px 14px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: #fde047;
  display: none;
  animation: pulseSolvency 0.8s infinite alternate;
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.45);
}

@keyframes pulseSolvency {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); filter: brightness(1.15); }
}

/* In-Game Multiplayer / Party Live Status Pill */
#duel-hud {
  position: absolute;
  top: max(46px, calc(env(safe-area-inset-top) + 40px));
  left: max(10px, env(safe-area-inset-left));
  background: rgba(10, 16, 28, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9999px;
  padding: 2px 6px 2px 9px;
  display: none;
  align-items: center;
  gap: 6px;
  z-index: 22;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  width: max-content;
  max-width: 85vw;
  box-sizing: border-box;
}

#duel-hud.active {
  display: flex;
}

.party-hud-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 800;
  white-space: nowrap;
}

.duel-status-badge {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid #22c55e;
  color: #4ade80;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.65rem;
  font-weight: 800;
}

.duel-status-badge.dead {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fca5a5;
}

.btn-leave-hud {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 900;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.btn-leave-hud:hover {
  background: rgba(239, 68, 68, 0.6);
  color: #ffffff;
  transform: scale(1.1);
}

.btn-leave-hud:hover {
  background: rgba(239, 68, 68, 0.4);
  color: #ffffff;
}

/* Spectating Floating Indicator */
.spectating-indicator {
  position: absolute;
  top: max(56px, calc(env(safe-area-inset-top) + 48px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.3);
  border: 1px solid #ef4444;
  color: #fca5a5;
  font-family: var(--font-mono);
  font-size: 0.80rem;
  font-weight: 900;
  padding: 5px 14px;
  border-radius: 9999px;
  z-index: 60;
  animation: pulseDebt 0.8s infinite alternate;
  pointer-events: none;
  display: none;
}

/* Perfectly Centered Stage Upgrade Milestone Banner */
.stage-upgrade-banner {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  pointer-events: none;
  text-align: center;
  width: 90%;
  max-width: 360px;
  display: none;
  opacity: 0;
}

.stage-upgrade-banner.active {
  display: block;
  animation: stageBannerPop 3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes stageBannerPop {
  0% { opacity: 0; transform: translate(-50%, -60%) scale(0.85); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  22% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -40%) scale(0.95); }
}

.stage-banner-content {
  background: rgba(10, 15, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid #38bdf8;
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stage-banner-tag {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #38bdf8;
  text-transform: uppercase;
}

.stage-banner-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #ffffff;
  margin: 0;
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.stage-banner-desc {
  font-size: 0.78rem;
  color: #cbd5e1;
  font-weight: 600;
  margin: 0;
}

/* ================= SCREENS & MODALS ================= */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 10, 15, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  z-index: 20;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Start Menu Card */
.menu-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.6vh, 12px);
  margin: auto 0;
  position: relative;
}

.btn-sound-mini {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  z-index: 5;
}

.btn-sound-mini:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.08);
}

.menu-wallet-avatar-box {
  width: 110px;
  height: 75px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-pedestal-glow {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 24px;
  background: radial-gradient(ellipse, rgba(34, 197, 94, 0.45) 0%, rgba(251, 191, 36, 0.25) 50%, transparent 80%);
  border-radius: 50%;
  filter: blur(4px);
  pointer-events: none;
  animation: pulsePedestal 2s infinite alternate;
}

@keyframes pulsePedestal {
  0% { transform: translateX(-50%) scale(0.9); opacity: 0.6; }
  100% { transform: translateX(-50%) scale(1.15); opacity: 1; filter: blur(6px); }
}

.game-logo-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 3px 10px;
  border-radius: 999px;
  margin-top: 4px;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.game-logo {
  font-size: clamp(2.1rem, 5.5vh, 2.8rem);
  font-weight: 900;
  letter-spacing: -1.2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 0%, #4ade80 40%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(34, 197, 94, 0.45));
  line-height: 1.02;
}

.game-tagline {
  font-size: clamp(0.76rem, 1.8vh, 0.88rem);
  color: var(--text-muted);
  font-weight: 500;
  margin-top: -2px;
  letter-spacing: 0.3px;
}

/* Live Pilot Stats Row */
.menu-pilot-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.pilot-stat-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  transition: all 0.2s ease;
}

.pilot-stat-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.pilot-stat-item .stat-icon {
  font-size: 1.1rem;
}

.pilot-stat-item .stat-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pilot-stat-item .stat-title {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #94a3b8;
  text-transform: uppercase;
  white-space: nowrap;
}

.pilot-stat-item .stat-num {
  font-size: 0.82rem;
  font-weight: 800;
  color: #f8fafc;
  font-family: var(--font-mono);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Account Card & Profile Box */
.account-card-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 8px 12px;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.account-card-box:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.account-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.account-user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.account-avatar-icon {
  font-size: 1.3rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-text-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.account-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.account-type-tag {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

.account-type-tag.guest {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.account-type-tag.connected {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.account-stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #94a3b8;
}

.btn-account-switch {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-account-switch:hover {
  background: var(--primary-green);
  color: #052e16;
  border-color: var(--primary-green);
}

.profile-name {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.profile-vault {
  color: var(--accent-gold);
  font-weight: 800;
}

.level-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lvl-beginner { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.lvl-hustler { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
.lvl-stacker { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.lvl-exec { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
.lvl-tycoon { background: rgba(251, 191, 36, 0.22); color: #fde047; }
.lvl-billionaire {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.4) 0%, rgba(168, 85, 247, 0.4) 50%, rgba(236, 72, 153, 0.4) 100%);
  color: #67e8f9;
  border: 1px solid #22d3ee;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.6);
  animation: pulseBillionaire 1.2s infinite alternate;
}

@keyframes pulseBillionaire {
  0% { transform: scale(1); filter: hue-rotate(0deg); }
  100% { transform: scale(1.06); filter: hue-rotate(45deg); }
}

.lvl-millionaire {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.35) 0%, rgba(236, 72, 153, 0.35) 100%);
  color: #fef08a;
  border: 1px solid #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
  animation: pulseMillionaire 1s infinite alternate;
}

@keyframes pulseMillionaire {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

/* ================= PREMIUM MODERN GAMING & FINTECH BUTTON SYSTEM ================= */
.btn {
  width: 100%;
  box-sizing: border-box;
  padding: clamp(12px, 2vh, 15px) 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-family: var(--font-main);
  font-size: clamp(0.88rem, 1.8vh, 0.98rem);
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translateY(2px) scale(0.985);
}

.btn-row {
  display: flex;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.btn-row .btn {
  flex: 1;
  min-width: 0;
}

.btn-svg-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  transition: transform 0.2s ease;
}

.btn:hover .btn-svg-icon {
  transform: scale(1.12);
}

/* 1. Resume Flight Button (Rich Emerald Cyber Glass) */
.btn-resume {
  background: linear-gradient(180deg, #10b981 0%, #047857 100%);
  color: #ffffff;
  border: 1px solid #34d399;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-size: clamp(0.90rem, 1.9vh, 1.00rem);
  letter-spacing: 1.2px;
}

.btn-resume:hover {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* 2. Primary Play Solo Button (Luminous Emerald Glow) */
.btn-primary {
  background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
  color: #ffffff;
  border: 1px solid #4ade80;
  box-shadow: 0 4px 18px rgba(34, 197, 94, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-size: clamp(0.95rem, 2vh, 1.05rem);
  letter-spacing: 1.2px;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  box-shadow: 0 6px 25px rgba(34, 197, 94, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* 3. Gold / Multiplayer Button (Molten Amber 24K Gold) */
.btn-gold {
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
  color: #ffffff;
  border: 1px solid #fbbf24;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-size: clamp(0.92rem, 1.9vh, 1.02rem);
  letter-spacing: 1.2px;
}

.btn-gold:hover {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* 4. Secondary Utility Buttons (Sleek Obsidian Glass Tiles) */
.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: clamp(0.82rem, 1.7vh, 0.9rem);
  letter-spacing: 1px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* 5. Minimalist Outlined Install Button */
.btn-install {
  background: rgba(14, 165, 233, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #7dd3fc;
  font-size: clamp(0.78rem, 1.6vh, 0.86rem);
  padding: clamp(10px, 1.6vh, 12px) 14px;
  letter-spacing: 1.2px;
}

.btn-install:hover {
  background: rgba(14, 165, 233, 0.15);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
  transform: translateY(-1px);
}

/* 6. Rewarded Ad Button */
.btn-ad {
  background: linear-gradient(180deg, #8b5cf6 0%, #6d28d9 100%);
  color: #ffffff;
  border: 1px solid #a78bfa;
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  letter-spacing: 1px;
}

.btn-ad:hover {
  background: linear-gradient(180deg, #a78bfa 0%, #7c3aed 100%);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* Rewarded Ad Sponsor Overlay */
#ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.88);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

#ad-overlay.active {
  display: flex;
}

.ad-box {
  background: linear-gradient(180deg, #151928 0%, #0d111d 100%);
  border: 1.5px solid rgba(167, 139, 250, 0.4);
  border-radius: 20px;
  padding: 24px 20px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(139, 92, 246, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: scaleModalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ad-timer {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.15);
  border: 2px solid #a78bfa;
  color: #c4b5fd;
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.4);
  margin: 4px 0;
}

/* Install Guide Modal (iOS / Mac Safari / Android) */
.install-guide-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-steps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.guide-step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #f1f5f9;
}

.step-num {
  width: 24px;
  height: 24px;
  background: var(--primary-green);
  color: #052e16;
  font-weight: 900;
  font-family: var(--font-mono);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.78rem;
}

.step-text {
  flex: 1;
  line-height: 1.3;
}

.ios-icon {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 800;
  color: #38bdf8;
}

.btn-row {
  display: flex;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.btn-row .btn {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  padding: clamp(10px, 1.8vh, 13px) 8px;
  font-size: clamp(0.78rem, 1.6vh, 0.88rem);
}

/* ================= GAME OVER / PAUSE MODAL ================= */
.gameover-card {
  width: 100%;
  max-width: 380px;
  max-height: calc(100dvh - 32px);
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: clamp(14px, 2vh, 20px);
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vh, 12px);
  margin: auto 0;
  overflow-y: auto;
}

.gameover-title {
  font-size: clamp(1.3rem, 2.6vh, 1.55rem);
  font-weight: 900;
  color: var(--debt-red);
  text-transform: uppercase;
  letter-spacing: -0.5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: clamp(1.15rem, 2.2vh, 1.35rem);
  font-weight: 800;
  font-family: var(--font-mono);
  color: #fff;
}

.stat-value.gold {
  color: var(--accent-gold);
}

.stat-value.green {
  color: var(--primary-green);
}

/* ================= MODAL WINDOW & INLINE SKIN CARDS ================= */
.modal-window {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 28px);
  max-height: calc(100vh - 28px);
  background: #0c1320;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  margin: auto 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.skins-scroll-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.skins-scroll-list::-webkit-scrollbar,
.leaderboard-list::-webkit-scrollbar {
  width: 5px;
}

.skins-scroll-list::-webkit-scrollbar-thumb,
.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

/* Mobile-First Inline Skin Card */
.skin-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.skin-card.equipped {
  border-color: var(--primary-green);
  background: rgba(34, 197, 94, 0.09);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.15);
}

.skin-card-thumb-box {
  width: 58px;
  height: 44px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.skin-card-canvas {
  width: 56px;
  height: 40px;
  display: block;
}

.skin-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.skin-name {
  font-weight: 800;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skin-rarity {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rarity-Common { color: #94a3b8; }
.rarity-Uncommon { color: #38bdf8; }
.rarity-Rare { color: #a855f7; }
.rarity-Epic { color: #fbbf24; }
.rarity-Legendary { color: #f97316; }
.rarity-Mythic { color: #ec4899; text-shadow: 0 0 8px rgba(236, 72, 153, 0.5); }
.rarity-Transcendent {
  color: #fde047;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.8), 0 0 20px rgba(236, 72, 153, 0.5);
}
.rarity-Celestial {
  color: #34d399;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.7);
}
.rarity-Cosmic {
  color: #c084fc;
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.75);
}
.rarity-Dimensional {
  color: #38bdf8;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
}
.rarity-Sovereign {
  color: #f43f5e;
  text-shadow: 0 0 12px rgba(244, 63, 94, 0.85);
}
.rarity-Immortal {
  color: #fde047;
  text-shadow: 0 0 14px rgba(253, 224, 71, 0.9), 0 0 20px rgba(234, 179, 8, 0.6);
}
.rarity-GOD-TIER {
  color: #67e8f9;
  text-shadow: 0 0 12px rgba(103, 232, 249, 1), 0 0 22px rgba(236, 72, 153, 0.8);
  font-weight: 900;
  animation: pulseBillionaire 1s infinite alternate;
}

.skin-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.skin-actions {
  flex-shrink: 0;
}

/* 1v1 Duel Modal View */
.duel-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.room-input {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 4px;
  outline: none;
}

.room-input:focus {
  border-color: var(--primary-green);
  box-shadow: 0 0 10px var(--primary-green-glow);
}

.duel-waiting-box {
  background: rgba(0, 0, 0, 0.35);
  padding: 16px;
  border-radius: 14px;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.pulse-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(34, 197, 94, 0.2);
  border-top-color: var(--primary-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.party-player-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  border-radius: 10px;
  width: 100%;
  box-sizing: border-box;
}

.party-hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.8rem;
}

/* Leaderboards */
.tab-row {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 8px;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  font-size: 0.84rem;
}

.leaderboard-rank {
  font-weight: 900;
  width: 26px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.rank-1 { color: #fbbf24; }
.rank-2 { color: #94a3b8; }
.rank-3 { color: #d97706; }

.leaderboard-name {
  font-weight: 700;
  flex: 1;
}

.leaderboard-score {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--primary-green);
}

/* Toast Container */
#toast-container {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast-msg {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-weight: 700;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastSlideIn 0.25s ease forwards;
}

.toast-msg.error {
  border-color: #ef4444;
  color: #fca5a5;
}

.toast-msg.success {
  border-color: #22c55e;
  color: #86efac;
}

.toast-msg.info {
  border-color: #38bdf8;
  color: #bae6fd;
}

@keyframes toastSlideIn {
  0% { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Duel Result Dialog Modal */
.duel-result-card {
  width: 100%;
  max-width: 360px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  margin: auto 0;
}

.duel-result-title {
  font-size: 1.55rem;
  font-weight: 900;
}

.duel-result-title.win {
  color: #fbbf24;
}

.duel-result-title.lose {
  color: #ef4444;
}

/* Rewarded Ad Overlay */
#ad-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 300;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

#ad-overlay.active {
  opacity: 1;
  visibility: visible;
}

.ad-box {
  width: 100%;
  max-width: 330px;
  background: #1e293b;
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.ad-timer {
  font-size: 2.6rem;
  font-family: var(--font-mono);
  font-weight: 900;
  color: #a78bfa;
}
