/* ==========================================================================
   Tollbooth, Quillmark, Junkdrawer
   Screen-printed poster stock: eight inks, hard edges, no gradients in type.
   Ink values are hex so the DOM chrome and the canvas share exact plates.
   ========================================================================== */

:root {
  /* --- the eight plates --- */
  --ink:    #0A1F27;   /* deep teal-black, the stock */
  --ink-2:  #123540;   /* concourse floor */
  --ink-3:  #1B4A57;   /* raised edge */
  --bone:   #F2E7CE;   /* paper white plate */
  --ochre:  #E9A82F;   /* lamplight, marks, gold */
  --verm:   #D14428;   /* alarm, the crew, the strike */
  --sea:    #2E8F72;   /* signage, safe things */
  --plum:   #7A3A66;   /* the dreaming part */

  --bone-dim: #C9BFA9;
  --bone-mute: #93917F;

  /* --- type --- */
  --display: "Alfa Slab One", "Rockwell", Georgia, serif;
  --ui: "Barlow Condensed", "Oswald", "Haettenschweiler", sans-serif;

  /* --- z scale --- */
  --z-hud: 10;
  --z-touch: 20;
  --z-frame: 30;
  --z-screen: 40;
  --z-toast: 50;

  /* --- motion --- */
  --out: cubic-bezier(0.22, 1, 0.36, 1);
  --out-quint: cubic-bezier(0.16, 1, 0.3, 1);

  /* --- halftone --- */
  --dot: radial-gradient(circle at center, rgba(242,231,206,.055) 0.9px, transparent 1px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--ui);
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body::before {                      /* silkscreen tooth over everything */
  content: "";
  position: fixed; inset: 0;
  background-image: var(--grain, none), var(--dot);
  background-size: 128px 128px, 4px 4px;
  pointer-events: none;
  z-index: var(--z-frame);
  opacity: .5;
}

/* Sits under the HUD so readouts stay at full strength. */
#vig {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse 78% 78% at 50% 50%,
    rgba(10,31,39,0) 34%, rgba(10,31,39,.5) 100%);
}

canvas#game { display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }

/* ==========================================================================
   Poster frame
   ========================================================================== */

#frame {
  position: fixed; inset: clamp(6px, 1.1vmin, 14px);
  border: 2px solid var(--bone);
  opacity: .22;
  pointer-events: none;
  z-index: var(--z-frame);
}
#frame::before, #frame::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 2px solid var(--bone);
}
#frame::before { top: 6px; left: 6px; border-width: 2px 0 0 2px; }
#frame::after { bottom: 6px; right: 6px; border-width: 0 2px 2px 0; }

/* ==========================================================================
   Corner buttons
   ========================================================================== */

#sg-fs-btn {
  position: fixed; top: 8px; right: 8px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 6px;
  background: rgba(0,0,0,.45); color: #fff; cursor: pointer; z-index: 9999;
}
#sg-fs-btn:hover { background: rgba(0,0,0,.7); }

#mute-btn {
  position: fixed; top: 8px; right: 40px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 6px;
  background: rgba(0,0,0,.45); color: #fff; cursor: pointer; z-index: 9999;
}
#mute-btn:hover { background: rgba(0,0,0,.7); }
#sg-fs-btn:focus-visible, #mute-btn:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

/* ==========================================================================
   HUD
   ========================================================================== */

#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: var(--z-hud);
  padding: clamp(14px, 2.4vmin, 30px);
  display: flex; flex-direction: column; justify-content: space-between;
  font-family: var(--ui);
}
.hud-row { display: flex; align-items: flex-start; justify-content: space-between; gap: clamp(10px, 2vw, 28px); }
/* Clears the fixed fullscreen and sound buttons in the top-right corner. */
.hud-top { padding-right: 58px; }
.hud-bottom { align-items: flex-end; }

.readout { display: flex; flex-direction: column; line-height: .95; min-width: 5.5em; }
.readout-right { text-align: right; }
.readout-label {
  font-size: clamp(9px, 1.35vmin, 13px);
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--bone-dim); font-weight: 600;
}
.readout-value {
  font-family: var(--display);
  font-size: clamp(24px, 4.4vmin, 46px);
  color: var(--ochre);
  letter-spacing: -.02em;
  text-shadow: 2px 2px 0 rgba(10,31,39,.85);
}
#ro-depth .readout-value { color: var(--bone); }
.readout-value.bump { animation: bump .34s var(--out); }
@keyframes bump { 0% { transform: scale(1.28); color: var(--bone); } 100% { transform: scale(1); } }

