:root {
    --bg: #07050d; --ink: #ecebf5; --dim: #9a93b8; --pink: #ff3d8b; --cyan: #3cf0ff; --amber: #ffb238; --violet: #a46bff; --red: #ff2f5a;
    --panel: rgba(14, 10, 26, .94); --line: rgba(160, 140, 255, .22);
    --display: "Bungee", "Azeret Mono", monospace; --mono: "Azeret Mono", ui-monospace, monospace; --hand: "Caveat", "Comic Sans MS", cursive;
    --cut: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 500 15px/1.45 var(--mono); overflow: hidden; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; visibility: hidden; }
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); overflow: auto; }
.screen.menu { place-items: start center; align-content: start; gap: 14px; background: radial-gradient(ellipse at 50% 0, #2a0f4a, var(--bg) 70%); }
#game.screen { display: block; padding: 0; pointer-events: none; overflow: hidden; }
#game .hud, #game .inv, #game .closeup, #game .side, #game .chatbox, #game .overlay, #game .toasts > * { pointer-events: auto; }

/* ---------- title ---------- */
#title { background: var(--bg); }
.hero { position: fixed; inset: 0; background: url(art/hero.webp) center/cover; filter: saturate(1.15); animation: drift 30s ease-in-out infinite alternate; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(7, 5, 13, .92) 0, rgba(7, 5, 13, .55) 55%, rgba(7, 5, 13, .1)), linear-gradient(0deg, rgba(7, 5, 13, .9), transparent 40%); }
@keyframes drift { to { transform: scale(1.08) translateX(-2%); } }
.title-box { position: relative; justify-self: start; max-width: 560px; margin-left: clamp(0px, 4vw, 70px); animation: rise .9s cubic-bezier(.2, .9, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }
.kicker { font: 600 11px var(--mono); letter-spacing: .28em; text-transform: uppercase; color: var(--cyan); margin: 0 0 6px; }
h1 { font: 400 clamp(54px, 12vw, 116px)/.86 var(--display); margin: 0; display: grid; }
h1 .n1 { color: #fff; text-shadow: 0 0 8px var(--pink), 0 0 26px var(--pink), 0 0 60px rgba(255, 61, 139, .6); animation: flick 6s infinite; }
h1 .n2 { color: transparent; -webkit-text-stroke: 2px var(--cyan); text-shadow: 0 0 22px rgba(60, 240, 255, .55); letter-spacing: .04em; }
@keyframes flick { 0%, 19%, 21%, 62%, 64%, 100% { opacity: 1; } 20%, 63% { opacity: .35; } }
.tag { color: #cfc8e8; margin: 16px 0 18px; max-width: 480px; }
.namebox { display: flex; gap: 10px; align-items: center; color: var(--dim); font-size: 13px; margin-bottom: 14px; }
input, select { font: 700 15px var(--mono); color: var(--ink); background: rgba(10, 8, 20, .85); border: 1px solid var(--line); border-radius: 0; padding: 9px 11px; clip-path: var(--cut); }
input:focus, select:focus { outline: 1px solid var(--cyan); }
.col { display: grid; gap: 10px; justify-items: start; }
.joinrow { display: flex; gap: 8px; }
.joinrow input { width: 150px; text-transform: uppercase; letter-spacing: .15em; }
.link { color: var(--dim); font-size: 13px; text-decoration: none; margin-top: 8px; }
.link:hover { color: var(--cyan); }

/* ---------- buttons ---------- */
.btn { font: 800 14px var(--mono); color: var(--ink); background: linear-gradient(180deg, #221a3a, #120d22); border: 0; clip-path: var(--cut); padding: 11px 16px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; box-shadow: inset 0 0 0 1px var(--line); transition: filter .15s, transform .08s; }
.btn:hover { filter: brightness(1.25); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { font-size: 16px; padding: 15px 22px; min-width: min(340px, 86vw); }
.btn.neon { background: linear-gradient(90deg, var(--pink), #ff7a3c); color: #12040c; box-shadow: 0 0 24px rgba(255, 61, 139, .45); }
.btn.gold { background: linear-gradient(90deg, var(--amber), #ffe08a); color: #1a0f00; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { font-size: 12px; padding: 6px 10px; }
.ib { width: 40px; height: 40px; border: 0; background: rgba(12, 9, 24, .78); color: var(--ink); font: 800 15px var(--mono); cursor: pointer; clip-path: var(--cut); box-shadow: inset 0 0 0 1px var(--line); position: relative; }
.ib.on { background: var(--violet); color: #fff; }
.ib b { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--pink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.faint { color: var(--dim); font-size: 13px; }

/* ---------- lobby ---------- */
.bar { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; width: min(920px, 100%); }
.bar h2 { font: 400 26px var(--display); margin: 0; text-align: center; color: var(--amber); letter-spacing: .08em; }
.lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; width: min(920px, 100%); }
.panel { background: var(--panel); padding: 16px; clip-path: var(--cut); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 10px; align-content: start; }
.panel h3 { font: 400 18px var(--display); margin: 0; color: var(--cyan); }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255, 255, 255, .04); }
.plist .sw { width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.plist .rl { margin-left: auto; font-size: 12px; color: var(--dim); }
.plist .me { color: var(--amber); }
.seg { display: grid; gap: 6px; }
.seg button { font: 700 13px var(--mono); color: var(--ink); background: rgba(255, 255, 255, .05); border: 1px solid var(--line); padding: 10px; cursor: pointer; text-align: left; }
.seg button.on { background: rgba(60, 240, 255, .14); border-color: var(--cyan); color: #fff; }
.looks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.looks button { width: 100%; height: 96px; display: grid; place-items: center; position: relative; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); cursor: pointer; padding: 0; }
.looks button.on { border-color: var(--amber); background: rgba(255, 178, 56, .12); }
.looks canvas { width: auto; height: 84px; }
.looks button span { position: absolute; bottom: 2px; font: 700 10px var(--mono); color: var(--c); }
.mine p { margin: 0 0 4px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .15em; }

/* ---------- HUD ---------- */
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 10px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.clockbox { background: rgba(10, 6, 20, .82); clip-path: var(--cut); padding: 6px 12px 8px; box-shadow: inset 0 0 0 1px rgba(255, 47, 90, .4); min-width: 132px; }
.clockbox .lbl { display: block; font: 700 9px var(--mono); letter-spacing: .25em; color: var(--red); }
#h-clock { font: 400 26px/1 var(--display); color: #fff; text-shadow: 0 0 12px rgba(255, 47, 90, .8); }
#h-clock.low { color: var(--red); animation: pulse .8s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.track { height: 4px; background: rgba(255, 255, 255, .1); margin-top: 6px; position: relative; }
.track i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--cyan), var(--red)); }
.trainmap { display: flex; gap: 3px; align-items: center; background: rgba(10, 6, 20, .7); padding: 8px; clip-path: var(--cut); margin: 0 auto; }
.trainmap button { position: relative; width: 52px; height: 30px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--dim); font: 700 10px var(--mono); cursor: pointer; padding: 0; }
.trainmap button.last { border-radius: 0 14px 4px 0; }
.trainmap button.open { color: var(--ink); border-color: rgba(60, 240, 255, .5); }
.trainmap button.shut { opacity: .5; }
.trainmap button.view { background: rgba(60, 240, 255, .2); border-color: var(--cyan); color: #fff; }
.trainmap .dots { position: absolute; left: 2px; right: 2px; bottom: -6px; display: flex; gap: 2px; justify-content: center; }
.trainmap .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 5px var(--c); }
.hud-right { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; max-width: 50vw; }
.role-banner { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); margin: 0; font: 700 12px var(--mono); letter-spacing: .12em; color: var(--cyan); background: rgba(8, 6, 16, .7); padding: 4px 10px; text-transform: uppercase; pointer-events: none; white-space: nowrap; }

/* inventory */
.inv { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 8px max(10px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); overflow-x: auto; background: linear-gradient(0deg, rgba(7, 5, 13, .92), rgba(7, 5, 13, .5)); z-index: 6; min-height: 74px; align-items: center; }
.inv .lbl { font: 700 10px var(--mono); color: var(--dim); writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: .2em; }
.inv button { flex: none; width: 62px; height: 62px; background: rgba(20, 14, 38, .9); border: 1px solid var(--line); cursor: pointer; display: grid; place-items: center; position: relative; padding: 0; color: var(--ink); }
.inv button.sel { border-color: var(--amber); box-shadow: 0 0 14px rgba(255, 178, 56, .6); background: rgba(255, 178, 56, .15); }
.inv button.cmb { border-color: var(--violet); box-shadow: 0 0 14px rgba(164, 107, 255, .6); }
.inv button.new { animation: newitem 1.2s ease-out; }
@keyframes newitem { from { box-shadow: 0 0 0 3px var(--cyan), 0 0 30px var(--cyan); transform: scale(1.15); } }
.inv button .worn { position: absolute; bottom: 1px; left: 0; right: 0; font-size: 9px; color: var(--violet); text-align: center; }
.inv .empty { color: var(--dim); font-size: 12px; }
.ic { display: grid; place-items: center; width: 50px; height: 50px; position: relative; }
.ic.art img { max-width: 100%; max-height: 100%; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }
.ictag { position: absolute; right: 0; bottom: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 2px solid #111; }
.ic.paper { background: var(--p); width: 40px; height: 48px; padding: 9px 7px; display: grid; gap: 5px; align-content: start; transform: rotate(-4deg); box-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
.ic.paper i { height: 2px; background: rgba(0, 0, 0, .35); }
.ic.plate { width: 44px; height: 44px; background: linear-gradient(#e9edf5, #9aa3b5); border-radius: 6px; color: #111; box-shadow: 0 3px 0 #555; }
.ic.plate svg { color: #111; }
.ic.stencil { width: 46px; height: 46px; background: #e8d8a8; display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; padding: 3px; }
.ic.stencil i.h { background: #111; border-radius: 50%; }

/* ---------- close-up ---------- */
.closeup { position: absolute; inset: 0 0 78px; display: flex; align-items: center; justify-content: center; padding: 60px 10px 10px; background: rgba(3, 2, 8, .55); z-index: 5; }
.cu { width: min(560px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: var(--panel); clip-path: var(--cut); box-shadow: inset 0 0 0 1px rgba(60, 240, 255, .35); }
.closeup.fresh .cu { animation: cuin .18s ease-out; }
.cu header { position: sticky; top: 0; z-index: 2; background: #160f28; }
@keyframes cuin { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.cu header { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(255, 61, 139, .12), transparent); }
.cu-art { width: 56px; height: 56px; object-fit: contain; }
.cu h3 { font: 400 18px var(--display); margin: 0; }
.cu .sub { margin: 0; color: var(--dim); font-size: 12px; }
.x { background: none; border: 0; color: var(--ink); font-size: 20px; cursor: pointer; padding: 6px; }
.cu-body { padding: 14px; display: grid; gap: 12px; }
.cu-body h4 { margin: 0; font: 400 14px var(--display); color: var(--amber); }
.done { color: var(--cyan); font-size: 13px; }
.ok { color: var(--cyan); margin: 0; }
.model { margin: 0; font-size: 13px; color: var(--dim); } .model b { color: #fff; background: #333; padding: 1px 6px; }
.selhint { margin: 0; padding: 8px 14px; background: rgba(255, 178, 56, .14); color: var(--amber); font-size: 13px; }
.tagchip { display: inline-flex; align-items: center; gap: 4px; font: 800 12px var(--mono); color: #0b0b14; background: var(--c); padding: 2px 8px 2px 4px; border-radius: 99px; vertical-align: middle; white-space: nowrap; }
.tagchip svg { color: #0b0b14; }
.lock { background: rgba(255, 255, 255, .03); border: 1px solid var(--line); padding: 12px; display: grid; gap: 10px; justify-items: center; position: relative; }
.lock.shake { animation: shake .4s; border-color: var(--red); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.lock.dead > *:not(.lockhead):not(.nopower) { opacity: .25; pointer-events: none; }
.nopower { position: absolute; inset: auto 0 40%; text-align: center; font: 400 22px var(--display); color: var(--red); text-shadow: 0 0 12px var(--red); }
.lockhead { justify-self: start; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }
.wheels { display: flex; gap: 6px; }
.wheel { display: grid; justify-items: center; background: linear-gradient(90deg, #2a2a33, #6a6a78 50%, #2a2a33); padding: 2px; }
.wheel b { font: 800 30px var(--mono); color: #f4f4f8; width: 46px; text-align: center; background: linear-gradient(#111 0, #333 30%, #444 50%, #333 70%, #111); padding: 4px 0; }
.wheel button, .pad button, .dpad button { font: 800 16px var(--mono); color: var(--ink); background: #1b1630; border: 1px solid var(--line); cursor: pointer; width: 46px; height: 34px; }
.lcd { font: 800 28px var(--mono); letter-spacing: .25em; color: #9dffcf; background: #04120c; padding: 6px 16px; min-width: 200px; text-align: center; box-shadow: inset 0 0 12px rgba(0, 255, 140, .25); }
.lcd.freq { color: var(--amber); background: #140b02; letter-spacing: .05em; }
.pad { display: grid; grid-template-columns: repeat(3, 64px); gap: 6px; }
.pad button { width: 64px; height: 48px; font-size: 20px; }
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 48px); gap: 4px; }
.dpad button { width: 56px; height: 48px; font-size: 22px; }
.dpad [data-dir=U] { grid-column: 2; grid-row: 1; } .dpad [data-dir=L] { grid-column: 1; grid-row: 2; } .dpad [data-dir=R] { grid-column: 3; grid-row: 2; } .dpad [data-dir=D] { grid-column: 2; grid-row: 3; }
.symkeys { display: grid; grid-template-columns: repeat(3, 72px); gap: 8px; }
.sk { width: 72px; height: 72px; background: linear-gradient(#f2f4fa, #a8b0c2); border: 0; border-radius: 8px; box-shadow: 0 4px 0 #4a4f5c; color: #111; cursor: pointer; display: grid; place-items: center; }
.sk svg { color: #111; }
.sk.lit { background: linear-gradient(#bffaff, #54d8f0); box-shadow: 0 4px 0 #1d6070, 0 0 16px var(--cyan); }
.sk.missing { background: #111; box-shadow: inset 0 0 0 2px #444; color: #666; font: 800 26px var(--mono); }
.seq { display: flex; gap: 8px; }
.seq i { width: 16px; height: 16px; border-radius: 50%; background: #222; border: 1px solid #555; }
.seq i.on { background: var(--c, var(--cyan)); box-shadow: 0 0 8px var(--c, var(--cyan)); }
.levers { display: flex; gap: 14px; }
.lever { width: 40px; height: 110px; background: #15121f; border: 1px solid var(--line); position: relative; cursor: pointer; }
.lever i { position: absolute; left: 7px; right: 7px; height: 46px; background: linear-gradient(#ff9a5a, #c2391e); border-radius: 6px; transition: top .15s; box-shadow: 0 3px 0 #5a1a0a; }
.lever.up i { top: 6px; } .lever.dn i { top: 56px; }
.cbtns { display: flex; gap: 10px; }
.cbtns button { width: 56px; height: 56px; border-radius: 50%; border: 3px solid rgba(0, 0, 0, .5); background: radial-gradient(circle at 35% 30%, #fff8, var(--c) 45%); color: rgba(0, 0, 0, .55); font: 800 14px var(--mono); cursor: pointer; box-shadow: 0 0 14px var(--c); }
.cbtns button:active { filter: brightness(1.6); }
.patch { position: relative; width: 280px; height: 200px; }
.patch svg { position: absolute; inset: 0; pointer-events: none; }
.plugs, .sockets { position: absolute; top: 0; bottom: 0; display: grid; grid-template-rows: repeat(4, 50px); align-items: center; }
.plugs { left: 10px; } .sockets { right: 10px; }
.plug { width: 60px; height: 36px; background: var(--c); border: 2px solid #111; font: 800 13px var(--mono); cursor: pointer; border-radius: 6px 18px 18px 6px; }
.plug.sel { outline: 3px solid #fff; box-shadow: 0 0 14px var(--c); }
.sock { width: 50px; height: 36px; background: #0a0a12; color: var(--amber); border: 2px solid #555; font: 800 16px var(--mono); cursor: pointer; border-radius: 50% 8px 8px 50%; }
input[type=range] { width: 100%; clip-path: none; padding: 0; }
.brakes { display: flex; gap: 18px; }
.brake { width: 110px; height: 150px; background: #1a0d10; border: 2px solid var(--red); cursor: pointer; display: grid; align-items: end; justify-items: center; padding: 8px; position: relative; color: var(--ink); font: 800 12px var(--mono); touch-action: none; }
.brake i { position: absolute; top: 14px; width: 26px; height: 90px; background: linear-gradient(90deg, #ff4d4d, #8a1010); border-radius: 13px; transition: transform .2s; transform-origin: bottom center; }
.brake.held { background: #3a0d12; box-shadow: 0 0 24px var(--red); }
.brake.held i { transform: scaleY(.55) translateY(70px); }
.socket { display: flex; gap: 12px; align-items: center; width: 100%; padding: 14px; background: #0b0912; border: 2px dashed rgba(255, 178, 56, .5); color: var(--ink); font: 600 14px var(--mono); cursor: pointer; text-align: left; }
.socket .si { font-size: 26px; width: 40px; text-align: center; }
.loot { display: flex; gap: 8px; flex-wrap: wrap; }
.lootitem { display: grid; justify-items: center; gap: 4px; width: 100px; padding: 8px 4px; background: rgba(60, 240, 255, .07); border: 1px solid rgba(60, 240, 255, .4); color: var(--ink); font: 600 11px var(--mono); cursor: pointer; }
.lootitem:hover { background: rgba(60, 240, 255, .18); }
.toggles { display: grid; gap: 8px; }
.tog { display: flex; align-items: center; gap: 10px; padding: 12px; background: #120e1e; border: 1px solid var(--line); color: var(--ink); font: 700 14px var(--mono); cursor: pointer; }
.tog i { width: 18px; height: 18px; border-radius: 50%; background: #333; }
.tog b { margin-left: auto; color: var(--dim); }
.tog.on b { color: #fff; }
.tog.lights.on i { background: #ffe28a; box-shadow: 0 0 12px #ffe28a; } .tog.uv.on i { background: #b25cff; box-shadow: 0 0 12px #b25cff; } .tog.heat.on i { background: #ff7a2f; box-shadow: 0 0 12px #ff7a2f; }
.aids { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 700 12px var(--mono); background: #1a1530; color: var(--ink); border: 1px solid var(--line); padding: 6px 10px; cursor: pointer; }
.chip.on { background: var(--amber); color: #1a0f00; }
.morse { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.morse .lamp { width: 34px; height: 34px; border-radius: 50%; background: #331a08; border: 2px solid #111; }
.morse .lamp.on { background: #ffcf5a; box-shadow: 0 0 22px #ffcf5a; }
.acts { margin-top: 4px; }

/* clues */
.surface { display: grid; place-items: center; }
.note { position: relative; width: min(380px, 100%); padding: 18px 20px; color: #2a2230; font: 700 26px/1.2 var(--hand); background: #efe6cf; transform: rotate(-1.2deg); box-shadow: 0 8px 20px rgba(0, 0, 0, .5); }
.note.napkin { background: #f6f0e8 repeating-linear-gradient(45deg, transparent 0 8px, rgba(0, 0, 0, .03) 8px 9px); }
.note.ticket { background: #ffd9a8; border-left: 6px dashed rgba(0, 0, 0, .2); }
.note.datapad { background: #10202e; color: #8fe9ff; font-family: var(--mono); font-size: 17px; border: 2px solid #2f4a5e; transform: none; }
.note p { margin: 0 0 8px; }
.note .sig { font-size: 20px; opacity: .75; margin-top: 10px; }
.val { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: center; font: 400 40px/1.1 var(--hand); }
.val .ch { font-weight: 700; }
.val .ch.unit { font-size: 22px; align-self: flex-end; }
.val .ch.sym svg { color: currentColor; }
.val .ch.lev { font: 700 24px sans-serif; } .val .ch.lev.up { color: #c2391e; } .val .ch.lev.dn { color: #1e4ec2; }
.dot, .val .ch.dot { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: rgba(0, 0, 0, .6); font: 800 12px var(--mono); box-shadow: 0 0 6px var(--c); vertical-align: middle; }
.ch.wire { font: 700 22px var(--mono); display: inline-flex; gap: 4px; align-items: center; }
.val.small { font-size: 18px; justify-content: flex-start; font-family: var(--mono); }
.val.small .dot { width: 20px; height: 20px; font-size: 10px; }
.uvink { color: transparent; }
.uvink.lit { color: #e2a6ff; text-shadow: 0 0 10px #b25cff, 0 0 24px #8a2cff; }
.note.uvlit { background: #2a1450; color: #d9b8ff; }
.note.wall { background: #2b2f3a; color: #aab; transform: none; }
.note.darkroom { background: #05060a; }
.glow { color: transparent; } .glow.lit { color: #d8ff7a; text-shadow: 0 0 12px #a6ff3a, 0 0 30px #6fff1a; }
.glowt .tagchip { box-shadow: 0 0 12px var(--c); }
.pane { width: min(380px, 100%); min-height: 160px; display: grid; place-items: center; background: linear-gradient(160deg, #1a2440, #0a0f1e); border: 6px solid #333a4a; color: #9ab; }
.pane.fogged { background: radial-gradient(circle at 40% 40%, #dfe6ee, #b4bfcc); color: #24334a; }
.finger { text-align: center; } .finger .val { font-size: 46px; filter: blur(.4px); }
.redbox { position: relative; height: 120px; overflow: hidden; background: #fbf3ef; }
.redbox .noise i { position: absolute; font: 800 30px var(--mono); color: rgba(225, 30, 40, .85); font-style: normal; }
.redbox .hidden-ink { position: absolute; inset: 0; color: rgba(70, 170, 220, .32); font-family: var(--mono); font-size: 44px; }
.redbox.filtered { background: #ff1a2a; }
.redbox.filtered .noise { opacity: 0; }
.redbox.filtered .hidden-ink { color: #1a0004; }
.note.redview { background: #ff3a3a; color: #2a0000; }
.mirrored { transform: scaleX(-1); }
.val.micro { font: 600 4px/1 var(--mono); letter-spacing: 0; opacity: .8; }
.val.micro .ch.sym svg { width: 6px; height: 6px; }
.val.lens { border-radius: 50%; border: 6px solid #b88a3a; padding: 28px 12px; background: radial-gradient(circle, #fff9, transparent 75%); font-family: var(--mono); font-size: 34px; }
.val.cipher { font: 800 28px var(--mono); letter-spacing: .06em; }
.note.torn.left { clip-path: polygon(0 0, 88% 0, 96% 20%, 86% 42%, 97% 64%, 88% 84%, 95% 100%, 0 100%); }
.note.torn.right { clip-path: polygon(6% 0, 100% 0, 100% 100%, 8% 100%, 0 80%, 10% 60%, 2% 38%, 12% 18%); }
.note.taped::after { content: ""; position: absolute; top: -6px; bottom: -6px; left: 48%; width: 30px; background: rgba(255, 255, 220, .55); transform: rotate(3deg); }
.hand { font-family: var(--hand); font-size: 26px; }
.term { width: min(420px, 100%); background: #031418; color: #6ef2ff; font: 600 15px var(--mono); padding: 14px; border: 2px solid #155; box-shadow: inset 0 0 30px rgba(60, 240, 255, .15); }
.term p { margin: 0 0 6px; } .term .val { font-family: var(--mono); font-size: 30px; justify-content: flex-start; color: #fff; }
.blink { animation: pulse 1s steps(1) infinite; }
.lightbox { background: #0d0b18; padding: 12px; border: 3px solid var(--pink); box-shadow: 0 0 20px rgba(255, 61, 139, .4); width: min(380px, 100%); }
.koi { width: 100%; height: auto; }
.legend { margin: 8px 0 0; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.legend .dot { width: 22px; height: 22px; font-size: 10px; }
.clockface { display: grid; justify-items: center; gap: 8px; }
.clk { width: 200px; height: 200px; } .clk circle:first-child { fill: #f4f4f0; stroke: #888; stroke-width: 4; }
.clk .tk line { stroke: #222; stroke-width: 2; } .clk .hh { stroke: #111; stroke-width: 6; stroke-linecap: round; } .clk .mm { stroke: #111; stroke-width: 3.5; stroke-linecap: round; } .clk circle:last-child { fill: #c00; }
.lettergrid { display: grid; justify-items: center; gap: 8px; }
.grid6 { display: grid; grid-template-columns: repeat(6, 40px); gap: 4px; background: #232838; padding: 10px; }
.grid6 i { font: 800 22px var(--mono); font-style: normal; color: #d8f4ff; text-align: center; padding: 4px 0; }
.stencilled .grid6 { background: #e8d8a8; }
.grid6 i.masked { color: transparent; }
.grid6 i.hole { background: #111; border-radius: 50%; color: #fff; }

/* side panel: archive / hints */
.side { position: absolute; top: 60px; right: 8px; bottom: 82px; width: min(420px, calc(100% - 16px)); background: var(--panel); clip-path: var(--cut); box-shadow: inset 0 0 0 1px rgba(164, 107, 255, .45); z-index: 7; display: grid; grid-template-rows: auto 1fr; }
.side header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.side header nav { font: 400 16px var(--display); color: var(--violet); }
#side-body { overflow: auto; padding: 12px; }
.atabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.atabs button { font: 700 12px var(--mono); background: #1a1530; color: var(--ink); border: 1px solid var(--line); padding: 6px 9px; cursor: pointer; }
.atabs button.on { background: var(--violet); color: #fff; }
.abody p { margin: 0 0 8px; font-size: 13px; }
.cgrid { border-collapse: collapse; margin: 0 auto; }
.cgrid th, .cgrid td { width: 40px; height: 40px; text-align: center; border: 1px solid var(--line); font: 800 18px var(--mono); }
.cgrid th { color: var(--amber); font-size: 13px; }
.mchart { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 4px 10px; font-size: 14px; }
.mchart b { display: inline-block; width: 18px; color: var(--amber); }
.reg { width: 100%; border-collapse: collapse; font-size: 13px; }
.reg td, .reg th { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; }
.guide { padding-left: 18px; margin: 0; font-size: 13px; } .guide li { margin-bottom: 8px; }
.hrow { border: 1px solid var(--line); padding: 10px; margin-bottom: 8px; display: grid; gap: 6px; }
.hrow .hh { font-size: 13px; }
.hint { margin: 0; font-size: 13px; color: #e8dcff; } .hint.h2 { color: var(--amber); font-weight: 800; }

/* chat */
.chatbox { position: absolute; left: 8px; bottom: 82px; width: min(360px, calc(100% - 16px)); background: var(--panel); clip-path: var(--cut); box-shadow: inset 0 0 0 1px var(--line); z-index: 7; padding: 10px; display: grid; gap: 8px; }
.chatbox .log { max-height: 30vh; overflow: auto; font-size: 13px; display: grid; gap: 3px; }
.chatbox .log b { color: var(--amber); }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }
.quick button { font: 600 11px var(--mono); background: #1a1530; color: var(--ink); border: 1px solid var(--line); padding: 4px 7px; cursor: pointer; }
#chat-form { display: flex; gap: 6px; } #chat-form input { flex: 1; min-width: 0; }

.toasts { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; z-index: 9; pointer-events: none; width: min(560px, 92vw); }
.toast { background: rgba(10, 6, 20, .92); border-left: 3px solid var(--cyan); padding: 8px 14px; font-size: 13px; animation: cuin .2s; box-shadow: 0 4px 20px rgba(0, 0, 0, .5); }
.toast.warn { border-color: var(--red); } .toast.good { border-color: var(--amber); } .toast.chat { border-color: var(--violet); }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(3, 2, 8, .6); z-index: 10; padding: 16px; }
.overlay .card { background: var(--panel); clip-path: var(--cut); padding: 26px; text-align: center; max-width: 460px; box-shadow: inset 0 0 0 1px var(--line); animation: cuin .3s; }
.overlay h2 { font: 400 38px var(--display); margin: 0 0 8px; }
.card.win h2 { color: var(--cyan); text-shadow: 0 0 20px var(--cyan); } .card.lose h2 { color: var(--red); text-shadow: 0 0 20px var(--red); }
.loading { position: fixed; inset: auto 0 0 0; padding: 10px; display: grid; gap: 4px; font-size: 12px; color: var(--dim); z-index: 20; pointer-events: none; }
.loading i { display: block; height: 3px; background: var(--pink); width: 0; transition: width .2s; }

@media (max-width: 640px) {
    .trainmap button { width: 34px; font-size: 9px; }
    .clockbox { min-width: 92px; padding: 5px 8px 7px; } #h-clock { font-size: 20px; }
    .hud-right { max-width: 46vw; } .ib { width: 34px; height: 34px; font-size: 13px; }
    .role-banner { top: 112px; font-size: 10px; }
    .pad { grid-template-columns: repeat(3, 56px); } .pad button { width: 56px; }
    .symkeys { grid-template-columns: repeat(3, 62px); } .sk { width: 62px; height: 62px; }
}
@media (max-height: 460px) {
    .closeup { padding-top: 54px; inset: 0 0 70px; } .inv { min-height: 66px; padding-top: 4px; } .inv button { width: 54px; height: 54px; }
    .note { font-size: 22px; } .val { font-size: 32px; }
}

/* Tick Box manual pages inside the train (rules scoped from ../manual.css) */
.tbman { --paper: #f2e9d4; --paper2: #e9dcbf; --ink: #231a12; --dim: #6a5a44; --red: #b8321f; --rule: rgba(35, 26, 18, .25);
    --display: "Fraunces", Georgia, serif; --mono: "IBM Plex Mono", ui-monospace, monospace; }
.tbman .page, .tbman .cover { background: var(--paper); background-image: radial-gradient(ellipse at 20% 0, rgba(255, 255, 255, .5), transparent 60%), linear-gradient(var(--paper), var(--paper2));
    border-radius: 4px; padding: 22px clamp(14px, 4vw, 34px); margin: 0 0 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); position: relative; }
.tbman .cover { text-align: center; padding: 48px 20px; border-top: 10px solid var(--red); }
.tbman .cover h1 { font: 900 clamp(38px, 8vw, 64px)/1 var(--display); margin: 8px 0 14px; }
.tbman .cover h1 em { font-weight: 500; font-style: italic; color: var(--red); }
.tbman .kicker { letter-spacing: .3em; text-transform: uppercase; font-size: 11px; color: var(--red); margin: 0; }
.tbman .cover p { max-width: 560px; margin: 10px auto; }
.tbman .warn { border: 2px dashed var(--red); padding: 8px 12px; border-radius: 6px; color: var(--red); font-weight: 700; }
.tbman h2 { font: 900 28px/1.1 var(--display); margin: 0 0 12px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.tbman h2 span { color: var(--red); font-weight: 500; margin-right: 6px; }
.tbman h2 small { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .15em; background: var(--red); color: #fff; padding: 2px 7px; border-radius: 99px; vertical-align: 6px; }
.tbman h4 { font: 800 17px var(--display); margin: 14px 0 6px; }
.tbman ol, .tbman ul { padding-left: 22px; margin: 6px 0; }
.tbman li { margin: 3px 0; }
.tbman .mono { font-family: var(--mono); font-weight: 700; }
.tbman .lead { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.tbman .fig { width: 120px; height: 120px; border-radius: 6px; flex: none; box-shadow: 0 3px 8px rgba(0, 0, 0, .35); }
.tbman .look { margin: 0; color: var(--dim); font-style: italic; }
.tbman .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 22px; }
.tbman .cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 26px; }
.tbman .t { border-collapse: collapse; margin: 8px 0; font-size: 13.5px; width: auto; max-width: 100%; }
.tbman .t th, .tbman .t td { border: 1px solid var(--rule); padding: 4px 8px; text-align: left; vertical-align: middle; }
.tbman .t th { background: rgba(35, 26, 18, .07); font-weight: 700; }
.tbman .t.small { font-size: 12.5px; }
.tbman .t td svg, .tbman .t th svg { vertical-align: -5px; }
.tbman .page { overflow-x: auto; }
.tbman .sw { display: inline-block; width: 13px; height: 13px; border-radius: 3px; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .4); }
.tbman .lamp { display: inline-block; font: 700 12px var(--mono); background: #2a2420; color: #f3ecd8; padding: 0 6px; border-radius: 4px; }
.tbman .lamp.on { box-shadow: 0 0 0 2px #f3d65a; }
.tbman .sheet { margin-top: 12px; border: 1.5px solid var(--ink); border-radius: 6px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.tbman .sheet b { width: 100%; font-family: var(--display); font-size: 15px; }
.tbman .glyph-cols { display: flex; gap: 8px; flex-wrap: wrap; }
.tbman .gcol { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1.5px solid var(--ink); border-radius: 6px; padding: 6px 4px; background: rgba(255, 255, 255, .35); }
.tbman .gcol b { font-family: var(--display); color: var(--red); }
.tbman .glyph { color: var(--ink); }
.tbman .morse { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 2px 10px; font-size: 13px; margin: 8px 0; }
.tbman .mc b { display: inline-block; width: 16px; color: var(--red); }
.tbman .mazes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tbman .mz { width: 100%; height: auto; }
.tbman .words { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 4px 10px; font-size: 14px; }
.tbman .lpats, .tbman .vpats { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.tbman .lpats > div, .tbman .vpats > div { display: flex; gap: 8px; align-items: center; }
.tbman .lgrid { display: grid; grid-template-columns: repeat(3, 16px); gap: 3px; }
.tbman .vgrid { display: grid; grid-template-columns: repeat(4, 13px); gap: 3px; }
.tbman .lgrid i, .tbman .vgrid i { display: block; height: 16px; border-radius: 3px; border: 1.5px solid var(--ink); }
.tbman .vgrid i { height: 13px; border-radius: 50%; }
.tbman .lgrid i.on, .tbman .vgrid i.on { background: #f0a020; box-shadow: inset 0 0 0 2px #fff3c4; }
.tbman .tip { color: var(--dim); font-size: 13px; }
.tbman .needy { border-left: 6px solid var(--red); }
.tbman .foot { text-align: center; color: var(--dim); font-size: 13px; }
.tbman .foot a { color: var(--red); }
.tbman .pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 2px 14px; font-size: 13.5px; margin: 6px 0; }
.tbman .pairs span { border-bottom: 1px dotted var(--rule); padding: 2px 0; }
.tbman .link { background: none; border: 0; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; padding: 0; }
.tbman .cw { display: inline-flex; align-items: center; gap: 4px; }
.tbman .cw::before { content: ""; width: 18px; height: 6px; border-radius: 3px; background: var(--c); border: 1px solid rgba(0, 0, 0, .5); }
.tbman { color: var(--ink); font: 500 14px/1.5 var(--mono); display: grid; gap: 10px; text-align: left; }
.tbman .page, .tbman .cover { margin: 0; padding: 16px 14px; }
.tbman .cover { padding: 20px 14px; }
.tbman .cover h1 { font-size: 34px; }
.tbman h2 { font-size: 22px; }
.tbman .fig { width: 92px; height: 92px; }
.tbman .tbjump { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 10px; }
.tbman .tbjump button { font: 700 11px var(--mono); background: #fff8; border: 1px solid var(--rule); color: var(--ink); padding: 4px 7px; cursor: pointer; border-radius: 4px; }
.tbman .cw { display: inline-flex; align-items: center; gap: 4px; }
.tbman .cw::before { content: ""; width: 18px; height: 6px; border-radius: 3px; background: var(--c); border: 1px solid rgba(0, 0, 0, .5); }
.cu.item:has(.tbman) { width: min(760px, 100%); }
.ic.book { width: 40px; height: 50px; background: linear-gradient(90deg, #8a2a1a 0 5px, #b8321f 5px); color: #f3e9d4; display: grid; place-content: center; text-align: center; font: 800 6px var(--mono); border-radius: 2px 5px 5px 2px; box-shadow: 0 2px 4px rgba(0,0,0,.5); }
.ic.book i { font: 600 6px var(--mono); font-style: italic; }
/* Tick Box panel in a lock */
.lock.t-tbx { gap: 8px; }
.tbslot { width: min(330px, 100%); }
.tbpanel canvas { display: block; width: 100%; aspect-ratio: 1; touch-action: none; border-radius: 6px; box-shadow: 0 0 0 3px #4a3420, 0 0 0 5px #d4ab55, 0 8px 24px rgba(0,0,0,.6); }
.tbmarks { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center; font: 700 12px var(--mono); background: #f3ecd8; color: #1a1410; padding: 6px 10px; border-radius: 4px; width: 100%; }
.tbmarks span { display: grid; text-align: center; }
.tbmarks i { font: 700 8px var(--mono); font-style: normal; color: #b8321f; letter-spacing: .1em; }
.tbmarks em { font-style: normal; padding: 0 4px; background: #2a2420; color: #f3ecd8; border-radius: 3px; }
.tbmarks em.lit { box-shadow: 0 0 0 2px #f3d65a; }
.tbmarks .code b { background: #1a0f08; color: #ffd890; padding: 0 6px; border-radius: 3px; letter-spacing: .1em; }

/* phones: every lock widget fits a 320px-wide body; short landscape screens get a tighter frame */
.cu header { background-color: #160f28; }
.cbtns { flex-wrap: wrap; justify-content: center; }
.patch { width: min(280px, 100%); }
.lock { max-width: 100%; overflow: hidden; }
@media (max-width: 420px) {
    .cu-body { padding: 10px; } .lock { padding: 10px 6px; }
    .cbtns button { width: 48px; height: 48px; }
    .wheel b { width: 40px; font-size: 26px; } .wheel button { width: 40px; }
    .levers { gap: 9px; } .lever { width: 36px; }
    .brakes { gap: 10px; } .brake { width: 96px; }
    .note { font-size: 22px; padding: 14px; } .val { font-size: 34px; }
    .grid6 { grid-template-columns: repeat(6, 34px); }
}
@media (max-height: 460px) {
    .closeup { padding: 50px 8px 6px; inset: 0 0 70px; }
    .cu header { padding: 6px 12px; } .cu-art { width: 40px; height: 40px; } .cu h3 { font-size: 15px; }
    .cu-body { padding: 10px; gap: 8px; }
    .pad button { height: 40px; } .lcd { font-size: 22px; padding: 4px 12px; }
    .dpad { grid-template-rows: repeat(3, 40px); } .dpad button { height: 40px; }
    .lever { height: 90px; } .lever.dn i { top: 38px; }
    .brake { height: 120px; }
    .tbslot { width: min(250px, 100%); }
    /* side by side instead of stacked, so a whole lock fits a short screen */
    .lock { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px; }
    .lockhead, .lock > .faint, .tbmarks, .lock > .row { flex-basis: 100%; justify-content: center; }
    .lock > .faint { text-align: center; margin: 0; }
    /* the close-up takes the whole height above the pockets (it covers the HUD while open) */
    .closeup { padding: 6px 8px; z-index: 8; }
    .cu header { padding: 4px 10px; gap: 8px; } .cu-art { width: 30px; height: 30px; } .cu .sub { display: none; }
    .cu header .x { padding: 2px 6px; }
    .lock { padding: 8px; }
    .pad { gap: 4px; } .pad button { height: 36px; }
    .dpad { grid-template-rows: repeat(3, 36px); gap: 3px; } .dpad button { height: 36px; }
    .patch { height: 170px; } .plugs, .sockets { grid-template-rows: repeat(4, 42px); }
    .tbmarks { flex-basis: auto; width: 150px; flex-direction: column; align-items: stretch; }
    .t-tbx > .faint { display: none; }
    .tbslot { width: min(205px, 100%); }
    .symkeys { grid-template-columns: repeat(3, 56px); } .sk { width: 56px; height: 56px; }
}
