/* Trickle: one CRT screen of an early-90s adventure game. Every frame is a nine-sliced pixel plate
   (art/ui.py), every picture a generated sprite; the page itself is black glass. */
@font-face { font-family: "VGA"; src: url("/fonts/Web437_IBM_VGA_9x16.woff") format("woff"); font-display: block; }

:root {
  --ink: #f2f2f2; --dim: #aaaaaa; --faint: #6b7c84;
  --cyan: #55ffff; --blue: #5555ff; --yellow: #ffff55; --green: #55ff55; --magenta: #ff55ff; --red: #ff5555; --orange: #ffaa00;
  --gap: 12px;
  --side: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #000; color: var(--ink); }
body {
  font: 16px/20px "VGA", ui-monospace, monospace;
  -webkit-font-smoothing: none; font-smooth: never;
  cursor: url("/art/cursor.png") 0 0, auto;
  overflow-x: hidden;
}
a, button, input, select, label, [role="button"] { cursor: url("/art/cursor.png") 0 0, pointer; }
button, input { font: inherit; color: inherit; }
img { image-rendering: pixelated; }
h1, h2, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }

/* the glass: scanlines, a soft phosphor bloom and the tube's dark corners, over everything, never catching clicks */
.crt { position: relative; min-height: 100vh; padding: 14px 20px 18px; }
.crt::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: url("/art/scan.png") repeat, radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,.55) 100%);
}
.crt { text-shadow: 0 0 6px rgba(120, 220, 255, .18); }

.title { display: grid; justify-items: center; gap: 4px; margin-bottom: 10px; }
.title h1 img { display: block; width: auto; height: clamp(56px, 13vh, 160px); max-width: 70vw; object-fit: contain; }
.premise { color: var(--cyan); text-align: center; max-width: 64ch; }

/* ---- layout: room | verbs, console | taps, inventory + prompt across */
.stage {
  display: grid; gap: var(--gap);
  grid-template-columns: minmax(0, 1fr) var(--side);
  grid-template-rows: minmax(420px, 1fr) auto auto auto;
  grid-template-areas: "room verbs" "console taps" "inv taps" "prompt prompt";
}
.win { border: 12px solid transparent; border-image: url("/art/win_white.png") 12 stretch; padding: 6px; }
.room { grid-area: room; min-height: 0; display: flex; flex-direction: column; padding: 2px 4px; }
.verbs { grid-area: verbs; display: flex; flex-direction: column; gap: 2px; padding: 4px 6px; }
.console { grid-area: console; border-image-source: url("/art/win_console.png"); border-image-slice: 16; border-width: 16px; height: clamp(88px, 15vh, 168px); overflow: hidden; }
.taps { grid-area: taps; min-height: 0; overflow: auto; border-image-source: url("/art/win_cyan.png"); padding: 0 4px; }
.inventory { grid-area: inv; }
.prompt { grid-area: prompt; }

