/* =====================================================================
 * SPACE TRADER: STAR ROUTES - MAIN STYLESHEET (MOBILE-FIRST)
 * ===================================================================== */

:root {
  /* Common System Colors */
  --color-success: #22c55e;
  --color-danger: #ef4444;
  --color-info: #3b82f6;
}

/* 1. Theme Configuration Mapping */
body.theme-industrial {
  /* StarCraft 1 Retro-Industrial Style */
  --color-bg: #0c0d12;
  --color-panel: #181c26;
  --color-border: #475569;
  --color-accent: #eab308;        /* Terran Amber */
  --color-accent-rgb: 234, 179, 8;
  --color-text: #cbd5e1;
  --color-text-bright: #ffffff;
  --font-display: 'Share Tech Mono', monospace;
  --font-body: 'Share Tech Mono', monospace;
  --panel-radius: 4px;
  --panel-glow: none;
  --panel-border-width: 2px;
  --grid-line-color: rgba(71, 85, 105, 0.15);
  --header-bg: #2d3748;
}

body.theme-quantum {
  /* Quantum Neon-Cyberpunk Style */
  --color-bg: #030712;
  --color-panel: rgba(17, 24, 39, 0.6); /* Translucent Slate */
  --color-border: #06b6d4;        /* Cyan */
  --color-accent: #d946ef;        /* Magenta glow */
  --color-accent-rgb: 217, 70, 239;
  --color-text: #cbd5e1;
  --color-text-bright: #ffffff;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --panel-radius: 16px;
  --panel-glow: 0 0 20px rgba(6, 182, 212, 0.25);
  --panel-border-width: 1px;
  --grid-line-color: rgba(6, 182, 212, 0.08);
  --header-bg: rgba(31, 41, 55, 0.4);
}

/* 2. Global Reset and Layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: #030712;
  color: var(--color-text);
  font-family: var(--font-body);
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--color-bg);
  transition: background-color 0.8s ease, color 0.5s ease;
}

/* 3. Mobile Container Frame */
#appContainer {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 460px; /* Centered mobile container on desktop */
  background: var(--color-bg);
  border: var(--panel-border-width) solid var(--color-border);
  box-shadow: var(--panel-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border 0.8s ease, box-shadow 0.8s ease;
}

@media (min-width: 480px) {
  #appContainer {
    height: 92%;
    border-radius: var(--panel-radius);
  }
}

/* Grid overlay background effect for Sci-Fi atmosphere */
#gridOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-image: linear-gradient(var(--grid-line-color) 1px, transparent 1px),
                    linear-gradient(90deg, var(--grid-line-color) 1px, transparent 1px);
  background-size: 20px 20px;
  z-index: 1;
}

/* 4. Dashboard Header Block */
header {
  position: relative;
  z-index: 2;
  background: var(--header-bg);
  border-bottom: var(--panel-border-width) solid var(--color-border);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background 0.8s ease, border-bottom 0.8s ease;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.day-badge {
  font-family: var(--font-display);
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-border);
  padding: 4px 8px;
  border-radius: var(--panel-radius);
  color: var(--color-text-bright);
  font-weight: 800;
}

.header-stats {
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: var(--panel-radius);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--color-text-bright);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.stat-val {
  font-family: var(--font-display);
  font-size: 1.0rem;
  color: var(--color-text-bright);
  font-weight: 800;
}

.highlight-gold {
  color: #fbbf24 !important;
}

/* 5. Main Tab Content Area */
main {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

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

/* Standard Panel Cards */
.panel-card {
  background: var(--color-panel);
  border: var(--panel-border-width) solid var(--color-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-glow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.8s ease, border 0.8s ease, border-radius 0.8s ease, box-shadow 0.8s ease;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

/* 6. Market Trading Tab */
.market-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.market-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
  border-radius: var(--panel-radius);
  transition: border-radius 0.8s ease;
}

.item-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-icon {
  font-size: 1.4rem;
}

.item-meta {
  display: flex;
  flex-direction: column;
}

.item-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-bright);
}

.item-qty {
  font-size: 0.85rem;
  color: var(--color-text-bright);
  margin-top: 3px;
}

.item-pricing {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.item-price {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.trade-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.btn-trade {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border);
  color: var(--color-text-bright);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--panel-radius);
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.2s, border 0.8s, border-radius 0.8s;
}

.btn-trade:active {
  background: rgba(var(--color-accent-rgb), 0.2);
}

.btn-trade:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* 7. Navigation Warp Gates Tab */
.navigation-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 12px;
  border-radius: var(--panel-radius);
  font-size: 1.0rem;
  color: var(--color-text-bright);
}

.warp-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.btn-warp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-panel);
  border: var(--panel-border-width) solid var(--color-border);
  border-radius: var(--panel-radius);
  padding: 14px;
  color: var(--color-text-bright);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.8s, border 0.8s, border-radius 0.8s;
}

.btn-warp:active {
  transform: scale(0.97);
  background: rgba(var(--color-accent-rgb), 0.12);
}

.gate-sector {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-accent);
}

.gate-info {
  font-size: 0.95rem;
  color: var(--color-text-bright);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 8. Shipyard & Upgrades Tab */
.upgrade-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: var(--panel-radius);
}

.upgrade-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 60%;
}

