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

html, body, #app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.screen { position: absolute; inset: 0; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* =================================================================== */
/* MAIN MENU                                                            */
/* =================================================================== */
#menu {
  position: absolute; inset: 0;
  overflow: hidden;
}
.menu-bg {
  position: absolute; inset: 0;
  background-image: url("images/menu-bg.png");
  background-size: cover;
  background-position: center right;
  background-repeat: no-repeat;
}
.menu-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(
    to right,
    rgba(0,0,0,0.75) 0%,
    rgba(0,0,0,0.30) 50%,
    rgba(0,0,0,0.0) 100%
  );
}

.gear-menu {
  position: absolute; top: 24px; left: 24px;
  width: 50px; height: 50px;
  background: rgba(15, 20, 35, 0.85);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #fff; font-size: 22px; cursor: pointer;
  z-index: 10;
}

.menu-content {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  z-index: 5;
}

.menu-title {
  text-align: center;
  margin-bottom: 36px;
}
.title-mars {
  font-size: 92px;
  font-weight: 900;
  letter-spacing: 10px;
  line-height: 0.95;
  color: #fff;
  text-shadow: 0 4px 30px rgba(255, 122, 48, 0.3);
}
.title-pioneer {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 10px;
  color: #ff7a30;
  text-shadow: 0 2px 18px rgba(255, 122, 48, 0.4);
  margin-top: -6px;
}
.title-sub {
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: 5px;
  color: rgba(255,255,255,0.7);
}

