/* After Hours — Marching Dogs climb. Layout boxes follow the measured original (viewport fractions, ±0.03);
   hues, type and ornament are the brand's. Colour tokens live in assets/colors/tokens.css. System fonts only. */
:root {
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --inset: clamp(14px, 2.2vw, 32px);
  --hud-h: 34px;
  --dialog-pad: 30px;
  --btn-h: 45px;
  /* notch / home-indicator insets (viewport-fit=cover): every edge-hugging box keeps max(its inset, the safe area) */
  --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px);
  --pad-h: 109px;                       /* touch pad height = stick diameter */
  --pad-b: max(16px, var(--sa-b));      /* touch pad bottom inset */
  --focus-ring: 0 0 0 3px var(--md-mustard);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--md-ink); color: var(--md-cream); font-family: var(--sans); overscroll-behavior: none; }
body { overflow: hidden; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: none; box-shadow: var(--focus-ring); } /* every button: the same 3px mustard ring the primary always had */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#arcade { position: fixed; inset: 0; overflow: hidden; background: var(--md-ink); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; outline: none; }

/* ---------- HUD ---------- */
#hud { position: absolute; left: max(var(--inset), var(--sa-l)); right: max(var(--inset), var(--sa-r)); top: max(var(--inset), var(--sa-t)); height: var(--hud-h); display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; text-shadow: 0 1px 0 rgba(0,0,0,.6); }
#hud button { pointer-events: auto; }
/* while the title card is up, a soft top scrim keeps the HUD labels readable over the shelves (gone once the run starts) */
#arcade[data-mode="ready"] #hud::before { content: ''; position: absolute; left: calc(-1 * max(var(--inset), var(--sa-l)) - 2px); right: calc(-1 * max(var(--inset), var(--sa-r)) - 2px); top: calc(-1 * max(var(--inset), var(--sa-t)) - 2px); height: calc(max(var(--inset), var(--sa-t)) + var(--hud-h) + 30px); background: linear-gradient(rgba(21,18,26,.82), rgba(21,18,26,.55) 55%, rgba(21,18,26,0)); pointer-events: none; }
.hud-left { position: relative; display: flex; align-items: flex-start; height: 100%; }
.hud-mark { width: 3px; height: 100%; background: var(--md-orange); margin-right: 8px; border-radius: 1px; }
#floor-id { font: 700 11px/1.75 var(--mono); color: var(--md-orange); width: 54px; margin-top: 7px; letter-spacing: .04em; white-space: nowrap; }
.hud-room { display: flex; flex-direction: column; }
#room { font: 700 clamp(14px, 1.45vw, 20px)/1.05 var(--sans); color: var(--md-cream); letter-spacing: -.01em; white-space: nowrap; }
#mode-badge { font: 700 9px/1.1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--md-green); margin-top: 4px; }
#arcade[data-difficulty="nightmare"] #mode-badge { color: var(--md-red); }
.hud-right { position: relative; display: flex; align-items: center; height: 100%; gap: 6px; font: 700 13px/1.15 var(--mono); color: var(--md-cream); }
.hud-ico { display: inline-flex; color: var(--md-muted); }
#deaths { margin-right: 21px; }
#timer { margin-right: 19px; min-width: 2.2em; }
/* pause: a 44x44 touch target drawn as the original 36x34 (32x32 on phones) plate; the plate is ::before, the glyph sits on top */
#pause { --plate-w: 36px; --plate-h: 34px; position: relative; width: 44px; height: 44px; margin: 0 calc((var(--plate-w) - 44px) / 2); padding: 0; border: 0; background: none; color: var(--md-cream); font-size: 12px; letter-spacing: -.1em; display: inline-flex; align-items: center; justify-content: center; }
#pause::before { content: ''; position: absolute; left: calc((44px - var(--plate-w)) / 2); top: calc((44px - var(--plate-h)) / 2); width: var(--plate-w); height: var(--plate-h); border: 1px solid var(--md-panel-line); border-radius: 3px; background: rgba(21,18,26,.78); }
#pause > span { position: relative; }
#pause:hover::before, #pause:focus-visible::before { border-color: var(--md-mustard); }
#pause:focus-visible { box-shadow: none; } #pause:focus-visible::before { box-shadow: var(--focus-ring); }

