:root {
  --bg-deep: #070c1e;
  --bg-card: rgba(14, 23, 53, 0.88);
  --cyan-bright: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.4);
  --yellow-bolt: #ffd600;
  --yellow-glow: rgba(255, 214, 0, 0.45);
  --purple-boost: #b026ff;
  --red-brake: #ff3366;
  --green-snake: #00ff88;
  --text-white: #ffffff;
  --text-dim: #94a3b8;
  --border-line: rgba(0, 240, 255, 0.25);
  --font-main: Inter, system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-white);
  font-family: var(--font-main);
  touch-action: none;
}

/* Ambient sky storm glow */
.sky-storm-ambient {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 10%, rgba(0, 240, 255, 0.12), transparent 60%),
              radial-gradient(circle at 80% 30%, rgba(176, 38, 255, 0.08), transparent 50%),
              linear-gradient(180deg, #070c1e 0%, #030611 100%);
  z-index: 0;
  pointer-events: none;
}

.game-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 12px 12px;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  gap: 12px;
  flex-shrink: 0;
}

.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-white);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
}

.nav-back:hover {
  background: rgba(0, 240, 255, 0.18);
  border-color: var(--cyan-bright);
  transform: translateX(-2px);
}

.back-arrow {
  color: var(--yellow-bolt);
  font-size: 16px;
}

.game-headline {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--cyan-bright);
  text-transform: uppercase;
}

.game-title {
  font-size: clamp(16px, 2.4vw, 22px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 16px var(--cyan-glow);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-white);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.pill-btn:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--cyan-bright);
}

/* Stage & Viewport */
.stage-container {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-top: 8px;
  gap: 8px;
}

/* Dashboard HUD */
.dashboard-hud {
  display: grid;
  grid-template-columns: 130px 145px 170px 1fr 125px 115px;
  gap: 8px;
  flex-shrink: 0;
}

.health-track {
  border-color: rgba(0, 255, 136, 0.4);
}

.health-fill {
  background: linear-gradient(90deg, #ff3366, #ffd600, #00ff88);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}

.hud-box {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.hud-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cyan-bright);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.speed-readout {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.speed-readout strong {
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.speed-readout .unit {
  font-size: 11px;
  font-weight: 800;
  color: var(--yellow-bolt);
}

.speed-tag {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-dim);
  margin-top: 2px;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.status-ready {
  font-size: 10px;
  font-weight: 900;
  color: var(--yellow-bolt);
  text-shadow: 0 0 8px var(--yellow-glow);
}

.meter-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 214, 0, 0.3);
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff9900, #ffd600, #00f0ff);
  border-radius: 999px;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 10px var(--yellow-glow);
}

.sub-hint {
  font-size: 8px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.powers-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-height: 24px;
}

.no-powers-label {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

.power-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: pulse-glow 1.5s infinite alternate;
}

.power-tag.shield {
  background: rgba(0, 240, 255, 0.22);
  border: 1px solid var(--cyan-bright);
  color: #fff;
  box-shadow: 0 0 8px var(--cyan-glow);
}

.power-tag.nitro {
  background: rgba(176, 38, 255, 0.25);
  border: 1px solid var(--purple-boost);
  color: #fff;
  box-shadow: 0 0 8px rgba(176, 38, 255, 0.5);
}

.power-tag.magnet {
  background: rgba(255, 214, 0, 0.22);
  border: 1px solid var(--yellow-bolt);
  color: #fff;
  box-shadow: 0 0 8px var(--yellow-glow);
}

.stat-box strong {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.stat-highlight {
  color: var(--green-snake) !important;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}

/* Storm Alert Banner */
.storm-alert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(90deg, rgba(255, 51, 102, 0.9), rgba(176, 38, 255, 0.9));
  border: 1px solid #ff3366;
  border-radius: 12px;
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 51, 102, 0.6);
  animation: alert-flash 0.8s infinite alternate ease-in-out;
  flex-shrink: 0;
}

.storm-alert.hidden {
  display: none;
}

.alert-icon {
  font-size: 20px;
  animation: wobble 0.6s infinite alternate;
}

.alert-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.alert-text strong {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.alert-text span {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.95;
}

/* Canvas Area */
.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border-line);
  background: #050814;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7), 0 12px 32px rgba(0, 0, 0, 0.5);
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Floating Superpower Banner */
.superpower-announcer {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  background: rgba(14, 23, 53, 0.92);
  border: 2px solid var(--yellow-bolt);
  border-radius: 999px;
  box-shadow: 0 0 24px var(--yellow-glow), 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: banner-pop 0.3s ease-out;
  z-index: 10;
}

.superpower-announcer.hidden {
  display: none;
}

.announcer-icon {
  font-size: 26px;
}

.announcer-text {
  display: flex;
  flex-direction: column;
}

.announcer-text strong {
  font-size: 14px;
  font-weight: 900;
  color: var(--yellow-bolt);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.announcer-text span {
  font-size: 11px;
  color: #fff;
  font-weight: 700;
}

/* Touch Controls */
.touch-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px 0;
  flex-shrink: 0;
}

.touch-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.touch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background 0.12s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.touch-btn:active {
  transform: scale(0.94);
}

.steer-btn {
  height: 52px;
  min-width: 80px;
  padding: 0 18px;
  font-size: 13px;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.steer-btn:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--cyan-bright);
}

