/* ============================================================
   Storeyrafter — play screen
   Night tower, lit rooms, amber window light. 1px structure.
   Motion 120-180ms. No bloom, no grain, no vignette.
   ============================================================ */

:root {
  --ink: #0b0d11;
  --room: #161b23;
  --line: #2b333f;
  --amber: #ffb347;
  --amber-dim: #a8743a;
  --up: #2fd987;
  --down: #ff4f6d;
  --cream: #f2e9dc;
  --muted: #8b95a4;

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --disp: "Oswald", "Arial Narrow", system-ui, sans-serif;
  --fast: 140ms;
  --snap: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; }

/* Hiding is how token-gated and symbol-dependent UI stays off the page before
   launch, so it has to beat every `display` declared below. Our own classes
   (.g-btn, .g-overlay, .g-chainpill, .g-tick…) set `display`, which outranks
   the UA's `[hidden]` rule on specificity and left hidden elements rendering.
   One global rule, instead of a `[hidden]` escape hatch per component. */
[hidden] { display: none !important; }

html, body { height: 100%; }

.g-body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  overflow-x: hidden;
}

.g-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- top bar ---------- */

.g-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  min-height: 46px;
}

.g-home {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--cream);
  text-decoration: none;
}

.g-home-mark {
  width: 13px; height: 17px;
  flex: none;
  background:
    linear-gradient(var(--amber), var(--amber)) 0 0 / 100% 1px no-repeat,
    linear-gradient(var(--amber-dim), var(--amber-dim)) 0 100% / 100% 1px no-repeat;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  position: relative;
}
.g-home-mark::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; top: 6px;
  height: 1px;
  background: var(--line);
}

.g-brand {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .13em;
  text-transform: uppercase;
  line-height: 1;
}

.g-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.g-chainpill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 9px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.g-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.g-chainpill.is-ok .g-dot { background: var(--up); }
.g-chainpill.is-bad .g-dot { background: var(--down); }

.g-docslink {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.g-docslink:hover { color: var(--amber); border-color: var(--amber-dim); }

/* ---------- live price rail ---------- */

.g-rail {
  flex: none;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: #0e1218;
  min-height: 34px;
  overflow: hidden;
}

.g-rail-label {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-right: 1px solid var(--line);
  color: var(--amber-dim);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.g-rail-track {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  overscroll-behavior-x: contain;
}
.g-rail-track::-webkit-scrollbar { display: none; }

.g-rail-wait { padding: 0 10px; color: var(--muted); }

.g-tick {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 11px;
  border-right: 1px solid var(--line);
  height: 100%;
  line-height: 32px;
}
.g-tick-sym { color: var(--muted); letter-spacing: .04em; }
.g-tick-px  { color: var(--cream); font-weight: 500; }
/* during a shift the rail leads with the desk, then dims the rest of the board */
.g-tick.is-mine { background: rgba(255, 179, 71, .07); }
.g-tick.is-mine .g-tick-sym { color: var(--amber); }
.g-tick.is-mine .g-tick-px { color: var(--cream); }
.g-tick.is-off { opacity: .42; }
.g-tick-mine {
  font-size: 8.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--amber-dim);
  border: 1px solid var(--amber-dim);
  padding: 0 3px;
  line-height: 1.4;
}

/* the ticker the live order names */
.g-tick.is-live { background: rgba(255, 179, 71, .18); opacity: 1; }
.g-tick.is-live .g-tick-sym { color: var(--amber); }
.g-tick.is-live .g-tick-px { color: var(--cream); font-weight: 600; }

.g-rail.is-desk .g-rail-label { color: var(--amber); }

/* ---------- main ---------- */

.g-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}

.g-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 320px;
  display: flex;
  overflow: hidden;
  background: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

/* The renderer sets an explicit px width/height on the canvas so the floor is
   letterboxed at a whole number of css pixels per art pixel; `margin:auto`
   centres what is left. Until the first frame runs it just fills the stage. */
.g-canvas {
  display: block;
  width: 100%;
  height: 100%;
  margin: auto;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- overlays ---------- */

.g-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px;
  background: rgba(11, 13, 17, .93);
  text-align: center;
  animation: g-fade var(--fast) var(--snap) both;
}
/* the global [hidden] rule above covers this; the animation must not run */
.g-overlay[hidden] { animation: none; }

@keyframes g-fade { from { opacity: 0 } to { opacity: 1 } }