/* ---------- start screen ---------- */
#entry { position: absolute; top: 14%; left: 50%; transform: translateX(-50%); width: min(530px, calc(100% - 36px)); display: flex; flex-direction: column; align-items: center; text-align: center; }
/* scrim behind the card so the premise and hint read over the shelf art (no layout change: it is a pseudo-element) */
#entry::before { content: ''; position: absolute; left: -36px; right: -36px; top: -46px; bottom: -26px; z-index: -1; border-radius: 28px; background: radial-gradient(ellipse at 50% 48%, rgba(21,18,26,.9) 0%, rgba(21,18,26,.84) 52%, rgba(21,18,26,.5) 76%, rgba(21,18,26,0) 100%); pointer-events: none; }
#entry .kicker { position: absolute; bottom: calc(100% + 9px); left: 0; right: 0; margin: 0; display: flex; align-items: center; justify-content: center; gap: 7px; font: 700 10px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--md-mustard); white-space: nowrap; }
#entry .kicker img { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--md-panel-line); background: var(--md-panel); image-rendering: auto; }
#entry h1 { margin: 0 0 13px; width: 300px; height: 116px; display: flex; flex-direction: column; align-items: center; font: 900 50px/1 var(--sans); letter-spacing: .02em; text-transform: uppercase; }
#entry h1 .awning { width: 100%; height: 14px; margin-bottom: 2px; flex: none; }
#entry h1 .t1 { color: var(--md-cream); text-shadow: 0 3px 0 var(--md-brick-hi), 0 4px 0 rgba(0,0,0,.5); }
#entry h1 .t2 { color: var(--md-mustard); text-shadow: 0 3px 0 var(--md-mustard-shadow), 0 4px 0 rgba(0,0,0,.5); }
#entry .premise { margin: 0 0 19px; max-width: 440px; font: 500 16px/1.42 var(--sans); color: var(--md-cream); text-shadow: 0 1px 0 rgba(0,0,0,.6); }
#start-choices { display: flex; justify-content: center; gap: 9px; width: 100%; }
#start-choices button, #dialog-choices button { display: inline-flex; align-items: center; gap: 10px; height: 54.5px; padding: 0 16px 0 14px; border: 1px solid var(--md-panel-line); border-radius: 3px; background: rgba(29,23,32,.88); color: var(--md-cream); text-align: left; box-shadow: 0 2px 0 rgba(0,0,0,.4); }
#start-choices button .ico { color: var(--md-green); display: inline-flex; }
#start-choices button[data-difficulty="nightmare"] { border-color: var(--md-nightmare-line); }
#start-choices button[data-difficulty="nightmare"] .ico { color: var(--md-red); }
#start-choices .lbl, #dialog-choices .lbl { display: flex; flex-direction: column; }
#start-choices b, #dialog-choices b { font: 700 16px/1.2 var(--sans); }
#start-choices small, #dialog-choices small { font: 500 10.5px/1.3 var(--mono); color: var(--md-muted); letter-spacing: .02em; }
#start-choices button:hover, #start-choices button:focus-visible, #dialog-choices button:hover, #dialog-choices button:focus-visible { border-color: var(--md-mustard); background: rgba(50,35,34,.95); }
#start-choices button:focus-visible, #dialog-choices button:focus-visible { box-shadow: var(--focus-ring), 0 2px 0 rgba(0,0,0,.4); }
#quick-hint { margin: 12.5px 0 0; width: 100%; text-align: center; font: 600 10px/1.1 var(--mono); letter-spacing: .04em; color: var(--md-muted); text-shadow: 0 1px 0 rgba(0,0,0,.6); white-space: nowrap; }

