:root {
  --bg: #080b0d;
  --bg-2: #0d1114;
  --panel: rgba(22, 28, 31, 0.92);
  --panel-2: rgba(13, 17, 19, 0.95);
  --line: rgba(201, 218, 216, 0.16);
  --line-strong: rgba(220, 237, 233, 0.3);
  --text: #eef4f1;
  --muted: #82908c;
  --green: #69f6a1;
  --green-soft: rgba(105, 246, 161, 0.13);
  --red: #ff3f2f;
  --red-dark: #8f1711;
  --orange: #ff8b31;
  --amber: #ffc34d;
  --danger-soft: rgba(255, 63, 47, 0.14);
  --radius: 9px;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 50% 20%, rgba(57, 77, 75, 0.14), transparent 34%),
    linear-gradient(180deg, #0a0d0f 0%, #07090b 100%);
  color: var(--text);
  font-family: var(--mono);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
  z-index: -1;
}

button, a, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.noise {
  position: fixed;
  inset: 0;
  opacity: .035;
  pointer-events: none;
  z-index: 50;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.65'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.scanline {
  position: fixed;
  left: 0; right: 0;
  height: 1px;
  top: -2px;
  opacity: 0;
  pointer-events: none;
  z-index: 49;
  background: linear-gradient(90deg, transparent, rgba(255, 105, 81, .6), transparent);
}

body[data-mode="emergency"] .scanline,
body[data-mode="critical"] .scanline {
  opacity: .4;
  animation: scan 5s linear infinite;
}

@keyframes scan { to { transform: translateY(110vh); } }

.topbar {
  min-height: 84px;
  margin: 18px 18px 0;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 20;
}

.system-panel {
  border: 1px solid var(--line);
  border-top-color: rgba(255,255,255,.24);
  background: linear-gradient(145deg, rgba(30, 37, 40, .86), rgba(12, 15, 17, .95));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.045),
    inset 0 -22px 50px rgba(0,0,0,.12),
    0 18px 60px rgba(0,0,0,.28);
  border-radius: var(--radius);
}

.brand-wrap, .top-actions, .identifier-line, .timer-leds { display: flex; align-items: center; }
.brand-wrap { gap: 14px; }

.brand-logo {
  width: 56px;
  height: 56px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(255, 63, 47, .22));
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.brand { margin-top: 4px; font-weight: 800; letter-spacing: .08em; font-size: clamp(13px, 2vw, 17px); }

.top-actions { gap: 10px; }
.utility-btn, .copy-btn, .safe-action, .danger-action, .rebuild-btn {
  border: 1px solid var(--line-strong);
  background: #101517;
  padding: 10px 13px;
  cursor: pointer;
  transition: 160ms ease;
}
.utility-btn:hover, .copy-btn:hover, .safe-action:hover, .rebuild-btn:hover { border-color: rgba(105,246,161,.55); }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(105,246,161,.23);
  background: var(--green-soft);
  padding: 10px 12px;
  color: var(--green);
  font-size: 11px;
  letter-spacing: .12em;
}
.status-chip i, .ok i, .footer-status i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 12px rgba(105,246,161,.7);
}

.app-shell { min-height: calc(100vh - 102px); }
.view { display: none; }
.active-view { display: block; }

.stable-view { padding: 18px; }
.stable-grid {
  min-height: calc(100vh - 170px);
  display: grid;
  grid-template-columns: minmax(215px, .72fr) minmax(420px, 1.6fr) minmax(215px, .72fr);
  gap: 14px;
}