.g-how {
  max-width: 50ch;
  display: grid;
  gap: 8px;
}
.g-how p { margin: 0; color: var(--cream); font-size: 14px; }
.g-how-2 { color: var(--muted) !important; }
.g-how b { color: var(--amber); font-weight: 600; }

.g-keycap {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--room);
  color: var(--cream);
  font-family: var(--mono);
  font-size: .9em;
  text-align: center;
}

.g-start {
  font-family: var(--disp);
  background: var(--amber);
  color: var(--ink);
  border: 0;
  padding: 14px 30px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  transition: transform var(--fast) var(--snap), filter var(--fast) var(--snap);
}
.g-start:hover { filter: brightness(1.08); }
.g-start:active { transform: translateY(1px); }
.g-start-main {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  line-height: 1.1;
}
.g-start-sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  opacity: .78;
}

.g-tol { margin: 0; color: var(--muted); font-size: 11.5px; letter-spacing: .03em; max-width: 46ch; }

.g-keys {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  justify-content: center;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}
.g-keys-or { color: var(--amber-dim); }
.g-keys .g-keycap { margin-right: 2px; }
/* a phone has no WASD: show only the drag hint there, and only the keys on a desktop */
@media (hover: none) and (pointer: coarse) { .g-keys > span:first-child { display: none; } }
@media (hover: hover) and (pointer: fine) { .g-keys-or { display: none; } }

.g-go-num {
  font-family: var(--disp);
  font-size: clamp(64px, 22vw, 128px);
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  animation: g-pop 180ms var(--snap) both;
}
@keyframes g-pop { from { opacity: .2; transform: scale(.88) } to { opacity: 1; transform: none } }
.g-go-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
}

.g-down-h {
  font-family: var(--disp);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0;
  color: var(--down);
}
.g-down-p { margin: 0; max-width: 44ch; color: var(--muted); font-size: 13.5px; }

/* ---------- result ---------- */

.g-overlay--result {
  justify-content: flex-start;
  overflow-y: auto;
  gap: 14px;
  padding: 20px 16px 28px;
  -webkit-overflow-scrolling: touch;
}

.g-res-head { display: grid; gap: 4px; }
.g-res-h {
  font-family: var(--disp);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.1;
}
.g-res-h.is-up { color: var(--up); }
.g-res-h.is-down { color: var(--down); }
.g-res-sub { margin: 0; color: var(--muted); font-size: 12.5px; }

.g-res-grid {
  margin: 0;
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  gap: 0;
}
.g-res-cell {
  padding: 11px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: var(--room);
}
.g-res-cell:nth-child(2n) { border-right: 0; }
.g-res-cell:nth-last-child(-n+2) { border-bottom: 0; }
.g-res-grid dt {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.g-res-grid dd {
  margin: 3px 0 0;
  font-size: 24px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  line-height: 1.1;
}

.g-res-tally {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.g-res-tally b { color: var(--cream); font-weight: 500; }

.g-proof {
  width: 100%;
  max-width: 520px;
  text-align: left;
  border: 1px solid var(--line);
  padding: 12px;
}
.g-proof-h {
  margin: 0;
  font-family: var(--disp);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--cream);
}
.g-proof-p { margin: 5px 0 9px; color: var(--muted); font-size: 11.5px; }
.g-proof-p code { color: var(--amber-dim); }

.g-proof-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.g-proof-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.g-proof-list li:first-child { border-top: 0; }
.g-proof-sym { color: var(--amber); width: 5.5ch; flex: none; }
.g-proof-round {
  color: var(--cream);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  flex: 1 1 10ch;
  min-width: 0;
}
.g-proof-link { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); white-space: nowrap; }
.g-proof-link:hover { color: var(--amber); border-color: var(--amber-dim); }
.g-proof-none { color: var(--muted); font-size: 12px; margin: 0; }

.g-res-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }

.g-btn {
  font-family: var(--disp);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: transparent;
  color: var(--cream);
  border: 1px solid var(--line);
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color var(--fast) var(--snap), color var(--fast) var(--snap);
}
.g-btn:hover { border-color: var(--amber-dim); color: var(--amber); }
.g-btn--primary { background: var(--amber); color: var(--ink); border-color: var(--amber); }
.g-btn--primary:hover { color: var(--ink); filter: brightness(1.08); }

.g-lock {
  margin: 0;
  max-width: 50ch;
  color: var(--muted);
  font-size: 11.5px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}
.g-lock b { color: var(--cream); font-weight: 500; }

/* ---------- clerk name, holder address, burn receipt ---------- */