.menu-buttons {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 320px;
}
.menu-btn {
  position: relative;
  display: flex; align-items: center;
  gap: 14px;
  background: rgba(20, 28, 45, 0.92);
  border: 1.5px solid rgba(78, 161, 255, 0.45);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 16px 28px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 56px;
  transition: all 0.15s ease;
  backdrop-filter: blur(6px);
}
.menu-btn:hover {
  background: rgba(40, 60, 100, 0.95);
  border-color: rgba(78, 161, 255, 0.85);
  transform: translateX(4px);
}
.menu-btn .btn-icon {
  width: 28px; text-align: center; font-size: 18px;
  color: #4ea1ff;
}
.menu-btn.primary {
  background: linear-gradient(180deg, #34b04b 0%, #2ea043 100%);
  border-color: #2ea043;
}
.menu-btn.primary .btn-icon { color: #fff; }
.menu-btn.primary:hover { background: linear-gradient(180deg, #3cc053 0%, #36b552 100%); }

/* Status + log cards */
.status-card, .log-card {
  position: absolute;
  bottom: 24px;
  background: rgba(8, 12, 22, 0.92);
  border: 1px solid rgba(78, 161, 255, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 280px;
  z-index: 5;
  backdrop-filter: blur(8px);
  font-family: "SF Mono", Menlo, monospace;
}
.status-card { left: 24px; }
.log-card    { right: 24px; }
.card-title {
  font-size: 11px;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.55);
  margin-bottom: 8px;
}
.card-row {
  font-size: 14px;
  color: #fff;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
  line-height: 1.5;
}
.card-row.dim { color: rgba(255,255,255,0.5); font-size: 12px; }
.card-row .dot {
  width: 8px; height: 8px;
  background: #2ea043;
  border-radius: 50%;
  box-shadow: 0 0 8px #2ea043;
}
.card-row .speaker { color: #4ea1ff; font-weight: 700; }

#pilot-name {
  margin-top: 8px;
  background: #0e0e14; border: 1px solid #333; color: #fff;
  font-size: 13px; padding: 8px 10px; border-radius: 6px; outline: none;
  font-family: inherit;
  width: 100%;
}
#pilot-name:focus { border-color: #ff8a5b; }
#pilot-display { color: #fff; }

/* =================================================================== */
/* GAME SCENE                                                           */
/* =================================================================== */
#game { background: #000; }
#three-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* Angular cockpit frame overlay — drawn over the canvas */
#cockpit-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}
body.cam-chase #cockpit-frame,
body.cam-far #cockpit-frame,
body.cam-stagecam #cockpit-frame { display: none; }
/* In external cameras the dashboard fades slightly so the rocket is the star */
body.cam-chase .systems-panel,
body.cam-far .systems-panel,
body.cam-stagecam .systems-panel { opacity: 0.75; }

/* HUD */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.hud-box {
  position: absolute;
  background: rgba(8, 8, 14, 0.85);
  border: 1.5px solid rgba(255,255,255,0.12);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-family: "SF Mono", Menlo, monospace;
}
.hud-box .label { opacity: 0.5; margin-right: 6px; }
.top-left { top: 16px; left: 84px; }
.top-right { top: 16px; right: 20px; }

.gear {
  position: absolute; top: 16px; left: 16px;
  width: 56px; height: 56px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(8, 8, 14, 0.85);
  color: #fff; font-size: 22px; cursor: pointer;
  z-index: 11;
}

/* Checklist — dark themed */
.checklist {
  position: absolute;
  top: 60px;
  right: 20px;
  background: rgba(8, 8, 14, 0.92);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 16px 22px;
  width: 270px;
  z-index: 20;
  font-family: "SF Mono", Menlo, monospace;
  backdrop-filter: blur(6px);
}
.checklist h3 {
  font-size: 13px;
  letter-spacing: 2px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 10px; margin-bottom: 10px;
  color: rgba(255,255,255,0.75);
}
.checklist ul { list-style: none; }
.checklist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  min-height: 36px;
  color: rgba(255,255,255,0.85);
  transition: background 0.12s;
}
.checklist-item:hover { background: rgba(255,255,255,0.05); }
.checklist-item .num { color: rgba(255,255,255,0.5); min-width: 18px; }
.checklist-item .tick { margin-left: auto; color: #2ea043; opacity: 0; font-weight: 700; font-size: 18px; }
.checklist-item.done .tick { opacity: 1; }
.checklist-item.done { color: #fff; }

/* =================================================================== */
/* DASHBOARD (bottom panel, matches reference)                          */
/* =================================================================== */
.dashboard {
  position: absolute;
  left: 0; right: 0; bottom: 56px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(8, 8, 14, 0.92);
  border-top: 1.5px solid rgba(255,255,255,0.12);
  z-index: 20;
  backdrop-filter: blur(8px);
}
body.cam-chase .dashboard,
body.cam-far .dashboard { opacity: 0.85; }

.dash-btn-wrap { display: flex; align-items: stretch; }
.dash-col {
  display: flex; flex-direction: column;
  gap: 8px;
  align-items: stretch;
  justify-content: center;
}

/* ---- SYSTEMS panel (left) ---- */
.systems-panel {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: "SF Mono", Menlo, monospace;
  min-width: 170px;
  display: flex; flex-direction: column;
  justify-content: center;
}
.systems-title {
  font-size: 12px; letter-spacing: 2px;
  color: rgba(255,255,255,0.6);
  text-align: center;
  margin-bottom: 6px;
}
.systems-row {
  display: flex; justify-content: space-between;
  font-size: 13px;
  padding: 2px 0;
  color: #2ea043;
}
.systems-row .sys-name  { color: #2ea043; }
.systems-row .sys-state { color: #2ea043; font-weight: 700; }
.systems-row.warn .sys-state { color: #ff7a30; }
.systems-row.fail .sys-state { color: #ff3a3a; }

/* ---- Big dashboard buttons ---- */
.dash-btn-big {
  background: rgba(20, 22, 32, 0.95);
  border: 1.5px solid rgba(255,255,255,0.22);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  min-width: 110px;
  min-height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 12px 18px;
  transition: all 0.12s ease;
  font-family: inherit;
}
.dash-btn-big:hover  { background: rgba(40, 44, 60, 0.95); transform: translateY(-1px); }
.dash-btn-big:active { transform: scale(0.97); }

/* Disabled = visible but greyed out and non-interactive */
.dash-btn-big.disabled,
.dash-btn-big:disabled {
  background: rgba(30, 30, 38, 0.7) !important;
  border-color: rgba(255,255,255,0.12) !important;
  opacity: 0.45;
  cursor: not-allowed;
  animation: none !important;
  transform: none !important;
  box-shadow: none !important;
}
.dash-btn-big.disabled:hover,
.dash-btn-big:disabled:hover { background: rgba(30, 30, 38, 0.7) !important; transform: none; }
.dash-btn-big.disabled .big-label,
.dash-btn-big:disabled .big-label { color: rgba(255,255,255,0.6); }
.dash-btn-big .big-label {
  font-size: 15px; font-weight: 800; letter-spacing: 2px; color: #fff;
}
.dash-btn-big .big-icon { font-size: 26px; line-height: 1; }

.dash-btn-big.engines {
  background: linear-gradient(180deg, #34b04b 0%, #2ea043 100%);
  border-color: #2ea043;
}
.dash-btn-big.engines:hover { background: linear-gradient(180deg, #3cc053 0%, #36b552 100%); }

.dash-btn-big.stage {
  background: linear-gradient(180deg, #ff8a3a 0%, #ff7a30 100%);
  border-color: #ff7a30;
  animation: pulseOrange 1.2s ease-in-out infinite;
  min-height: 56px;
}
.dash-btn-big.view {
  background: linear-gradient(180deg, #5db1ff 0%, #4ea1ff 100%);
  border-color: #4ea1ff;
  min-height: 56px;
}
.dash-btn-big.launch {
  background: linear-gradient(180deg, #34b04b 0%, #2ea043 100%);
  border-color: #2ea043;
  min-width: 150px;
  min-height: 84px;
}
.dash-btn-big.launch .big-label { font-size: 22px; }
.dash-btn-big.launch:hover { background: linear-gradient(180deg, #3cc053 0%, #36b552 100%); }

/* ---- Vertical throttle with ticks ---- */
.throttle-block {
  display: flex; flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
}
.throttle-v {
  position: relative;
  width: 38px; height: 130px;
  background: rgba(0,0,0,0.6);
  border: 1.5px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
}
.throttle-v-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(to top, #2ea043, #6ad08a);
  border-radius: 6px;
  transition: height 0.08s linear;
}
.throttle-v-handle {
  position: absolute;
  left: -6px; right: -6px;
  height: 14px;
  background: #fff;
  border-radius: 3px;
  bottom: -7px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  pointer-events: none;
}
.throttle-ticks {
  position: absolute;
  top: -6px; bottom: -6px;
  left: 48px;
  display: flex; flex-direction: column;
  justify-content: space-between;
  font-size: 10px;
  font-family: "SF Mono", Menlo, monospace;
  color: rgba(255,255,255,0.6);
  pointer-events: none;
  white-space: nowrap;
}
.dash-btn {
  background: rgba(20, 22, 32, 0.95);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.18);
  padding: 16px 22px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 60px;
  min-width: 96px;
  transition: all 0.12s ease;
  font-family: inherit;
}
.dash-btn:hover { background: rgba(40, 44, 60, 0.95); border-color: rgba(255,255,255,0.35); }
.dash-btn:active { transform: scale(0.97); }
.dash-btn.stage {
  background: #ff7a30;
  border-color: #ff7a30;
  color: #fff;
  animation: pulseOrange 1.2s ease-in-out infinite;
}
@keyframes pulseOrange {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 48, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255, 122, 48, 0); }
}
.dash-btn.launch {
  background: #2ea043;
  border-color: #2ea043;
  color: #fff;
  min-width: 130px;
  font-size: 16px;
}
.dash-btn.launch:hover { background: #36b552; border-color: #36b552; }

/* Throttle */
.throttle-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.throttle-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.6);
  font-family: "SF Mono", Menlo, monospace;
}
.throttle-h-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.throttle-end {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-family: "SF Mono", Menlo, monospace;
  min-width: 32px;
  text-align: center;
}
.throttle-h {
  flex: 1;
  position: relative;
  height: 14px;
  background: #0e0e14;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  cursor: pointer;
  touch-action: none;
}
.throttle-h-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(to right, #2ea043, #6ad08a);
  border-radius: 7px;
  transition: width 0.08s linear;
}
.throttle-h-handle {
  position: absolute;
  top: -5px;
  width: 18px; height: 24px;
  background: #fff;
  border-radius: 3px;
  left: 0%;
  transform: translateX(-50%);
  box-shadow: 0 1px 5px rgba(0,0,0,0.6);
  pointer-events: none;
}
.throttle-readout {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  font-family: "SF Mono", Menlo, monospace;
  margin-top: 2px;
}

/* =================================================================== */
/* COUNTDOWN                                                            */
/* =================================================================== */
.countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 50;
}
#countdown-number {
  font-size: 220px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(255, 140, 80, 0.9), 0 0 80px rgba(255, 80, 30, 0.5);
  font-family: "SF Mono", Menlo, monospace;
  animation: countpop 0.85s ease-out;
}
@keyframes countpop {
  0%   { transform: scale(0.5); opacity: 0; }
  35%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* =================================================================== */
/* MARS RETICLE                                                         */
/* =================================================================== */
.mars-reticle {
  position: absolute;
  top: 45%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  text-align: center;
  z-index: 30;
}
.reticle-ring {
  width: 120px; height: 120px;
  border: 3px solid #ff9a5b;
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(255, 154, 91, 0.5), inset 0 0 30px rgba(255, 154, 91, 0.2);
  margin: 0 auto;
  animation: reticle-spin 6s linear infinite;
}
@keyframes reticle-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.reticle-label {
  margin-top: 10px;
  font-size: 12px; letter-spacing: 3px;
  color: #ff9a5b;
  font-family: "SF Mono", Menlo, monospace;
}
.alignment-bar {
  margin-top: 8px;
  width: 200px; height: 8px;
  background: rgba(0,0,0,0.7);
  border: 1px solid #ff9a5b;
  border-radius: 4px;
  overflow: hidden;
  margin-left: auto; margin-right: auto;
}
#mars-bar {
  height: 100%; width: 0%;
  background: linear-gradient(to right, #ff7a30, #ffb070);
  transition: width 0.1s linear;
}

/* =================================================================== */
/* DIALOGUE — top of screen so the dashboard is never blocked           */
/* =================================================================== */
.dialogue {
  position: absolute;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 40;
  width: min(880px, calc(100vw - 60px));
}
.dialogue-bar {
  background: rgba(0, 0, 0, 0.85);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 15px;
  line-height: 1.4;
  backdrop-filter: blur(4px);
}
.dialogue-bar .speaker {
  color: #4ea1ff; font-weight: 700; margin-right: 8px; letter-spacing: 1px;
}
.choices { display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.choice-btn {
  background: rgba(20, 30, 50, 0.92);
  border: 1.5px solid #3a5a8a;
  color: #fff;
  font-size: 15px;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
  min-height: 44px;
  font-family: inherit;
}
.choice-btn:hover { background: rgba(40, 60, 100, 0.95); }
.choice-btn:active { background: rgba(60, 90, 140, 0.95); transform: scale(0.98); }
.choice-btn .num { color: #4ea1ff; font-weight: 700; margin-right: 8px; }

/* Dialogue with choices stays anchored to the top — choices stack below */

/* =================================================================== */
/* OVERLAY (settings, credits)                                          */
/* =================================================================== */
.overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.overlay-card {
  background: #15151c;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 28px;
  min-width: 320px;
  max-width: 90vw;
  display: flex; flex-direction: column; gap: 14px;
}
.overlay-card h2 { font-size: 20px; }
.overlay-card label { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.overlay-card button {
  padding: 12px 16px;
  background: #2ea043;
  border: none; border-radius: 6px;
  color: #fff; cursor: pointer; font-weight: 600;
  min-height: 44px;
  font-family: inherit;
}
#btn-clear-cache { background: #444; }
#btn-clear-cache:hover { background: #555; }

/* =================================================================== */
/* RESPONSIVE                                                           */
/* =================================================================== */
@media (max-width: 900px) {
  .title-mars { font-size: 64px; letter-spacing: 6px; }
  .title-pioneer { font-size: 42px; letter-spacing: 6px; }
  .menu-buttons { min-width: 280px; }
  .menu-btn { font-size: 15px; padding: 14px 22px; min-height: 50px; }
  .status-card, .log-card { min-width: 220px; padding: 12px 14px; }
  .dashboard { padding: 10px 12px; gap: 10px; bottom: 60px; }
  .dash-btn { padding: 12px 14px; min-width: 80px; font-size: 12px; min-height: 50px; }
  .dash-btn.launch { min-width: 100px; font-size: 14px; }
  #countdown-number { font-size: 140px; }
  .checklist { width: 220px; font-size: 13px; padding: 12px 14px; }
  .top-left { left: 78px; font-size: 13px; }
  .top-right { right: 14px; font-size: 13px; }
}

@media (max-width: 600px) {
  .status-card, .log-card { display: none; }
  .dashboard { flex-wrap: wrap; }
}
