/* ============================================================
   COSMIC COMMAND: STARSHIP NOVA — Design System
   ============================================================ */

/* --- CSS RESET & BASE --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Core palette */
  --bg-deep: #06060f;
  --bg-space: #0a0a1a;
  --bg-panel: rgba(15, 15, 40, 0.75);
  --bg-card: rgba(20, 20, 55, 0.6);
  --bg-card-hover: rgba(30, 30, 70, 0.7);
  --bg-input: rgba(10, 10, 30, 0.8);

  /* Neon accents */
  --cyan: #00f0ff;
  --cyan-dim: #00a0b0;
  --cyan-glow: rgba(0, 240, 255, 0.3);
  --purple: #a855f7;
  --purple-dim: #7c3aed;
  --purple-glow: rgba(168, 85, 247, 0.3);
  --pink: #ec4899;
  --pink-glow: rgba(236, 72, 153, 0.25);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.25);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.25);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.25);
  --gold: #ffd700;

  /* Text */
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --text-bright: #ffffff;

  /* Borders */
  --border-subtle: rgba(100, 100, 180, 0.15);
  --border-glow: rgba(0, 240, 255, 0.25);

  /* Fonts */
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;

  /* Spacing */
  --nav-height: 72px;
  --topbar-height: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 240, 255, 0.1);
  --shadow-glow-cyan: 0 0 20px rgba(0, 240, 255, 0.2), 0 0 60px rgba(0, 240, 255, 0.05);
  --shadow-glow-purple: 0 0 20px rgba(168, 85, 247, 0.2), 0 0 60px rgba(168, 85, 247, 0.05);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* --- STARS CANVAS --- */
#stars-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* --- SCREENS --- */
.screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

/* --- ONBOARDING --- */
.onboarding-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
  z-index: 2;
  position: relative;
}

.onboarding-logo {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.logo-ring {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  box-shadow: var(--shadow-glow-cyan), inset 0 0 20px rgba(0, 240, 255, 0.1);
  animation: spin-slow 12s linear infinite;
}

.logo-ring::before {
  content: '';
  position: absolute;
  top: -4px; left: 50%;
  width: 8px; height: 8px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--cyan);
  transform: translateX(-50%);
}

.logo-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 15px rgba(0, 240, 255, 0.4));
  animation: float 3s ease-in-out infinite;
}

.onboarding-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--text-bright);
  letter-spacing: 4px;
  text-shadow: 0 0 20px var(--cyan-glow);
  margin-bottom: 0.25rem;
}

.onboarding-subtitle {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 6px;
  margin-bottom: 1.5rem;
}

.onboarding-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  max-width: 320px;
}

.onboarding-form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-align: left;
}

/* --- INPUTS --- */
.neon-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-glow);
  border-radius: 10px;
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.neon-input::placeholder {
  color: var(--text-muted);
}

.neon-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.15), inset 0 0 10px rgba(0, 240, 255, 0.05);
}

.math-input {
  font-family: var(--font-display);
  font-size: 1.5rem;
  text-align: center;
  max-width: 160px;
  letter-spacing: 4px;
}

/* Hide number input spinners */
.neon-input[type="number"]::-webkit-inner-spin-button,
.neon-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.neon-input[type="number"] { -moz-appearance: textfield; }

