*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: var(--step-0);
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,p,figure,ul,ol { margin: 0; }
ul,ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
/* A class that sets display would otherwise beat the hidden attribute, which
   is how the start button used to show up before the switch was flipped. */
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

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

#app { min-height: 100%; position: relative; z-index: 1; }
#app:focus { outline: none; }

/* Shared FX canvas — one canvas, one loop, for the entire site. */
#fx {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 60; opacity: 0;
}
#fx.is-live { opacity: 1; }

/* Arc-flash / blowout layer. Single frame then slow fade — never a strobe. */
#flash {
  position: fixed; inset: 0; z-index: 70; pointer-events: none;
  background: #fff; opacity: 0;
}
#flash.is-fire { animation: flashout .5s ease-out forwards; }
@keyframes flashout { 0% { opacity: .92; } 100% { opacity: 0; } }

/* Photocopy grain — one shared layer, costs nothing. */
.grain {
  position: fixed; inset: 0; z-index: 80; pointer-events: none; opacity: .16;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.noscript {
  padding: 3rem var(--gut); font-family: var(--f-mono); max-width: 34rem; margin: 0 auto;
}
.noscript h1 { font-family: var(--f-display); font-size: var(--step-3); letter-spacing: .02em; }
.noscript p { font-size: var(--step--1); line-height: 1.7; margin-top: 1rem; }

/* ---------- shared industrial primitives ---------- */

.mono { font-family: var(--f-mono); }
.tiny { font-size: var(--step--2); letter-spacing: .09em; text-transform: uppercase; }
.dim  { color: var(--ink-faint); }

/* Dymo embossed label tape */
.dymo {
  display: inline-block; font-family: var(--f-mono); font-weight: 700;
  font-size: var(--step--2); letter-spacing: .16em; text-transform: uppercase;
  background: #3A3934; color: #E8E6E0; padding: .35em .7em .3em;
  border-radius: 3px; box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 1px 2px rgba(0,0,0,.4);
}

/* Masking tape + sharpie */
.tape {
  display: inline-block; font-family: var(--f-hand); font-size: var(--step--1);
  color: var(--blue); background: #E4DCC4; padding: .25em .55em;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
  clip-path: polygon(1% 4%, 99% 0%, 100% 96%, 0% 100%);
}

/* Hazard stripe rule */
.hazard {
  height: 12px;
  background: repeating-linear-gradient(-45deg,
    var(--yellow) 0 14px, var(--ink) 14px 28px);
}
.hazard--thin { height: 6px; }

/* Stamped inspection mark */
.stamp {
  font-family: var(--f-mono); font-weight: 700; font-size: var(--step--2);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--red); border: 2px solid var(--red); padding: .3em .6em;
  display: inline-block; opacity: .82; border-radius: 2px;
}

/* Big utility button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6em;
  min-height: 56px; padding: 0 1.6em;
  font-family: var(--f-mono); font-weight: 700; font-size: var(--step-0);
  letter-spacing: .1em; text-transform: uppercase;
  background: var(--ink); color: var(--paper);
  border-radius: 2px; box-shadow: 0 3px 0 rgba(0,0,0,.35);
  transition: transform .06s, box-shadow .06s;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0,0,0,.35); }
.btn--warn { background: var(--yellow); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn[disabled] { opacity: .35; pointer-events: none; }

/* Pinned decal, bottom centre. Sits on a small sticker so it stays legible on
   the paper feed, the grey panel and the game canvas alike. Decorative only:
   pointer-events are off so it can never eat a tap during a game. */
.brand {
  position: fixed; z-index: 85; pointer-events: none;
  left: 50%; bottom: calc(8px + var(--safe-b));
  transform: translateX(-50%) rotate(-1.6deg);
  background: var(--paper);
  padding: 7px 14px 6px;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 2px 8px rgba(0,0,0,.28);
  opacity: .96;
}
.brand::after {         /* a peeling corner, because nothing here is applied well */
  content: ''; position: absolute; right: 0; bottom: 0;
  border-width: 0 0 9px 9px; border-style: solid;
  border-color: transparent transparent rgba(0,0,0,.14) transparent;
}
.brand__img {
  display: block; width: 118px; height: auto;
}

@media (min-width: 40rem) {
  :root { --brand-h: 114px; }        /* 152*212/400 = 80.6 + 17 + 12 */
  .brand { bottom: calc(12px + var(--safe-b)); padding: 9px 18px 8px; }
  .brand__img { width: 152px; }
}
/* Very short screens (landscape phones): shrink rather than crowd the game. */
@media (max-height: 560px) {
  :root { --brand-h: 62px; }         /* 84*212/400 = 44.5 + 7 + 8 */
  .brand { padding: 4px 9px 3px; }
  .brand__img { width: 84px; }
}

/* Mute — an actual toggle switch, bottom-left, out of thumb-scroll territory */
.mute {
  position: fixed; left: max(10px, env(safe-area-inset-left)); z-index: 90;
  bottom: calc(10px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px; touch-action: manipulation;
}
.mute__plate {
  width: 30px; height: 46px; border-radius: 3px;
  background: linear-gradient(#DCDAD1, #B4B2A8);
  box-shadow: var(--shadow-panel); position: relative; display: block;
}
.mute__lever {
  position: absolute; left: 6px; width: 18px; height: 20px; border-radius: 2px;
  background: linear-gradient(#F2F0E8, #CFCDC4);
  box-shadow: 0 1px 2px rgba(0,0,0,.35); top: 5px;
  transition: top .1s cubic-bezier(.2,.9,.3,1.4);
}
.mute[aria-pressed="true"] .mute__lever { top: 21px; }
.mute[aria-pressed="true"] .mute__plate { background: linear-gradient(#C2BFB4, #A3A197); }
.mute__label {
  font-family: var(--f-mono); font-size: 8px; font-weight: 700;
  letter-spacing: .14em; color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
