/* manno: neon vector look. Colours are lights on black; glow comes from layered text-shadow /
   box-shadow, and motion from CSS keyframes (flicker, scan, deal, flip). */
:root {
  --bg: #05020c;
  --ink: #e8e6ff;
  --dim: #8a83b8;
  --cyan: #7df9ff;
  --magenta: #ff3df2;
  --green: #39ff88;
  --amber: #ffb020;
  --blue: #4d8bff;
  --yellow: #fff36b;
  --c: var(--cyan);
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--mono); overflow: hidden; }
body::after { /* scanlines */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
#field { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
kbd { font: inherit; font-size: .85em; padding: 0 .35em; border: 1px solid currentColor; border-radius: 3px; opacity: .85; }
a { color: var(--cyan); }
button, input, select { font: inherit; color: inherit; }
.neon { text-shadow: 0 0 4px currentColor, 0 0 14px currentColor; }

/* ---- HUD ------------------------------------------------------------------------------ */
.hud { position: fixed; left: 0; right: 0; padding: 14px 20px; pointer-events: none; z-index: 10; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.hud > * { pointer-events: auto; }
.hud.top { top: 0; }
.hud.bottom { bottom: 0; align-items: flex-end; }
h1 { margin: 0; font-size: 26px; letter-spacing: .14em; color: var(--cyan); text-shadow: 0 0 6px var(--cyan), 0 0 22px var(--magenta); }
h1 small { font-size: 12px; letter-spacing: .1em; margin-left: .7em; color: var(--dim); text-shadow: none; }
.glitch { position: relative; display: inline-block; animation: flicker 6s infinite steps(1); }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; opacity: 0; }
.glitch::before { color: var(--magenta); animation: glitch 4.2s infinite steps(1); }
.glitch::after { color: var(--green); animation: glitch 5.3s infinite steps(1) reverse; }
@keyframes flicker { 0%, 100% { opacity: 1; } 41% { opacity: .55; } 42% { opacity: 1; } 77% { opacity: .8; } 78% { opacity: 1; } }
@keyframes glitch { 0%, 92%, 100% { opacity: 0; transform: none; } 93% { opacity: .8; transform: translate(-3px, 1px); } 95% { opacity: .8; transform: translate(3px, -1px); } 97% { opacity: 0; } }
.realm-status { margin: 4px 0 0; font-size: 12px; color: var(--dim); padding: 2px 10px; border: 1px solid #2a2350; border-radius: 99px; }
.realm-status::before { content: "●"; margin-right: .5em; color: #554; }
.realm-status.on { color: var(--green); border-color: rgba(57, 255, 136, .35); }
.realm-status.on::before { color: var(--green); text-shadow: 0 0 8px var(--green); animation: beat 2s infinite; }
@keyframes beat { 50% { opacity: .35; } }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }
.legend button, .nodes button {
  --c: var(--cyan);
  background: rgba(5, 2, 12, .7); color: var(--c); border: 1px solid var(--c); border-radius: 4px; padding: 4px 10px; cursor: pointer;
  box-shadow: 0 0 8px -2px var(--c), inset 0 0 8px -4px var(--c); text-shadow: 0 0 6px var(--c); transition: background .15s, transform .15s;
}
.legend button:hover, .legend button:focus-visible, .nodes button:hover { background: color-mix(in srgb, var(--c) 18%, transparent); transform: translateY(-1px); outline: none; }
.legend kbd { margin-right: .5em; border: 0; padding: 0; opacity: .6; }
.help { margin: 0; font-size: 12px; color: var(--dim); text-align: right; }
.log { position: fixed; left: 20px; bottom: 64px; margin: 0; padding: 0; list-style: none; z-index: 10; font-size: 12px; pointer-events: none; }
.log li { color: var(--c); text-shadow: 0 0 6px var(--c); animation: log-in .3s ease-out; transition: opacity 1.5s; }
.log li.old { opacity: .3; }
@keyframes log-in { from { opacity: 0; transform: translateX(-12px); } }

/* ---- panel ---------------------------------------------------------------------------- */
.panel {
  --c: var(--cyan);
  position: fixed; z-index: 20; top: 70px; right: 20px; bottom: 76px; width: min(760px, calc(100vw - 40px));
  display: flex; flex-direction: column; background: rgba(6, 3, 16, .9); border: 1px solid var(--c); border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset, 0 0 24px -6px var(--c), 0 0 60px -20px var(--c);
  backdrop-filter: blur(3px); animation: panel-in .28s cubic-bezier(.2, .9, .3, 1.2);
  overflow: hidden;
}
.panel[hidden] { display: none; }
.panel::before { /* a scan beam running down the frame */
  content: ""; position: absolute; left: 0; right: 0; height: 60px; top: -60px; pointer-events: none;
  background: linear-gradient(transparent, color-mix(in srgb, var(--c) 10%, transparent), transparent);
  animation: scan 4s linear infinite;
}
@keyframes scan { to { top: 100%; } }
@keyframes panel-in { from { opacity: 0; transform: translateX(30px) scale(.97); clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
.panel[data-node="memory"], .panel[data-node="cinema"] { width: min(980px, calc(100vw - 40px)); }
.panel > header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.panel h2 { margin: 0; font-size: 16px; letter-spacing: .2em; text-transform: uppercase; color: var(--c); text-shadow: 0 0 8px var(--c); }
#panel-close { background: none; border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); color: var(--c); border-radius: 4px; cursor: pointer; padding: 2px 8px; font-size: 12px; }
#panel-body { flex: 1; overflow: auto; padding: 16px; }
.page[hidden] { display: none; }
.page > p:first-child { margin-top: 0; }
.lead { font-size: 18px; color: var(--c); text-shadow: 0 0 8px color-mix(in srgb, var(--c) 60%, transparent); }
.fine { font-size: 12px; color: var(--dim); }
.nodes { list-style: none; padding: 0; display: grid; gap: 10px; }
.nodes button { margin-right: .8em; min-width: 7.5em; text-align: left; }
.page button.big, .page form button, .page select {
  background: transparent; color: var(--c); border: 1px solid var(--c); border-radius: 4px; padding: 6px 14px; cursor: pointer;
  box-shadow: 0 0 10px -3px var(--c); text-shadow: 0 0 6px var(--c);
}
.page button.big { font-size: 18px; padding: 10px 22px; animation: pulse 2s infinite; }
.page button:disabled { opacity: .5; cursor: wait; }
@keyframes pulse { 50% { box-shadow: 0 0 24px -2px var(--c); } }
.page input { background: #0b0720; border: 1px solid #2c2560; border-radius: 4px; padding: 6px 10px; outline: none; }
.page input:focus { border-color: var(--c); box-shadow: 0 0 10px -3px var(--c); }
.page select { background: #0b0720; }

/* ---- shell ------------------------------------------------------------------------------ */
.page[data-page="shell"] { display: flex; flex-direction: column; height: 100%; }
.page[data-page="shell"][hidden] { display: none; }
.term { flex: 1; overflow: auto; white-space: pre-wrap; word-break: break-word; color: var(--green); text-shadow: 0 0 5px rgba(57, 255, 136, .6); min-height: 200px; }
.term .echo { color: var(--ink); text-shadow: none; opacity: .8; margin-top: .3em; }
.term .err { color: var(--magenta); text-shadow: 0 0 6px rgba(255, 61, 242, .6); }
.term .dim { color: var(--dim); text-shadow: none; }
.term .ok { color: var(--yellow); }
.term .files { color: var(--cyan); text-shadow: 0 0 5px rgba(125, 249, 255, .6); }
.term .art { color: var(--cyan); text-shadow: 0 0 6px var(--cyan), 0 0 16px var(--magenta); white-space: pre; }
.term-line { display: flex; gap: .6em; align-items: center; border-top: 1px dashed #24304a; padding-top: 8px; margin-top: 8px; }
.term-line .prompt { color: var(--green); white-space: nowrap; text-shadow: 0 0 6px var(--green); }
.term-line input { flex: 1; background: transparent !important; border: 0 !important; box-shadow: none !important; color: var(--ink); caret-color: var(--green); padding: 2px 0; }

/* ---- memory ------------------------------------------------------------------------------ */
.mem-form { display: flex; gap: 8px; flex-wrap: wrap; }
.mem-form input { flex: 1; min-width: 220px; }
.mem-status { min-height: 1.5em; margin: 10px 0 4px; font-size: 13px; color: var(--dim); }
.mem-status.busy::after { content: "▌"; animation: beat .8s infinite; color: var(--c); }
.mem-status.ok { color: var(--cyan); }
.mem-status.warn { color: var(--amber); }
.mem-status.win { color: var(--yellow); text-shadow: 0 0 10px var(--yellow); }
.mem-stats { display: flex; gap: 1.5em; font-size: 12px; color: var(--dim); margin-bottom: 10px; }
.mem-stats [data-realm] { margin-left: auto; color: var(--magenta); }
.mem-board { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 116px)); justify-content: center; gap: 8px; perspective: 900px; }
.card { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: none; cursor: pointer; transform-style: preserve-3d; transition: transform .35s; animation: deal .4s backwards cubic-bezier(.2, .9, .3, 1.3); }
.card > span { position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden; overflow: hidden; }
.card .back {
  border: 1px solid rgba(255, 61, 242, .6); box-shadow: inset 0 0 14px -4px var(--magenta), 0 0 8px -4px var(--magenta);
  background: radial-gradient(circle at 50% 50%, rgba(255, 61, 242, .25) 0 8%, transparent 9%),
              repeating-linear-gradient(45deg, rgba(255, 61, 242, .12) 0 2px, transparent 2px 10px), #0b0518;
}
.card .face { transform: rotateY(180deg); border: 1px solid var(--cyan); background: #0a0a14; box-shadow: 0 0 12px -3px var(--cyan); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.up { transform: rotateY(180deg); }
.card.found .face { border-color: var(--green); box-shadow: 0 0 16px -2px var(--green); animation: found .5s; }
.card.found { cursor: default; }
.card.miss .back { animation: miss .4s; }
.card:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
@keyframes deal { from { opacity: 0; transform: translateY(-20px) rotate(-8deg) scale(.6); } }
@keyframes found { 50% { filter: brightness(1.8); } }
@keyframes miss { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.mem-board.won .card { animation: won 1.2s; }
@keyframes won { 30% { filter: brightness(2) hue-rotate(90deg); } }

/* ---- cinema ------------------------------------------------------------------------------ */
.marquee { overflow: hidden; border: 1px solid var(--amber); border-radius: 4px; margin-bottom: 12px; color: var(--amber); text-shadow: 0 0 8px var(--amber); box-shadow: 0 0 14px -4px var(--amber); white-space: nowrap; }
.marquee span { display: inline-block; padding: 4px 0; padding-left: 100%; animation: marquee 14s linear infinite; letter-spacing: .3em; }
@keyframes marquee { to { transform: translateX(-100%); } }
.screen { margin-bottom: 14px; }
.screen video { width: 100%; max-height: 52vh; background: #000; border: 1px solid var(--amber); border-radius: 4px; box-shadow: 0 0 30px -8px var(--amber); display: block; }
.now { display: flex; flex-wrap: wrap; gap: .5em 1em; align-items: center; font-size: 13px; margin-top: 8px; }
.now b { color: var(--amber); text-shadow: 0 0 6px var(--amber); }
.now span { color: var(--dim); }
.now select { padding: 2px 6px; font-size: 12px; }
.now a { margin-left: auto; font-size: 12px; color: var(--amber); }
.cin-search { display: flex; gap: 8px; flex-wrap: wrap; }
.cin-search input { flex: 1; min-width: 200px; }
.cin-status { font-size: 13px; color: var(--dim); min-height: 1.4em; }
.reel { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.ticket { width: 100%; text-align: left; padding: 0; background: #0b0614; border: 1px solid #3a2a10; border-radius: 6px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s, transform .15s; }
.ticket:hover, .ticket:focus-visible { border-color: var(--amber); box-shadow: 0 0 16px -4px var(--amber); transform: translateY(-2px); outline: none; }
.ticket img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; filter: saturate(.8) contrast(1.05); background: #111; }
.ticket .t { padding: 6px 8px 0; font-size: 13px; line-height: 1.3; }
.ticket .m { padding: 2px 8px 8px; font-size: 11px; color: var(--dim); }

.noscript { position: fixed; inset: 40% 0 auto; text-align: center; color: var(--dim); }

@media (max-width: 760px) {
  .help, h1 small, .legend kbd { display: none; }
  .legend { gap: 6px; flex-wrap: nowrap; }
  .legend button { padding: 3px 8px; font-size: 12px; }
  .realm-status { white-space: nowrap; font-size: 11px; }
  .panel { top: 64px; right: 8px; left: 8px; bottom: 64px; width: auto !important; }
  .mem-board { --cols: 5 !important; }
  .hud { padding: 10px 12px; }
  .log { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