/* --- BUTTONS --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.75rem;
  background: linear-gradient(135deg, var(--cyan-dim), var(--purple-dim));
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 10px;
  color: var(--text-bright);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.3s, opacity 0.3s;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.btn-glow {
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.25), 0 0 60px rgba(168, 85, 247, 0.1);
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-ghost:hover, .btn-ghost:active {
  color: var(--cyan);
  border-color: var(--cyan-dim);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
}

.btn-danger {
  background: linear-gradient(135deg, #991b1b, #7f1d1d);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-success {
  background: linear-gradient(135deg, #166534, #14532d);
  border-color: rgba(34, 197, 94, 0.3);
}

/* --- TOP BAR --- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  padding-top: var(--safe-top);
  height: calc(var(--topbar-height) + var(--safe-top));
  background: rgba(6, 6, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.commander-avatar {
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 50%;
}

.commander-info {
  display: flex;
  flex-direction: column;
}

.commander-rank {
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--cyan);
  letter-spacing: 2px;
}

.commander-name-display {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.top-bar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  cursor: pointer;
}

.app-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 4px;
  color: var(--text-bright);
  text-shadow: 0 0 10px var(--cyan-glow);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.coin-display, .streak-display {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.75rem;
}

.coin-display {
  border-color: rgba(255, 215, 0, 0.25);
  color: var(--gold);
}

.streak-display {
  color: var(--amber);
}

.coin-icon, .streak-icon {
  font-size: 0.9rem;
}

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 52px + 1rem);
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
}

/* --- MUSIC PLAYER --- */
.music-player {
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  background: rgba(6, 6, 15, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  transition: border-color 0.5s;
}

.music-player.playing {
  border-top-color: rgba(168, 85, 247, 0.35);
}

.music-player-inner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.music-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  transition: color 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.music-btn:active {
  transform: scale(0.9);
}

.music-btn-play {
  font-size: 1.05rem;
  color: var(--purple);
}

.music-player.playing .music-btn-play {
  color: var(--cyan);
  filter: drop-shadow(0 0 6px var(--cyan-glow));
}

.music-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 0.3rem;
}

.music-title {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 1px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-artist {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-volume {
  width: 50px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-subtle);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.music-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--purple);
  border: none;
  cursor: pointer;
}

.music-volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--purple);
  border: none;
  cursor: pointer;
}

/* Tab panels */
.tab-panel {
  display: none;
  animation: fadeSlideIn 0.3s ease-out;
}

.tab-panel.active {
  display: block;
}

/* --- NAV BADGE (unread indicator) --- */
.nav-btn {
  position: relative;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  background: var(--red);
  color: white;
  font-family: var(--font-display);
  font-size: 0.5rem;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  box-shadow: 0 0 6px var(--red-glow);
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* --- COMMS CHAT --- */
.comms-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.comms-chat-container {
  flex: 1;
  min-height: 300px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem !important;
  -webkit-overflow-scrolling: touch;
}

.comms-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.comms-message {
  display: flex;
  max-width: 80%;
}

.comms-message.from-commander {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.comms-message.from-command {
  align-self: flex-start;
}

.comms-bubble {
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  position: relative;
}

.from-commander .comms-bubble {
  background: linear-gradient(135deg, rgba(0, 160, 176, 0.25), rgba(0, 240, 255, 0.15));
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-bottom-right-radius: 4px;
}

.from-command .comms-bubble {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-bottom-left-radius: 4px;
}

.comms-sender {
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 1.5px;
  margin-bottom: 0.25rem;
}

.from-commander .comms-sender {
  color: var(--cyan);
}

.from-command .comms-sender {
  color: var(--purple);
}

.comms-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.comms-time {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.comms-input-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.comms-input {
  flex: 1;
  padding: 0.7rem 0.85rem !important;
  font-size: 0.9rem !important;
}

.comms-send-btn {
  padding: 0.7rem 1rem !important;
  font-size: 1.1rem !important;
  min-width: auto;
  letter-spacing: 0;
}

.comms-mic-btn {
  padding: 0.7rem 0.8rem !important;
  font-size: 1.1rem !important;
  min-width: auto;
  letter-spacing: 0;
  background: rgba(168, 85, 247, 0.15) !important;
  border: 1px solid rgba(168, 85, 247, 0.3) !important;
}

.comms-mic-btn.mic-active {
  background: rgba(239, 68, 68, 0.3) !important;
  border-color: var(--red) !important;
  box-shadow: 0 0 15px var(--red-glow);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 8px var(--red-glow); }
  50% { box-shadow: 0 0 20px var(--red-glow), 0 0 40px rgba(239, 68, 68, 0.2); }
}

/* Admin comms */
.admin-comms-chat {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0;
  -webkit-overflow-scrolling: touch;
}

.admin-comms-msg {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  max-width: 85%;
}

.admin-comms-msg.from-kid {
  align-self: flex-start;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.15);
}

.admin-comms-msg.from-dad {
  align-self: flex-end;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.15);
}

