/* Labyrinth — amber phosphor.
   One hue, one font, and a lot of black. The scanlines and the vignette are not
   nostalgia for its own sake: a low-resolution buffer upscaled hard needs
   something on top of it, and the vignette is what makes a dark corridor read as
   dark rather than as an unlit canvas. */

:root {
  --amber: #ffb000;
  --amber-dim: #a87000;
  --amber-hot: #ffe9b8;
  --ink: #0a0600;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--amber);
  font: 500 15px/1.5 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  touch-action: none;
  background: #05030a;
  overflow: hidden;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Nothing on this canvas is ever a target: it is the map, and the map is a
     picture. Every gesture belongs to the corridor or to the stage. */
  pointer-events: none;
}

/* Placed by the layout rather than by CSS: it is one pane of a split, and the
   split moves. */
#fp {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}

/* The buffer is small on purpose; do not let the browser smooth it back into
   mush on the way up.

   Deliberately no CSS `filter` here. A filter on a full-screen element is a
   composited pass every frame, and this canvas already redraws every frame
   under a second canvas and two overlays — on iOS that stack is the thing most
   likely to cost the frame rate, not the raycaster (which measures at well
   under a millisecond). Any color grading belongs in the palette, where it is
   free. */
#fp {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  overflow: hidden;
}

#overlay { pointer-events: none; }

#scanlines, #vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Plain alpha rather than `mix-blend-mode: multiply`. Over a scene this dark the
   two are all but indistinguishable, and multiply forces its own blended
   compositing layer on every frame. */
#scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.17) 3px,
    rgba(0, 0, 0, 0.17) 4px
  );
}

#vignette {
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.55) 88%, rgba(0,0,0,0.82) 100%);
}

/* --- HUD --- */

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  pointer-events: none;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spacer { flex: 1; }

.stat {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.45);
}

.stat .lbl {
  color: var(--amber-dim);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.stat.done { color: var(--amber-hot); }

#facing {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--amber-dim);
  white-space: nowrap;
}

/* Deliberately off-axis: say so rather than round it away. */
#facing.off { color: var(--amber); }

button {
  pointer-events: auto;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  background: rgba(20, 12, 0, 0.62);
  border: 1px solid rgba(255, 176, 0, 0.38);
  border-radius: 6px;
  padding: 7px 11px;
  min-height: 36px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

button:active { background: rgba(255, 176, 0, 0.2); }
button[aria-pressed="true"] { background: rgba(255, 176, 0, 0.26); color: var(--amber-hot); }

/* The back strip. Present enough to be found, faint enough not to sit in the
   middle of the view all round. */
/* Placed by the layout too, for the same reason: it is the bottom of the
   corridor, and the corridor is a pane. */
#back-zone {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(255, 176, 0, 0.10), rgba(255, 176, 0, 0));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

#back-zone .chev {
  width: 58px;
  height: 24px;
  fill: var(--amber);
  opacity: 0.55;
  filter: drop-shadow(0 0 6px rgba(255, 176, 0, 0.55));
}

#back-zone.pulse {
  animation: back-pulse 0.4s ease-out;
}

/* Held down and reversing: the strip stays lit for as long as the walk runs, so
   the gesture is visibly still happening rather than something that fired once. */
#back-zone.live {
  background: linear-gradient(to top, rgba(255, 176, 0, 0.26), rgba(255, 176, 0, 0));
}

#back-zone.live .chev {
  opacity: 0.95;
}

@keyframes back-pulse {
  0% { background: linear-gradient(to top, rgba(255, 176, 0, 0.34), rgba(255, 176, 0, 0)); }
  100% { background: linear-gradient(to top, rgba(255, 176, 0, 0.10), rgba(255, 176, 0, 0)); }
}

@media (prefers-reduced-motion: reduce) {
  #back-zone.pulse { animation: none; }
}

/* --- transient copy --- */

#toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 12, 0, 0.7);
  border: 1px solid rgba(255, 176, 0, 0.3);
  color: var(--amber-hot);
  font-size: 13px;
  letter-spacing: 0.03em;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show { opacity: 1; }

/* The instructions sit over whatever corridor the maze happened to start you in,
   so they cannot rely on the view behind them being dark — and the view is never
   still. A translucent window of their own is the only way they stay readable in
   a lit corridor, and it also gives the panel an edge, which is what makes it
   read as something that will go away rather than part of the furniture. */
#hint {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  /* Clear of the back strip's chevron, which lives at the very bottom. */
  margin-bottom: 40px;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(10, 6, 0, 0.72);
  border: 1px solid rgba(255, 176, 0, 0.22);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  color: var(--amber-dim);
  font-size: 12.5px;
  line-height: 1.55;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* "gesture — description" is a two-column table pretending to be prose, and
   centering it makes every row start in a different place, so the eye has to
   find the gesture on each line instead of running down a column of them. */
#hint dl {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 5px;
  margin: 0;
  align-items: baseline;
}

#hint dt {
  color: var(--amber);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

#hint dd { margin: 0; }
#hint.gone { opacity: 0; }

/* --- panels --- */

#menu, #win {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 3, 0, 0.78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 10;
  padding: 20px;
}

#menu[hidden], #win[hidden] { display: none; }

.panel {
  width: min(420px, 100%);
  background: rgba(16, 10, 0, 0.94);
  border: 1px solid rgba(255, 176, 0, 0.34);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 0 60px rgba(255, 176, 0, 0.09);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 0.28em;
  font-weight: 600;
  color: var(--amber-hot);
}

.blurb {
  margin: 0 0 18px;
  color: var(--amber-dim);
  font-size: 13px;
  line-height: 1.65;
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  font-size: 13px;
}

.field > span { color: var(--amber-dim); text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; }

.field.check { align-items: flex-start; line-height: 1.5; }
.field.check span { text-transform: none; letter-spacing: 0; font-size: 12.5px; }

select {
  flex: 1;
  font: inherit;
  font-size: 13px;
  color: var(--amber);
  background: rgba(255, 176, 0, 0.08);
  border: 1px solid rgba(255, 176, 0, 0.3);
  border-radius: 6px;
  padding: 7px 9px;
}

input[type="checkbox"] {
  accent-color: var(--amber);
  width: 17px;
  height: 17px;
  margin-top: 1px;
  flex: none;
}

.seedline {
  margin: 16px 0 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber-dim);
}

.seedline span { color: var(--amber); }

.buttons {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.buttons button { flex: 1; }

.score {
  margin: 6px 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 26px;
  color: var(--amber-hot);
}

.score .lbl {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber-dim);
}

@media (prefers-reduced-motion: reduce) {
  #toast, #hint { transition: none; }
}
