/* Full-screen 3D scene on top, cockpit dashboard below. Builds on style.css tokens. */
body.game { height: 100dvh; overflow: hidden; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); background: #03040a; }
[hidden] { display: none !important; }

.view { position: relative; min-height: 0; min-width: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fade { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.boot { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #c9cbe0; letter-spacing: .14em; text-transform: uppercase; font-size: 12px; background: #03040a; }

/* Top bar floats over the scene */
.topbar { position: absolute; z-index: 5; inset: 0 0 auto 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px 30px; background: linear-gradient(180deg, rgba(3, 4, 10, .7), transparent); color: #f1ede4; }
.topbar .brand { color: #f1ede4; }
.brand-role { font: 500 12px var(--mono); color: #b8bccb; margin-left: 6px; letter-spacing: .04em; }
.topbar .seg { border-color: rgba(241, 237, 228, .35); }
.topbar .seg button { color: #b8bccb; }
.topbar .seg button[aria-pressed="true"] { background: #f1ede4; color: #05070d; }
.topbar .icon-btn { color: #f1ede4; border-color: rgba(241, 237, 228, .35); }
.chipbtn { display: inline-flex; align-items: center; border: 1px solid rgba(241, 237, 228, .35); border-radius: 999px; padding: 6px 12px; font: 600 12px var(--sans); color: inherit; background: transparent; text-decoration: none; cursor: pointer; white-space: nowrap; }
.chipbtn:hover { border-color: var(--accent); color: var(--accent); }

.prog { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); width: min(420px, 80%); color: #f1ede4; text-align: center; }
.prog span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.prog div { height: 4px; margin-top: 6px; background: rgba(255, 255, 255, .18); border-radius: 4px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.end {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  padding: 0 max(24px, 6vw); color: #f1ede4; animation: rise .6s ease-out both;
  background: linear-gradient(90deg, rgba(3, 4, 10, .9) 0%, rgba(3, 4, 10, .7) 38%, transparent 62%);
}
.end .kicker { color: var(--accent); }
.end h2 { font-size: clamp(42px, 6.5vw, 92px); color: #f1ede4; }
.end-p { color: #c9c6d3; max-width: 38ch; margin: 10px 0 22px; font-size: 17px; }
.end .btn.line { color: #f1ede4; border-color: rgba(241, 237, 228, .35); }
.end .replay { margin-top: 14px; padding: 8px 14px; font-size: 13px; }

/* Dashboard: a cockpit console */
.dash {
  --metal-1: #1b1f2c; --metal-2: #10131c; --edge: #2c3245; --ink: #d9dcea; --dim: #8389a0;
  position: relative; display: grid; grid-template-columns: 210px minmax(0, 1fr) 250px; gap: 12px;
  height: clamp(210px, 31vh, 290px); padding: 14px 16px 16px;
  background: linear-gradient(180deg, var(--metal-1), var(--metal-2));
  border-top: 2px solid var(--accent); color: var(--ink);
  box-shadow: 0 -18px 40px rgba(0, 0, 0, .55);
}
[data-theme="light"] .dash { --metal-1: #e3dac7; --metal-2: #cfc4ad; --edge: #b3a68b; --ink: #2a2620; --dim: #6b604c; }
.dash-tabs { display: none; }
.panel { position: relative; min-height: 0; border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px; background: rgba(0, 0, 0, .18); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05); }
[data-theme="light"] .panel { background: rgba(255, 255, 255, .25); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6); }
.panel::before, .panel::after { content: ""; position: absolute; top: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--edge); }
.panel::before { left: 6px; }
.panel::after { right: 6px; }
.plabel { margin: 0 0 8px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); display: flex; justify-content: space-between; gap: 8px; }

.sys { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font: 500 13px var(--sans); }
.sys li { display: flex; align-items: center; gap: 9px; color: var(--dim); }
.sys li i { width: 9px; height: 9px; border-radius: 50%; background: #3a2a2a; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4); }
.sys li:not(.ok):not(.wip) i { background: #ff4d4d; opacity: .55; animation: blink 1.6s infinite; }
.sys li.ok { color: var(--ink); }
.sys li.ok i { background: #7fe0a7; box-shadow: 0 0 8px #7fe0a7; }
.sys li.wip { color: var(--ink); }
.sys li.wip i { background: #ffc857; box-shadow: 0 0 8px #ffc857; }
.d-sys .met { position: absolute; left: 12px; right: 12px; bottom: 8px; margin: 0; font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-sys .met #met { color: var(--ink); }

/* CRT screen */
.d-crt { padding: 6px; }
.crt {
  position: relative; height: 100%; display: flex; flex-direction: column; border-radius: 8px; padding: 8px 12px 8px;
  background: radial-gradient(120% 140% at 50% 40%, #0b2117 0%, #04100a 70%); color: #8dffbf;
  font: 20px/1.15 "VT323", var(--mono); text-shadow: 0 0 6px rgba(80, 255, 160, .45);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .8), 0 0 0 2px #0a0d12; overflow: hidden;
}
.crt::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(180deg, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px); border-radius: 8px; }
.crt-label { color: #4fbf85; margin-bottom: 2px; justify-content: flex-start; align-items: center; }
.live { width: 7px; height: 7px; border-radius: 50%; background: #8dffbf; box-shadow: 0 0 8px #8dffbf; animation: blink 1.4s infinite; }
.crt .comms-log { flex: 1; min-height: 0; max-height: none; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2f6b4c transparent; }
.crt .cl { grid-template-columns: 74px minmax(0, 1fr); gap: 10px; padding: 3px 0; border: 0; animation: none; }
.crt .cl .who { font: 18px "VT323", var(--mono); letter-spacing: .04em; color: #ffc46b; text-shadow: 0 0 6px rgba(255, 180, 80, .4); padding-top: 0; }
.crt .cl .who:not(.flight) { color: #9fc4ff; text-shadow: none; }
.crt .cl p { margin: 0 0 4px; }
.crt .cl b { color: #d6ffe6; font-weight: 400; }
.crt .cl b.ok { color: #8dffbf; }
.crt .cl b.wip { color: #ffc857; }
.crt .cl code { font: inherit; background: rgba(141, 255, 191, .12); padding: 0 4px; }
.crt .cl a { color: #d6ffe6; }
.crt .cl .row-btns { gap: 6px; margin-top: 6px; }
.crt .cl .btn { font: 13px var(--sans); padding: 5px 10px; background: transparent; color: #8dffbf; border-color: #2f6b4c; text-shadow: none; }
.crt .cl .btn:first-child { background: #8dffbf; color: #04100a; }
.crt .typing { padding: 6px 0 6px 84px; }
.crt .typing i { background: #8dffbf; }
.crt .chips { padding: 4px 0; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.crt .chip { flex: none; border-color: #2f6b4c; color: #8dffbf; background: transparent; font: 17px "VT323", var(--mono); padding: 1px 10px; border-radius: 4px; }
.crt .chip:hover { border-color: #8dffbf; color: #d6ffe6; }
.crt .ask { gap: 6px; align-items: center; border-top: 1px solid #1c4030; padding-top: 4px; }
.crt .prompt { color: #8dffbf; }
.crt .ask input { background: transparent; border: 0; border-radius: 0; padding: 2px 0; color: #d6ffe6; font: 20px "VT323", var(--mono); caret-color: #8dffbf; }
.crt .ask input::placeholder { color: #3f8a63; }
.sendbtn { border: 1px solid #2f6b4c; background: transparent; color: #8dffbf; font: 17px "VT323", var(--mono); padding: 1px 10px; border-radius: 4px; cursor: pointer; }
.sendbtn:hover { border-color: #8dffbf; }

/* Controls: keycaps and switches */
.keys { display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 40px); gap: 6px; justify-content: center; }
.keys button {
  border: 1px solid var(--edge); border-radius: 8px; background: linear-gradient(180deg, #2a3042, #1a1e2a); color: var(--ink);
  font: 600 16px var(--mono); cursor: pointer; box-shadow: 0 3px 0 #0a0c12; touch-action: none; user-select: none;
}
[data-theme="light"] .keys button { background: linear-gradient(180deg, #f4efe4, #dcd2bf); box-shadow: 0 3px 0 #a69a80; }
.keys button:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a0c12; }
.keys .k-up { grid-column: 2; grid-row: 1; }
.keys .k-left { grid-column: 1; grid-row: 2; }
.keys .k-down { grid-column: 2; grid-row: 2; }
.keys .k-right { grid-column: 3; grid-row: 2; }
.keys .k-act { grid-column: 3; grid-row: 1; color: var(--accent); border-color: var(--accent); }
.switches { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--edge); border-radius: 999px; background: transparent; color: var(--ink); font: 600 12px var(--sans); padding: 5px 12px 5px 6px; cursor: pointer; }
.toggle i { position: relative; width: 30px; height: 16px; border-radius: 999px; background: #3a3f52; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #f1ede4; transition: transform .2s; }
.toggle[aria-pressed="true"] i { background: #3cbf7a; }
.toggle[aria-pressed="true"] i::after { transform: translateX(14px); }
.d-ctl .chipbtn { color: var(--ink); border-color: var(--edge); }
.keys-hint { margin: 10px 0 0; font-size: 10.5px; color: var(--dim); text-align: center; line-height: 1.4; }

/* Phone: scene on top, dashboard below with two tabs */
@media (max-width: 760px) {
  .brand-role { display: none; }
  .topbar { padding: 10px 12px 24px; }
  .topbar .chipbtn { display: none; }
  .dash { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); height: 46dvh; padding: 8px 10px 10px; gap: 8px; }
  .dash-tabs { display: flex; gap: 6px; }
  .dash-tabs button { flex: 1; border: 1px solid var(--edge); background: transparent; color: var(--dim); font: 600 12px var(--mono); letter-spacing: .1em; padding: 6px; border-radius: 8px; }
  .dash-tabs button[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); }
  .dash[data-tab="comms"] .d-sys, .dash[data-tab="comms"] .d-ctl { display: none; }
  .dash[data-tab="ctl"] .d-crt { display: none; }
  .dash[data-tab="ctl"] { grid-template-rows: auto auto 1fr; }
  .d-sys .sys { grid-template-columns: 1fr 1fr; }
  .d-sys .met { position: static; margin-top: 8px; }
  .crt { font-size: 18px; }
  .crt .cl { grid-template-columns: 1fr; gap: 0; }
  .crt .typing { padding-left: 0; }
  .end { justify-content: flex-end; padding-bottom: 20px; background: linear-gradient(0deg, rgba(3, 4, 10, .92) 0%, rgba(3, 4, 10, .6) 60%, transparent 100%); }
  .end .row-btns .btn { padding: 7px 11px; font-size: 12px; }
}
.dash > * { min-width: 0; }

/* Dashboard can be hidden to watch the scene full screen */
body.dash-off .dash { display: none; }
#dashToggle .dt-show, body.dash-off #dashToggle .dt-hide { display: none; }
body.dash-off #dashToggle .dt-show { display: inline; }
@media (max-width: 760px) { .topbar #dashToggle { display: inline-flex; padding: 6px 10px; } }

/* Mission tracker: current objective, top left of the scene */
.mission {
  position: absolute; z-index: 4; left: 20px; top: 66px; width: min(330px, calc(100% - 40px));
  padding: 10px 14px 11px; border-radius: 10px; color: #f1ede4;
  background: rgba(8, 10, 20, .62); border: 1px solid rgba(255, 200, 87, .35); border-left: 3px solid #ffc857;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: border-color .2s, box-shadow .2s;
}
.mission p { margin: 0; }
.m-k { display: flex; justify-content: space-between; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: #ffc857; }
.m-obj { font: 600 17px/1.25 var(--sans); margin-top: 3px !important; }
.m-hint { font-size: 11.5px; color: #c9c6d3; margin-top: 4px !important; }
.mission.near { border-color: #7fe0a7; border-left-color: #7fe0a7; box-shadow: 0 0 18px rgba(127, 224, 167, .35); }
.mission.near .m-hint { color: #7fe0a7; font-weight: 600; }
body:has(.end:not([hidden])) .mission { display: none; }

/* Holographic card: what the astronaut reads after each step */
.holo {
  position: absolute; z-index: 4; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); padding: 12px 18px 14px; border-radius: 12px;
  color: #dff8ff; background: linear-gradient(180deg, rgba(20, 60, 90, .55), rgba(8, 20, 40, .72));
  border: 1px solid rgba(111, 214, 255, .55); box-shadow: 0 0 30px rgba(111, 214, 255, .22), inset 0 0 22px rgba(111, 214, 255, .1);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: holo-in .45s cubic-bezier(.2, .9, .3, 1.2) both;
}
.holo::after { content: ""; position: absolute; inset: 0; border-radius: 12px; pointer-events: none; background: repeating-linear-gradient(180deg, rgba(111, 214, 255, .06) 0 1px, transparent 1px 4px); }
.holo .h-k { margin: 0; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: #6fd6ff; }
.holo h3 { margin: 4px 0 2px; font: 500 22px/1.15 var(--serif); letter-spacing: -.02em; color: #fff; }
.holo .h-b { margin: 4px 0 0; font-size: 15px; line-height: 1.45; color: #d4eef7; }
.holo.ok { border-color: rgba(127, 224, 167, .6); box-shadow: 0 0 30px rgba(127, 224, 167, .22), inset 0 0 22px rgba(127, 224, 167, .08); }
.holo.ok .h-k { color: #7fe0a7; }
.holo.wip { border-color: rgba(255, 200, 87, .6); box-shadow: 0 0 30px rgba(255, 200, 87, .2); }
.holo.wip .h-k { color: #ffc857; }
@keyframes holo-in { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

@media (max-width: 760px) {
  .mission { left: 10px; top: 56px; width: min(260px, calc(100% - 20px)); padding: 7px 10px 8px; }
  .m-obj { font-size: 14px; }
  .m-hint { font-size: 10.5px; }
  .holo { bottom: 10px; padding: 9px 12px 10px; }
  .holo h3 { font-size: 20px; }
  .holo .h-b { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .holo { animation: none; } }
@media (max-width: 760px) { .prog { top: 150px; } }

/* Systems panel: the list scrolls if the dashboard is short, the clock stays below it */
.d-sys { display: flex; flex-direction: column; }
.d-sys .sys { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; align-content: start; }
.d-sys .met { position: static; margin-top: 6px; }
@media (max-height: 820px) and (min-width: 761px) { .sys { gap: 2px; font-size: 12.5px; } }

/* The card sits in the bottom-right corner so it never hides the astronaut or the repair ring */
.holo { left: auto; right: 20px; bottom: 20px; transform: none; width: min(420px, calc(100% - 40px)); animation-name: holo-in-side; }
@keyframes holo-in-side { from { opacity: 0; transform: translateX(18px) scale(.97); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) { .holo { left: 10px; right: 10px; bottom: 10px; width: auto; } }

/* Launch countdown: 3 · 2 · 1 · LIFTOFF, huge in the middle of the scene */
.count {
  position: absolute; z-index: 6; inset: 0; display: grid; place-items: center; margin: 0; pointer-events: none;
  font: 500 clamp(120px, 24vh, 260px)/1 var(--serif); color: #fff;
  text-shadow: 0 0 30px rgba(255, 160, 80, .9), 0 0 80px rgba(255, 122, 69, .6);
  animation: count-pop 1s cubic-bezier(.2, .8, .3, 1) both;
}
.count.go { font: 600 clamp(48px, 9vh, 104px)/1 var(--mono); letter-spacing: .25em; color: #ffd27a; animation-duration: 1.8s; }
@keyframes count-pop {
  0% { opacity: 0; transform: scale(1.8); }
  18% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; transform: scale(.94); }
  100% { opacity: 0; transform: scale(.85); }
}
@media (prefers-reduced-motion: reduce) { .count { animation: none; opacity: 0; } }