.admin-comms-sender {
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.admin-comms-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  margin: 0.15rem 0;
}

.admin-comms-time {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-align: right;
}

/* --- BOTTOM NAV --- */
.bottom-nav {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-height) + var(--safe-bottom));
  background: rgba(6, 6, 15, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn .nav-icon {
  font-size: 1.35rem;
  transition: transform 0.2s;
}

.nav-btn .nav-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 1px;
}

.nav-btn.active {
  color: var(--cyan);
}

.nav-btn.active .nav-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px var(--cyan-glow));
}

.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2px;
  background: var(--cyan);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 0 10px var(--cyan);
}

/* --- GLASS CARDS --- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, border-color 0.3s;
}

.glass-card:active {
  transform: scale(0.98);
}

.glass-card.glow-cyan {
  border-color: rgba(0, 240, 255, 0.2);
  box-shadow: var(--shadow-card), var(--shadow-glow-cyan);
}

.glass-card.glow-purple {
  border-color: rgba(168, 85, 247, 0.2);
  box-shadow: var(--shadow-card), var(--shadow-glow-purple);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--text-bright);
}

.card-header .card-icon {
  font-size: 1.2rem;
}

/* --- SECTION TITLES --- */
.section-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 3px;
  color: var(--cyan);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-glow), transparent);
}

/* --- MINERAL GRID (Cargo Link) --- */
.mineral-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.mineral-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.mineral-card.selected {
  border-color: var(--cyan);
  background: rgba(0, 240, 255, 0.06);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}

.mineral-card .mineral-icon {
  font-size: 1.5rem;
}

.mineral-card .mineral-name {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 1px;
  color: var(--text-secondary);
  text-align: center;
}

.mineral-card .mineral-qty-input {
  width: 60px;
  padding: 0.35rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  color: var(--cyan);
  outline: none;
}

.mineral-card .mineral-qty-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.mineral-card .mineral-unit-toggle {
  font-size: 0.55rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: none;
  transition: color 0.2s;
}

.mineral-card .mineral-unit-toggle.active {
  color: var(--cyan);
  border-color: var(--cyan-dim);
}

/* --- PROGRESS BARS --- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease-out;
  position: relative;
}

.progress-fill.cyan {
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  box-shadow: 0 0 8px var(--cyan-glow);
}

.progress-fill.purple {
  background: linear-gradient(90deg, var(--purple-dim), var(--purple));
  box-shadow: 0 0 8px var(--purple-glow);
}

.progress-fill.gold {
  background: linear-gradient(90deg, #b8860b, var(--gold));
  box-shadow: 0 0 8px var(--amber-glow);
}

.progress-fill.green {
  background: linear-gradient(90deg, #166534, var(--green));
  box-shadow: 0 0 8px var(--green-glow);
}

/* --- MODALS --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: linear-gradient(145deg, rgba(15, 15, 45, 0.95), rgba(10, 10, 30, 0.98));
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.1), 0 20px 60px rgba(0, 0, 0, 0.5);
  position: relative;
  animation: modalSlideUp 0.3s ease-out;
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.modal-close:active {
  color: var(--text-primary);
  background: var(--bg-card);
}

.modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.modal-icon {
  font-size: 2.5rem;
  animation: float 2s ease-in-out infinite;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: var(--cyan);
}

.math-question {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-bright);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.math-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.math-feedback {
  min-height: 1.5rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

.math-feedback.correct {
  color: var(--green);
  text-shadow: 0 0 10px var(--green-glow);
}

.math-feedback.incorrect {
  color: var(--red);
}

.admin-gate-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

/* --- GEOLOGY MODAL --- */
.geology-modal-card {
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  text-align: left;
  padding: 1.75rem;
}

