/* Retro Box (web). Same look as the real one: black screen, IBM Plex Mono, grey text, green prompt. */
@font-face { font-family: "IBM Plex Mono"; src: local("IBM Plex Mono"), url("fonts/IBMPlexMono-Regular.ttf"); font-weight: 400; }
@font-face { font-family: "IBM Plex Mono"; src: local("IBM Plex Mono Bold"), url("fonts/IBMPlexMono-Bold.ttf"); font-weight: 700; }

:root { --bg: #000; --fg: #c8c8c8; --dim: #6c6c6c; --accent: #00d7d7; --green: #5fd75f; --red: #ff5f5f; --unit: clamp(14px, 2.6vh, 30px); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
body { font: 400 var(--unit)/1.35 "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace; }
[hidden] { display: none !important; }
.dim { color: var(--dim); } .accent { color: var(--accent); } .white { color: #fff; }
.b { font-weight: 700; } .g { color: var(--green); font-weight: 700; } .red { color: var(--red); }

/* ---- shell */
#term { position: absolute; inset: 0; padding: 12px 16px; overflow-y: auto; word-break: break-word; scrollbar-width: none; }
#out > div, #line { white-space: pre-wrap; }   /* only text lines keep their spaces, not the gaps in the page's own markup */
#term::-webkit-scrollbar { display: none; }
#out > div { min-height: 1.35em; }
#cursor { background: var(--fg); color: var(--bg); }
#cursor.ghost { color: #666; }                 /* the cursor sitting on the first letter of the grey suggestion */
#term.busy #line, #term.busy #menu { display: none; }
#ghost { color: var(--dim); }
#menu { margin-top: .2em; display: grid; grid-template-columns: max-content 1fr; width: max-content; max-width: 100%; }
#menu span { padding: 0 1ch; background: #303030; color: #c0c0c0; }
#menu span.meta { background: #262626; color: #8a8a8a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#menu span.on { background: #00afaf; color: #000; }

/* ---- library: two rows of box art, like retro-library */
#library { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; --line: calc(var(--unit) * 1.35); --pad: max(8px, 1.1vh); }
#lib-head, #lib-foot { height: calc(var(--line) * 2); padding: var(--pad) calc(var(--pad) * 2); white-space: pre; flex: none; overflow: hidden; }
#lib-grid { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; display: grid; justify-content: center; align-content: start;
  --tile-h: calc((100vh - var(--line) * 4) / 2); --cover-h: calc(var(--tile-h) - var(--line) * 2 - var(--pad) * 3);
  --tile-w: calc(var(--cover-h) * 0.78 + var(--pad) * 2);
  grid-template-columns: repeat(auto-fill, var(--tile-w)); grid-auto-rows: var(--tile-h); scroll-snap-type: y mandatory; }
#lib-grid::-webkit-scrollbar { display: none; }
@media (max-height: 599px) { #lib-grid { --tile-h: calc(100vh - var(--line) * 4); } }
.tile { padding: var(--pad); display: flex; flex-direction: column; align-items: center; cursor: pointer; border: max(3px, calc(var(--pad) / 3)) solid transparent; scroll-snap-align: start; overflow: hidden; }
.tile .cover { height: var(--cover-h); width: 100%; display: flex; align-items: flex-end; justify-content: center; flex: none; }
.tile img { max-width: 100%; max-height: 100%; display: block; }
.tile .noart { align-self: center; color: var(--fg); text-align: center; }
.tile .name { margin-top: calc(var(--pad) / 2); text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.tile.on { border-color: var(--accent); }
.tile.on .name { background: var(--accent); color: #000; }
#lib-empty { position: absolute; top: 50%; left: 0; right: 0; text-align: center; }

/* ---- player */
#player { position: absolute; inset: 0; background: #000; }
#stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#stage canvas { display: block; image-rendering: pixelated; background: #000; outline: none; }
#stage.nocursor, #stage.nocursor canvas { cursor: none; }
#loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6em; text-align: center; padding: 1em; background: #000; }
#loading-title { color: #fff; font-weight: 700; }
#loading-bar { width: min(60vw, 30em); height: .5em; border: 1px solid var(--dim); }
#loading-bar i { display: block; height: 100%; width: 0; background: var(--accent); }
#bar { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 1ch; align-items: center; padding: .3em 1ch; background: rgba(20, 20, 20, .92);
  font-size: calc(var(--unit) * .7); transform: translateY(-100%); transition: transform .15s; }
#player.show-bar #bar { transform: none; }
#bar .spacer { flex: 1; }
#bar button { font: inherit; color: #000; background: var(--fg); border: 0; padding: .1em 1ch; cursor: pointer; }
#bar button:hover { background: var(--accent); }