/* setlist / encore clock */
.setlist { flex: 1 1 auto; max-width: 34ch; text-align: center; }
.setlist-label {
  display: block;
  font-family: var(--display);
  font-size: clamp(12px, 2vmin, 21px);
  letter-spacing: -.01em;
  color: var(--bone);
}
.setlist-bar {
  height: 7px; margin: 5px 0 3px;
  background: rgba(242,231,206,.16);
  box-shadow: inset 0 0 0 1px rgba(242,231,206,.3);
}
.setlist-bar > i { display: block; height: 100%; width: 100%; background: var(--ochre); transform-origin: left center; }
.setlist.urgent .setlist-bar > i { background: var(--verm); }
.setlist.urgent .setlist-label { color: var(--verm); }
.setlist-sub {
  font-size: clamp(9px, 1.35vmin, 13px);
  letter-spacing: .14em; text-transform: uppercase; color: var(--bone-dim); font-weight: 600;
}

/* junkdrawer */
#drawer { display: flex; flex-direction: column; gap: 5px; }
.drawer-label {
  font-size: clamp(9px, 1.35vmin, 13px);
  letter-spacing: .16em; text-transform: uppercase; color: var(--bone-dim); font-weight: 600;
}
#drawer-slots { display: flex; gap: 5px; list-style: none; }
#drawer-slots li {
  width: clamp(24px, 4.1vmin, 42px); height: clamp(24px, 4.1vmin, 42px);
  background: rgba(10,31,39,.62);
  box-shadow: inset 0 0 0 2px rgba(242,231,206,.26);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
#drawer-slots li.full { background: var(--ink-3); box-shadow: inset 0 0 0 2px var(--bone); }
#drawer-slots li.tool { box-shadow: inset 0 0 0 2px var(--ochre); }
#drawer-slots li canvas { width: 100%; height: 100%; image-rendering: pixelated; }
#drawer-slots li.pop { animation: pop .3s var(--out); }
@keyframes pop { 0% { transform: translateY(6px) scale(.7); } 100% { transform: none; } }

#seen-meter { display: flex; align-items: center; gap: 8px; }
#seen-meter span {
  font-size: clamp(9px, 1.35vmin, 13px); letter-spacing: .18em;
  text-transform: uppercase; color: var(--verm); font-weight: 700;
}
.seen-bar { width: clamp(70px, 13vmin, 150px); height: 7px; box-shadow: inset 0 0 0 1px var(--verm); }
.seen-bar > i { display: block; height: 100%; width: 100%; background: var(--verm); transform-origin: left center; transform: scaleX(0); }

/* interaction prompt */
#prompt {
  position: absolute; left: 50%; bottom: clamp(58px, 13vmin, 116px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  padding: 7px 15px 7px 9px;
  background: var(--bone); color: var(--ink);
  box-shadow: 4px 4px 0 rgba(10,31,39,.6);
  font-size: clamp(12px, 1.9vmin, 19px); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
}
#prompt b {
  font-family: var(--ui); display: grid; place-items: center;
  min-width: 1.7em; height: 1.7em; padding: 0 .3em;
  background: var(--ink); color: var(--bone); font-size: .85em;
}
.prompt-hold { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(10,31,39,.18); }
.prompt-hold > i { display: block; height: 100%; width: 100%; background: var(--verm); transform-origin: left; transform: scaleX(0); }