.geo-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.geo-icon {
  font-size: 2.5rem;
}

.geo-title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 2px;
  color: var(--text-bright);
}

.geo-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

.geo-classification {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.geo-stat {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.geo-stat-label {
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.geo-stat-value {
  font-size: 0.75rem;
  color: var(--text-primary);
}

.geo-headline {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--cyan);
  letter-spacing: 2px;
  margin-bottom: 0.75rem;
}

.geo-facts {
  margin-bottom: 1.25rem;
}

.geo-facts p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border-subtle);
}

.geo-dyk, .geo-mc {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  padding: 1rem;
  margin-bottom: 1rem;
}

.geo-dyk h4, .geo-mc h4 {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--amber);
  margin-bottom: 0.5rem;
}

.geo-mc h4 {
  color: var(--green);
}

.geo-dyk p, .geo-mc p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
}

/* --- ACHIEVEMENT MODAL --- */
.achievement-modal-card {
  overflow: visible;
}

.achievement-burst {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.15), transparent 70%);
  border-radius: 50%;
  animation: pulse-burst 1.5s ease-out;
  pointer-events: none;
}

.achievement-icon-big {
  font-size: 4rem;
  display: block;
  margin-bottom: 0.75rem;
  animation: bounce-in 0.5s ease-out;
}

.achievement-title {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: var(--cyan);
  letter-spacing: 3px;
  margin-bottom: 0.5rem;
}

.achievement-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.achievement-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.achievement-reward {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 20px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.8rem;
  margin-bottom: 1.25rem;
}

/* --- CARGO TAB SPECIFICS --- */
.cargo-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.cargo-instructions {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.cargo-instructions strong {
  color: var(--cyan);
}

/* --- COIN VAULT --- */
.vault-container {
  text-align: center;
  padding: 1.5rem 0;
}

.vault-balance {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--gold);
  text-shadow: 0 0 20px var(--amber-glow);
  margin: 0.5rem 0;
}

.vault-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 3px;
  color: var(--text-muted);
}

.redeem-section {
  margin-top: 1.5rem;
}

.redeem-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.btn-redeem {
  margin-top: 1rem;
  width: 100%;
  padding: 1rem;
  font-size: 0.9rem;
}

.btn-redeem:disabled {
  background: var(--bg-card);
  border-color: var(--border-subtle);
}

/* --- MISSION CARDS --- */
.mission-card {
  margin-bottom: 1rem;
}

.mission-type {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 2px;
  color: var(--purple);
  margin-bottom: 0.25rem;
}

.mission-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-bright);
  margin-bottom: 0.5rem;
}

.mission-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.mission-reward {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 12px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.7rem;
}

.mission-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* --- PROFILE --- */
.profile-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.profile-avatar {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 15px var(--cyan-glow));
}

.profile-commander-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text-bright);
  margin-bottom: 0.15rem;
}

.profile-username {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.profile-rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  margin-top: 0.75rem;
}

.profile-rank-badge .rank-icon {
  font-size: 1rem;
}

.profile-rank-badge .rank-name {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--cyan);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-bright);
}

.stat-label {
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Achievement grid */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  text-align: center;
  transition: opacity 0.2s;
}

.badge-card.locked {
  opacity: 0.35;
  filter: grayscale(0.7);
}

.badge-card.unlocked {
  border-color: rgba(255, 215, 0, 0.3);
  background: rgba(255, 215, 0, 0.04);
}

.badge-icon {
  font-size: 1.5rem;
}

.badge-name {
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

/* --- ADMIN PANEL --- */
.admin-container {
  padding: 1.5rem;
  padding-top: calc(1.5rem + var(--safe-top));
  overflow-y: auto;
  height: 100%;
  -webkit-overflow-scrolling: touch;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.admin-header h1 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--text-bright);
}

.admin-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.25rem;
}

.admin-card h3 {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--cyan);
  margin-bottom: 0.75rem;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-row:last-child {
  border-bottom: none;
}