.status-panel, .external-panel, .emergency-side { padding: 18px; min-height: 100%; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
  color: #b7c1be;
  letter-spacing: .13em;
  font-size: 10px;
}
.tiny-index { color: #5d6966; }

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,.055);
  color: #7f8d89;
  font-size: 10px;
}
.status-row strong { display: flex; align-items: center; gap: 7px; font-size: 10px; letter-spacing: .08em; }
.status-row .ok { color: var(--green); }
.status-row .muted-status { color: #b8c1be; }
.status-row .muted-status i { width: 7px; height: 7px; background: #58615f; border-radius: 50%; }

.mini-diagram {
  position: relative;
  width: min(100%, 230px);
  aspect-ratio: 1;
  margin: 26px auto 18px;
}
.diagram-ring {
  position: absolute;
  inset: 7%;
  border: 1px solid rgba(105,246,161,.13);
  border-radius: 50%;
}
.ring-one { border-style: dashed; animation: rotateSlow 22s linear infinite; }
.ring-two { inset: 21%; border-color: rgba(255,255,255,.09); animation: rotateSlow 15s linear infinite reverse; }
.diagram-core {
  position: absolute;
  inset: 35%;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid rgba(105,246,161,.28);
  background: radial-gradient(circle, rgba(105,246,161,.1), rgba(105,246,161,.01));
  color: var(--green);
  font-size: 11px;
}
.diagram-core small { font-size: 8px; color: #73817d; }
.dot { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(105,246,161,.6); }
.d1 { left: 18%; top: 24%; } .d2 { right: 14%; top: 44%; } .d3 { left: 43%; bottom: 8%; }
@keyframes rotateSlow { to { transform: rotate(360deg); } }
.micro-copy, .external-footnote { margin-top: auto; color: #56615e; font-size: 9px; line-height: 1.7; letter-spacing: .08em; }

.center-stage {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 47%, rgba(255,255,255,.045), transparent 28%),
    linear-gradient(180deg, rgba(16,21,23,.62), rgba(9,12,14,.82));
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 46px 28px;
}
.center-stage::before,
.center-stage::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  border-color: rgba(255,255,255,.07);
  pointer-events: none;
}
.center-stage::before { top: 20px; left: 20px; border-left: 1px solid; border-top: 1px solid; }
.center-stage::after { right: 20px; bottom: 20px; border-right: 1px solid; border-bottom: 1px solid; }

.stage-copy { position: absolute; left: 6%; top: 7%; z-index: 2; max-width: 46%; }


.stage-copy h1 {
  margin: 10px 0 8px;
  font-family: var(--sans);
  font-size: clamp(42px, 5.4vw, 78px);
  line-height: .86;
  letter-spacing: -.065em;
  font-weight: 850;
  color: #f2f6f3;
}
.stage-copy p { color: #707d79; margin: 0; font-size: 11px; }

.emergency-console {
  width: min(620px, 90%);
  margin-top: 180px;
  border: 1px solid #3b4141;
  padding: 14px;
  background: linear-gradient(145deg, #24282a, #111416 58%, #0a0c0d);
  box-shadow: 0 35px 80px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.08);
  position: relative;
}
.warning-strip {
  min-height: 28px;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(135deg, #b39a40 0 14px, #121416 14px 28px);
  color: #0c0d0e;
  font-weight: 900;
  font-size: 9px;
  letter-spacing: .15em;
  text-shadow: 0 1px rgba(255,255,255,.12);
}
.warning-strip span { background: #c7a945; }
.bottom-strip { margin-top: 12px; color: #e7ce74; background: #171a1b; border: 1px solid rgba(226,186,69,.18); }
.console-body {
  min-height: 330px;
  margin-top: 12px;
  border: 1px solid #373d3e;
  background:
    linear-gradient(90deg, transparent 49.7%, rgba(255,255,255,.025) 50%, transparent 50.3%),
    radial-gradient(circle at center, #202629 0%, #14191b 50%, #0d1011 100%);
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.cover-track { position: absolute; inset: 34px 23% 38px; z-index: 4; perspective: 800px; }
.cover-track.open { pointer-events: none; }
.glass-cover {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(222,241,237,.28);
  background: linear-gradient(145deg, rgba(180,220,213,.11), rgba(200,226,224,.035));
  box-shadow: inset 0 0 30px rgba(160,220,211,.05), 0 12px 25px rgba(0,0,0,.22);
  backdrop-filter: blur(1px);
  cursor: pointer;
  transform-origin: top center;
  transition: transform .72s cubic-bezier(.2,.8,.2,1), opacity .5s;
}
.glass-cover.open { transform: rotateX(72deg) translateY(-25px); opacity: .48; pointer-events: none; }
.glass-reflection { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 22%, rgba(255,255,255,.14) 35%, transparent 50%); }
.cover-label { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); padding: 7px 10px; background: rgba(7,10,11,.72); border: 1px solid rgba(255,255,255,.12); font-size: 9px; letter-spacing: .12em; white-space: nowrap; }
.cover-hinge { position: absolute; top: -10px; width: 42px; height: 15px; background: linear-gradient(#555d5d,#202426); border: 1px solid #626b6a; }
.hinge-left { left: 8%; } .hinge-right { right: 8%; }

.physical-button {
  width: 168px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  background: transparent;
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 18px 18px rgba(0,0,0,.45));
}
.physical-button:disabled { cursor: not-allowed; }
.button-face {
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  display: grid;
  align-content: center;
  place-items: center;
  gap: 3px;
  background: radial-gradient(circle at 40% 30%, #ff6253, #d92319 46%, #8a0f0a 78%);
  border: 6px solid #3a0d0b;
  box-shadow: inset 0 8px 8px rgba(255,255,255,.13), inset 0 -12px 14px rgba(50,0,0,.3), 0 0 0 8px #17191a, 0 0 0 10px #3d4142;
  transition: transform .15s ease;
}
.physical-button:not(:disabled):active .button-face { transform: translateY(7px) scale(.98); }
.button-face small { font-size: 9px; color: #ffd2cd; letter-spacing: .15em; }
.button-face strong { font-family: var(--sans); font-weight: 900; font-size: 20px; letter-spacing: .03em; }
.button-glow { position: absolute; inset: 11px; border-radius: 50%; box-shadow: 0 0 50px rgba(255,63,47,.08); transition: .25s; }
.physical-button:not(:disabled) .button-glow { box-shadow: 0 0 60px rgba(255,63,47,.25); }
.hardware-labels { position: absolute; left: 18px; right: 18px; bottom: 14px; display: flex; justify-content: space-between; color: #5f6a67; font-size: 8px; }

.external-stack { padding-top: 13px; }
.external-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #c8d2cf;
  text-decoration: none;
  padding: 15px 0;
  border-bottom: 1px solid rgba(255,255,255,.055);
  transition: .15s ease;
  font-size: 11px;
}
.external-link:hover { color: var(--green); padding-left: 5px; }
.external-link b { font-size: 14px; font-weight: 400; }
.identifier-block { margin-top: 28px; padding-top: 17px; border-top: 1px solid var(--line); }
.identifier-label { color: #687470; font-size: 9px; letter-spacing: .12em; }
.identifier-line { gap: 8px; margin-top: 10px; }
.identifier-line code { min-width: 0; flex: 1; color: #a9b5b1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 9px; }
.copy-btn { font-size: 9px; padding: 8px; }
.external-footnote { margin-top: 36px; }

.footer-status {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
  color: #57635f;
  font-size: 8px;
  letter-spacing: .1em;
}
.footer-status span:first-child { display: inline-flex; align-items: center; gap: 7px; color: #7d908a; }
.footer-status b { color: #8b9995; font-weight: 500; }

.confirm-view, .result-view {
  min-height: calc(100vh - 102px);
  padding: 30px 18px;
  place-items: center;
}
.confirm-view.active-view, .result-view.active-view { display: grid; }
.confirm-card, .result-card { width: min(680px, 100%); padding: 46px; text-align: center; }
.hazard-symbol {
  width: 66px; height: 66px;
  margin: 0 auto 24px;
  display: grid; place-items: center;
  color: var(--red);
  border: 1px solid rgba(255,63,47,.45);
  background: var(--danger-soft);
  font-family: var(--sans); font-size: 34px; font-weight: 900;
  clip-path: polygon(50% 0, 100% 88%, 0 88%);
  padding-top: 12px;
}
.warning-text { color: #c66a62; }
.confirm-card h2, .result-card h2, .destroyed-terminal h2 { font-family: var(--sans); font-size: clamp(40px, 8vw, 82px); letter-spacing: -.06em; line-height: .9; margin: 12px 0 18px; }
.confirm-card p { color: #899590; max-width: 480px; margin: 0 auto 28px; line-height: 1.6; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.danger-action { background: linear-gradient(#e84235,#a81d15); border-color: #f1594e; font-weight: 800; }
.danger-action:hover { filter: brightness(1.08); }
.safe-action { color: #c7d0cd; }
.confirm-card small { display: block; color: #59625f; margin-top: 18px; }

body[data-mode="emergency"], body[data-mode="critical"] {
  background:
    radial-gradient(circle at 50% 18%, rgba(130, 18, 11, .18), transparent 34%),
    #08090a;
}
body[data-mode="critical"] { animation: criticalAmbient 1.1s ease-in-out infinite alternate; }
@keyframes criticalAmbient { from { background-color: #08090a; } to { background-color: #110a09; } }
body[data-mode="emergency"] .system-panel,
body[data-mode="critical"] .system-panel { border-color: rgba(255,89,70,.17); }

.emergency-view { padding: 0 18px 18px; }
.emergency-frame { min-height: calc(100vh - 102px); border: 1px solid rgba(255,63,47,.16); background: rgba(8,9,10,.7); position: relative; overflow: hidden; }
.emergency-frame::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 100px rgba(255,31,20,.055); }
.emergency-marquee { height: 28px; display: flex; align-items: center; justify-content: space-around; gap: 30px; overflow: hidden; background: rgba(104,14,9,.25); border-bottom: 1px solid rgba(255,63,47,.18); color: #cf5349; font-size: 8px; letter-spacing: .15em; white-space: nowrap; }
.bottom-marquee { position: absolute; bottom: 0; width: 100%; border-top: 1px solid rgba(255,63,47,.18); border-bottom: 0; }
.emergency-layout { min-height: calc(100vh - 160px); display: grid; grid-template-columns: minmax(180px,.62fr) minmax(420px,1.7fr) minmax(180px,.62fr); gap: 12px; padding: 12px 12px 40px; }
.emergency-side { min-height: auto; }
.emergency-heading { color: #bd5b53; }
.critical-stack { padding-top: 9px; }
.critical-stack > div { padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,.05); display: flex; justify-content: space-between; gap: 10px; font-size: 9px; color: #6c7673; }
.critical-stack b { color: #e55a4e; }
.event-log { margin-top: 20px; height: 190px; overflow: hidden; font-size: 8px; color: #68716f; line-height: 1.5; }
.event-log div { display: grid; grid-template-columns: 43px 1fr; gap: 8px; margin-bottom: 8px; }
.event-log time { color: #a64840; }

.mission-area { min-width: 0; padding: 6px 8px 20px; display: flex; flex-direction: column; }
.timer-module {
  width: min(690px, 100%);
  align-self: center;
  padding: 17px 24px 19px;
  border: 1px solid rgba(255,63,47,.32);
  background: linear-gradient(180deg, rgba(39,17,15,.93), rgba(13,12,12,.97));
  box-shadow: inset 0 0 40px rgba(255,34,20,.035), 0 15px 40px rgba(0,0,0,.25);
  text-align: center;
  position: relative;
}
.timer-leds { justify-content: center; gap: 5px; margin-bottom: 9px; }
.timer-leds i { width: 5px; height: 5px; background: #6e1b16; border-radius: 50%; }
.timer-leds i:first-child { background: var(--red); box-shadow: 0 0 10px rgba(255,63,47,.8); }
.timer-label { color: #d7574c; font-size: 9px; letter-spacing: .17em; }
.timer-display { font-family: var(--sans); font-size: clamp(58px, 9vw, 118px); font-weight: 850; line-height: .9; letter-spacing: -.055em; color: #f0e7e5; margin: 8px 0 4px; font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(255,55,39,.08); }
.timer-subtitle { color: #6f5956; font-size: 8px; letter-spacing: .15em; }
.timer-progress { height: 3px; margin-top: 14px; background: #231514; overflow: hidden; }
.timer-progress span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--orange)); transform-origin: left; transition: width .15s linear; }
body[data-mode="critical"] .timer-display { color: #ff5c4d; text-shadow: 0 0 35px rgba(255,63,47,.22); }
body[data-mode="critical"] .timer-module { box-shadow: inset 0 0 60px rgba(255,34,20,.08), 0 0 50px rgba(255,34,20,.04); }

.mission-header { margin: 20px 0 11px; display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; }
.mission-header h2 { margin: 5px 0 0; font-family: var(--sans); letter-spacing: -.04em; font-size: clamp(25px, 3.6vw, 44px); }
.phase-status { padding: 8px 10px; border: 1px solid rgba(255,255,255,.1); color: #6e7976; font-size: 9px; }
.task-container {
  min-height: 260px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(19,22,23,.85), rgba(10,12,13,.95));
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.mission-message { margin-top: 10px; text-align: center; color: #94524c; font-size: 9px; letter-spacing: .13em; min-height: 14px; }

.task-intro { color: #7f8a86; font-size: 10px; line-height: 1.5; margin-bottom: 18px; max-width: 640px; }
.task-title { color: #c9d2cf; letter-spacing: .1em; font-size: 10px; margin-bottom: 8px; }
.success-text { color: var(--green)!important; }
.error-text { color: #ff6a5e!important; }

.connection-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.node-column { display: grid; gap: 10px; }
.node-btn {
  min-height: 54px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.11);
  background: #111516;
  color: #aeb9b5;
  cursor: pointer;
  text-align: left;
  transition: .15s;
}
.node-btn:hover { border-color: rgba(255,139,49,.38); }
.node-btn.selected { border-color: var(--orange); box-shadow: inset 0 0 25px rgba(255,139,49,.06); color: #ffd4ad; }
.node-btn.connected { border-color: rgba(105,246,161,.35); color: var(--green); }
.connection-bus { width: 44px; display: grid; gap: 10px; }
.connection-bus span { height: 2px; background: #3b312d; }

.code-display {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,195,77,.22);
  background: rgba(54,38,12,.08);
}
.memory-code { font-family: var(--sans); font-size: clamp(44px,7vw,82px); letter-spacing: .22em; margin-left: .22em; color: #f0dbc0; }
.code-input-wrap { display: flex; gap: 10px; max-width: 480px; margin: 12px auto 0; }
.abort-code-input { flex: 1; min-width: 0; background: #0b0e0f; border: 1px solid rgba(255,255,255,.12); color: #f2f4f3; padding: 13px; text-align: center; letter-spacing: .3em; outline: none; }
.abort-code-input:focus { border-color: rgba(255,139,49,.5); }
.task-action { border: 1px solid rgba(255,139,49,.4); background: rgba(255,139,49,.11); color: #ffc18d; padding: 12px 14px; cursor: pointer; }

.sequence-display { display: flex; justify-content: center; gap: 10px; margin: 18px 0 24px; flex-wrap: wrap; }
.sequence-display span { min-width: 56px; height: 56px; display: grid; place-items: center; border: 1px solid rgba(255,195,77,.32); color: var(--amber); background: rgba(255,195,77,.055); font-size: 17px; }
.sequence-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 560px; margin: 0 auto; }
.sector-btn { aspect-ratio: 1.6; border: 1px solid rgba(255,255,255,.11); background: #121516; color: #b5bfbc; cursor: pointer; font-size: 18px; transition: .14s; }
.sector-btn:hover { border-color: rgba(255,195,77,.42); }
.sector-btn.active { background: rgba(255,195,77,.12); color: var(--amber); border-color: rgba(255,195,77,.55); }

.energy-task { max-width: 680px; margin: 10px auto 0; }
.energy-track { position: relative; height: 54px; border: 1px solid rgba(255,255,255,.1); background: linear-gradient(90deg,#291311 0 28%,#15231a 28% 66%,#291311 66% 100%); overflow: hidden; }
.safe-zone { position: absolute; left: 28%; width: 38%; top: 0; bottom: 0; border-left: 1px solid rgba(105,246,161,.35); border-right: 1px solid rgba(105,246,161,.35); }
.energy-needle { position: absolute; top: 6px; bottom: 6px; width: 3px; background: #fff; box-shadow: 0 0 12px rgba(255,255,255,.6); left: 50%; }
.energy-readout { display: flex; justify-content: space-between; margin-top: 9px; color: #69736f; font-size: 9px; }
.energy-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.energy-controls button { padding: 13px; border: 1px solid rgba(255,255,255,.1); background: #111516; color: #c5cecb; cursor: pointer; }

.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 700px; margin: 0 auto; }
.sync-module { border: 1px solid rgba(255,255,255,.09); padding: 16px; text-align: center; }
.sync-dial { width: 130px; height: 130px; border-radius: 50%; margin: 8px auto 14px; border: 1px solid rgba(255,255,255,.13); position: relative; background: radial-gradient(circle,#171c1e,#0c0f10); }
.sync-hand { position: absolute; width: 2px; height: 50px; background: var(--orange); left: calc(50% - 1px); bottom: 50%; transform-origin: bottom center; box-shadow: 0 0 9px rgba(255,139,49,.4); }
.sync-value { color: #8d9995; font-size: 10px; }
.sync-btn { margin-top: 12px; width: 100%; padding: 12px; border: 1px solid rgba(255,139,49,.32); background: rgba(255,139,49,.07); color: #e9b183; cursor: pointer; }

.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.module-card { min-height: 100px; border: 1px solid rgba(255,255,255,.09); background: #101415; color: #9ba6a2; cursor: pointer; text-align: left; padding: 13px; position: relative; }
.module-card i { display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(105,246,161,.4); margin-bottom: 18px; }
.module-card small { display: block; margin-top: 8px; color: #59635f; }
.module-card:hover { border-color: rgba(255,139,49,.38); }

.process-list { display: grid; gap: 9px; }
.process-btn { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; text-align: left; border: 1px solid rgba(255,255,255,.09); background: #101415; color: #aab5b1; padding: 12px; cursor: pointer; }
.process-btn span:first-child { color: #69736f; }
.process-btn b { color: #8f534c; font-size: 9px; font-weight: 500; }
.process-btn.done { border-color: rgba(105,246,161,.3); color: var(--green); }
.process-btn.done b { color: var(--green); }

.abort-final { display: grid; place-items: center; min-height: 235px; text-align: center; }
.abort-final button { min-width: min(420px, 90%); padding: 22px; border: 1px solid #ff6a5e; background: linear-gradient(#d9362b,#8d1711); color: white; font-family: var(--sans); font-size: clamp(18px,3vw,30px); font-weight: 850; letter-spacing: -.02em; cursor: pointer; box-shadow: 0 0 40px rgba(255,63,47,.08); }
.abort-final button:hover { filter: brightness(1.09); box-shadow: 0 0 55px rgba(255,63,47,.15); }

.telemetry { padding-top: 12px; display: grid; gap: 18px; }
.telemetry-item > span { color: #68726f; font-size: 9px; }
.telemetry-item > b { float: right; color: #c85b51; font-size: 9px; }
.telemetry-item > div { clear: both; height: 3px; background: #241716; margin-top: 8px; }
.telemetry-item > div i { display: block; height: 100%; width: 50%; background: linear-gradient(90deg,#b32e24,#f4783f); transition: .3s; }
.side-message { margin-top: 26px; min-height: 74px; border: 1px solid rgba(255,63,47,.12); display: grid; place-items: center; text-align: center; color: #d0584e; font-size: 10px; letter-spacing: .12em; padding: 10px; }
.locked-links { margin-top: 22px; color: #5f4e4b; font-size: 8px; line-height: 1.5; }

.result-card { position: relative; overflow: hidden; }
.result-card .eyebrow { color: var(--green); }
.result-card h2 { font-size: clamp(46px,8vw,90px); color: #eaf3ee; }
.result-card > p { color: var(--green); letter-spacing: .2em; }
.result-time { width: fit-content; margin: 22px auto 8px; padding: 10px 16px; border: 1px solid rgba(105,246,161,.24); color: var(--green); font-size: 25px; }
.dry-message { margin-top: 24px; font-family: var(--sans); font-size: 19px; color: #9ba7a2; }
.incident-note { margin: 10px 0 26px; color: #5f6c67; font-size: 9px; letter-spacing: .12em; }
.incident-note strong { color: #97a49f; }
.safe-action.large { padding: 14px 22px; }
.result-orbit { position: absolute; width: 390px; height: 390px; border: 1px solid rgba(105,246,161,.07); border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%,-50%); pointer-events: none; }
.result-orbit span { position: absolute; width: 5px; height: 5px; background: var(--green); border-radius: 50%; box-shadow: 0 0 10px rgba(105,246,161,.5); }
.result-orbit span:nth-child(1) { top: 8%; left: 50%; } .result-orbit span:nth-child(2) { bottom: 17%; left: 12%; } .result-orbit span:nth-child(3) { right: 7%; top: 53%; }

.failure-view { background: #000; }
.destroyed-terminal { text-align: center; padding: 32px; max-width: 760px; }
.destroyed-terminal .eyebrow { color: #4f4f4f; }
.destroyed-terminal h2 { color: #d6d6d6; }
.destroyed-terminal p { color: #555; }
.dead-dot { width: 8px; height: 8px; border-radius: 50%; background: #3e0806; margin: 0 auto 20px; }
.rebuild-btn { margin-top: 22px; color: #9a9a9a; border-color: #2d2d2d; background: #080808; }
.rebuild-btn:hover { color: #ddd; border-color: #555; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 9px 12px; border: 1px solid rgba(105,246,161,.26); background: #0c1510; color: var(--green); font-size: 9px; letter-spacing: .13em; z-index: 100; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

.destruction-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.fragment {
  position: absolute;
  border: 1px solid rgba(255,68,50,.25);
  background: rgba(25,10,8,.83);
  box-shadow: 0 0 30px rgba(255,40,20,.08);
  animation: fallFragment 1.5s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes fallFragment {
  0% { opacity: 1; transform: translate(0,0) rotate(0) scale(1); }
  100% { opacity: 0; transform: translate(var(--x), 120vh) rotate(var(--r)) scale(.65); }
}
body.destroying [data-destructible] { animation: panelFailure .9s steps(2,end) forwards; }
body.destroying .topbar { animation-delay: .3s; }
body.destroying .left-side { animation-delay: .1s; }
body.destroying .right-side { animation-delay: .55s; }
body.destroying .mission-area { animation-delay: .85s; }
@keyframes panelFailure {
  0% { opacity:1; transform: translate(0); filter:none; }
  25% { transform: translate(3px,-1px); filter: brightness(1.6) saturate(1.5); }
  45% { transform: translate(-7px,2px); }
  100% { opacity:0; transform: translateY(80px) rotate(1deg); filter: brightness(.2); }
}

.flash-red::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 70; background: rgba(255,28,15,.12); animation: flashOut .55s ease-out forwards; }
@keyframes flashOut { to { opacity: 0; } }

@media (max-width: 1080px) {
  .stable-grid { grid-template-columns: 1fr 1.7fr; }
  .external-panel { grid-column: 1 / -1; min-height: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
  .external-stack { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
  .external-link { border: 1px solid rgba(255,255,255,.065); padding: 12px; }
  .identifier-block { margin-top: 12px; padding-top: 0; border-top: 0; }
  .external-footnote { display: none; }
  .emergency-layout { grid-template-columns: 1fr 2fr; }
  .right-side { grid-column: 1 / -1; display: grid; grid-template-columns: 1.5fr .7fr .7fr; gap: 20px; align-items: start; }
  .right-side .panel-heading { grid-column: 1 / -1; }
  .side-message, .locked-links { margin-top: 0; }
}

@media (max-width: 760px) {
  .topbar { margin: 8px 8px 0; min-height: 70px; padding: 12px; }
  .brand .brand { font-size: 13px; }
  .brand-wrap .eyebrow { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .utility-btn { font-size: 8px; padding: 9px 8px; }
  .status-chip { padding: 9px 8px; font-size: 8px; }
  .stable-view, .emergency-view { padding: 8px; }
  .stable-grid { min-height: auto; grid-template-columns: 1fr; }
  .status-panel { min-height: 330px; }
  .center-stage { min-height: 650px; padding: 28px 12px; }
  .stage-copy { left: 20px; top: 24px; max-width: calc(100% - 40px); }
  .stage-copy h1 { font-size: 50px; }
  .emergency-console { width: 100%; margin-top: 165px; }
  .cover-track { inset-left: 16%; inset-right: 16%; }
  .external-panel { display: block; }
  .external-stack { grid-template-columns: 1fr; }
  .footer-status { flex-wrap: wrap; padding: 8px 4px; }
  .confirm-card, .result-card { padding: 34px 18px; }
  .emergency-frame { min-height: calc(100vh - 88px); }
  .emergency-layout { grid-template-columns: 1fr; padding: 8px 8px 42px; }
  .left-side { order: 2; }
  .mission-area { order: 1; padding: 2px 0 16px; }
  .right-side { order: 3; display: block; grid-column: auto; }
  .event-log { height: 120px; }
  .task-container { min-height: 300px; padding: 14px; }
  .connection-grid { grid-template-columns: 1fr; }
  .connection-bus { display: none; }
  .sequence-pad { grid-template-columns: repeat(2,1fr); }
  .module-grid { grid-template-columns: repeat(2,1fr); }
  .sync-grid { grid-template-columns: 1fr; }
  .right-side .side-message, .right-side .locked-links { margin-top: 20px; }
  .timer-display { font-size: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
