* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e0e0ff;
}

#renderCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  outline: none;
}

/* Screens */
.screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 0;
}
.screen.active { display: flex; }

.screen-content {
  background: rgba(10, 10, 40, 0.92);
  border: 2px solid rgba(100, 180, 255, 0.3);
  border-radius: 20px;
  padding: 30px 36px;
  text-align: center;
  max-width: 600px;
  width: 90%;
  margin: auto;
  animation: fadeIn 0.4s ease;
  flex-shrink: 0;
}

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

/* Menu */
.game-title {
  font-size: 3rem;
  background: linear-gradient(135deg, #00d4ff, #ff6b35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.subtitle { color: #8899bb; margin-bottom: 30px; font-size: 1.1rem; }
.menu-form { display: flex; flex-direction: column; gap: 16px; }
.welcome-back { margin-bottom: 8px; }
.welcome-text { color: #8899bb; font-size: 1.1rem; margin-bottom: 4px; }
.welcome-name {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ff6b35;
  background: linear-gradient(135deg, #ff6b35, #ffd166);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.menu-form label { font-size: 1.1rem; color: #aabbdd; }
.menu-form input {
  padding: 12px 16px;
  font-size: 1.2rem;
  border-radius: 10px;
  border: 2px solid rgba(100, 180, 255, 0.3);
  background: rgba(20, 20, 60, 0.8);
  color: #e0e0ff;
  text-align: center;
  outline: none;
}
.menu-form input:focus { border-color: #00d4ff; }

/* Buttons */
.btn {
  padding: 14px 32px;
  font-size: 1.3rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: scale(1.05); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  color: white;
  box-shadow: 0 4px 20px rgba(0, 180, 216, 0.3);
}
.btn-secondary {
  background: transparent;
  color: #8899bb;
  border: 2px solid rgba(100, 140, 180, 0.3);
  font-size: 1rem;
  padding: 10px 24px;
}
.btn-secondary:hover {
  border-color: rgba(100, 180, 255, 0.5);
  color: #aabbdd;
}
.btn-choice {
  padding: 10px 20px;
  font-size: 1rem;
  background: rgba(30, 30, 80, 0.9);
  color: #c0d0ff;
  border: 2px solid rgba(100, 180, 255, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
  text-align: left;
}
.btn-choice:hover { border-color: #00d4ff; background: rgba(0, 100, 180, 0.3); }
.btn-choice.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(100, 100, 100, 0.3);
}
.btn-choice.disabled:hover { background: rgba(30, 30, 80, 0.9); border-color: rgba(100, 100, 100, 0.3); }
.btn-action {
  padding: 12px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  background: rgba(30, 30, 80, 0.9);
  color: #c0d0ff;
  border: 2px solid rgba(100, 180, 255, 0.4);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-action:hover { border-color: #00d4ff; background: rgba(0, 80, 160, 0.4); }

/* Selection Screens */
.select-content { max-width: 720px; width: 95%; padding: 24px 28px; }
.select-content h2 { margin-bottom: 16px; color: #00d4ff; }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.selection-summary {
  background: rgba(20, 30, 60, 0.6);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: left;
}
.summary-label { font-size: 0.8rem; color: #8899bb; text-transform: uppercase; }
.summary-value { font-size: 1.2rem; font-weight: 700; color: #ff6b35; margin-bottom: 4px; }
.summary-meta { font-size: 0.85rem; color: #aabbcc; }
.meta-sep { margin: 0 8px; opacity: 0.5; }

.screen-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Loadout (legacy) */
.loadout-content h2 { margin-bottom: 14px; color: #00d4ff; }
.loadout-content { max-width: 720px; width: 95%; padding: 24px 28px; }
.ship-card {
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 10px;
}
.ship-card h3 { color: #ff6b35; margin-bottom: 8px; }
.ship-stats { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.ship-stat { background: rgba(0,0,0,0.3); padding: 4px 10px; border-radius: 8px; font-size: 0.85rem; }
.ship-passive { color: #77dd77; font-style: italic; margin-top: 6px; font-size: 0.85rem; }
.parts-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.part-slot {
  background: rgba(20, 30, 60, 0.8);
  border: 1px solid rgba(100, 180, 255, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
}
.part-slot .part-type { font-size: 0.75rem; color: #8899bb; text-transform: uppercase; }
.part-slot .part-name { font-weight: 700; color: #00d4ff; font-size: 0.9rem; }
.part-slot .part-desc { font-size: 0.8rem; color: #aabbcc; }

/* Ship & Mission Picker */
.ship-picker, .mission-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.pick-card {
  background: rgba(20, 30, 60, 0.8);
  border: 2px solid rgba(100, 180, 255, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  text-align: left;
}
.pick-card:hover { border-color: #00d4ff; background: rgba(0, 80, 160, 0.25); }
.pick-card.selected {
  border-color: #ff6b35;
  background: rgba(255, 107, 53, 0.12);
  box-shadow: 0 0 12px rgba(255, 107, 53, 0.3);
}
.pick-card h3 { color: #00d4ff; font-size: 1rem; margin-bottom: 6px; }
.pick-card.selected h3 { color: #ff6b35; }
.pick-card .pick-desc { font-size: 0.85rem; color: #aabbcc; margin-bottom: 8px; line-height: 1.4; }
.pick-card .pick-meta { font-size: 0.85rem; color: #8899bb; }

/* Locked cards */
.pick-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: rgba(80, 80, 80, 0.3);
  background: rgba(15, 15, 30, 0.6);
}
.pick-card.locked:hover {
  border-color: rgba(80, 80, 80, 0.3);
  background: rgba(15, 15, 30, 0.6);
  transform: none;
}
.pick-card.locked h3 { color: #666; }

/* HUD */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
  z-index: 20;
}
.hud-pilot { font-weight: 700; font-size: 1.1rem; color: #ff6b35; }
.hud-resources { display: flex; gap: 18px; }
.hud-res {
  display: flex; align-items: center; gap: 4px;
  font-size: 1.05rem; font-weight: 600;
}
#hud-hull { color: #ff6b6b; }
#hud-fuel { color: #ffd166; }
#hud-cargo { color: #64b5f6; }
#hud-credits { color: #81c784; }
#hud-shield { color: #4dd0e1; }

.hud-flash { animation: flashRes 0.5s ease; }
@keyframes flashRes {
  0% { transform: scale(1); }
  30% { transform: scale(1.4); color: white; }
  100% { transform: scale(1); }
}

/* Environment progress */
.env-progress {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 12px;
  z-index: 20;
}
.env-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.3);
  transition: all 0.3s;
}
.env-dot.active { background: #00d4ff; border-color: #00d4ff; box-shadow: 0 0 10px #00d4ff; }
.env-dot.done { background: #81c784; border-color: #81c784; }
.env-dot.star { border-radius: 3px; transform: rotate(45deg); }
.env-dot.star.active { background: #ffd166; border-color: #ffd166; box-shadow: 0 0 10px #ffd166; }

/* Overlays */
.overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  animation: fadeIn 0.3s ease;
}
.hidden { display: none !important; }

/* Environment transition */
.env-transition {
  background: rgba(5, 5, 20, 0.9);
}
.env-transition h2 { font-size: 2.2rem; color: #00d4ff; margin-bottom: 10px; }
.env-transition p { color: #8899bb; font-size: 1.1rem; }

/* Encounter card */
.encounter-card {
  background: rgba(5, 5, 25, 0.85);
  top: auto;
  bottom: 0;
  height: 40%;
  justify-content: flex-start;
  padding-top: 16px;
}
.encounter-card h3 { color: #ff6b35; font-size: 1.3rem; margin-bottom: 8px; }
.encounter-card p { max-width: 90%; line-height: 1.5; margin-bottom: 14px; color: #c0d0ee; font-size: 0.95rem; }
#enc-choices { display: flex; flex-direction: column; gap: 8px; max-width: 90%; width: 100%; }

/* Combat UI */
.combat-ui {
  background: rgba(5, 5, 25, 0.88);
  top: auto;
  bottom: 0;
  height: 45%;
  justify-content: flex-start;
  padding-top: 12px;
}
.combat-header {
  display: flex; align-items: center; gap: 30px;
  margin-bottom: 16px;
}
.combat-player, .combat-enemy {
  background: rgba(20, 20, 60, 0.8);
  border-radius: 12px;
  padding: 16px 24px;
  min-width: 180px;
  text-align: center;
}
.combat-player { border: 2px solid #00d4ff; }
.combat-enemy { border: 2px solid #ff6b6b; }
.combat-player h4 { color: #00d4ff; }
.combat-enemy h4 { color: #ff6b6b; }
.combat-vs { font-size: 1.8rem; font-weight: 900; color: #ff6b35; }
.combat-log {
  background: rgba(0,0,0,0.4);
  border-radius: 10px;
  padding: 14px;
  max-width: 500px;
  width: 90%;
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #a0b0cc;
}
.combat-round { font-weight: 700; color: #ffd166; margin-bottom: 12px; font-size: 1.1rem; }
.combat-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Enemy intent */
.enemy-intent {
  animation: fadeIn 0.3s ease;
}

/* Outcome toast */
.outcome-toast {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 40, 0.95);
  border: 2px solid #00d4ff;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  z-index: 40;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Results */
.results-content h2 { font-size: 2rem; margin-bottom: 20px; }
.results-content .result-success { color: #81c784; }
.results-content .result-fail { color: #ff6b6b; }
#results-body { margin-bottom: 24px; line-height: 1.8; }
#results-body .stat-line { font-size: 1.05rem; color: #a0b0cc; }

/* Shop */
.shop-content { max-width: 720px; width: 95%; padding: 24px 28px; }
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.shop-card {
  background: rgba(20, 30, 60, 0.8);
  border: 2px solid rgba(100, 180, 255, 0.2);
  border-radius: 12px;
  padding: 14px;
  text-align: left;
  transition: border-color 0.2s;
}
.shop-card:hover { border-color: rgba(100, 180, 255, 0.4); }
.shop-card.maxed { border-color: rgba(129, 199, 132, 0.3); }
.shop-slot { font-size: 0.7rem; color: #8899bb; text-transform: uppercase; margin-bottom: 2px; }
.shop-name { font-weight: 700; color: #00d4ff; font-size: 0.95rem; margin-bottom: 4px; }
.shop-tier { font-size: 0.85rem; color: #c0d0ee; margin-bottom: 4px; }
.shop-next { font-size: 0.8rem; color: #81c784; margin-bottom: 8px; }
.shop-cost { color: #ffd166; }
.btn-shop-upgrade {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  background: linear-gradient(135deg, #ffd166, #ff6b35);
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  width: 100%;
}
.btn-shop-upgrade:hover { transform: scale(1.03); }
.btn-shop-upgrade.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(100, 100, 100, 0.4);
  color: #888;
}
.btn-shop-upgrade.disabled:hover { transform: none; }
.shop-maxed-badge {
  text-align: center;
  color: #81c784;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 6px 0;
}

/* Equipment Screen */
.equip-content { max-width: 1000px; width: 95%; padding: 20px 24px; }
.equip-content h2 { margin-bottom: 12px; color: #00d4ff; }

.equip-columns {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 20px;
  margin-bottom: 16px;
}
.equip-col-left, .equip-col-right {
  text-align: left;
}
.equip-col-left h4, .equip-col-right h4 {
  color: #ff6b35;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

@media (max-width: 700px) {
  .equip-columns {
    grid-template-columns: 1fr;
  }
}

.equip-ship-header {
  background: rgba(20, 30, 60, 0.6);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: left;
}
.equip-ship-header h3 { color: #ff6b35; margin-bottom: 4px; }
.equip-ship-header p { color: #8899bb; font-size: 0.9rem; margin-bottom: 8px; }
.equip-ship-slots { display: flex; gap: 8px; flex-wrap: wrap; }

.slot-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}
.slot-badge.slot-w { background: rgba(255, 107, 107, 0.2); color: #ff6b6b; border: 1px solid rgba(255, 107, 107, 0.4); }
.slot-badge.slot-u { background: rgba(100, 181, 246, 0.2); color: #64b5f6; border: 1px solid rgba(100, 181, 246, 0.4); }
.slot-badge.slot-e { background: rgba(129, 199, 132, 0.2); color: #81c784; border: 1px solid rgba(129, 199, 132, 0.4); }

.ship-slots { display: flex; gap: 8px; margin-top: 6px; justify-content: center; }
.slot-indicator { font-size: 0.85rem; color: #aabbcc; background: rgba(0,0,0,0.3); padding: 2px 8px; border-radius: 6px; }

/* Equipped slots */
.equipped-slots { }
.slot-group { margin-bottom: 12px; text-align: left; }
.slot-group h4 { color: #8899bb; font-size: 0.8rem; margin-bottom: 6px; font-weight: 600; }
.slot-items { display: flex; flex-direction: column; gap: 6px; }

.equipped-part {
  background: rgba(20, 30, 60, 0.8);
  border: 2px solid rgba(100, 180, 255, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  position: relative;
}
.equipped-part.empty {
  border-style: dashed;
  border-color: rgba(100, 180, 255, 0.2);
  background: rgba(10, 20, 40, 0.5);
}
.equipped-part .part-name { font-weight: 700; color: #00d4ff; font-size: 0.9rem; }
.equipped-part.empty .part-name { color: #667788; }
.equipped-part .part-desc { font-size: 0.8rem; color: #aabbcc; }
.equipped-part.empty .part-desc { color: #556677; }
.equipped-part .tier-label { color: #ffd166; font-size: 0.75rem; font-weight: normal; }

.btn-remove {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(255, 107, 107, 0.2);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ff6b6b;
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.btn-remove:hover { background: rgba(255, 107, 107, 0.4); }

/* Equipment filters */
.equip-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(30, 40, 70, 0.8);
  color: #8899bb;
  border: 1px solid rgba(100, 140, 180, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn:hover {
  border-color: rgba(100, 180, 255, 0.5);
  color: #aabbdd;
}
.filter-btn.active {
  background: rgba(0, 180, 216, 0.2);
  border-color: #00d4ff;
  color: #00d4ff;
}

/* Available equipment */
.available-parts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 4px;
}
.available-part {
  background: rgba(20, 30, 60, 0.8);
  border: 2px solid rgba(100, 180, 255, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.available-part:hover { border-color: #00d4ff; background: rgba(0, 80, 160, 0.25); }
.available-part.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(60, 60, 80, 0.3);
}
.available-part.disabled:hover { border-color: rgba(60, 60, 80, 0.3); background: rgba(20, 30, 60, 0.8); }

.available-part .part-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.available-part .part-name { font-weight: 700; color: #00d4ff; font-size: 0.85rem; }
.available-part .tier-label { color: #ffd166; font-size: 0.7rem; }
.available-part .part-desc { font-size: 0.75rem; color: #8899bb; line-height: 1.4; }
.available-part .part-tag {
  margin-top: 6px;
  font-size: 0.7rem;
  color: #81c784;
  background: rgba(129, 199, 132, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

/* Vendor Screen */
.vendor-content { max-width: 650px; width: 95%; padding: 24px 28px; }

.vendor-bets {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.vendor-bet-card {
  background: rgba(20, 30, 60, 0.8);
  border: 2px solid rgba(206, 147, 216, 0.3);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 150px;
  text-align: center;
}
.vendor-bet-card:hover { border-color: #ce93d8; background: rgba(100, 50, 120, 0.3); }
.vendor-bet-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: rgba(80, 80, 80, 0.3);
}
.vendor-bet-card.disabled:hover { border-color: rgba(80, 80, 80, 0.3); background: rgba(20, 30, 60, 0.8); }
.vendor-bet-name { font-weight: 700; color: #ce93d8; font-size: 1.1rem; margin-bottom: 4px; }
.vendor-bet-cost { color: #ffd166; font-size: 0.95rem; margin-bottom: 6px; }
.vendor-bet-desc { color: #8899bb; font-size: 0.85rem; }

.vendor-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.vendor-card {
  width: 140px;
  min-height: 180px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  padding: 12px;
  text-align: center;
}
.vendor-card.face-down {
  background: linear-gradient(135deg, #2a1040, #1a0830);
  border: 2px solid rgba(206, 147, 216, 0.4);
}
.vendor-card.face-down:hover {
  border-color: #ce93d8;
  transform: translateY(-8px);
  box-shadow: 0 8px 24px rgba(206, 147, 216, 0.3);
}
.vendor-card-front {
  font-size: 3rem;
  color: #ce93d8;
}
.vendor-card.revealed {
  cursor: default;
  animation: cardReveal 0.4s ease;
}
@keyframes cardReveal {
  from { transform: scaleX(0); }
  50% { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.vendor-card.revealed.positive {
  background: rgba(129, 199, 132, 0.15);
  border: 2px solid rgba(129, 199, 132, 0.5);
}
.vendor-card.revealed.negative {
  background: rgba(255, 107, 107, 0.15);
  border: 2px solid rgba(255, 107, 107, 0.5);
}
.vendor-card.revealed.mixed {
  background: rgba(255, 209, 102, 0.15);
  border: 2px solid rgba(255, 209, 102, 0.5);
}
.vendor-card.unchosen { opacity: 0.4; }
.vendor-card.chosen {
  transform: translateY(-8px);
  box-shadow: 0 8px 24px rgba(206, 147, 216, 0.3);
}
.vendor-card-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 8px;
}
.vendor-card.positive .vendor-card-name { color: #81c784; }
.vendor-card.negative .vendor-card-name { color: #ff6b6b; }
.vendor-card.mixed .vendor-card-name { color: #ffd166; }
.vendor-card-desc {
  font-size: 0.8rem;
  color: #c0d0ee;
  line-height: 1.4;
}
.vendor-continue { margin-top: 12px; }