/* toasts */
#toast-rail {
  position: absolute; left: 50%; top: clamp(78px, 15vmin, 150px);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  z-index: var(--z-toast); width: min(90vw, 46ch);
}
.toast {
  font-family: var(--display);
  font-size: clamp(13px, 2.1vmin, 22px);
  letter-spacing: -.01em;
  color: var(--bone);
  text-shadow: 2px 2px 0 rgba(10,31,39,.9);
  animation: toast-in 3s var(--out) forwards;
  text-align: center;
}
.toast.gain { color: var(--ochre); }
.toast.bad { color: var(--verm); }
.toast.dream { color: #C79AD1; }
@keyframes toast-in {
  0%   { opacity: 0; transform: translateY(10px) scale(.94); }
  9%   { opacity: 1; transform: none; }
  74%  { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* ==========================================================================
   Touch controls
   ========================================================================== */

#touch { position: fixed; inset: 0; z-index: var(--z-touch); pointer-events: none; }
#stick { position: absolute; width: 128px; height: 128px; opacity: 0; transition: opacity .18s var(--out); }
#stick.on { opacity: .8; }
#stick-base, #stick-nub { position: absolute; border-radius: 50%; }
#stick-base { inset: 0; box-shadow: inset 0 0 0 3px var(--bone); }
#stick-nub {
  width: 52px; height: 52px; left: 38px; top: 38px;
  background: var(--bone);
}
#tbtns {
  position: absolute; right: clamp(16px, 4vw, 44px); bottom: clamp(16px, 5vh, 46px);
  display: grid; grid-template-columns: repeat(2, auto); gap: 12px; align-items: end;
  pointer-events: auto;
}
.tbtn {
  font-family: var(--ui); font-weight: 700; letter-spacing: .08em;
  border: 0; cursor: pointer;
  background: rgba(242,231,206,.14);
  box-shadow: inset 0 0 0 3px var(--bone);
  color: var(--bone);
  border-radius: 50%;
  display: grid; place-items: center;
  -webkit-user-select: none; user-select: none;
}
.tbtn-use  { width: 88px; height: 88px; font-size: 17px; grid-column: 2; grid-row: 1 / span 2; box-shadow: inset 0 0 0 3px var(--ochre); color: var(--ochre); }
.tbtn-dash { width: 62px; height: 62px; font-size: 13px; grid-column: 1; grid-row: 2; }
.tbtn-tool { width: 56px; height: 56px; font-size: 12px; grid-column: 1; grid-row: 1; box-shadow: inset 0 0 0 3px var(--sea); color: var(--sea); }
.tbtn.down { background: rgba(242,231,206,.42); }
.tbtn:disabled { opacity: .3; }

/* ==========================================================================
   Screens
   ========================================================================== */

.screen {
  position: fixed; inset: 0; z-index: var(--z-screen);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(20px, 4vmin, 52px);
  background: rgba(10,31,39,.9);
  overflow-y: auto; overscroll-behavior: contain;
  animation: screen-in .3s var(--out);
}
/* The mall keeps running behind the title, so the plate carries its own scrim. */
#title {
  background: radial-gradient(ellipse at center,
    rgba(10,31,39,.94) 0%, rgba(10,31,39,.8) 46%, rgba(10,31,39,.58) 100%);
  transition: background .8s var(--out);
}
#title.watching { background: rgba(10,31,39,.12); }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

.title-plate {
  text-align: center; max-width: 62ch;
  transition: opacity .7s var(--out), transform .7s var(--out);
}
.title-plate.faded { opacity: 0; transform: scale(.985); pointer-events: none; }

.overline {
  font-size: clamp(10px, 1.5vmin, 15px);
  letter-spacing: .3em; text-transform: uppercase;
  color: var(--sea); font-weight: 700;
  margin-bottom: clamp(10px, 1.8vmin, 20px);
}

/* wordmark, three plates slightly out of register */
.wordmark {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, 8.4vmin, 84px);
  line-height: .92;
  letter-spacing: -.025em;
  text-transform: none;
  color: var(--bone);
  text-wrap: balance;
}
.wm-line { display: block; position: relative; }
.wm-line::before, .wm-line::after {
  content: attr(data-t);
  position: absolute; left: 0; top: 0; width: 100%;
  pointer-events: none;
}
.wm-line::before { color: var(--verm); transform: translate(-3px, 2px); z-index: -2; }
.wm-line::after  { color: var(--sea);  transform: translate(3px, -2px); z-index: -1; }
.wm-line:nth-child(2)::before { color: var(--ochre); transform: translate(3px, 2px); }
.wm-line:nth-child(2)::after  { color: var(--plum);  transform: translate(-3px, -2px); }
.wm-line:nth-child(3)::before { color: var(--plum);  transform: translate(-2px, 3px); }
.wm-line:nth-child(3)::after  { color: var(--verm);  transform: translate(2px, -3px); }
.wm-line { animation: register 7s ease-in-out infinite; }
.wm-line:nth-child(2) { animation-delay: -2.4s; }
.wm-line:nth-child(3) { animation-delay: -4.8s; }
@keyframes register {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(1.5px); }
}

