:root {
  --bg: #050a14;
  --surface: rgba(9, 19, 36, 0.74);
  --surface-solid: #0b1729;
  --line: rgba(150, 196, 230, 0.18);
  --line-strong: rgba(150, 196, 230, 0.36);
  --text: #eaf4ff;
  --muted: #8ba6bf;
  --accent: #5ce1e6;
  --accent-dim: rgba(92, 225, 230, 0.14);
  --warm: #ff9a52;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }

#app { position: relative; width: 100%; height: 100%; min-height: 520px; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay > * { pointer-events: auto; }

/* ---------- top HUD ---------- */
.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 32px;
  background: linear-gradient(180deg, rgba(3, 8, 18, 0.72), transparent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  position: relative;
  width: 32px; height: 32px;
  border: 1px solid var(--accent);
  transform: rotate(45deg);
  display: grid;
  place-items: center;
}
.brand-mark span { position: absolute; background: var(--accent); }
.brand-mark span:first-child { width: 14px; height: 1px; }
.brand-mark span:last-child { width: 1px; height: 14px; }
.brand-copy strong { display: block; font-size: 15px; letter-spacing: .14em; font-weight: 600; }
.brand-copy strong span { color: var(--accent); font-family: var(--mono); font-size: 12px; letter-spacing: .2em; }
.brand-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; letter-spacing: .1em; }

.mission-meta { display: flex; align-items: center; gap: 26px; }
.meta-item { display: flex; flex-direction: column; gap: 4px; }
.meta-item span { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .16em; }
.meta-item b { font-family: var(--mono); font-size: 13px; font-weight: 500; letter-spacing: .06em; }
.status {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong);
  padding: 7px 12px;
  font-size: 11px; letter-spacing: .12em;
  background: rgba(8, 18, 34, 0.5);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1.8s ease-in-out infinite; }
