:root {
  --bg-color: #080314;
  --surface-color: rgba(20, 10, 35, 0.88);
  --neon-cyan: #00f3ff;
  --neon-pink: #ff007f;
  --neon-purple: #9d00ff;
  --neon-yellow: #ffe600;
  --text-main: #f0f4fc;
  --text-muted: #8d98b0;
  --glow-cyan: 0 0 15px rgba(0, 243, 255, 0.6);
  --glow-pink: 0 0 15px rgba(255, 0, 127, 0.6);
  --font-display: 'Orbitron', monospace, sans-serif;
  --font-body: 'Rajdhani', sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
}

/* Sponsor / Monetization Header */
.sponsor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: linear-gradient(90deg, #130924 0%, #200f3c 50%, #130924 100%);
  border-bottom: 1px solid rgba(0, 243, 255, 0.25);
  font-size: 0.8rem;
  z-index: 100;
  position: relative;
  height: 38px;
  min-height: 38px;
  flex-shrink: 0;
}

.sponsor-tag {
  background: var(--neon-pink);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.sponsor-text {
  color: var(--text-main);
  flex: 1;
  text-align: center;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sponsor-cta {
  color: var(--neon-cyan);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 8px;
  border: 1px solid var(--neon-cyan);
  border-radius: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sponsor-cta:hover {
  background: var(--neon-cyan);
  color: #000;
  box-shadow: var(--glow-cyan);
}

/* Main Container & Canvas */
#game-container {
  position: relative;
  width: 100vw;
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 12px);
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* HUD Overlay */
.hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 10;
  pointer-events: none;
}

.hud-overlay button {
  pointer-events: auto;
}

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
}

.hud-right {
  align-items: flex-end;
}

.hud-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.hud-label.mt {
  margin-top: 6px;
}

.hud-val {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: var(--glow-cyan);
}

.hud-val-sm {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.badge {
  background: rgba(255, 0, 127, 0.2);
  border: 1px solid var(--neon-pink);
  color: var(--neon-pink);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  text-shadow: var(--glow-pink);
}

.shield-tag {
  background: rgba(0, 243, 255, 0.2);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.7; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1.03); }
}

.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 1.05rem;
  cursor: pointer;
  margin-top: 8px;
  backdrop-filter: blur(8px);
}

/* Screen Overlays */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  background: rgba(8, 3, 20, 0.78);
  backdrop-filter: blur(8px);
  padding: 20px;
  transition: opacity 0.3s ease;
}

.hidden {
  display: none !important;
}

.neon-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-color);
  border: 1px solid rgba(0, 243, 255, 0.35);
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.15), inset 0 0 20px rgba(0, 243, 255, 0.05);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.glitch-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-pink);
  margin-bottom: 4px;
}

.subtitle {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--neon-pink);
  margin-bottom: 18px;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: all 0.2s ease;
}

.mode-btn.active {
  border-color: var(--neon-cyan);
  background: rgba(0, 243, 255, 0.1);
  box-shadow: var(--glow-cyan);
}

.mode-tag {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.mode-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.instructions {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 18px;
  font-size: 0.85rem;
  text-align: left;
}

.inst-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.inst-item:last-child {
  margin-bottom: 0;
}

.key-tag {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--font-display);
  color: var(--neon-cyan);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #080314;
  background: linear-gradient(90deg, var(--neon-cyan) 0%, #00bcff 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.98);
}

.quick-stats {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.highlight {
  color: var(--neon-yellow);
  font-weight: 700;
}

/* Game Over Card */
.game-over-header {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--neon-pink);
  text-shadow: var(--glow-pink);
  letter-spacing: 2px;
  margin-bottom: 14px;
}

.final-score-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.stat-unit {
  margin-bottom: 10px;
}

.stat-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.stat-big {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--neon-cyan);
  text-shadow: var(--glow-cyan);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}

.stat-cell {
  display: flex;
  flex-direction: column;
}

.cell-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.cell-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.revive-container {
  margin-bottom: 14px;
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: rgba(157, 0, 255, 0.3);
  border: 1px solid var(--neon-purple);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(157, 0, 255, 0.3);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(157, 0, 255, 0.5);
}

.revive-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.btn-share {
  flex: 1;
  padding: 13px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  cursor: pointer;
}

.monetize-footer {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.coffee-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.coffee-link:hover {
  color: var(--neon-yellow);
}

/* Toast */
.toast {
  position: absolute;
  bottom: 24px;
  background: #000;
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  box-shadow: var(--glow-cyan);
  padding: 10px 20px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  z-index: 50;
  animation: popToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popToast {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .glitch-title {
    font-size: 1.8rem;
  }
  .stat-big {
    font-size: 2rem;
  }
  .action-buttons {
    flex-direction: column;
  }
}