.boost-btn {
  height: 52px;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(135deg, #b026ff, #ff0077);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 16px rgba(176, 38, 255, 0.4);
  gap: 6px;
}

.boost-btn:active {
  transform: scale(0.96);
  filter: brightness(1.2);
}

.lightning-btn {
  height: 52px;
  padding: 0 26px;
  background: linear-gradient(135deg, #ff9900, #ffd600);
  color: #070c1e;
  border: 2px solid #fff;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  gap: 8px;
  box-shadow: 0 0 22px var(--yellow-glow);
  animation: pulse-glow 1.5s infinite alternate;
}

.lightning-btn:active {
  background: #ffea00;
}

.lightning-btn.disabled {
  opacity: 0.45;
  filter: grayscale(0.7);
  pointer-events: none;
  animation: none;
}

.lightning-btn .btn-icon {
  font-size: 20px;
}

.controls-hint {
  text-align: center;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.controls-hint b {
  color: var(--cyan-bright);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 17, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
  animation: fade-in 0.25s ease-out;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  background: linear-gradient(160deg, #131c3d, #090e24);
  border: 2px solid var(--border-line);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px var(--cyan-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.modal-icon {
  font-size: 44px;
}

.modal-card h2 {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: -6px;
}

.modal-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  text-align: left;
}

.step-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.step-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--yellow-bolt);
  color: #000;
  font-weight: 900;
  font-size: 12px;
  flex-shrink: 0;
}

.step-card strong {
  display: block;
  font-size: 12px;
  color: #fff;
  margin-bottom: 2px;
}

.step-card p {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
}

.step-card b {
  color: var(--cyan-bright);
}

.game-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-pill span {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}

.stat-pill strong {
  font-size: 18px;
  font-weight: 900;
  color: var(--cyan-bright);
}

.modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.big-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #00d2ff, #00f0ff);
  color: #070c1e;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 0 20px var(--cyan-glow);
  transition: transform 0.15s ease;
}

.big-btn:hover {
  transform: scale(1.02);
}

.big-btn:active {
  transform: scale(0.97);
}

.restart-btn {
  background: linear-gradient(135deg, #ff9900, #ffd600);
  box-shadow: 0 0 20px var(--yellow-glow);
}

.home-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.home-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Animations */
@keyframes pulse-glow {
  0% { transform: scale(1); filter: brightness(1); }
  100% { transform: scale(1.04); filter: brightness(1.25); }
}

@keyframes alert-flash {
  0% { opacity: 0.85; transform: scale(0.99); }
  100% { opacity: 1; transform: scale(1.01); }
}

@keyframes banner-pop {
  0% { transform: translate(-50%, -20px) scale(0.8); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .dashboard-hud {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .hud-box.powers-active-box {
    grid-column: span 2;
  }
}

@media (max-width: 600px) {
  .game-shell {
    padding: 4px 6px 8px;
  }
  .top-nav {
    padding: 6px 8px;
  }
  .nav-brand {
    display: none;
  }
  .speed-readout strong {
    font-size: 20px;
  }
  .touch-btn {
    height: 46px;
  }
  .steer-btn {
    padding: 0 10px;
    font-size: 11px;
  }
  .lightning-btn {
    padding: 0 14px;
    font-size: 12px;
  }
  .gas-btn {
    padding: 0 14px;
    font-size: 12px;
  }
}
