:root {
  --black: #000; --blue: #0000d7; --red: #d70000; --cyan: #00d7d7; --yellow: #d7d700; --white: #d7d7d7; --bright: #fff; --shelf: #1a1a1a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  background: var(--blue); color: var(--white);
  font: 16px/1.4 system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
.px { display: block; image-rendering: pixelated; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
#stripes { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; display: none; }

/* Buttons: black slabs with pixel labels */
.btn {
  display: inline-grid; place-items: center; min-height: 48px; padding: 0 18px;
  background: var(--black); color: var(--white); border: 3px solid var(--white); border-radius: 0;
  font: inherit; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--white); border-color: var(--white); }
.btn:active { transform: translateY(2px); }

/* Home: the tape shelf */
#home { height: 100%; overflow-y: auto; padding: 20px 16px 40px; max-width: 640px; margin: 0 auto; touch-action: pan-y; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.actions { display: flex; gap: 10px; }
.note { margin: 0 0 16px; padding: 12px 14px; background: var(--black); border-left: 6px solid var(--yellow); }
.tapes { list-style: none; margin: 0; padding: 12px; display: grid; gap: 8px; background: var(--shelf); border: 4px solid var(--black); }
.tape { display: grid; grid-template-columns: 22px 1fr auto; align-items: stretch; min-height: 64px; background: var(--black); }
.tape .stripes { background: repeating-linear-gradient(to bottom, var(--red) 0 4px, var(--cyan) 4px 8px); }
.tape .play { all: unset; cursor: pointer; display: grid; gap: 6px; align-content: center; padding: 10px 14px; }
.tape .play:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }
.tape .tools { display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.tape .tool { all: unset; cursor: pointer; padding: 10px 8px; }
.tape .tool:focus-visible { outline: 3px solid var(--yellow); }
.empty { padding: 28px 18px; background: var(--black); display: grid; gap: 14px; justify-items: start; }

/* Loading */
#loading { height: 100%; display: grid; place-items: center; }
.loading-screen { width: min(90vw, 120vh); aspect-ratio: 4/3; background: var(--white); color: var(--black); display: grid; place-items: center; padding: 16px; }
#loading-text { display: grid; gap: 10px; justify-items: center; }

/* Game */
#game { height: 100%; display: grid; place-items: center; touch-action: none; }
#screen { image-rendering: crisp-edges; image-rendering: pixelated; background: #000; }
/* Always-visible way out of a game (the app has no browser back button when installed) */
.btn.corner { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: calc(env(safe-area-inset-left) + 10px); min-height: 40px; padding: 0 12px; border-width: 2px; }

/* Scanner */
#scan, #share, #message { height: 100%; display: grid; place-items: center; align-content: center; gap: 18px; padding: 16px; background: var(--black); }
.scan-frame { position: relative; width: min(92vw, 70vh); aspect-ratio: 1; overflow: hidden; background: #111; }
#scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-target { position: absolute; inset: 10%; border: 4px dashed var(--yellow); }
.status { display: grid; gap: 8px; justify-items: center; text-align: center; max-width: 34ch; }

/* Share */
#share { background: var(--white); color: var(--black); }
#share-qr { width: min(86vw, 62vh); height: auto; image-rendering: pixelated; background: #fff; }

/* Dialogs */
dialog { border: 4px solid var(--white); background: var(--black); color: var(--white); padding: 22px; display: grid; gap: 12px; justify-items: stretch; min-width: 240px; }
dialog:not([open]) { display: none; }
dialog::backdrop { background: rgba(0,0,0,.6); }