.admin-row-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.admin-row-value {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-bright);
}

.admin-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  outline: none;
}

.admin-number-input {
  width: 80px;
  padding: 0.4rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-bright);
  outline: none;
}

/* Redemption log */
.redemption-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.redemption-item:last-child { border-bottom: none; }

.redemption-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.redemption-status {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 1px;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.redemption-status.pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.redemption-status.fulfilled {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* --- GEOLOGY GRID --- */
.geology-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.geo-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  cursor: pointer;
}

.geo-card.locked {
  opacity: 0.4;
}

.geo-card .geo-card-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.geo-card .geo-card-info {
  display: flex;
  flex-direction: column;
}

.geo-card .geo-card-name {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 1px;
  color: var(--text-bright);
}

.geo-card .geo-card-status {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.geo-card .geo-card-status.unlocked {
  color: var(--green);
}

/* --- HISTORY LOG --- */
.history-log {
  max-height: 250px;
  overflow-y: auto;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.history-entry:last-child { border-bottom: none; }

.history-timestamp {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-detail {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.history-coins {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--gold);
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

@keyframes pulse-burst {
  from { transform: translateX(-50%) scale(0.5); opacity: 1; }
  to { transform: translateX(-50%) scale(1.5); opacity: 0; }
}

@keyframes bounce-in {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 5px rgba(0, 240, 255, 0.2); }
  50% { box-shadow: 0 0 20px rgba(0, 240, 255, 0.4), 0 0 40px rgba(0, 240, 255, 0.1); }
}

@keyframes coin-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.coin-pop {
  animation: coin-pop 0.4s ease-out;
}

/* --- ERROR SHAKE --- */
@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-6px); }
  30%, 70% { transform: translateX(6px); }
}

.error-shake {
  animation: error-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  border-color: var(--red) !important;
  box-shadow: 0 0 15px var(--red-glow) !important;
}

/* --- COIN EXPLOSION PARTICLES --- */
@keyframes coin-fly {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0) rotate(var(--rot));
    opacity: 0;
  }
}

.coin-particle {
  position: fixed;
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 999;
  animation: coin-fly 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
}

/* --- MUSIC EQUALIZER --- */
.music-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  padding: 0 4px;
  flex-shrink: 0;
}

.music-eq-bar {
  width: 3px;
  background: var(--purple);
  border-radius: 1px;
  transition: height 0.15s;
}

.music-player.playing .music-eq-bar { background: var(--cyan); }

.music-player.playing .eq-1 { animation: eq-bounce 0.45s ease-in-out infinite alternate; }
.music-player.playing .eq-2 { animation: eq-bounce 0.55s ease-in-out 0.1s infinite alternate; }
.music-player.playing .eq-3 { animation: eq-bounce 0.4s ease-in-out 0.2s infinite alternate; }

.music-player:not(.playing) .music-eq-bar {
  height: 3px !important;
}

@keyframes eq-bounce {
  0% { height: 4px; }
  100% { height: 14px; }
}

.glow-pulse {
  animation: glow-pulse 2s ease-in-out infinite;
}

/* --- SCROLLBAR --- */
.main-content::-webkit-scrollbar,
.geology-modal-card::-webkit-scrollbar,
.history-log::-webkit-scrollbar,
.admin-container::-webkit-scrollbar {
  width: 4px;
}

.main-content::-webkit-scrollbar-track,
.geology-modal-card::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb,
.geology-modal-card::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

/* --- UTILITY --- */
.text-cyan { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-muted { color: var(--text-muted); }
.text-bright { color: var(--text-bright); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }

.hidden { display: none !important; }

/* --- LANDSCAPE ADJUSTMENTS --- */
@media (orientation: landscape) {
  .mineral-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .geology-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .achievement-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* --- LARGER TABLETS --- */
@media (min-width: 768px) {
  .mineral-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .geology-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .main-content {
    padding: 1.5rem 2rem;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 52px + 2rem);
  }
  .modal-card {
    padding: 2.5rem 2rem;
  }
}