.status-dot.done { background: var(--warm); box-shadow: 0 0 10px var(--warm); animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- altitude ruler ---------- */
.altitude-ruler {
  position: absolute;
  left: 32px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  height: min(46vh, 340px);
}
.ruler-label, .ruler-value { font-family: var(--mono); font-size: 9px; letter-spacing: .18em; color: var(--muted); }
.ruler-value { color: var(--accent); font-size: 10px; }
.ruler-track { position: relative; flex: 1; width: 1px; background: var(--line); }
.ruler-track::before {
  content: ""; position: absolute; inset: 0 -5px;
  background: repeating-linear-gradient(180deg, var(--line-strong) 0 1px, transparent 1px 14px);
}
.ruler-fill { position: absolute; top: 0; left: 0; width: 1px; height: 0; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.ruler-marker { position: absolute; left: -4px; top: 0; width: 9px; height: 9px; border: 1px solid var(--accent); background: var(--bg); transform: translateY(-50%) rotate(45deg); }

/* ---------- telemetry panel ---------- */
.telemetry {
  position: absolute;
  top: 108px; right: 32px;
  width: 292px;
  padding: 18px 20px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.telemetry::before, .telemetry::after {
  content: ""; position: absolute; width: 9px; height: 9px; border-color: var(--accent); border-style: solid;
}
.telemetry::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.telemetry::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }
.panel-top { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.eyebrow { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--muted); }
.signal { display: flex; gap: 2px; align-items: flex-end; }
.signal i { display: block; width: 3px; background: var(--accent); opacity: .8; animation: bars 1.4s ease-in-out infinite; }
.signal i:nth-child(1) { height: 5px; animation-delay: 0s; }
.signal i:nth-child(2) { height: 8px; animation-delay: .2s; }
.signal i:nth-child(3) { height: 11px; animation-delay: .4s; }
.signal i:nth-child(4) { height: 14px; animation-delay: .6s; }
@keyframes bars { 50% { opacity: .25; } }
.phase-heading { display: flex; align-items: center; gap: 14px; margin: 18px 0 12px; }
.phase-index { font-family: var(--mono); font-size: 40px; line-height: 1; color: var(--accent); opacity: .85; }
.phase-heading h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: .06em; }
.phase-heading p { margin: 4px 0 0; font-family: var(--mono); font-size: 9px; letter-spacing: .18em; color: var(--muted); }
.phase-desc { min-height: 54px; margin: 0 0 16px; color: #b9cde0; font-size: 12px; line-height: 1.8; }
.stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.stat { padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.stat:nth-child(odd) { padding-right: 12px; border-right: 1px solid var(--line); }
.stat:nth-child(even) { padding-left: 14px; }
.stat:nth-last-child(-n+2) { border-bottom: none; }
.stat > span { display: block; font-size: 10px; color: var(--muted); letter-spacing: .08em; }
.stat > span small { font-size: 8px; opacity: .7; }
.stat strong { display: block; margin-top: 5px; font-family: var(--mono); font-size: 16px; font-weight: 500; color: #f2f9ff; white-space: nowrap; }
.stat strong em { font-size: 10px; font-style: normal; color: var(--muted); }
.panel-foot { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--muted); font-size: 9px; letter-spacing: .06em; }
.square { width: 5px; height: 5px; border: 1px solid var(--accent); }

/* ---------- bottom bar ---------- */
.bottom-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 30px 32px 18px;
  background: linear-gradient(180deg, transparent, rgba(3, 8, 18, 0.88) 46%, rgba(3, 8, 18, 0.96));
}
.phases { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.phase-chip {
  position: relative;
  text-align: left;
  padding: 9px 2px 7px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-top: 1px solid var(--line);
  transition: color .25s, border-color .25s;
}
.phase-chip::before {
  content: ""; position: absolute; top: -1px; left: 0; height: 1px; width: 0; background: var(--accent); transition: width .25s;
}
.phase-chip.active { color: var(--text); border-color: var(--line-strong); }
.phase-chip.active::before { width: 100%; }
.phase-chip .chip-row { display: flex; align-items: baseline; gap: 8px; }
.phase-chip .chip-num { font-family: var(--mono); font-size: 10px; color: var(--accent); opacity: .8; }
.phase-chip .chip-name { font-size: 12px; letter-spacing: .08em; }
.phase-chip .chip-en { margin-top: 3px; font-family: var(--mono); font-size: 8px; letter-spacing: .12em; opacity: .65; }
.phase-chip:hover { color: var(--text); }
.phase-chip:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

.controls { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  background: rgba(10, 22, 40, 0.8);
  color: var(--text);
  transition: border-color .2s, background .2s, transform .2s;
}
.icon-btn:hover { border-color: var(--accent); background: var(--accent-dim); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn.primary { background: var(--accent); border-color: var(--accent); color: #04121a; }
.icon-btn.primary:hover { background: #8af0f2; }
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
.time-readout { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; letter-spacing: .05em; }

input[type="range"] {
  flex: 1;
  min-width: 100px;
  height: 20px;
  margin: 0 6px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, var(--accent) var(--progress, 0%), var(--line-strong) var(--progress, 0%)); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px; margin-top: -4.5px;
  background: var(--bg); border: 1px solid var(--accent); transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(92, 225, 230, .6);
}
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; background: var(--bg); border: 1px solid var(--accent); border-radius: 0; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.speeds { display: flex; border: 1px solid var(--line-strong); flex: none; }
.speeds button {
  min-width: 42px; height: 34px;
  padding: 0 6px;
  border: none; border-right: 1px solid var(--line);
  background: rgba(10, 22, 40, 0.7);
  color: var(--muted);
  font-family: var(--mono); font-size: 10px;
  transition: color .2s, background .2s;
}
.speeds button:last-child { border-right: none; }
.speeds button:hover { color: var(--text); }
.speeds button[aria-pressed="true"] { background: var(--accent); color: #04121a; }
.speeds button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 980px) {
  .telemetry { top: 92px; right: 18px; width: 244px; padding: 14px 16px 12px; }
  .phase-desc { font-size: 11px; min-height: 48px; }
  .hud-top { padding: 18px; }
  .bottom-bar { padding: 24px 18px 14px; }
  .altitude-ruler { left: 16px; }
  .mission-meta { gap: 14px; }
  .meta-item:first-child { display: none; }
}

@media (max-width: 680px) {
  .hud-top { padding: 14px; }
  .brand-copy small, .status { display: none; }
  .meta-item span { font-size: 8px; }
  .meta-item b { font-size: 11px; }
  .telemetry { top: 68px; right: 12px; width: 190px; padding: 11px 12px 9px; }
  .phase-index { font-size: 30px; }
  .phase-heading { gap: 8px; margin: 12px 0 8px; }
  .phase-heading h1 { font-size: 15px; }
  .phase-desc { font-size: 10px; line-height: 1.55; min-height: 44px; margin-bottom: 10px; }
  .stat { padding: 8px 0 6px; }
  .stat strong { font-size: 12px; }
  .panel-foot { font-size: 8px; }
  .altitude-ruler { display: none; }
  .bottom-bar { padding: 20px 12px 12px; }
  .phases { gap: 5px; }
  .phase-chip .chip-en { display: none; }
  .phase-chip .chip-name { font-size: 10px; }
  .phase-chip .chip-num { font-size: 8px; }
  .controls { gap: 8px; }
  .icon-btn { width: 32px; height: 32px; }
  .time-readout, .speeds { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot, .signal i { animation: none; }
  *, *::before, *::after { scroll-behavior: auto !important; }
}