.tagline {
  margin: clamp(14px, 2.4vmin, 26px) auto 0;
  font-size: clamp(13px, 2vmin, 20px);
  line-height: 1.38;
  color: var(--bone-dim);
  max-width: 46ch;
  text-wrap: pretty;
}

.menu { display: flex; flex-direction: column; gap: 9px; align-items: center; margin-top: clamp(20px, 3.4vmin, 38px); }

.mbtn {
  font-family: var(--ui);
  font-size: clamp(14px, 2.1vmin, 21px);
  font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink); background: var(--bone);
  border: 0; border-radius: 2px;
  padding: .5em 1.5em;
  min-width: min(19em, 78vw);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink-3);
  transition: transform .14s var(--out), box-shadow .14s var(--out), background-color .14s var(--out);
}
.mbtn:hover, .mbtn.sel { background: var(--ochre); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink-3); }
.mbtn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink-3); }
.mbtn:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }
.mbtn.ghost { background: transparent; color: var(--bone); box-shadow: inset 0 0 0 2px var(--bone-mute); }
.mbtn.ghost:hover, .mbtn.ghost.sel { background: var(--verm); color: var(--bone); box-shadow: inset 0 0 0 2px var(--verm); }
.mbtn.wide { min-width: min(24em, 82vw); margin-top: clamp(16px, 2.6vmin, 30px); }

.hint { margin-top: clamp(14px, 2.2vmin, 24px); font-size: clamp(11px, 1.5vmin, 15px); letter-spacing: .12em; text-transform: uppercase; color: var(--bone-mute); }

.attract-note {
  position: absolute; bottom: clamp(22px, 4vmin, 46px); left: 50%; transform: translateX(-50%);
  font-size: clamp(11px, 1.5vmin, 15px); letter-spacing: .22em; text-transform: uppercase;
  color: var(--bone-mute);
  animation: blink 2.4s steps(1, end) infinite;
}
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .18; } }

/* --- sheets (tutorial / scores / settings / pause / over) --- */
.sheet {
  background: var(--ink-2);
  box-shadow: 8px 8px 0 rgba(0,0,0,.45), inset 0 0 0 2px var(--bone-mute);
  padding: clamp(20px, 3.4vmin, 42px);
  max-width: 74ch; width: 100%;
  margin: auto;
}
.sheet.narrow { max-width: 40ch; text-align: center; }
.sheet h2 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(24px, 4.4vmin, 46px);
  line-height: 1; letter-spacing: -.022em;
  color: var(--ochre);
  margin-bottom: clamp(12px, 2vmin, 22px);
  text-wrap: balance;
}
.sheet-sub { color: var(--bone-dim); font-size: clamp(13px, 1.9vmin, 18px); margin-bottom: 1em; line-height: 1.4; }

.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: clamp(14px, 2.4vmin, 26px); }
.notes article { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline; }
.notes b {
  font-family: var(--display); font-size: clamp(22px, 3.6vmin, 38px);
  color: var(--verm); line-height: 1; grid-row: 1 / span 2;
}
.notes h3 { font-size: clamp(15px, 2.1vmin, 21px); letter-spacing: .02em; color: var(--bone); font-weight: 700; }
.notes p { font-size: clamp(12.5px, 1.75vmin, 17px); line-height: 1.42; color: var(--bone-dim); max-width: 40ch; }