/* ---------- desktop dash marker, notice, roof prompt ---------- */
#dash-state { position: absolute; left: max(var(--inset), var(--sa-l)); bottom: max(var(--inset), var(--sa-b)); font: 700 10px/1.1 var(--mono); letter-spacing: .12em; color: var(--md-muted); display: inline-flex; align-items: center; gap: 5px; }
#dash-state .dot { width: 6px; height: 6px; background: var(--md-green); box-shadow: 0 0 6px var(--md-green); }
#dash-state[data-spent="true"] .dot { background: var(--md-dot-spent); box-shadow: none; }
#notice { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%); font: 700 12px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--md-mustard); background: rgba(21,18,26,.7); padding: 6px 10px; border-left: 3px solid var(--md-mustard); white-space: nowrap; }
#arcade[data-touch="true"] #notice { bottom: calc(var(--pad-b) + var(--pad-h) + 18px); } /* always clear of the thumb controls, on every phone, iPad and in landscape */
#roof-action { position: absolute; padding: 0 0 24px; white-space: nowrap; pointer-events: none; transform: translate(-50%, -100%); } /* the box keeps a clear 24px tail below the label, like the original's prompt box */
#roof-action .tag { display: inline-block; font: 700 12px/1.2 var(--mono); color: var(--md-cream); background: rgba(21,18,26,.85); border: 1px solid var(--md-mustard); border-bottom: 3px solid var(--md-mustard); padding: 6px 10px; }

/* ---------- touch pad (phone) ---------- */
#touch-pad { position: absolute; left: max(14px, var(--sa-l)); right: max(14px, var(--sa-r)); bottom: var(--pad-b); height: var(--pad-h); touch-action: none; user-select: none; -webkit-user-select: none; }
#stick { position: absolute; left: 0; top: 0; width: var(--pad-h); height: var(--pad-h); border-radius: 50%; background: rgba(21,18,26,.55); border: 1px solid rgba(243,231,201,.22); touch-action: none; }
#stick .ring { position: absolute; inset: 10px; border-radius: 50%; border: 1px dashed rgba(243,231,201,.18); }
#stick .arrows { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 9px; font: 700 22px/1 var(--sans); color: rgba(243,231,201,.45); }
#stick .knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, var(--md-muted), var(--md-knob-dark) 70%); border: 2px solid rgba(243,231,201,.5); box-shadow: 0 3px 0 rgba(0,0,0,.4); }
#touch-pad button { position: absolute; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; font: 700 11px/1 var(--mono); letter-spacing: .08em; color: var(--md-cream); border: 2px solid rgba(243,231,201,.35); touch-action: none; user-select: none; -webkit-user-select: none; padding: 0; }
#touch-pad button .glyph { font: 700 22px/1 var(--sans); margin-bottom: 3px; }
#touch-pad [data-key="dash"] { right: 98px; bottom: 21px; width: 66px; height: 66px; background: rgba(29,23,32,.8); }
#touch-pad [data-key="jump"] { right: 0; bottom: 2px; width: 90px; height: 90px; font-size: 13px; color: var(--md-ink); background: radial-gradient(circle at 40% 30%, var(--md-peach), var(--md-orange) 75%); border-color: var(--md-cream); box-shadow: 0 4px 0 var(--md-orange-shadow); }
#touch-pad button:active, #touch-pad button[data-down="true"] { filter: brightness(1.2); transform: translateY(1px); }

