:root {
  color-scheme: dark;
  --deep: #05080f;
  --cyan: #3de7ff;
  --magenta: #ff3d9a;
  --amber: #ffb020;
  --green: #3dff9a;
  --text: #d8e6f0;
  --muted: #7893a5;
  --panel: rgba(4, 13, 22, .84);
  --edge: rgba(61, 231, 255, .28);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #020409; }
body { color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { color: var(--text); }

#app { width: 100%; height: 100%; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #0a1b25 0, #03060b 48%, #010205 100%); }
#game-frame { position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16/9; overflow: hidden; background: var(--deep); box-shadow: 0 0 80px #000, inset 0 0 60px #000; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

.screen { position: absolute; inset: 0; z-index: 20; display: none; }
.screen.active { display: flex; }
.hidden { display: none !important; }
.glass { background: linear-gradient(135deg, rgba(10, 28, 40, .9), rgba(3, 10, 17, .82)); border: 1px solid var(--edge); box-shadow: inset 0 0 30px rgba(22, 139, 166, .05), 0 10px 36px rgba(0,0,0,.35); backdrop-filter: blur(10px); }
.eyebrow { color: var(--cyan); font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .28em; text-transform: uppercase; text-shadow: 0 0 12px rgba(61,231,255,.7); }

#title-screen { align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 60%, rgba(8, 52, 64, .17), transparent 52%), linear-gradient(180deg, rgba(2,5,10,.35), rgba(2,4,8,.84)); overflow: hidden; }
#title-screen::before { content: ""; position: absolute; inset: -20%; opacity: .26; background: repeating-radial-gradient(ellipse at center, transparent 0 30px, rgba(61,231,255,.06) 31px 32px), linear-gradient(90deg, transparent 49.9%, rgba(61,231,255,.14) 50%, transparent 50.1%); animation: sonar 9s linear infinite; }
#title-screen::after { content: ""; position: absolute; inset: 56% 0 0; background: linear-gradient(rgba(61,231,255,.11) 1px, transparent 1px), linear-gradient(90deg, rgba(61,231,255,.09) 1px, transparent 1px); background-size: 54px 32px; transform: perspective(300px) rotateX(63deg) scale(1.5); transform-origin: top; opacity: .3; mask-image: linear-gradient(#000, transparent 75%); }
.title-stack { position: relative; z-index: 2; width: 620px; text-align: center; transform: translateY(-7px); }
.logo { position: relative; margin: 12px 0 0; font-size: clamp(58px, 7.1vw, 98px); line-height: .96; letter-spacing: .12em; font-weight: 200; color: #e3faff; text-shadow: 0 0 7px #fff, 0 0 22px rgba(61,231,255,.7), 3px 0 2px rgba(255,61,154,.5); animation: logoPulse 5s ease-in-out infinite; }
.logo::after { content: attr(data-text); position: absolute; inset: 0; color: transparent; text-shadow: -3px 0 var(--magenta); clip-path: inset(38% 0 47% 0); transform: translateX(4px); opacity: 0; animation: glitch 7s steps(1) infinite; }
.subtitle { color: #8bb1c3; font: 500 10px/1 ui-monospace, monospace; letter-spacing: .48em; margin: 16px 0 38px; }
.title-actions { width: 280px; margin: auto; display: grid; gap: 8px; }
button { position: relative; min-height: 42px; padding: 0 20px; border: 1px solid rgba(115, 157, 177, .28); background: rgba(4, 12, 20, .72); text-transform: uppercase; letter-spacing: .16em; font: 600 11px ui-monospace, monospace; cursor: pointer; transition: border-color .18s, background .18s, color .18s, transform .18s, box-shadow .18s; }
button:hover:not(:disabled), button:focus-visible { border-color: var(--cyan); color: #fff; background: rgba(24, 92, 111, .24); box-shadow: 0 0 18px rgba(61,231,255,.13), inset 3px 0 var(--cyan); outline: none; transform: translateX(2px); }
button.primary { border-color: rgba(61,231,255,.65); color: var(--cyan); background: linear-gradient(90deg, rgba(61,231,255,.13), rgba(4,12,20,.76)); }
button.danger { color: #ff759f; }
button:disabled { opacity: .34; cursor: not-allowed; }
.save-info { min-height: 16px; margin: 15px 0 0; color: var(--muted); font: 10px ui-monospace, monospace; letter-spacing: .08em; }
.controls-strip { margin-top: 36px; color: #516a79; font: 9px ui-monospace, monospace; letter-spacing: .14em; }
.controls-strip i { display: inline-block; width: 3px; height: 3px; margin: 0 12px 2px; background: var(--cyan); transform: rotate(45deg); }
.title-status { position: absolute; z-index: 2; bottom: 24px; left: 28px; color: #4f6978; font: 9px ui-monospace, monospace; letter-spacing: .15em; }
.title-status span { display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 10px var(--magenta); animation: blink 1.4s steps(1) infinite; }
.title-particles { position: absolute; inset: 0; background-image: radial-gradient(circle, rgba(61,231,255,.7) 0 1px, transparent 1.5px), radial-gradient(circle, rgba(255,61,154,.45) 0 1px, transparent 1.5px); background-size: 83px 101px, 137px 173px; animation: drift 25s linear infinite; opacity: .28; }

.hud { position: absolute; z-index: 10; inset: 0; pointer-events: none; }
.hud-left { position: absolute; top: 18px; left: 18px; width: 248px; padding: 12px 14px 10px; }
.stat { height: 19px; display: grid; grid-template-columns: 33px 1fr 28px; align-items: center; gap: 8px; color: #82a3b3; font: 9px ui-monospace, monospace; letter-spacing: .12em; }
.stat em { color: #b8d1dc; font-style: normal; text-align: right; font-size: 9px; }
.bar { height: 3px; background: rgba(122,151,164,.17); overflow: visible; }
.bar b { display: block; width: 100%; height: 100%; background: var(--cyan); box-shadow: 0 0 9px var(--cyan); transition: width .18s; }
.oxygen-stat .bar b { background: #64a7ff; box-shadow: 0 0 9px #64a7ff; }
.hud-top { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); min-width: 355px; min-height: 48px; display: flex; align-items: center; padding: 7px 18px; }
.hud-top small, .room-tag small { display: block; color: #547382; font: 8px ui-monospace, monospace; letter-spacing: .2em; margin-bottom: 3px; }
.hud-top strong { color: #c7dce5; font: 600 10px ui-monospace, monospace; letter-spacing: .08em; }
.diamond { width: 7px; height: 7px; margin-right: 13px; border: 1px solid var(--cyan); transform: rotate(45deg); box-shadow: 0 0 8px rgba(61,231,255,.5); }
.room-tag { position: absolute; top: 18px; right: 18px; padding: 9px 13px; min-width: 175px; text-align: right; }
.room-tag strong { color: #c8e3ec; font: 500 11px ui-monospace, monospace; letter-spacing: .12em; }
.interaction-prompt { position: absolute; left: 50%; bottom: 108px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; color: #d9edf3; padding: 8px 12px; border-left: 1px solid var(--cyan); background: linear-gradient(90deg, rgba(5,17,26,.92), rgba(5,17,26,.64)); font: 10px ui-monospace, monospace; letter-spacing: .13em; }
kbd { min-width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid rgba(61,231,255,.55); color: var(--cyan); font: 10px ui-monospace, monospace; box-shadow: inset 0 0 8px rgba(61,231,255,.08); }
.hotbar { position: absolute; display: flex; gap: 5px; bottom: 18px; left: 50%; transform: translateX(-50%); }
.slot { width: 62px; height: 58px; position: relative; display: grid; place-items: center; background: rgba(3,10,17,.78); border: 1px solid rgba(89,130,148,.24); box-shadow: 0 8px 20px rgba(0,0,0,.3); }
.slot.active { border-color: var(--cyan); box-shadow: inset 0 -2px var(--cyan), 0 0 15px rgba(61,231,255,.12); }
.slot-key { position: absolute; top: 4px; left: 5px; color: #557280; font: 8px ui-monospace, monospace; }
.slot-icon { font-size: 18px; color: #83dbea; filter: drop-shadow(0 0 6px rgba(61,231,255,.35)); }
.slot-count { position: absolute; right: 5px; bottom: 4px; color: #d9f7ff; font: 9px ui-monospace, monospace; }
.slot-name { position: absolute; width: 100%; bottom: -14px; left: 0; text-align: center; color: #67818e; font: 7px ui-monospace, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-stack { position: absolute; right: 18px; bottom: 95px; width: 320px; display: grid; gap: 7px; }
.toast { padding: 11px 13px; border-right: 2px solid var(--cyan); background: rgba(4,14,23,.92); color: #bcd2dc; font: 10px/1.45 ui-monospace, monospace; letter-spacing: .04em; animation: toastIn .28s ease-out; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.toast.warn { border-color: var(--amber); }
.autosave { position: absolute; bottom: 24px; right: 22px; color: var(--cyan); opacity: 0; font: 8px ui-monospace, monospace; letter-spacing: .18em; transition: opacity .25s; }
.autosave.show { opacity: .8; }

.menu-screen { z-index: 30; align-items: center; justify-content: center; background: rgba(1,4,8,.72); }
.menu-panel { width: 540px; padding: 30px; }
.menu-panel.large h2 { font-size: 36px; font-weight: 200; letter-spacing: .25em; margin: 8px 0 24px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-screen { z-index: 40; align-items: center; justify-content: center; background: rgba(0,3,7,.68); }
.modal-panel { position: relative; width: min(760px, 88%); max-height: 84%; padding: 31px; overflow: auto; scrollbar-color: var(--cyan) #071018; }
.icon-button { position: absolute; z-index: 2; top: 10px; right: 10px; min-height: 28px; width: 30px; padding: 0; border: 0; background: transparent; font: 25px/1 sans-serif; color: #7795a3; }
.modal-panel h2 { margin: 4px 0 8px; color: #e0f6ff; font-weight: 300; font-size: 27px; letter-spacing: .14em; text-transform: uppercase; }
.modal-panel h3 { color: var(--cyan); font: 600 10px ui-monospace, monospace; letter-spacing: .18em; text-transform: uppercase; margin: 24px 0 10px; }
.modal-panel p { color: #a9c0cb; font-size: 13px; line-height: 1.7; }
.modal-panel .meta { color: #587787; font: 9px ui-monospace, monospace; letter-spacing: .13em; }
.modal-panel .quote { margin: 19px 0; padding: 17px 19px; border-left: 2px solid var(--magenta); background: rgba(255,61,154,.035); color: #c8d9e0; white-space: pre-line; }
.settings-grid { display: grid; grid-template-columns: 1fr 220px; gap: 16px 24px; align-items: center; margin-top: 25px; }
.settings-grid label { color: #9cb3bd; font: 10px ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
input[type="range"] { accent-color: var(--cyan); width: 100%; }
.toggle { justify-self: end; min-width: 125px; }
.toggle.on { color: var(--green); border-color: rgba(61,255,154,.4); }
.inventory-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 19px; }
.inventory-item { min-height: 73px; padding: 12px; border: 1px solid rgba(95,136,153,.18); background: rgba(5,14,21,.55); display: grid; grid-template-columns: 43px 1fr auto; gap: 10px; align-items: center; }
.inventory-item .item-icon { color: var(--cyan); font-size: 22px; text-align: center; }
.inventory-item strong { display: block; color: #d0e7ef; font: 600 10px ui-monospace, monospace; letter-spacing: .08em; }
.inventory-item small { display: block; color: #65808c; font-size: 9px; line-height: 1.4; margin-top: 4px; }
.inventory-item em { color: var(--cyan); font: normal 11px ui-monospace, monospace; }
.log-list { display: grid; gap: 7px; margin-top: 18px; }
.log-button { text-align: left; min-height: 52px; }
.log-button small { display: block; color: #587482; font-size: 8px; margin-top: 3px; }
.help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 28px; margin-top: 20px; }
.help-row { display: grid; grid-template-columns: 105px 1fr; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(82,126,145,.13); color: #94acb7; font-size: 11px; }
.help-row b { color: var(--cyan); font: 10px ui-monospace, monospace; letter-spacing: .08em; }
.terminal-form { display: flex; gap: 8px; margin-top: 18px; }
.terminal-form input { flex: 1; height: 44px; padding: 0 14px; border: 1px solid rgba(61,231,255,.35); outline: none; background: #030a10; color: var(--cyan); font: 13px ui-monospace, monospace; letter-spacing: .2em; text-transform: uppercase; }
.terminal-form button { min-width: 130px; }
.choice-list { display: grid; gap: 9px; margin-top: 20px; }
.choice-list button { min-height: 55px; text-align: left; }
.choice-list button span { display: block; margin-top: 4px; color: #67838f; font-size: 8px; letter-spacing: .05em; text-transform: none; }
#map-canvas { width: 100%; aspect-ratio: 16/8; display: block; margin-top: 18px; background: #03090e; border: 1px solid rgba(61,231,255,.2); }

.ending-screen { z-index: 50; align-items: center; justify-content: center; text-align: center; background: #020409; }
.ending-vignette { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(61,231,255,.18), transparent 48%), linear-gradient(90deg, rgba(255,61,154,.04), transparent, rgba(61,231,255,.04)); animation: endingGlow 5s ease-in-out infinite; }
.ending-copy { position: relative; z-index: 2; width: min(680px, 80%); }
.ending-copy h2 { margin: 12px 0 20px; color: #ecfbff; font-size: 43px; font-weight: 200; letter-spacing: .17em; }
.ending-copy p { color: #9db6c2; line-height: 1.8; font-size: 14px; }
.ending-stats { margin: 26px auto; color: #668592; font: 9px ui-monospace, monospace; letter-spacing: .13em; }
.ending-copy button { min-width: 220px; }

.screen-grain { pointer-events: none; position: absolute; inset: -30%; z-index: 60; opacity: .045; 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='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E"); animation: grain .22s steps(2) infinite; }
.scanlines { pointer-events: none; position: absolute; inset: 0; z-index: 59; opacity: .15; background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,.35) 3px 4px); }
.transition { pointer-events: none; position: absolute; inset: 0; z-index: 55; background: #02070c; opacity: 0; }
.transition.active { animation: roomWipe .7s ease-in-out; }

@keyframes sonar { to { transform: rotate(360deg) scale(1.04); } }
@keyframes drift { to { transform: translate3d(-83px, 101px, 0); } }
@keyframes logoPulse { 0%,100% { filter: brightness(.9); } 50% { filter: brightness(1.15); } }
@keyframes glitch { 0%,94%,100% { opacity: 0; transform: translateX(0); } 95% { opacity: .8; transform: translateX(5px); } 96% { opacity: .35; transform: translateX(-6px); } 97% { opacity: 0; } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes grain { 0% { transform: translate(0,0); } 25% { transform: translate(3%, -2%); } 50% { transform: translate(-2%, 4%); } 75% { transform: translate(4%, 2%); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }
@keyframes roomWipe { 0%,100% { opacity: 0; transform: scaleX(0); } 35%,65% { opacity: 1; transform: scaleX(1); } }
@keyframes endingGlow { 50% { filter: hue-rotate(40deg) brightness(1.3); } }

@media (max-width: 760px) {
  .title-stack { transform: scale(.8); }
  .hud-top { top: 80px; min-width: 300px; }
  .room-tag { display: none; }
  .menu-panel { transform: scale(.88); }
  .slot { width: 48px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; } }