.ctrl-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: clamp(14px, 2.4vmin, 26px); margin-top: clamp(18px, 3vmin, 34px); }
.ctrl-cols h4 { font-size: clamp(11px, 1.5vmin, 15px); letter-spacing: .2em; text-transform: uppercase; color: var(--sea); margin-bottom: .6em; }
.ctrl-cols ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.ctrl-cols li { font-size: clamp(12.5px, 1.75vmin, 17px); color: var(--bone-dim); }
.ctrl-cols b { color: var(--ochre); }
kbd {
  font-family: var(--ui); font-weight: 700; font-size: .92em;
  background: var(--ink); color: var(--bone);
  padding: .05em .45em; margin-right: .15em;
  box-shadow: inset 0 0 0 1px var(--bone-mute);
}

.scores { list-style: none; display: flex; flex-direction: column; }
.scores li {
  display: grid; grid-template-columns: 2.4em 4.5em 1fr auto;
  align-items: baseline; gap: 10px;
  padding: .34em 0;
  border-bottom: 1px solid rgba(242,231,206,.14);
  font-size: clamp(14px, 2.1vmin, 21px);
}
.scores li:last-child { border-bottom: 0; }
.scores .rank { color: var(--bone-mute); font-weight: 700; }
.scores .who { font-family: var(--display); color: var(--bone); letter-spacing: .02em; }
.scores .depth { color: var(--sea); font-size: .8em; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
.scores .val { font-family: var(--display); color: var(--ochre); justify-self: end; }
.scores li.fresh .who, .scores li.fresh .val { color: var(--verm); }
.scores .empty { color: var(--bone-mute); font-style: italic; }

.setting { display: grid; gap: 6px; margin-bottom: clamp(14px, 2.2vmin, 24px); }
.setting label { font-size: clamp(12px, 1.7vmin, 17px); letter-spacing: .12em; text-transform: uppercase; color: var(--bone-dim); font-weight: 600; }
.setting-row { grid-template-columns: 1fr auto; align-items: center; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; background: rgba(242,231,206,.18); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--bone-mute);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 22px; background: var(--ochre); border: 0; cursor: pointer;
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 22px; background: var(--ochre); border: 0; border-radius: 0; cursor: pointer; }
input[type="range"]:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ochre); cursor: pointer; }

.tally { display: grid; gap: 4px; margin: clamp(12px, 2vmin, 22px) 0; }
.tally .row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 12px; font-size: clamp(13px, 1.9vmin, 19px); color: var(--bone-dim); }
.tally .row b { font-family: var(--display); color: var(--bone); font-weight: 400; }
.tally .row.total { margin-top: 8px; padding-top: 8px; border-top: 2px solid var(--bone-mute); font-size: clamp(16px, 2.6vmin, 26px); color: var(--bone); }
.tally .row.total b { color: var(--ochre); font-size: 1.25em; }
.tally .row.best b { color: var(--verm); }

.initials { display: flex; gap: 10px; justify-content: center; margin: 10px 0 6px; }
.ini {
  font-family: var(--display); font-size: clamp(28px, 5.2vmin, 54px);
  width: 1.5em; height: 1.5em;
  background: var(--ink); color: var(--bone);
  border: 0; box-shadow: inset 0 0 0 2px var(--bone-mute);
  cursor: pointer; line-height: 1;
}
.ini.sel { background: var(--ochre); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ochre); animation: ini-blink 1s steps(1,end) infinite; }
@keyframes ini-blink { 0%,55% { opacity: 1; } 56%,100% { opacity: .62; } }
#initials-wrap { text-align: center; }

/* ==========================================================================
   Responsive + motion
   ========================================================================== */

@media (max-width: 560px) {
  .hud-top { flex-wrap: wrap; }
  .setlist { order: 3; flex-basis: 100%; max-width: none; margin-top: 6px; }
  .notes article { grid-template-columns: auto 1fr; }
  #prompt { bottom: clamp(150px, 30vh, 240px); }
  #toast-rail { top: clamp(96px, 20vmin, 150px); }
}

@media (max-height: 480px) and (orientation: landscape) {
  .sheet { padding: 16px 20px; }
  .sheet h2 { font-size: clamp(20px, 5.6vmin, 32px); }
  .menu { gap: 6px; margin-top: 14px; }
  .mbtn { padding: .34em 1.2em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .toast { animation: toast-static 3s linear forwards; }
  @keyframes toast-static { 0%, 88% { opacity: 1; } 100% { opacity: 0; } }
  .attract-note, .ini.sel { animation: none; }
}