/* ---------- dialog ---------- */
#overlay { position: absolute; inset: 0; background: rgba(21,18,26,.62); display: flex; align-items: center; justify-content: center; }
#dialog { position: relative; width: min(408px, calc(100% - 32px)); padding: var(--dialog-pad); background: var(--md-panel); border: 1px solid var(--md-panel-line); border-top: 4px solid var(--md-orange); box-shadow: 0 18px 40px rgba(0,0,0,.5); color: var(--md-cream); }
.dialog-dots { position: absolute; right: 12px; top: 6px; font: 700 10px/1 var(--mono); color: var(--md-muted); letter-spacing: -.1em; }
#dialog-kicker { margin: 0 0 13px; font: 700 11px/13px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--md-mustard); }
#dialog-title { margin: 0 0 10px; font: 900 45px/1 var(--sans); letter-spacing: -.01em; text-transform: uppercase; color: var(--md-cream); text-shadow: 0 3px 0 var(--md-brick-hi); }
#dialog-text { margin: 0 0 17.2px; min-height: 30.5px; font: 600 11px/1.4 var(--mono); color: var(--md-muted); white-space: pre-line; }
#dialog[data-view="won"] #dialog-text { font: 500 14px/1.5 var(--sans); color: var(--md-cream); }
#dialog[data-view="help"] #dialog-text { font: 500 13px/1.5 var(--sans); color: var(--md-cream); }
#dialog-buttons, #dialog-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#dialog[data-view="won"] #dialog-buttons, #dialog[data-view="help"] #dialog-buttons { grid-template-columns: 1fr; }
#dialog button { height: var(--btn-h); display: inline-flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--md-panel-line); border-radius: 2px; background: var(--md-button); color: var(--md-cream); font: 700 13px/1 var(--mono); text-align: left; }
#dialog button .ico { color: var(--md-muted); font-size: 13px; width: 14px; display: inline-flex; justify-content: center; }
#dialog button .lbl { white-space: nowrap; letter-spacing: -.02em; }
#dialog button:hover, #dialog button:focus-visible { border-color: var(--md-mustard); background: var(--md-button-hover); }
#dialog #primary { background: linear-gradient(90deg, var(--md-peach), var(--md-orange)); color: var(--md-ink); border-color: var(--md-cream); }
#dialog #primary .ico { color: var(--md-ink); }
#dialog-choices button { height: auto; min-height: var(--btn-h); }

/* ---------- phone (portrait, narrow) ---------- */
@media (max-width: 600px) {
  :root { --inset: 12px; --hud-h: 32px; --dialog-pad: 21px; }
  #floor-id { font-size: 9px; width: 48px; margin-top: 5px; }
  .hud-mark { margin-right: 6px; }
  #mode-badge { font-size: 8px; margin-top: 2px; }
  .hud-right { font-size: 11px; }
  #deaths { margin-right: 4px; }
  #timer { margin-right: 4px; }
  #pause { --plate-w: 32px; --plate-h: 32px; font-size: 11px; }
  #entry { top: 13%; }
  #entry::before { left: -22px; right: -22px; top: -40px; bottom: -22px; }
  #entry .kicker { bottom: calc(100% + 8px); font-size: 9px; }
  #entry .kicker img { width: 16px; height: 16px; }
  #entry h1 { width: 175px; height: 68px; font-size: 29px; margin-bottom: 10px; }
  #entry h1 .awning { width: 262px; height: 8px; margin-bottom: 1px; } /* the stripe spans the card, not just the word (flex centres the overflow) */
  #entry .premise { font-size: 13px; max-width: 280px; margin-bottom: 12px; }
  #start-choices button { height: 47.4px; padding: 0 5px 0 4px; gap: 6px; }
  #start-choices b { font-size: 15px; }
  #start-choices small { font-size: 10px; }
  #quick-hint { font-size: 9px; line-height: 1.5; margin-top: 13px; }
  #dialog-title { font-size: 31px; }
  #dialog button { font-size: 11px; }
  #notice { font-size: 11px; }
}
/* phone landscape: short viewport */
@media (max-height: 520px) {
  :root { --inset: 8px; --pad-h: min(109px, 24vh); --pad-b: max(10px, var(--sa-b)); }
  #entry { top: 6%; }
  #entry::before { top: -14px; bottom: -14px; }
  #entry .kicker { bottom: calc(100% + 3px); }
  #entry h1 { width: 132px; height: 52px; font-size: 22px; margin-bottom: 6px; }
  #entry h1 .awning { width: 220px; height: 6px; }
  #entry .premise { font-size: 12px; margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