/* ---- verbs: big words, the pressed one in inverse video, like the reference's menu */
.verbs button {
  all: unset; display: block; font-size: 32px; line-height: 36px; padding: 0 8px; color: var(--cyan); letter-spacing: 1px;
  cursor: url("/art/cursor.png") 0 0, pointer;
}
.verbs button:nth-child(3n+2) { color: var(--ink); }
.verbs button:hover, .verbs button:focus-visible, .verbs button[aria-pressed="true"] { background: var(--ink); color: #000; text-shadow: none; }
.verbs a.verb-link { display: block; font-size: 32px; line-height: 36px; padding: 0 8px; color: var(--yellow); letter-spacing: 1px; text-decoration: none; margin-top: auto; }
.verbs a.verb-link:hover, .verbs a.verb-link:focus-visible { background: var(--yellow); color: #000; text-shadow: none; outline: none; }
.verbs button[aria-disabled="true"] { color: #3d4a50; }
.verbs button[aria-disabled="true"]:hover { background: #1d2a30; color: #6b7c84; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---- taps list */
.taps h2 { color: var(--yellow); font-size: 16px; padding: 2px 4px 6px; }
.taps li button {
  all: unset; display: grid; grid-template-columns: 1fr auto; width: 100%; box-sizing: border-box; padding: 3px 4px;
  cursor: url("/art/cursor.png") 0 0, pointer;
}
.taps li button:hover, .taps li button[aria-current="true"] { background: #13303a; }
.taps li button:focus-visible { outline: 2px solid var(--yellow); }
.taps .sym { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.taps .st { font-size: 16px; }
.taps .empty { color: var(--dim); padding: 4px; }
.ph-filling { color: var(--yellow); } .ph-flowing { color: var(--cyan); } .ph-settled { color: var(--green); } .ph-failed { color: var(--red); }

/* ---- console */
.log { height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: none; }
.log li { white-space: pre-wrap; overflow-wrap: anywhere; }
.c-red { color: var(--red); } .c-yellow { color: var(--yellow); } .c-green { color: var(--green); } .c-cyan { color: var(--cyan); }
.c-magenta { color: var(--magenta); } .c-blue { color: #8f8fff; } .c-dim { color: var(--dim); } .c-white { color: var(--ink); }

/* ---- inventory: a titled rule, then slots */
.inv-title { display: flex; align-items: center; gap: 12px; color: var(--cyan); font-size: 16px; margin-bottom: 6px; }
.inv-title::before, .inv-title::after { content: ""; height: 2px; background: var(--ink); flex: 1; }
.inv-title::before { flex: 0 0 24px; }
.inv-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: nowrap; min-width: 0; }
.item {
  display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 6px 10px; color: var(--ink); text-decoration: none;
  border: 12px solid transparent; border-image: url("/art/slot.png") 4 stretch; border-width: 4px; border-image-width: 4px;
}
button.item { all: unset; display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 6px 10px; border: 4px solid transparent; border-image: url("/art/slot.png") 4 stretch; border-image-width: 4px; cursor: url("/art/cursor.png") 0 0, pointer; }
button.item:hover, a.item:not([aria-disabled="true"]):hover { background: #13303a; }
.item.scroll { flex: 1 1 380px; min-width: 150px; }
.ca-body { display: grid; min-width: 0; flex: 1; }
.ca-label { color: var(--yellow); }
.ca { font: inherit; color: var(--ink); overflow-wrap: anywhere; user-select: all; }
.ca.none { color: var(--dim); user-select: none; }
.links, .mine-set { display: flex; gap: 8px; flex: none; }
.item.mark { flex-direction: column; justify-content: center; gap: 4px; width: 84px; flex: none; padding: 6px 4px; }
.item.mark img { width: 30px; height: 30px; object-fit: contain; image-rendering: auto; }
.item.mark span { color: var(--ink); }
.item.mark[aria-disabled="true"] { opacity: .38; pointer-events: none; }
.item.mine { flex-direction: column; gap: 2px; width: 112px; flex: none; justify-content: center; font-size: 16px; padding: 6px 4px; }
.item.mine img { width: 40px; height: 40px; }
.item.mine span { color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mine-set { margin-left: 8px; }

/* ---- the command line */
.prompt { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.prompt .gt { color: var(--ink); font-size: 32px; line-height: 32px; }
.prompt input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--ink); caret-color: var(--ink); font-size: 16px; padding: 6px 0; }
.prompt input::placeholder { color: #4e5d63; }
.prompt .hint { color: var(--dim); letter-spacing: 1px; }
.prompt:focus-within .hint { color: var(--ink); }

/* ---- keys: text in square brackets that light up */
.key {
  all: unset; display: inline-block; padding: 4px 10px; color: #000; background: var(--cyan); text-shadow: none; white-space: nowrap;
  cursor: url("/art/cursor.png") 0 0, pointer;
}
.key:hover { background: var(--ink); }
.key:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.key[disabled], .key[aria-disabled="true"] { background: #25343a; color: #6b7c84; cursor: default; }
.key.red { background: var(--red); } .key.yellow { background: var(--yellow); } .key.green { background: var(--green); }
.key.big { font-size: 32px; line-height: 36px; padding: 6px 16px; }

/* ---- rooms */
.room-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 8px; flex-wrap: wrap; }
.room-head .coin { width: 48px; height: 48px; object-fit: cover; image-rendering: auto; border: 2px solid var(--ink); }
.room-head h2 { font-size: 32px; line-height: 34px; font-weight: normal; }
.room-head .sym { color: var(--yellow); }
.room-head .phase { padding: 2px 8px; color: #000; text-shadow: none; }
.room-head .phase.ph-filling { background: var(--yellow); } .room-head .phase.ph-flowing { background: var(--cyan); }
.room-head .phase.ph-settled { background: var(--green); } .room-head .phase.ph-failed { background: var(--red); }
.room-head .timer { margin-left: auto; text-align: right; }
.room-head .timer b { display: block; font-size: 32px; line-height: 32px; font-weight: normal; color: var(--yellow); }
.room-head .timer small { color: var(--dim); font-size: 16px; }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.tubes-wrap { min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--cyan) #061418; }
.tubes-wrap canvas { display: block; }
.side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; scrollbar-width: none; }
.scene { position: relative; width: 100%; max-width: min(256px, 27vh); align-self: center; aspect-ratio: 1; flex: none; }
.scene img, .scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.facts li { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.facts li b { font-weight: normal; }
.facts .v { text-align: right; }
.act { display: grid; gap: 8px; padding-top: 4px; }
.act .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 6px; border-bottom: 2px solid var(--ink); padding: 2px 0; }
.field input { width: 7ch; background: none; border: 0; outline: none; color: var(--yellow); font-size: 16px; }
.field input:focus { color: var(--ink); }
.note { color: var(--dim); }
.bad { color: var(--red); }
.good { color: var(--green); }

/* list room */
.list { overflow-y: auto; min-height: 0; flex: 1; }
.list h3 { font-weight: normal; margin: 10px 4px 4px; }
.list li button { all: unset; display: grid; grid-template-columns: 5ch minmax(0, 1.4fr) 1fr 1fr 9ch; gap: 12px; width: 100%; box-sizing: border-box; padding: 4px; cursor: url("/art/cursor.png") 0 0, pointer; }
.list li button:hover, .list li button:focus-visible { background: #13303a; outline: none; }
.list .num { text-align: right; }

/* open room (create) */
.open { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr); gap: 18px; overflow: hidden; }
.open form { overflow-y: auto; min-height: 0; display: grid; gap: 10px; align-content: start; padding-right: 6px; scrollbar-width: thin; scrollbar-color: var(--cyan) #061418; }
.opt { display: grid; grid-template-columns: 15ch 1fr; gap: 10px; align-items: center; }
.opt > span { color: var(--cyan); }
.chips { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.chips button { all: unset; padding: 2px 8px; color: var(--ink); cursor: url("/art/cursor.png") 0 0, pointer; }
.chips button:hover { background: #13303a; }
.chips button[aria-pressed="true"] { background: var(--ink); color: #000; text-shadow: none; }
.chips button:focus-visible { outline: 2px solid var(--yellow); }
.text-in { width: 100%; background: none; border: 0; border-bottom: 2px solid #4e5d63; color: var(--yellow); outline: none; padding: 2px 0; font-size: 16px; }
.text-in:focus { border-color: var(--ink); }
.pic { display: flex; gap: 10px; align-items: center; }
.pic img { width: 48px; height: 48px; object-fit: cover; image-rendering: auto; border: 2px solid var(--ink); }
input[type="range"] { accent-color: var(--yellow); width: 100%; }
.preview { min-height: 0; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.preview .tubes-wrap { flex: 1; }

/* read room */
.read { overflow-y: auto; min-height: 0; flex: 1; padding: 4px 8px; display: grid; gap: 12px; align-content: start; }
.read li { display: grid; grid-template-columns: 4ch 1fr; gap: 8px; max-width: 78ch; }
.read li b { font-weight: normal; }

/* wallet picker */
dialog.pick { color: var(--ink); background: #000; padding: 12px 18px; min-width: 300px; }
dialog.pick::backdrop { background: rgba(0, 0, 0, .7); }
dialog.pick h2 { font-size: 16px; color: var(--yellow); margin-bottom: 10px; font-weight: normal; }
dialog.pick li button { all: unset; display: block; padding: 4px 8px; width: 100%; box-sizing: border-box; cursor: url("/art/cursor.png") 0 0, pointer; }
dialog.pick li button:hover, dialog.pick li button:focus-visible { background: var(--ink); color: #000; }
dialog.pick .key { margin-top: 12px; }

@media (min-width: 1101px) and (max-width: 1250px) {
  :root { --side: 200px; }
  .split { grid-template-columns: minmax(0, 1fr) 240px; }
}
/* desktop home: exactly one screen, never a page scroll; only the tubes list scrolls inside the room */
@media (min-width: 1101px) and (min-height: 641px) {
  html:has(body.home), body.home { height: 100%; overflow: hidden; }
  body.home .crt { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; padding-top: 10px; padding-bottom: 10px; }
  body.home .title { flex: none; margin-bottom: 8px; }
  body.home .stage { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(250px, 1fr) auto auto auto; }
  body.home .room, body.home .verbs, body.home .taps { min-height: 0; overflow: hidden; }
  body.home .verbs { overflow-y: auto; scrollbar-width: none; }
}
@media (min-width: 1101px) and (max-height: 720px) {
  .premise { display: none; }
}
@media (min-width: 1101px) and (max-width: 1250px) {
  .item.mark { width: 60px; }
  .item.mine { width: 106px; }
  .item.mine img { width: 32px; height: 32px; }
  .mine-set { margin-left: 0; }
}
@media (min-width: 1101px) and (max-height: 820px) {
  .verbs button, .verbs a.verb-link { font-size: 16px; line-height: 24px; }
  .scene { max-width: min(256px, 19vh); }
}
/* phones and tablets: one column, the page scrolls; the verbs become a 4 x 2 keypad under the room */
@media (max-width: 1100px) {
  .crt { padding: 10px 10px 16px; }
  .premise { font-size: 16px; }
  .stage { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .room { min-height: 520px; }
  .verbs { order: 2; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
  .verbs button { font-size: 16px; line-height: 32px; text-align: center; padding: 0; }
  .console { order: 3; height: 150px; }
  .prompt { order: 4; }
  .prompt .hint { display: none; }
  .taps { order: 5; max-height: 260px; }
  .inventory { order: 6; }
  .split { grid-template-columns: 1fr; }
  .tubes-wrap { max-height: 520px; }
  .scene { max-width: 140px; }
  .open { grid-template-columns: 1fr; overflow: visible; }
  .open form { overflow: visible; }
  .opt { grid-template-columns: 1fr; gap: 4px; }
  .room-head h2 { font-size: 16px; line-height: 20px; }
  .room-head .timer b { font-size: 16px; line-height: 20px; }
  .list li button { grid-template-columns: 4ch minmax(0, 1fr) 9ch; }
  .list li button .hide-s { display: none; }
}
@media (prefers-reduced-motion: reduce) { .crt::after { background: url("/art/scan.png") repeat; } }

/* ---- the player's room */
.you { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
.you-main { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--cyan) #061418; padding-right: 6px; }
.you-main h3 { font-weight: normal; margin: 6px 0 6px; }
.you-list { display: grid; gap: 2px; margin-bottom: 12px; }
.you-row { display: grid; grid-template-columns: minmax(0, 24ch) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 4px 4px; border-bottom: 1px solid #1f2d33; }
.you-go { all: unset; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: url("/art/cursor.png") 0 0, pointer; }
.you-go:hover, .you-go:focus-visible { background: #13303a; outline: none; }
.you-state { overflow-wrap: anywhere; }
.you-side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; scrollbar-width: none; }
.you-card { display: flex; gap: 10px; align-items: flex-start; }
.you-card > div { display: grid; min-width: 0; }
.you-side .row { display: flex; gap: 8px; flex-wrap: wrap; }
a.key { text-decoration: none; }

/* ---- the boot screen: shown while the page loads and gone by itself at READY; if the script never runs it
   leaves after 9 s so nobody is ever locked out */
.boot { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; padding: 16px;
  animation: boot-bail 0.3s linear 9s forwards; }
.boot.gone { opacity: 0; visibility: hidden; transition: opacity .35s steps(4), visibility 0s .35s; }
@keyframes boot-bail { to { opacity: 0; visibility: hidden; } }
.boot-in { display: grid; justify-items: center; gap: 12px; width: min(640px, 100%); }
.boot-word { width: auto; height: clamp(60px, 14vh, 150px); max-width: 90vw; }
.boot-tap { width: min(180px, 22vh); max-width: none; }
.boot-log { margin: 0; width: 100%; min-height: 8.5em; font: inherit; color: var(--green); white-space: pre-wrap; text-align: left; }
.boot-bar { width: 100%; color: var(--cyan); text-align: left; white-space: pre; overflow: hidden; }
@media (max-width: 1100px) { .you { grid-template-columns: 1fr; } .you-row { grid-template-columns: 1fr; gap: 4px; } }
@media (max-width: 1100px) { .verbs a.verb-link { grid-column: 1 / -1; font-size: 16px; line-height: 32px; text-align: center; margin: 0; } }

/* ---- guidance: the stage track and the "now" line, the tube legend, the tube tooltip, the verb hint */
.now { display: flex; align-items: center; gap: 14px; padding: 6px 4px 10px; flex-wrap: wrap; border-bottom: 2px dotted #2a3a40; margin-bottom: 8px; }
.track { display: flex; align-items: center; gap: 6px; flex: none; }
.track span { padding: 1px 6px; color: #4e5d63; }
.track span.past { color: var(--dim); }
.track span.on { background: var(--yellow); color: #000; text-shadow: none; }
.track i { font-style: normal; color: #4e5d63; }
.now-text { flex: 1 1 320px; color: var(--ink); min-width: 0; }
.tubes-col { min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.tubes-col .tubes-wrap { flex: 1; }
.legend { color: var(--dim); }
.legend b { font-weight: normal; }
.tip { position: fixed; z-index: 40; pointer-events: none; background: #000; border: 2px solid var(--ink); padding: 6px 10px; max-width: 360px; }
.tip[hidden] { display: none; }
.verb-hint { color: var(--dim); font-size: 16px; line-height: 20px; padding: 6px 8px 0; margin-top: auto; min-height: 44px; }
.verbs a.verb-link { margin-top: 4px; }
@media (min-width: 1101px) and (max-height: 820px) { .now { padding: 2px 4px 6px; margin-bottom: 4px; } .verb-hint { min-height: 40px; } }
@media (max-width: 1100px) { .verb-hint { grid-column: 1 / -1; min-height: 0; } .now { gap: 8px; } }
.lg-lit { color: #ff55ff; } .lg-dim { color: #732673; }
@media (max-width: 1100px) {
  /* the contract on its own row, then the three links, then the wallet slots, every slot in a row the same size */
  .inv-row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; }
  .item.scroll { grid-column: 1 / -1; min-width: 0; }
  .links, .mine-set { display: contents; }
  .item.mark { grid-column: span 4; width: auto; min-height: 72px; }
  .item.mine { grid-column: span 3; width: auto; min-height: 76px; margin: 0; }
  .mine-set { margin: 0; }
}
@media (max-width: 520px) {
  .item.mine { grid-column: span 6; }
}
/* tablets: the room keeps its tubes beside the tap and the keypad reads bigger */
@media (min-width: 761px) and (max-width: 1100px) {
  .crt { padding: 16px 24px 24px; }
  .split { grid-template-columns: minmax(0, 1fr) 260px; }
  .scene { max-width: 220px; }
  .room { min-height: 620px; }
  .tubes-wrap { max-height: 600px; }
  .verbs button, .verbs a.verb-link { font-size: 24px; line-height: 44px; }
  .console { height: 170px; }
  .open { grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr); }
  .opt { grid-template-columns: 15ch 1fr; }
}
@media (min-width: 1101px) and (max-height: 900px) {
  .now { flex-wrap: nowrap; }
  .now-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (min-width: 1101px) and (max-height: 720px) { .legend { display: none; } }
.tubes-col, .side { min-width: 0; }
@media (max-width: 1100px) { .track { flex-wrap: wrap; } }
@media (max-width: 1100px) { .track { flex: 1 1 100%; min-width: 0; } }
/* laptops: slimmer slots so the contract keeps two lines at most; on short screens the verb hint yields to DOCS */
@media (min-width: 1101px) and (max-width: 1500px) {
  .item.mark { width: 64px; }
  .item.mine { width: 106px; }
  .item.mine img { width: 32px; height: 32px; }
  .mine-set { margin-left: 0; }
}
@media (min-width: 1101px) and (max-height: 820px) {
  .verb-hint { display: none; }
  .item, button.item { min-height: 56px; }
  .item.mark img { width: 24px; height: 24px; }
  .item.mine img { width: 28px; height: 28px; }
}
