/* CSS Variables - Dark Sci-Fi Neon Palette */
:root {
  --bg-color: #070a10;
  --bg-secondary: #0d131f;
  --card-bg: #121a2a;
  --card-border: rgba(0, 243, 255, 0.15);
  --card-hover-border: rgba(0, 243, 255, 0.4);
  
  --primary-cyan: #00f3ff;
  --primary-cyan-glow: rgba(0, 243, 255, 0.3);
  --green-energy: #00ff88;
  --green-glow: rgba(0, 255, 136, 0.3);
  --purple-quantum: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.35);
  --dark-matter-gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.35);
  --danger-red: #f43f5e;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --nav-height: 65px;
  --header-height: 110px;
  --border-radius: 12px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Solar Gold Theme */
[data-theme="gold"] {
  --bg-color: #0b0904;
  --bg-secondary: #141006;
  --card-bg: #1c160b;
  --card-border: rgba(251, 191, 36, 0.2);
  --card-hover-border: rgba(251, 191, 36, 0.45);
  --primary-cyan: #fbbf24;
  --primary-cyan-glow: rgba(251, 191, 36, 0.35);
}

/* Deep Space OLED Theme */
[data-theme="oled"] {
  --bg-color: #000000;
  --bg-secondary: #050505;
  --card-bg: #0d0d0d;
  --card-border: rgba(255, 255, 255, 0.15);
  --card-hover-border: rgba(0, 243, 255, 0.4);
}

/* Quantum Violet Theme */
[data-theme="violet"] {
  --bg-color: #090511;
  --bg-secondary: #120b20;
  --card-bg: #1b1030;
  --card-border: rgba(168, 85, 247, 0.2);
  --card-hover-border: rgba(168, 85, 247, 0.45);
  --primary-cyan: #c084fc;
  --primary-cyan-glow: rgba(192, 132, 252, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  touch-action: manipulation;
}

html, body {
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* App Container */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  background: radial-gradient(circle at 50% 0%, #111a2e 0%, var(--bg-color) 70%);
  overflow: hidden;
}

/* Top Resource Bar (2-Row Multidimensional Layout) */
header.resource-bar {
  flex-shrink: 0;
  background: rgba(13, 19, 31, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 100;
  box-sizing: border-box;
  gap: 6px;
}

.resource-row-primary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.energy-display {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-shrink: 0;
}

.energy-amount {
  font-size: clamp(1.15rem, 4.4vw, 1.65rem);
  font-weight: 800;
  color: var(--primary-cyan);
  text-shadow: 0 0 12px var(--primary-cyan-glow);
  line-height: 1.1;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.energy-rate {
  font-size: 0.76rem;
  color: var(--green-energy);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 1px;
  white-space: nowrap;
}

.battery-compact-box {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  max-width: 260px;
}

.battery-compact-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
}

.battery-label-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.battery-upgrade-btn {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.18), rgba(0, 255, 136, 0.18));
  border: 1px solid var(--primary-cyan);
  color: var(--primary-cyan);
  font-weight: 700;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.2s ease;
  box-shadow: 0 0 6px rgba(0, 243, 255, 0.2);
  font-family: inherit;
  white-space: nowrap;
}

.battery-upgrade-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.35), rgba(0, 255, 136, 0.35));
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
  color: #ffffff;
}

.battery-upgrade-btn:disabled {
  opacity: 0.45;
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
  cursor: not-allowed;
}

.battery-upgrade-btn.affordable-pulse {
  animation: battPulse 1.8s infinite alternate;
}

@keyframes battPulse {
  0% { box-shadow: 0 0 4px rgba(0, 243, 255, 0.3); }
  100% { box-shadow: 0 0 12px rgba(0, 243, 255, 0.75); border-color: #00ff88; }
}

.battery-track {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 243, 255, 0.15);
  position: relative;
}

.battery-fill {
  height: 100%;
  background: linear-gradient(90deg, #00f3ff, #00ff88);
  width: 0%;
  border-radius: 10px;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px var(--primary-cyan-glow);
}

.battery-fill.full {
  background: linear-gradient(90deg, #f43f5e, #fbbf24);
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.6);
}

.resource-row-secondary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 4px;
}

.res-chips-scrollable {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 1px;
}

.res-chips-scrollable::-webkit-scrollbar {
  display: none;
}

.res-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 2px 7px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: clamp(0.66rem, 2.4vw, 0.74rem);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.res-chip.rp {
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.res-chip.plasma {
  border-color: rgba(192, 132, 252, 0.35);
  color: #c084fc;
  background: rgba(192, 132, 252, 0.08);
}

.res-chip.dust {
  border-color: rgba(52, 211, 153, 0.35);
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
}

.res-chip.dm {
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--dark-matter-gold);
  background: rgba(251, 191, 36, 0.08);
}

.header-action-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.header-action-btn {
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.header-action-btn.stats {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid var(--purple-quantum);
  color: var(--purple-quantum);
}

.header-action-btn.guide {
  background: rgba(0, 243, 255, 0.15);
  border: 1px solid var(--primary-cyan);
  color: var(--primary-cyan);
}

.header-action-btn:hover {
  transform: scale(1.05);
}

/* Main Content Area */
main.content-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
  scroll-behavior: smooth;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bottom Navigation Bar */
nav.tab-bar {
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(13, 19, 31, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
  flex: 1;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.tab-icon-wrapper {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.tab-btn .tab-icon {
  font-size: 1.3rem;
  transition: transform var(--transition-fast);
}

.tab-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  width: 8px;
  height: 8px;
  background: var(--primary-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary-cyan-glow);
  display: none;
  pointer-events: none;
}

.tab-badge.active {
  display: block;
  animation: badgePulse 1.2s infinite alternate ease-in-out;
}

.tab-badge.count {
  width: auto;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 7px;
  font-size: 0.6rem;
  font-weight: 800;
  color: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  top: -4px;
  right: -10px;
}

.tab-badge.green {
  background: var(--green-energy);
  box-shadow: 0 0 8px var(--green-glow);
}

.tab-badge.purple {
  background: var(--purple-quantum);
  box-shadow: 0 0 8px var(--purple-glow);
}

.tab-badge.gold {
  background: var(--dark-matter-gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

@keyframes badgePulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.25); opacity: 1; }
}

.tab-btn.active {
  color: var(--primary-cyan);
}

.tab-btn.active .tab-icon {
  transform: translateY(-2px) scale(1.15);
  filter: drop-shadow(0 0 6px var(--primary-cyan-glow));
}

.tab-btn:active {
  transform: scale(0.92);
}

/* Utilities */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sub-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
