@font-face { font-family: "Jersey 10"; src: url("/fonts/Jersey10-Regular.ttf") format("truetype"); font-display: swap; }
:root { --ink: #f2ecff; --dim: #b9b2d6; --night: #0b0a1a; --panel: #1a1840; --edge: #6f67c9; --gold: #f8cf52; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--night); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.55; -webkit-text-size-adjust: 100%; }
a { color: var(--gold); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---- the game page: the canvas owns the whole screen, nothing scrolls or zooms ---- */
body.game { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; background: #000;
  image-rendering: pixelated; touch-action: none; }
#safe-probe { position: fixed; top: 0; left: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
[hidden] { display: none !important; }

.cover { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(rgba(11, 10, 26, .55), rgba(11, 10, 26, .9)), url("/img/title.png") center / cover no-repeat var(--night);
  image-rendering: pixelated; text-align: center; }
.start-card { margin: auto; max-width: 34rem; }
.logo { font-family: "Jersey 10", ui-monospace, monospace; font-weight: 400; font-size: clamp(3.2rem, 15vmin, 7rem); line-height: .9; margin: 0 0 .15em;
  letter-spacing: .02em; color: #fff; text-shadow: 0 .06em 0 #3a2f8f, 0 .12em 0 #16122a; }
.logo.small { font-size: clamp(2.2rem, 9vmin, 4rem); }
.tag { margin: 0 0 1.2em; color: var(--ink); font-size: clamp(.95rem, 2.6vmin, 1.15rem); }
.note { margin: 1em 0 0; color: var(--dim); font-size: .9rem; }
.btn { font-family: "Jersey 10", ui-monospace, monospace; font-size: clamp(1.8rem, 7vmin, 2.6rem); line-height: 1; color: #16122a; background: var(--gold);
  border: 0; border-bottom: .16em solid #9c6218; border-radius: .2em; padding: .3em 1.5em .22em; min-width: 9em; min-height: 48px; cursor: pointer; touch-action: manipulation; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(.08em); border-bottom-width: .08em; }
.btn:disabled { filter: grayscale(.8); cursor: default; }
.links { display: flex; flex-wrap: wrap; gap: .3em 1.2em; justify-content: center; font-size: .85rem; color: var(--dim); }
.links a { color: var(--ink); padding: .5em .2em; touch-action: manipulation; }
.bar { width: min(22rem, 76vw); height: 14px; margin: 1.2em auto 0; background: #16122a; border: 2px solid var(--edge); border-radius: 3px; overflow: hidden; }
#bar-fill { width: 0; height: 100%; background: var(--gold); transition: width .15s linear; }

/* the game is laid out for a wide screen: on an upright phone, ask for a turn */
#rotate { display: none; z-index: 8; background: var(--night); }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 900px) { body.playing #rotate { display: flex; } }
.phone { width: 54px; height: 96px; margin: 0 auto 1.4em; border: 4px solid var(--ink); border-radius: 10px; animation: turn 2.4s ease-in-out infinite; }
@keyframes turn { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { .phone { animation: none; transform: rotate(-90deg); } #bar-fill { transition: none; } }

.fs { position: fixed; z-index: 9; top: max(6px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); width: 44px; height: 44px;
  display: grid; place-items: center; padding: 0; color: #fff; background: rgba(11, 10, 26, .55); border: 2px solid rgba(255, 255, 255, .5); border-radius: 8px;
  opacity: .5; cursor: pointer; touch-action: manipulation; transition: opacity .2s; }
.fs:hover, .fs:focus-visible { opacity: 1; }
body:not(.playing) .fs { opacity: .9; }

/* ---- the reading pages ---- */
body.doc { min-height: 100vh; }
.doc header { padding: 1.2rem 1rem .4rem; text-align: center; }
.doc header a { text-decoration: none; }
.doc main { max-width: 46rem; margin: 0 auto; padding: 0 1.1rem 3rem; }
.doc h1 { font-family: "Jersey 10", ui-monospace, monospace; font-weight: 400; font-size: 2.6rem; line-height: 1; margin: .6em 0 .2em; }
.doc h2 { font-size: 1.15rem; margin: 1.8em 0 .4em; color: #fff; }
.doc p, .doc li { color: #ddd7f3; }
.doc .meta { color: var(--dim); font-size: .9rem; }
.doc nav { display: flex; gap: 1.2em; justify-content: center; flex-wrap: wrap; padding: 1.2rem 1rem 2rem; border-top: 1px solid #2a2658; font-size: .9rem; }
.doc table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: .45em .6em .45em 0; border-bottom: 1px solid #2a2658; color: #ddd7f3; }
