/* ==========================================================================
   RUN: LOST FRONTIER - AAA Mobile & Desktop Game Styling System
   Glassmorphism, tactical HUD telemetry, glowing gauges, and responsive UI.
   ========================================================================== */

:root {
  --bg-dark: #090d16;
  --bg-surface: rgba(15, 23, 42, 0.78);
  --bg-surface-elevated: rgba(30, 41, 59, 0.88);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(56, 189, 248, 0.4);

  --accent-cyan: #38bdf8;
  --accent-gold: #f59e0b;
  --accent-emerald: #10b981;
  --accent-crimson: #ef4444;
  --accent-purple: #a855f7;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Chakra Petch', monospace, sans-serif;
  --font-metric: 'Teko', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

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

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

#viewport-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#viewport-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* --- OPTICAL OVERLAYS --- */
.optical-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at center, transparent 75%, rgba(0, 0, 0, 0.25) 100%);
}

.hidden {
  display: none !important;
}

/* --- BUTTON STYLES --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 4px 20px rgba(2, 132, 199, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  box-shadow: 0 6px 28px rgba(56, 189, 248, 0.6);
}

.btn-embank {
  font-size: 20px;
  padding: 18px 48px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fbbf24;
  color: #0f172a;
  font-weight: 800;
  box-shadow: 0 6px 30px rgba(245, 158, 11, 0.5);
  animation: pulseEmbark 2.4s infinite ease-in-out;
}

@keyframes pulseEmbark {
  0%, 100% { box-shadow: 0 6px 30px rgba(245, 158, 11, 0.4); transform: scale(1); }
  50% { box-shadow: 0 10px 45px rgba(245, 158, 11, 0.8); transform: scale(1.03); }
}

.btn-active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.btn-upgrade {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-unlock {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.btn-claim {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #34d399;
  color: #fff;
  animation: bounceClaim 1.5s infinite;
}

@keyframes bounceClaim {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* --- LOADING SCREEN --- */
#loading-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #111827 0%, #030712 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-logo-box {
  text-align: center;
  margin-bottom: 40px;
}

.loading-logo-box h1 {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  text-shadow: 0 0 25px rgba(56, 189, 248, 0.6);
}

.loading-logo-box p {
  color: var(--accent-gold);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.3em;
  margin-top: 6px;
}

.loading-progress-container {
  width: 85%;
  max-width: 380px;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

#loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0284c7, #38bdf8, #f59e0b);
  border-radius: var(--radius-full);
  transition: width 0.2s ease;
}

#loading-status-text {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

/* --- MAIN MENU --- */
#main-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  pointer-events: none;
}

#main-menu > * {
  pointer-events: auto;
}

/* Top Status Bar */
.menu-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 20px;
}

.profile-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-tag {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  background: var(--accent-cyan);
  color: #0f172a;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.callsign {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.currency-bar {
  display: flex;
  align-items: center;
  gap: 18px;
}

.currency-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.currency-item.credits { color: var(--accent-gold); }
.currency-item.relics { color: var(--accent-cyan); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  transition: color 0.2s;
}

.btn-icon:hover { color: var(--text-primary); }

/* Center Menu Hero */
.menu-center-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.game-title-group h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 8vw, 68px);
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.0;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.8));
}

.game-title-group .subtitle {
  font-family: var(--font-display);
  font-size: clamp(12px, 3vw, 18px);
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--accent-gold);
  margin-top: 8px;
}

/* Bottom Navigation */
.menu-bottom-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-btn {
  font-size: 13px;
  padding: 10px 18px;
  background: var(--bg-surface);
}

/* --- IN-GAME HUD --- */
#game-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
}

#game-hud > * {
  pointer-events: auto;
}

.hud-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-stats-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-score-box {
  font-family: var(--font-metric);
  font-size: clamp(42px, 7vw, 64px);
  font-weight: 700;
  line-height: 0.85;
  color: #fff;
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

.hud-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.hud-dist { color: var(--accent-cyan); }
.hud-relics-count { color: var(--accent-gold); }

.hud-biome-badge {
  display: inline-block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-cyan);
}