.upgrade-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-bright);
}

.upgrade-desc {
  font-size: 0.8rem;
  color: var(--color-text-bright);
  line-height: 1.3;
}

.upgrade-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.upgrade-cost {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fbbf24;
}

/* 9. Accessible Monospace Logs (Braille console) */
#brailleConsole {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000000;
  color: #00ff66; /* Retro green phosphor */
  font-family: 'Share Tech Mono', monospace;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 4px solid #005500;
}

#brailleConsole.hidden {
  display: none;
}

#brailleConsole h2 {
  font-size: 1.3rem;
  border-bottom: 2px solid #005500;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

#brailleConsole .hud-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  background: #051505;
  padding: 6px 10px;
  border: 1px solid #005500;
  margin-bottom: 12px;
}

#brailleLog {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #005500;
  background: #020802;
  padding: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 12px;
}

#brailleConsole footer {
  font-size: 0.8rem;
  color: #00aa44;
  border-top: 1px solid #005500;
  padding-top: 8px;
}

/* 10. Floating Overlay Modals (Encounters & Decisions) */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

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

.modal-dialog {
  width: 100%;
  background: var(--color-panel);
  border: 2px solid var(--color-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-glow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.modal-icon {
  font-size: 3rem;
  animation: pulse-glow 2s infinite ease-in-out;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-accent);
  text-transform: uppercase;
}

.modal-text {
  font-size: 1.0rem;
  line-height: 1.5;
  color: var(--color-text-bright);
}

.modal-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 11. Custom Button UI */
.btn {
  background: linear-gradient(135deg, var(--color-border), #0f172a);
  border: var(--panel-border-width) solid var(--color-border);
  border-radius: var(--panel-radius);
  color: var(--color-text-bright);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px 20px;
  width: 100%;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 0.1s, box-shadow 0.8s, border 0.8s, border-radius 0.8s;
}

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

.btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  background: #1e293b;
  border-color: #334155;
  text-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent), #4b1450);
  border-color: var(--color-accent);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #450a0a);
  border-color: #ef4444;
}

/* 12. Bottom Tab Bar Navigation */
nav {
  position: relative;
  z-index: 2;
  background: var(--header-bg);
  border-top: var(--panel-border-width) solid var(--color-border);
  display: flex;
  width: 100%;
  height: 58px;
  transition: background 0.8s ease, border-top 0.8s ease;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  color: var(--color-text);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color 0.3s;
}

.nav-tab.active {
  color: var(--color-accent);
  background: rgba(255, 255, 255, 0.02);
}

.nav-tab-icon {
  font-size: 1.15rem;
}

.nav-tab-lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.05em;
}

/* 13. Subtitles Overlay */
#subtitlesContainer {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--color-border);
  padding: 6px 14px;
  border-radius: 20px;
  max-width: 90%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, border 0.8s;
}

#subtitlesContainer.active {
  opacity: 1;
}

#subtitleText {
  color: #ffffff;
  font-size: 1.05rem;
  text-align: center;
  font-weight: 700;
}

/* 14. Keyframe Animations */
@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.85;
    transform: scale(1);
    filter: drop-shadow(0 0 5px var(--color-accent));
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
    filter: drop-shadow(0 0 20px var(--color-accent));
  }
}

/* 15. Custom Accessibility Checkboxes */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  background-color: var(--color-danger); /* Red when unchecked */
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

input[type="checkbox"]:checked {
  background-color: var(--color-success); /* Green when checked */
}

input[type="checkbox"]::after {
  content: "✖";
  font-size: 0.85rem;
  color: #ffffff;
  font-weight: 700;
}

input[type="checkbox"]:checked::after {
  content: "✔";
  font-size: 0.9rem;
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* 16. High-Contrast Text Outline for Astigmatism/Nearsightedness */
h1, h2, h3, h4, h5, p, label, b, strong, button, input,
.game-title, .day-badge, .stat-lbl, .stat-val, .panel-title,
.item-name, .item-qty, .item-price, .btn-trade, .navigation-info,
.gate-sector, .gate-info, .upgrade-name, .upgrade-desc, .upgrade-cost,
.btn, .nav-tab-lbl, #subtitleText, input::after {
  text-shadow: 
    -1px -1px 0 #000000,  
     1px -1px 0 #000000,
    -1px  1px 0 #000000,
     1px  1px 0 #000000,
     0px    2px   4px rgba(0, 0, 0, 0.95);
}

/* 17. Dynamic Event Banner & Contracts Styles */
.event-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--color-danger, #ef4444);
  padding: 10px 14px;
  border-radius: var(--panel-radius, 8px);
  margin-bottom: 12px;
  box-shadow: var(--panel-glow);
  animation: pulse-glow 2s infinite ease-in-out;
}
.event-banner.hidden {
  display: none !important;
}
.banner-icon {
  font-size: 1.5rem;
}
.banner-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.banner-title {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--color-danger, #ef4444);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 1px;
}
.banner-text {
  font-size: 0.8rem;
  color: var(--color-text-bright, #cbd5e1);
}

.contract-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 12px;
  border-radius: var(--panel-radius);
}

.contract-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

.contract-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-accent);
}

.contract-desc {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--color-text-bright);
}

.contract-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.contract-reward {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fbbf24;
}


