@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --bg-dark: #070a12;
  --panel-bg: rgba(15, 23, 42, 0.92);
  --border-color: #334155;
  --accent-amber: #f59e0b;
  --accent-cyan: #38bdf8;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* CRT Scanline and Vignette Effect */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.6) 100%),
              linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.18) 50%);
  background-size: 100% 100%, 100% 4px;
  z-index: 100;
}

/* App Container */
#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Splash Screen Modal */
#splash-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, #111827 0%, #030712 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  overflow-y: auto;
}

.splash-card {
  max-width: 680px;
  width: 100%;
  background: var(--panel-bg);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(245, 158, 11, 0.15);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#game-canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.ingame-mute-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 34px;
  height: 34px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.90);
  border: 1px solid #475569;
  border-radius: 6px;
  color: #f8fafc;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: all 0.15s ease-in-out;
  backdrop-filter: blur(4px);
  padding: 0;
}

.ingame-mute-btn .mute-label {
  display: none;
}

.ingame-mute-btn .mute-icon {
  font-size: 16px;
}

.ingame-mute-btn:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: var(--accent-cyan);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
}

.splash-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.retro-mute-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.8);
  border: 1.5px solid var(--accent-amber);
  border-radius: 8px;
  color: #f8fafc;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 10px rgba(245, 158, 11, 0.25);
  transition: all 0.15s ease-in-out;
  flex-shrink: 0;
}

.retro-mute-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: #facc15;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), 0 0 14px rgba(245, 158, 11, 0.4);
}

.retro-mute-btn.muted,
.ingame-mute-btn.muted {
  border-color: #ef4444;
  color: #fca5a5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 8px rgba(239, 68, 68, 0.25);
}

.logo-header {
  text-align: left;
  flex: 1;
}

.logo-header h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 32px;
  color: var(--accent-amber);
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.6), 3px 3px 0 #b45309;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.logo-header p {
  color: var(--accent-cyan);
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
}

/* Daily Seed Banner */
.daily-banner {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: monospace;
  font-size: 13px;
}

.daily-banner span.seed-code {
  color: var(--accent-amber);
  font-weight: bold;
}

/* Course Selector */
.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.course-btn {
  background: rgba(30, 41, 59, 0.5);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.15s ease;
}

.course-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
}

.course-btn.active {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.course-btn[data-tier="C1"] { color: #4ade80; }
.course-btn[data-tier="C2"] { color: #38bdf8; }
.course-btn[data-tier="C3"] { color: #f87171; }

/* Auth / Profile Bar */
.auth-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
}

.auth-bar input {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  flex: 1;
}

.auth-bar input:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.auth-bar button {
  background: #334155;
  border: none;
  border-radius: 6px;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-bar button:hover {
  background: #475569;
}

/* Logged-In Profile Status */
.auth-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 8px;
  padding: 8px 14px;
}

.auth-status-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
}

.btn-logout {
  background: #334155;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* Action Controls */
.controls-hint {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: rgba(30, 41, 59, 0.4);
  border-radius: 8px;
  padding: 12px;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.controls-hint strong {
  color: var(--accent-cyan);
}

.launch-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 10px;
}

.btn-launch {
  border: none;
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
  user-select: none;
  text-decoration: none;
}

.btn-play-daily {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  box-shadow: 0 6px 0 #92400e, 0 10px 20px rgba(245, 158, 11, 0.4);
}

.btn-play-daily:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #92400e, 0 14px 24px rgba(245, 158, 11, 0.55);
}

.btn-play-daily:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #92400e, 0 4px 10px rgba(245, 158, 11, 0.3);
}

.btn-launch .btn-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.btn-play-daily .btn-title {
  color: #0f172a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-launch .btn-sub {
  font-family: monospace;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.92;
}

.btn-play-daily .btn-sub {
  color: #451a03;
}

/* Game Canvas Viewport */
#game-canvas-container {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Post-Race Leaderboard Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 60;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.leaderboard-modal {
  max-width: 520px;
  width: 100%;
  background: var(--panel-bg);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: var(--accent-amber);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-family: monospace;
  font-size: 13px;
}

.leaderboard-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.leaderboard-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.leaderboard-table tr:hover td {
  background: rgba(56, 189, 248, 0.08);
}

.leaderboard-table .rank-1 { color: #facc15; font-weight: bold; }
.leaderboard-table .rank-2 { color: #e2e8f0; font-weight: bold; }
.leaderboard-table .rank-3 { color: #d97706; font-weight: bold; }

/* Tactical Dispatch Briefing Overlay (Load-Gated Loading Screen) */
.briefing-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.96) 0%, rgba(2, 6, 23, 0.99) 100%);
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.briefing-card {
  max-width: 580px;
  width: 100%;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #38bdf8;
  border-radius: 12px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(56, 189, 248, 0.25);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.briefing-meta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  padding-bottom: 12px;
}

.briefing-status {
  font-family: monospace;
  font-size: 11px;
  font-weight: bold;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.briefing-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  min-height: 220px;
  justify-content: center;
  transition: opacity 0.35s ease-in-out, transform 0.35s ease-in-out;
}

.briefing-slide.dissolving {
  opacity: 0;
  transform: scale(0.96);
}

.briefing-art {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.6));
}

.briefing-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #facc15;
  letter-spacing: 0.5px;
  margin: 0;
}

.briefing-desc {
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
  max-width: 480px;
  margin: 0;
}

.briefing-progress-track {
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}

.briefing-progress-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  border-radius: 3px;
  animation: briefingIndeterminate 1.1s ease-in-out infinite;
}

@keyframes briefingIndeterminate {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

/* Cinematic End Sequence Modal */
.end-sequence-card {
  max-width: 540px;
  width: 100%;
  background: rgba(15, 23, 42, 0.97);
  border: 2px solid #facc15;
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.95), 0 0 40px rgba(250, 204, 21, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  animation: modalPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.end-sequence-card.card-drowned {
  border-color: #38bdf8;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.95), 0 0 40px rgba(56, 189, 248, 0.35);
}

.end-sequence-card.card-defeated {
  border-color: #ef4444;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.95), 0 0 40px rgba(239, 68, 68, 0.35);
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1.0); }
}

.end-sequence-icon {
  font-size: 52px;
  line-height: 1;
}

.end-sequence-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  margin: 0;
  letter-spacing: 0.5px;
}

.end-sequence-subtitle {
  font-family: monospace;
  font-size: 13px;
  color: #94a3b8;
  margin: 0;
}

.end-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  margin: 8px 0;
}

.end-stat-box {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.end-stat-label {
  font-family: monospace;
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
}

.end-stat-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  color: #f8fafc;
}

.end-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
}

.btn-end-primary {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  cursor: pointer;
  background: #facc15;
  color: #0f172a;
  box-shadow: 0 4px 0 #ca8a04;
  transition: all 0.1s ease;
}

.btn-end-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #ca8a04;
}

.btn-end-secondary {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: 1.5px solid #475569;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  cursor: pointer;
  background: rgba(30, 41, 59, 0.8);
  color: #f8fafc;
  transition: all 0.1s ease;
}

.btn-end-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
}