/* Combo Badge */
.hud-combo-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.combo-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  padding: 4px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
  animation: pulseCombo 0.8s infinite alternate;
}

@keyframes pulseCombo {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.combo-timer-bar {
  width: 90px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

#hud-combo-meter {
  height: 100%;
  width: 100%;
  background: #f59e0b;
}

/* Bottom Threat Radar & Power-Up Slots */
.hud-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.threat-radar {
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.threat-radar.safe { border-color: var(--accent-emerald); color: var(--accent-emerald); }
.threat-radar.caution { border-color: var(--accent-gold); color: var(--accent-gold); }
.threat-radar.critical {
  border-color: var(--accent-crimson);
  color: var(--accent-crimson);
  animation: threatBlink 0.6s infinite alternate;
}

@keyframes threatBlink {
  0% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.3); }
  100% { box-shadow: 0 0 25px rgba(239, 68, 68, 0.8); }
}

.powerup-slots {
  display: flex;
  gap: 8px;
}

.powerup-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent-cyan);
  position: relative;
  overflow: hidden;
}

.powerup-ring {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(56, 189, 248, 0.25);
  pointer-events: none;
}

/* Touch Control Hints on Mobile */
.mobile-touch-hints {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 32px;
  font-family: var(--font-display);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

/* --- MODAL DIALOGS --- */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Character & Upgrade Cards */
.character-card, .upgrade-card, .mission-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}

.character-card.selected {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.char-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.char-name { font-family: var(--font-display); font-size: 16px; font-weight: 800; }
.char-title { font-size: 12px; color: var(--text-secondary); }
.char-desc { font-size: 13px; color: var(--text-muted); }
.char-specialty { font-size: 13px; font-weight: 700; color: var(--accent-gold); }

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 11px;
  margin-top: 4px;
}

.stat-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  background: var(--accent-cyan);
}

/* Upgrade Card */
.upgrade-card {
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.upgrade-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent-gold);
}

.upgrade-info { flex: 1; }
.upgrade-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.upgrade-desc { font-size: 12px; color: var(--text-muted); margin: 2px 0 6px; }

.upgrade-pips {
  display: flex;
  align-items: center;
  gap: 6px;
}

.upgrade-pip {
  width: 14px;
  height: 6px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
}

.upgrade-pip.filled { background: var(--accent-gold); }
.lvl-label { font-size: 11px; color: var(--text-secondary); margin-left: 6px; font-family: var(--font-display); }

/* Mission Card */
.mission-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.mission-title { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.mission-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }

.mission-progress-bar {
  width: 160px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill { height: 100%; background: var(--accent-emerald); }
.mission-counts { font-size: 11px; color: var(--text-secondary); font-family: var(--font-display); margin-top: 2px; }

.reward-tag {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
}

.reward-tag.relics { color: var(--accent-cyan); margin-left: 6px; }

/* Leaderboard */
.leaderboard-row {
  display: grid;
  grid-template-columns: 40px 1fr 90px 110px;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 14px;
}

.leaderboard-row.top-1 { background: rgba(245, 158, 11, 0.12); font-weight: 800; }
.char-tag { font-size: 11px; color: var(--text-muted); margin-left: 6px; font-weight: 400; }
.player-dist { color: var(--accent-cyan); }
.player-score { text-align: right; color: var(--accent-gold); font-weight: 700; }

/* --- SETTINGS FORM --- */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

.setting-row select, .setting-row input[type="range"] {
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
}

/* --- RESULTS SCREEN --- */
#results-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.results-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
}

.results-header h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.highscore-tag {
  display: inline-block;
  margin-top: 6px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  animation: pulseCombo 1s infinite alternate;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.res-stat-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.res-stat-box.full-width { grid-column: span 2; }
.res-stat-label { font-size: 11px; font-family: var(--font-display); color: var(--text-muted); }
.res-stat-val { font-family: var(--font-metric); font-size: 32px; font-weight: 700; color: #fff; }
.res-stat-val.score { font-size: 48px; color: var(--accent-gold); }

.results-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

/* --- PAUSE MENU --- */
#pause-menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  background: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(15px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.pause-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
