/* PUNK MUD - one stylesheet, written phone-first. Wider screens add columns at the bottom of the file. */

@font-face { font-family: 'Silkscreen'; src: url('/fonts/Silkscreen-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Silkscreen'; src: url('/fonts/Silkscreen-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --bg: #0a0a0f;
  --panel: #12121c;
  --panel-2: #1b1b2b;
  --line: #2c2c44;
  --text: #ecebf5;
  --dim: #9a99b5;
  --pink: #ff2e88;
  --cyan: #00fff9;
  --yellow: #ffd23f;
  --green: #3dff8f;
  --orange: #ff8a3d;
  --red: #ff4d5e;
  --pixel: 'Silkscreen', ui-monospace, monospace;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', Menlo, Consolas, monospace;
  --hud-h: 52px;
  --tabs-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--mono);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; touch-action: manipulation;
}
#app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
h1, h2, h3, .px { font-family: var(--pixel); font-weight: 400; letter-spacing: .02em; margin: 0; }
.dim { color: var(--dim); }
.hide { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  padding: 10px 14px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--cyan);
  border-radius: 6px; transition: transform .06s, background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { background: #23233a; box-shadow: 0 0 14px rgba(0, 255, 249, .18); }
.btn:active:not(:disabled) { transform: scale(.985); background: #2a2a45; }
.btn:disabled { opacity: .5; border-left-color: var(--line); }
.btn .grow { flex: 1; min-width: 0; }
.btn .sub { display: block; font-size: 12.5px; color: var(--dim); line-height: 1.35; margin-top: 2px; }
.btn .key { font: 11px var(--pixel); color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; display: none; }
.btn.pink { border-left-color: var(--pink); }
.btn.pink:hover:not(:disabled) { box-shadow: 0 0 14px rgba(255, 46, 136, .25); }
.btn.yellow { border-left-color: var(--yellow); }
.btn.red { border-left-color: var(--red); }
.btn.commit { border-color: var(--yellow); border-left-width: 3px; background: #2a2412; }
.btn.center { justify-content: center; text-align: center; font-family: var(--pixel); letter-spacing: .04em; }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.small { min-height: 38px; padding: 6px 10px; font-size: 14px; }
.badge { font: 11px var(--pixel); padding: 3px 6px; border-radius: 4px; background: #000; border: 1px solid currentColor; white-space: nowrap; }
.badge.good { color: var(--green); } .badge.ok { color: var(--yellow); } .badge.bad { color: var(--red); }
.badge.cyan { color: var(--cyan); } .badge.pink { color: var(--pink); } .badge.dim { color: var(--dim); }
.mark { color: var(--yellow); font-family: var(--pixel); text-shadow: 0 0 8px var(--yellow); animation: bob 1s ease-in-out infinite; display: inline-block; }
@keyframes bob { 50% { transform: translateY(-2px); } }

/* ------------------------------------------------------------------ login */
.login {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background: radial-gradient(ellipse at 50% 0%, #2a0b3a 0%, var(--bg) 60%);
}
.login img.logo { width: min(78vw, 360px); height: auto; image-rendering: pixelated; mix-blend-mode: screen; animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.login .tag { margin: 10px 0 22px; text-align: center; color: var(--dim); max-width: 30ch; }
.login form { width: min(100%, 360px); display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field label { font: 12px var(--pixel); color: var(--cyan); letter-spacing: .06em; }
.field input {
  min-height: 48px; padding: 10px 12px; background: #06060a; border: 1px solid var(--line); border-radius: 6px; font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 255, 249, .15); }
.login .err { color: var(--red); min-height: 1.4em; font-size: 14px; text-align: center; }
.login .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.login .row .btn { font-size: 13px; padding: 10px 6px; letter-spacing: 0; }
.login .fine { font-size: 12px; color: var(--dim); text-align: center; margin-top: 6px; }

/* ------------------------------------------------------------------ shell */
.shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hud {
  flex: none; height: calc(var(--hud-h) + var(--safe-t)); padding: var(--safe-t) 10px 0;
  display: flex; align-items: center; gap: 10px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.hud .who { min-width: 0; flex: 0 1 auto; line-height: 1.15; background: none; border: 0; padding: 0; text-align: left; }
.hud .who b { font: 13px var(--pixel); color: var(--pink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.hud .who span { font-size: 11px; color: var(--dim); white-space: nowrap; }
.hud .bars { flex: 1; min-width: 60px; display: grid; gap: 3px; }
.bar { height: 14px; background: #06060a; border: 1px solid var(--line); border-radius: 3px; position: relative; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--green); transition: width .35s ease-out, background .3s; }
.bar > span { position: absolute; inset: 0; font: 700 11px/13px var(--mono); text-align: center; color: #fff; text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000, 0 0 4px #000; }
.bar.xp { height: 5px; border: 0; background: #1c1c2c; } .bar.xp > i { background: var(--cyan); }
.bar.low > i { background: var(--red); } .bar.mid > i { background: var(--yellow); }
.bar.foe > i { background: var(--pink); }
.hud .cred { font: 13px var(--pixel); color: var(--yellow); white-space: nowrap; }
.hud .pts { font: 11px var(--pixel); color: #000; background: var(--yellow); border: 0; border-radius: 4px; padding: 4px 6px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 12px var(--yellow); } }
.hud .net { position: absolute; left: 0; right: 0; top: 100%; background: var(--red); color: #000; font: 11px var(--pixel); text-align: center; padding: 3px; }

.layout { flex: 1; min-height: 0; display: flex; }
.stage { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.side { display: none; }
.sheet { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 20px; }

.tabs {
  flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--panel); border-top: 1px solid var(--line);
}
.tabs button {
  background: none; border: 0; border-top: 2px solid transparent; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: 10px var(--pixel); letter-spacing: .04em; position: relative;
}
.tabs button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.tabs button.on { color: var(--cyan); border-top-color: var(--cyan); text-shadow: 0 0 8px rgba(0, 255, 249, .6); }
.tabs button .dot { position: absolute; top: 6px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 8px var(--pink); }

/* ------------------------------------------------------------------ art panel */
.art {
  flex: none; position: relative; width: 100%; aspect-ratio: 3 / 2; max-height: 40dvh; overflow: hidden; background: #000;
  border-bottom: 1px solid var(--line);
}
.art img.pic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; animation: drift 24s ease-in-out infinite alternate; }
.art img.pic.on { opacity: 1; }
@keyframes drift { from { transform: scale(1); } to { transform: scale(1.06) translateY(-1%); } }
.art::after { /* scanlines + vignette */
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, .16) 2px 3px), radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%);
}
.art .over { position: absolute; left: 0; right: 0; z-index: 3; padding: 6px 8px; pointer-events: none; }
.art .over.top { top: 0; background: linear-gradient(#000c, #0000); }
.art .over.bottom { bottom: 0; background: linear-gradient(#0000, #000e 42%); }
.art .over.bottom:not(:empty) { padding-top: 26px; }
.art .fxl { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.art.compact { max-height: 34dvh; }
.art img.pic.cut { opacity: 0; transition: none; z-index: 1; animation: none; }
.art img.pic.cut.on { opacity: 1; }
.art.tappable { cursor: pointer; }

/* art effects */
.art.fx-shake, .shake { animation: shake .32s linear; }
@keyframes shake { 10% { transform: translate(-5px, 2px); } 30% { transform: translate(5px, -3px); } 50% { transform: translate(-4px, 3px); } 70% { transform: translate(3px, -2px); } 90% { transform: translate(-2px, 1px); } }
.art .wash { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; }
.art.fx-flash .wash { background: #fff; animation: flash .5s ease-out; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }
.art.fx-alarm .wash { background: var(--red); animation: alarm 1s ease-in-out infinite; mix-blend-mode: screen; }
@keyframes alarm { 50% { opacity: .35; } }
.art.fx-dark img.pic { filter: brightness(.35) saturate(.6); }
.art.fx-glitch img.pic.on { animation: glitch .9s steps(2) 3; }
@keyframes glitch {
  0% { transform: translate(0); filter: none; } 20% { transform: translate(-6px, 2px); filter: hue-rotate(90deg) saturate(2); clip-path: inset(10% 0 55% 0); }
  40% { transform: translate(6px, -2px); clip-path: inset(60% 0 8% 0); } 60% { transform: translate(-3px, 0); filter: hue-rotate(-60deg); clip-path: inset(30% 0 30% 0); }
  80% { transform: translate(3px, 1px); clip-path: none; } 100% { transform: translate(0); filter: none; }
}
.art.fx-static .wash, .art.fx-boot .wash {
  opacity: .22; mix-blend-mode: screen;
  background-image: repeating-radial-gradient(circle at 17% 32%, #fff 0 1px, transparent 1px 3px), repeating-radial-gradient(circle at 73% 61%, #9ff 0 1px, transparent 1px 4px);
  animation: noise .25s steps(3) infinite;
}
@keyframes noise { 33% { background-position: 13px -7px, -9px 11px; } 66% { background-position: -11px 5px, 7px -13px; } }
.art.fx-boot img.pic.on { animation: boot 1.6s ease-out; }
@keyframes boot { 0% { transform: scaleY(.004) scaleX(.2); filter: brightness(8); } 35% { transform: scaleY(.004) scaleX(1); filter: brightness(8); } 60% { transform: scaleY(1); filter: brightness(2); } 100% { filter: none; } }
.art.fx-speed .wash { opacity: .5; background: repeating-linear-gradient(100deg, transparent 0 22px, rgba(255, 255, 255, .5) 22px 24px, transparent 24px 60px); background-size: 200% 100%; animation: speed .35s linear infinite; mix-blend-mode: overlay; }
@keyframes speed { to { background-position: -120px 0; } }

/* sprites, numbers */
.spr { position: absolute; width: 46%; max-width: 260px; left: 50%; top: 46%; transform: translate(-50%, -50%); image-rendering: pixelated; filter: drop-shadow(0 0 10px rgba(255, 255, 255, .5)); }
.spr.hit { animation: sprHit .5s ease-out forwards; }
@keyframes sprHit { 0% { transform: translate(-50%, -50%) scale(.3) rotate(-18deg); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.18) rotate(4deg); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.3) rotate(8deg); opacity: 0; } }
.spr.inc { animation: sprInc .55s ease-in forwards; }
@keyframes sprInc { 0% { transform: translate(-50%, -50%) scale(.25); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(-50%, -10%) scale(2.3); opacity: 0; } }
.spr.aura { animation: sprAura .7s ease-out forwards; }
@keyframes sprAura { 0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; } 30% { opacity: .95; } 100% { transform: translate(-50%, -58%) scale(1.25); opacity: 0; } }
.spr.self { top: 78%; width: 36%; }
.num { position: absolute; font: 700 26px var(--pixel); color: #fff; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 0 0 10px currentColor; animation: num .9s ease-out forwards; white-space: nowrap; z-index: 6; pointer-events: none; }
.num.crit { color: var(--yellow); font-size: 38px; }
.num.heal { color: var(--green); } .num.hurt { color: var(--red); } .num.info { color: var(--cyan); font-size: 16px; }
@keyframes num { 0% { transform: translate(-50%, 0) scale(.5); opacity: 0; } 15% { transform: translate(-50%, -8px) scale(1.25); opacity: 1; } 100% { transform: translate(-50%, -64px) scale(1); opacity: 0; } }
.hurtwash { position: fixed; inset: 0; pointer-events: none; z-index: 40; box-shadow: inset 0 0 90px 30px rgba(255, 40, 60, .55); animation: flash .45s ease-out forwards; }

/* ------------------------------------------------------------------ story */
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px calc(18px + var(--safe-b)); scroll-behavior: smooth; }
.place { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.place h2 { font-size: 18px; color: var(--cyan); text-shadow: 0 0 10px rgba(0, 255, 249, .5); }
.speaker { display: flex; align-items: baseline; gap: 2px 8px; margin-bottom: 4px; flex-wrap: wrap; }
.speaker b { font: 16px var(--pixel); color: var(--pink); text-shadow: 0 0 10px rgba(255, 46, 136, .55); }
.speaker.lu b { color: var(--cyan); text-shadow: 0 0 10px rgba(0, 255, 249, .7); }
.speaker span { font-size: 12px; color: var(--dim); }
.prose p { margin: 0 0 .8em; overflow-wrap: anywhere; }
/* Guidance told in the story's own voices: Lu whispering over a scene, or the implant's readout. */
.prose p.aside { position: relative; font-size: 14px; padding: 7px 10px 8px 12px; border-left: 2px solid var(--cyan); background: linear-gradient(90deg, rgba(0, 255, 249, .09), transparent 85%); border-radius: 0 6px 6px 0; color: #b9fffd; }
.prose p.aside .from { display: block; font: 10px var(--pixel); letter-spacing: .08em; color: var(--cyan); opacity: .85; margin-bottom: 2px; }
.prose p.aside.sys { border-left-color: var(--green); background: linear-gradient(90deg, rgba(57, 255, 136, .08), transparent 85%); color: #b6f5cc; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; letter-spacing: .02em; }
.prose p.aside.sys .from { color: var(--green); }
.prose.lu p { color: #b9fffd; }
.prose .w { opacity: 0; animation: word .28s ease-out forwards; }
.prose.instant .w { animation: none; opacity: 1; }
@keyframes word { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
.wait { opacity: 0; pointer-events: none; }
.shown { animation: rise .3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.section { margin-top: 14px; }
.section > h3 { font-size: 11px; color: var(--dim); letter-spacing: .12em; margin-bottom: 6px; }
.list { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; padding: 8px 10px; border-radius: 6px; border: 1px solid; font-size: 13.5px; animation: pop .3s ease-out; }
.check.pass { border-color: var(--green); background: #0b1c12; color: var(--green); }
.check.fail { border-color: var(--red); background: #1f0c10; color: var(--red); }
.check b { font-family: var(--pixel); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.meters { display: grid; gap: 6px; margin: 0 0 12px; }
.meter { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; font: 11px var(--pixel); color: var(--dim); }
.meter .pips { display: flex; gap: 4px; }
.meter .pips i { flex: 1; height: 10px; max-width: 34px; background: #06060a; border: 1px solid var(--line); border-radius: 2px; transition: background .25s, box-shadow .25s; }
.meter .pips i.on { background: var(--c, var(--cyan)); box-shadow: 0 0 8px var(--c, var(--cyan)); border-color: transparent; }
.person { display: flex; align-items: center; gap: 10px; }
.thumb { width: 54px; height: 54px; flex: none; border-radius: 6px; border: 1px solid var(--line); background: #000 50% 8% / auto 165% no-repeat; }
.exits { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .exits { grid-template-columns: 1fr 1fr; } }
.arrow { font: 16px var(--pixel); color: var(--cyan); width: 18px; text-align: center; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); background: var(--panel); }
.chip.good { color: var(--green); border-color: #1f6b43; } .chip.bad { color: var(--red); border-color: #7a2630; }
.chip b { font-weight: 400; color: var(--text); }

/* ------------------------------------------------------------------ combat */
.fight { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.plate { display: flex; align-items: center; gap: 8px; }
.plate b { font: 14px var(--pixel); text-shadow: 0 0 8px #000, 0 1px 0 #000; }
.plate .bar { flex: 1; height: 16px; }
.plate .bar > span { line-height: 15px; }
.intent { display: flex; gap: 8px; align-items: center; font-size: 13px; text-shadow: 0 1px 2px #000; }
.intent .ico { font: 14px var(--pixel); padding: 2px 6px; border-radius: 4px; background: #000a; border: 1px solid var(--dim); color: var(--dim); flex: none; }
.intent.attack .ico { color: var(--orange); border-color: var(--orange); }
.intent.windup .ico { color: var(--yellow); border-color: var(--yellow); }
.intent.danger .ico { color: #000; background: var(--red); border-color: var(--red); animation: pulseRed .6s infinite; }
.intent.danger { color: #ffd0d4; }
@keyframes pulseRed { 50% { box-shadow: 0 0 14px var(--red); } }
.intent small { display: block; color: var(--dim); font-size: 11.5px; }
.me { flex: none; padding: 8px 12px 6px; display: grid; gap: 6px; background: var(--panel); border-bottom: 1px solid var(--line); }
.me .row { display: flex; align-items: center; gap: 10px; }
.me .bar { flex: 1; height: 18px; } .me .bar > span { line-height: 17px; font-size: 11px; }
.pips { display: flex; gap: 4px; }
.charge i { width: 16px; height: 16px; border: 1px solid #6b5a17; background: #06060a; transform: rotate(45deg) scale(.72); transition: background .2s, box-shadow .2s; }
.charge i.on { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); border-color: transparent; }
.log { flex: 1; min-height: 44px; overflow: hidden; padding: 6px 12px; font-size: 13px; color: var(--dim); display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.log div { opacity: .55; } .log div:nth-last-child(2) { opacity: .8; } .log div:last-child { opacity: 1; animation: rise .2s ease-out; }
.log div:last-child { color: var(--text); }
.log .say { color: var(--pink); font-style: italic; }
.moves { flex: none; max-height: 62%; overflow-y: auto; padding: 6px 10px calc(10px + var(--safe-b)); display: grid; gap: 8px; align-content: start; border-top: 1px solid var(--line); background: var(--panel); }
.movegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.move {
  position: relative; min-height: 64px; padding: 8px 8px 8px 50px; text-align: left; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line); overflow: hidden;
}
.move:active:not(:disabled) { transform: scale(.97); }
.move:hover:not(:disabled) { border-color: var(--cyan); box-shadow: 0 0 12px rgba(0, 255, 249, .2); }
.move img { position: absolute; left: 4px; top: 50%; width: 42px; height: 42px; object-fit: contain; transform: translateY(-50%); image-rendering: pixelated; }
.move b { display: block; font: 12px var(--pixel); line-height: 1.2; }
.move .nums { font-size: 12px; color: var(--dim); }
.move .nums em { color: var(--orange); font-style: normal; }
.move .cost { position: absolute; right: 5px; top: 5px; display: flex; gap: 2px; }
.move .cost i { width: 7px; height: 7px; background: var(--yellow); transform: rotate(45deg); }
.move.guard { border-left: 3px solid var(--cyan); } .move.attack { border-left: 3px solid var(--pink); } .move.buff, .move.heal { border-left: 3px solid var(--green); }
.move:disabled { opacity: .45; }
.move .why { font-size: 11px; color: var(--red); }
.move .desc { display: none; font-size: 12px; color: var(--dim); margin-top: 3px; line-height: 1.35; }
.movegrid.explain { grid-template-columns: 1fr; } .movegrid.explain .desc { display: block; }
.fightbar { display: flex; gap: 8px; flex-wrap: wrap; }
.fightbar .btn { width: auto; flex: 1 1 auto; }
.splash { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; background: #000a; pointer-events: none; animation: splash 1s ease-out forwards; }
.splash b { font: 700 40px var(--pixel); color: var(--pink); text-shadow: 3px 3px 0 #000, 0 0 24px var(--pink); transform: rotate(-4deg); }
.splash.win b { color: var(--yellow); text-shadow: 3px 3px 0 #000, 0 0 24px var(--yellow); }
@keyframes splash { 0% { opacity: 0; transform: scale(1.6); } 18% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ------------------------------------------------------------------ mini-games */
.game { display: grid; gap: 12px; justify-items: center; }
.game h2 { color: var(--cyan); font-size: 16px; text-align: center; }
.game .intro { font-size: 14px; color: var(--dim); text-align: center; max-width: 46ch; }
.rows { display: grid; gap: 6px; }
.coderow { display: flex; gap: 6px; justify-content: center; }
.cell { width: 46px; height: 46px; display: grid; place-items: center; font-size: 22px; border-radius: 6px; border: 2px solid var(--line); background: #06060a; }
.cell.hit { background: #0e3a22; border-color: var(--green); color: var(--green); }
.cell.near { background: #3a300b; border-color: var(--yellow); color: var(--yellow); }
.cell.miss { color: var(--dim); }
.cell.cur { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0, 255, 249, .4); }
.keys { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 340px; }
.keys button { width: 52px; height: 52px; font-size: 24px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.keys button:active { background: var(--cyan); color: #000; }
.keys button:disabled { opacity: .3; }
.pads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(78vw, 300px); aspect-ratio: 1; }
.pad { border-radius: 14px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 14%, #000); transition: background .08s, box-shadow .08s, transform .08s; }
.pad.lit, .pad:active:not(:disabled) { background: var(--c); box-shadow: 0 0 34px var(--c); transform: scale(.97); }
.track { position: relative; width: min(92%, 440px); height: 46px; border-radius: 8px; background: #06060a; border: 2px solid var(--line); overflow: hidden; }
.track .zone { position: absolute; top: 0; bottom: 0; background: rgba(61, 255, 143, .25); border-left: 2px solid var(--green); border-right: 2px solid var(--green); }
.track .zone::after { content: ''; position: absolute; top: 0; bottom: 0; left: 30%; right: 30%; background: rgba(255, 210, 63, .5); }
.track .needle { position: absolute; top: -2px; bottom: -2px; width: 5px; margin-left: -2px; background: #fff; box-shadow: 0 0 12px #fff, 0 0 4px var(--cyan); }
.dots { display: flex; gap: 6px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.dots i.perfect { background: var(--yellow); border-color: var(--yellow); } .dots i.good { background: var(--green); border-color: var(--green); } .dots i.miss { background: var(--red); border-color: var(--red); }

/* ------------------------------------------------------------------ panels */
.panel h2 { font-size: 15px; color: var(--pink); margin: 4px 0 10px; text-shadow: 0 0 10px rgba(255, 46, 136, .45); }
.panel h3 { font-size: 11px; color: var(--dim); letter-spacing: .12em; margin: 16px 0 6px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.card + .card { margin-top: 8px; }
.card h4 { margin: 0 0 2px; font: 13px var(--pixel); color: var(--text); }
.card p { margin: 4px 0 0; font-size: 13.5px; color: #cfcfe0; }
.card .where { color: var(--yellow); font-size: 12.5px; margin-top: 6px; }
.side-street { --s: var(--green); } .side-zenith { --s: #7aa7ff; } .side-static { --s: var(--pink); }
.card[class*='side-'] { border-left: 3px solid var(--s); }
.stand { display: grid; grid-template-columns: 96px 1fr 26px; gap: 8px; align-items: center; font-size: 12.5px; margin: 4px 0; }
.stand .bar > i { background: var(--s); }
.act { font: 12px var(--pixel); color: var(--yellow); letter-spacing: .08em; }

.mapwrap { position: relative; width: 100%; max-width: 460px; margin: 0 auto; }
.mapgrid { display: grid; gap: 10px 6px; position: relative; z-index: 1; }
.maplines { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.maplines line { stroke: #3a3a5c; stroke-width: 2; } .maplines line.locked { stroke-dasharray: 4 5; stroke: #5a2a3a; }
.node {
  min-height: 50px; padding: 4px 3px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line);
  font: 9.5px/1.2 var(--pixel); color: var(--dim); position: relative; display: grid; place-items: center; text-align: center; overflow-wrap: anywhere;
}
.node.visited { color: var(--text); }
.node.next { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(0, 255, 249, .25); }
.node.here { border-color: var(--pink); color: #fff; background: #3a0f24; box-shadow: 0 0 14px rgba(255, 46, 136, .55); }
.node.unknown { border-style: dashed; }
.node .m { position: absolute; top: -9px; right: -4px; font-size: 15px; }
.node .p { position: absolute; bottom: 2px; left: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }

.repbar { height: 8px; background: #06060a; border: 1px solid var(--line); border-radius: 4px; position: relative; margin-top: 8px; }
.repbar::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--dim); }
.repbar i { position: absolute; top: 0; bottom: 0; background: var(--green); border-radius: 3px; }
.repbar i.neg { background: var(--red); }
.statrow { display: grid; grid-template-columns: 1fr auto 40px; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.statrow b { font: 15px var(--pixel); color: var(--cyan); text-align: right; }
.statrow button { width: 36px; height: 32px; border-radius: 6px; border: 1px solid var(--yellow); background: #2a2412; color: var(--yellow); font: 16px var(--pixel); }
.mv { display: flex; gap: 10px; align-items: center; }
.mv img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; flex: none; }
.toggle { display: flex; gap: 6px; }
.toggle button { flex: 1; min-height: 38px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font: 11px var(--pixel); color: var(--dim); }
.toggle button.on { color: #000; background: var(--cyan); border-color: var(--cyan); }

.chat { display: flex; flex-direction: column; height: 100%; min-height: 300px; }
.chat .msgs { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 8px 2px; font-size: 14px; }
.chat .msgs b { color: var(--cyan); font-weight: 400; } .chat .msgs .g b { color: var(--pink); } .chat .msgs .sys { color: var(--yellow); font-size: 12.5px; }
.chat form { display: flex; gap: 8px; }
.chat input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 10px; background: #06060a; border: 1px solid var(--line); border-radius: 6px; font-size: 16px; }

/* ------------------------------------------------------------------ toasts, modals */
.toasts { position: fixed; left: 0; right: 0; top: calc(var(--hud-h) + var(--safe-t) + 6px); z-index: 50; display: grid; justify-items: center; gap: 6px; pointer-events: none; padding: 0 10px; }
.toast {
  max-width: 440px; padding: 7px 12px; border-radius: 6px; font-size: 13.5px; background: #000d; border: 1px solid var(--line);
  backdrop-filter: blur(6px); animation: toastIn .25s ease-out, toastOut .35s ease-in forwards; animation-delay: 0s, var(--life, 2.6s);
}
.toast b { font-family: var(--pixel); font-weight: 400; }
.toast.good { border-color: var(--green); color: var(--green); } .toast.bad { border-color: var(--red); color: var(--red); }
.toast.gold { border-color: var(--yellow); color: var(--yellow); } .toast.cyan { border-color: var(--cyan); color: var(--cyan); }
.toast.quest { border-color: var(--yellow); background: #17140af0; color: var(--text); width: 100%; }
.toast.quest b { color: var(--yellow); display: block; font-size: 12px; letter-spacing: .06em; }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-6px); opacity: 0; } }
.modal { position: fixed; inset: 0; z-index: 60; background: #000c; display: grid; place-items: center; padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal .box { width: min(100%, 420px); max-height: 86dvh; overflow-y: auto; background: var(--panel); border: 1px solid var(--pink); border-radius: 10px; padding: 18px; box-shadow: 0 0 40px rgba(255, 46, 136, .35); animation: pop .25s ease-out; }
.modal h2 { font-size: 22px; color: var(--yellow); text-align: center; text-shadow: 0 0 16px rgba(255, 210, 63, .6); }
.modal p { margin: 10px 0; text-align: center; }
.modal .btn { margin-top: 10px; }
.levelup h2 { animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { text-shadow: 0 0 28px var(--yellow), 0 0 4px #fff; } }

/* ------------------------------------------------------------------ ending */
.ending h1 { font-size: clamp(26px, 8vw, 44px); text-align: center; color: var(--yellow); text-shadow: 3px 3px 0 #000, 0 0 26px currentColor; margin: 6px 0 14px; animation: glow 1.6s ease-in-out infinite alternate; }
.ending.side-zenith h1 { color: #9cc0ff; } .ending.side-static h1 { color: var(--pink); }
.ending .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin: 14px 0; }
.ending .stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 2px; font-size: 11px; color: var(--dim); }
.ending .stats b { display: block; font: 18px var(--pixel); color: var(--cyan); }

/* ------------------------------------------------------------------ small or sideways phones */
@media (max-height: 640px) and (orientation: portrait) { .art { max-height: 32dvh; } .art.compact { max-height: 26dvh; } }
@media (orientation: landscape) and (max-height: 520px) {
  :root { --hud-h: 40px; --tabs-h: 44px; }
  .stage { flex-direction: row; }
  .stage > .art { width: 46%; height: 100%; max-height: none; aspect-ratio: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .stage > .rest { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
  .tabs button svg { width: 18px; height: 18px; } .tabs button span { display: none; }
}
.rest { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ tablets and desktops: add a side column */
@media (min-width: 900px) {
  body { font-size: 16.5px; }
  .shell { max-width: 1680px; width: 100%; margin: 0 auto; }
  .hud { padding-left: 18px; padding-right: 18px; gap: 16px; }
  .hud .who b { max-width: 220px; font-size: 15px; }
  .hud .bars { max-width: 420px; }
  .layout { gap: 0; }
  .stage { border-right: 1px solid var(--line); }
  .art { max-height: 46dvh; }
  .scroll { padding: 18px 26px 26px; }
  .scroll > * { max-width: 720px; margin-left: auto; margin-right: auto; }
  .side { display: flex; flex-direction: column; width: clamp(340px, 30vw, 430px); flex: none; min-height: 0; background: #0d0d15; }
  .side .tabs { height: 46px; padding: 0; border-top: 0; border-bottom: 1px solid var(--line); }
  .side .tabs button { flex-direction: row; gap: 6px; border-top: 0; border-bottom: 2px solid transparent; font-size: 11px; }
  .side .tabs button.on { border-bottom-color: var(--cyan); }
  .side .tabs button svg { width: 16px; height: 16px; }
  .side .sheet { padding: 14px 16px 24px; }
  .shell > .tabs, .stage > .sheet { display: none; }
  .btn .key { display: inline-block; }
  .movegrid { grid-template-columns: repeat(3, 1fr); }
  .moves, .me, .log { padding-left: 26px; padding-right: 26px; }
  .moves > *, .me > *, .log > * { max-width: 720px; width: 100%; margin-left: auto; margin-right: auto; }
  .toasts { top: calc(var(--hud-h) + 12px); }
}
/* very wide: a second side column so the journal and the map are both always in view */
@media (min-width: 1400px) {
  .side.left { order: -1; border-right: 1px solid var(--line); }
}
@media (max-width: 1399px) { .side.left { display: none; } }

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

/* ------------------------------------------------------------------ the interface boots; Lu whispers */
.toast.boot { border-color: var(--green); color: var(--green); font: 11px/1.5 var(--pixel); letter-spacing: .05em; background: #06140cf0; }
.tabs button.fresh { color: var(--green); animation: tabBoot 1.1s ease-in-out 8; }
@keyframes tabBoot { 0%, 100% { text-shadow: none; filter: none; } 50% { text-shadow: 0 0 12px var(--green); filter: drop-shadow(0 0 6px var(--green)); } }
.panel.offline { display: grid; place-content: center; text-align: center; min-height: 220px; opacity: .7; }
.panel.offline h2 { animation: alarm 1.6s steps(2) infinite; }
.notes details { border-bottom: 1px solid var(--line); padding: 7px 0; }
.notes summary { cursor: pointer; font-size: 13.5px; color: var(--cyan); }
.notes p { margin: 6px 0 2px; font-size: 13.5px; color: #b9fffd; }

.whisper { display: flex; align-items: flex-start; gap: 10px; text-align: left; font: inherit; color: #b9fffd; border: 1px solid var(--cyan); border-radius: 10px; background: #06161af2; padding: 9px 12px; box-shadow: 0 0 18px rgba(0, 255, 249, .22); cursor: pointer; animation: rise .3s ease-out; }
.whisper .thumb { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--cyan); }
.whisper .chipset { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--green); border-radius: 6px; color: var(--green); font-size: 18px; }
.whisper .say { font-size: 14px; line-height: 1.4; }
.whisper .say b { display: block; font: 10px var(--pixel); letter-spacing: .08em; color: var(--cyan); margin-bottom: 2px; }
.whisper.sys { border-color: var(--green); color: #b6f5cc; background: #06140cf2; box-shadow: 0 0 18px rgba(57, 255, 136, .2); }
.whisper.sys .say { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.whisper.sys .say b { color: var(--green); }
.whisper.inline { width: 100%; margin: 0 0 12px; }
.whisper.inline.read { box-shadow: none; opacity: .72; cursor: default; }
.whisper.float { position: fixed; z-index: 45; left: 10px; right: 10px; bottom: 90px; }
.whisper.out { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
.nudge { animation: nudge 1s ease-in-out infinite; border-radius: 8px; }
@keyframes nudge { 50% { box-shadow: 0 0 0 2px var(--cyan), 0 0 16px var(--cyan); } }
@media (prefers-reduced-motion: reduce) { .tabs button.fresh, .nudge, .panel.offline h2 { animation: none; } .nudge { box-shadow: 0 0 0 2px var(--cyan); } }

.chip.tap { cursor: pointer; }
.exits > :only-child { grid-column: 1 / -1; }
/* A mini-game needs the room more than the picture does (phones, upright). */
@media (orientation: portrait) and (max-width: 899px) { .stage:has(.rest .game) .art.compact { max-height: 20dvh; } }