.g-field { display: grid; gap: 5px; width: min(100%, 46ch); text-align: left; }
.g-field label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.g-opt { color: var(--amber-dim); text-transform: none; letter-spacing: .02em; margin-left: 4px; }
.g-field input,
.g-burn input {
  font: 500 14px var(--mono);
  color: var(--cream);
  background: var(--ink);
  border: 1px solid var(--line);
  padding: 9px 10px;
  min-width: 0;
  width: 100%;
}
.g-field input:focus-visible,
.g-burn input:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber-dim); }
.g-field-row { display: flex; gap: 8px; align-items: stretch; }
.g-field-row .g-btn { white-space: nowrap; padding: 9px 12px; font-size: 12.5px; }
.g-field-note { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.g-field-note code { color: var(--cream); }
.g-field-note[data-tone="ok"] { color: var(--up); }
.g-field-note[data-tone="bad"] { color: var(--down); }

.g-holder { display: grid; gap: 12px; justify-items: center; width: min(100%, 52ch); }
.g-burn { width: min(100%, 46ch); text-align: left; font-size: 11.5px; color: var(--muted); }
.g-burn summary { cursor: pointer; color: var(--cream); padding: 4px 0; }
.g-burn summary:hover { color: var(--amber); }
.g-burn[open] { display: grid; gap: 8px; }

@media (max-width: 420px) {
  .g-field-row { flex-direction: column; }
}

/* ---------- thumb stick ---------- */

.g-stick {
  position: absolute;
  z-index: 3;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  border: 1px solid var(--amber-dim);
  border-radius: 50%;
  background: rgba(22, 27, 35, .42);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--fast) var(--snap);
}
.g-stick.is-on { opacity: 1; }

.g-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 1px var(--ink);
}

/* a quiet hint of where the stick lives, before the first touch */
.g-hint-stick {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 72px;
  height: 72px;
  border: 1px dashed var(--line);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}

.g-foot {
  flex: none;
  margin: 0;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- focus ---------- */

:where(a, button):focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ---------- phone ---------- */

@media (max-width: 719px) {
  .g-body { font-size: 14px; }
  .g-rail-label { display: none; }
  .g-res-grid dd { font-size: 20px; }
  .g-res-h { font-size: 23px; }
  .g-how p { font-size: 13px; }
  .g-start-main { font-size: 20px; }
  .g-foot { font-size: 10px; }
  .g-overlay { padding: 14px; gap: 13px; }
  .g-stage { min-height: 240px; }
}

@media (max-width: 400px) {
  .g-top { padding: 8px 10px; }
  .g-top-right { gap: 8px; font-size: 11px; }
  .g-chainpill { padding: 3px 7px; }
}

/* short landscape phones: keep the controls reachable */
@media (max-height: 560px) {
  .g-stage { min-height: 200px; }
  .g-how p { font-size: 12px; }
  .g-overlay { gap: 9px; padding: 10px; }
  .g-foot { font-size: 9px; padding: 6px 10px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- practice run ---------- */
.g-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  background: transparent;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 8px 10px;
}
.g-link:hover, .g-link:focus-visible { color: var(--amber); }

/* sits above the canvas bottom hint line; only the buttons take taps, the rest
   lets the thumb stick through */
.g-coach {
  position: absolute;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  padding: 10px 14px 8px;
  background: rgba(11, 13, 17, .92);
  border: 1px solid var(--amber-dim);
  text-align: center;
  pointer-events: none;
  z-index: 5;
}
.g-coach-step { margin: 0 0 4px; font: 500 11px/1 var(--disp); letter-spacing: .18em; text-transform: uppercase; color: var(--amber); }
.g-coach-text { margin: 0; font-size: 13px; line-height: 1.45; color: var(--cream); }
.g-coach.is-bad { border-color: var(--down); }
.g-coach.is-bad .g-coach-step { color: var(--down); }
.g-coach.is-good { border-color: var(--up); }
.g-coach.is-good .g-coach-step { color: var(--up); }
.g-coach-actions { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 4px; pointer-events: auto; }
.g-coach-actions .g-btn { margin-top: 6px; }
@media (max-width: 560px) {
  .g-coach { padding: 5px 8px 1px; bottom: calc(6px + env(safe-area-inset-bottom, 0px)); width: calc(100% - 12px); }
  .g-coach-step { margin-bottom: 2px; font-size: 10px; }
  .g-coach-text { font-size: 10.5px; line-height: 1.3; }
  .g-coach-actions .g-btn { margin-top: 2px; padding: 7px 14px; }
  .g-coach-actions .g-link { padding: 4px 8px; font-size: 11px; }
}
