/* ============================================================
   Supermarket Guard — UI skin "SHIFT"
   The interface borrows from what the player is wearing and standing in:
   a hi-vis vest (lime), a security badge (cut corners, hazard stripes),
   a cash register (mono numerals, receipt leaders) and a CCTV monitor
   (green phosphor). Nothing here is a default rounded card.
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* --- surfaces: cold steel-navy, the guard's uniform --- */
  --ink-950: #05080f;
  --ink-900: #090f1b;
  --ink-850: #0d1626;
  --ink-800: #122036;
  --ink-700: #1a2c47;
  --hair: rgba(146, 186, 255, 0.16);
  --hair-2: rgba(146, 186, 255, 0.30);

  /* --- accents --- */
  --hv: #d8f227;          /* hi-vis vest — primary action */
  --hv-lo: #93ad00;
  --hv-ink: #17200a;
  --gold: #ffc84a;        /* money */
  --gold-lo: #b06f00;
  --gold-ink: #3a2500;
  --cy: #57d8ff;          /* tech: cameras, upgrades */
  --cy-lo: #0a6f95;
  --ok: #46e08e;
  --ok-lo: #067a45;
  --bad: #ff4d61;
  --bad-lo: #9d1d2c;
  --warn: #ff9f1c;
  --violet: #a78bfa;
  --violet-lo: #5b21b6;
  --steel: #4a6488;      /* neutral action */
  --steel-lo: #2a3a52;
  --slate: #2f4159;      /* the quieter, "step back" action */
  --slate-lo: #1a2536;

  --txt: #e9f0ff;
  --dim: rgba(233, 240, 255, 0.62);
  --dimmer: rgba(233, 240, 255, 0.34);

  /* --- type --- */
  --f-ui: 'Segoe UI', Roboto, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --f-dis: 'Arial Black', 'Segoe UI', Roboto, system-ui, sans-serif;
  --f-num: ui-monospace, 'Cascadia Mono', Consolas, 'Roboto Mono', 'DejaVu Sans Mono', monospace;

  /* --- the signature shape: a clipped badge corner ---
     Interactive and hero surfaces are cut; informational ones stay rounded.
     `--cut` is overridden per component and resolved where the path is used. */
  --cut: 12px;
  --cutpath: polygon(
    0 0,
    calc(100% - var(--cut)) 0,
    100% var(--cut),
    100% 100%,
    var(--cut) 100%,
    0 calc(100% - var(--cut))
  );

  --hazard: repeating-linear-gradient(
    135deg, var(--hv) 0 10px, #10192a 10px 20px
  );
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100%);
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: none;
  background: var(--ink-900);
  font-family: var(--f-ui);
  color: var(--txt);
}

/* extra room at the bottom on touch devices so the platform sticky banner
   never sits on top of the joystick or the stun button */
:root { --safe-bottom: 0px; }
@media (pointer: coarse) {
  :root { --safe-bottom: 56px; }
}

#ui-root, .screen, #game-canvas {
  height: 100%;
  height: var(--app-height, 100%);
}

/* Explicit stacking: both layers are fixed and full-screen, so without a
   z-index the UI relied on document order alone and HUD buttons could lose the
   hit test to the canvas. */
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  display: block;
  touch-action: none;
  z-index: 0;
}

#ui-root {
  position: fixed;
  inset: 0;
  width: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen.hud-screen {
  pointer-events: none !important;
  justify-content: flex-start;
}
.screen.hud-screen > * { pointer-events: auto; }
/* `> *` above outranks the elements' own `pointer-events: none`, so purely
   decorative overlays must opt out explicitly or they swallow taps meant for
   the canvas (camera drag) and for the joystick underneath. */
.screen.hud-screen .no-pe,
.screen.hud-screen > .toast-area,
.screen.hud-screen > .key-hints,
.screen.hud-screen > .joystick,
.screen.hud-screen > .joystick-ghost { pointer-events: none; }

/* ============================================================
   Buttons — solid faces with a hard bottom lip. The shape is clipped, so
   the depth comes from a gradient bevel and a drop-shadow that follows the
   silhouette (a box-shadow would square off the cut corners).
   ============================================================ */
button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  touch-action: none;
  color: #fff;
  font-weight: 800;
}

.btn {
  --cut: 12px;
  --face: var(--steel);
  --edge: var(--steel-lo);
  --ink: var(--txt);
  position: relative;
  min-height: 52px;
  padding: 12px 26px;
  font-family: var(--f-dis);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink);
  background:
    linear-gradient(180deg,
      rgba(255,255,255,0.30) 0%,
      rgba(255,255,255,0.05) 34%,
      rgba(0,0,0,0.06) 62%,
      rgba(0,0,0,0.18) 100%),
    linear-gradient(180deg, var(--face) 0 78%, var(--edge) 78% 100%);
  clip-path: var(--cutpath);
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.30)) drop-shadow(0 8px 16px rgba(0,0,0,0.45));
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s;
}
.btn:active {
  transform: translateY(3px);
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.3)) drop-shadow(0 3px 8px rgba(0,0,0,0.4));
}
/* "green" is the primary slot in the markup — here it is the hi-vis vest */
.btn.btn-green { --face: var(--hv); --edge: var(--hv-lo); --ink: var(--hv-ink); }
.btn.btn-yellow { --face: var(--gold); --edge: var(--gold-lo); --ink: var(--gold-ink); }
.btn.btn-red { --face: var(--bad); --edge: var(--bad-lo); --ink: #fff; }
.btn.btn-gray { --face: var(--slate); --edge: var(--slate-lo); --ink: rgba(233,240,255,0.82); }
.btn:disabled { filter: grayscale(0.75) brightness(0.62); cursor: default; }
.btn:disabled:active { transform: none; }

.btn-icon {
  --cut: 10px;
  width: 52px;
  height: 52px;
  min-width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0.02) 40%, rgba(0,0,0,0.14) 100%),
    linear-gradient(180deg, #17273f 0 80%, #0b1524 80% 100%);
  clip-path: var(--cutpath);
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.35)) drop-shadow(0 5px 12px rgba(0,0,0,0.5));
  transition: transform 0.08s ease, filter 0.15s;
}
.btn-icon:active { transform: translateY(2px) scale(0.97); }
.btn-icon svg { width: 27px; height: 27px; }

/* A thin hi-vis rule under a title or above a block — the house divider. */
.rule {
  height: 3px;
  background: linear-gradient(90deg, var(--hv), rgba(216,242,39,0) 78%);
  flex: 0 0 auto;
}

/* ============================================================
   Sign plate — the badge surface used by the logo and every modal.
   Two clipped layers: the element is the outline, ::after is the fill, so the
   diagonal corner keeps its border (an inset shadow would square it off).
   ============================================================ */
.plate {
  position: relative;
  --cut: 16px;
  background: transparent;
  clip-path: var(--cutpath);
  filter: drop-shadow(0 14px 34px rgba(0,0,0,0.55));
}
.plate::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hair-2);
  clip-path: var(--cutpath);
}
.plate::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: linear-gradient(180deg, var(--ink-800) 0%, var(--ink-900) 100%);
  clip-path: var(--cutpath);
}
.plate > * { position: relative; z-index: 1; }

/* hazard tape: used sparingly, as a header strip */
.hazard {
  height: 7px;
  background: var(--hazard);
  background-size: 28.3px 28.3px;
  flex: 0 0 auto;
}

/* ---------- Loading ---------- */
#screen-loading {
  background:
    radial-gradient(ellipse at 50% 0%, #17395e 0%, rgba(23,57,94,0) 62%),
    linear-gradient(180deg, #0d2038 0%, var(--ink-900) 70%);
  z-index: 60;
  gap: 30px;
}
/* faint camera scanlines behind the boot logo — the game opens on a monitor */
#screen-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px);
  opacity: 0.55;
}
.boot { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.load-wrap { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.load-bar {
  position: relative;
  width: min(360px, 74vw);
  height: 20px;
  background: var(--ink-950);
  box-shadow: inset 0 0 0 2px rgba(146,186,255,0.24), inset 0 2px 6px rgba(0,0,0,0.8);
}
.load-bar-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(135deg, var(--hv) 0 11px, var(--hv-lo) 11px 22px);
  background-size: 31.1px 31.1px;
  animation: hazardRoll 0.6s linear infinite;
  transition: width 0.2s ease;
}
@keyframes hazardRoll { to { background-position: 31.1px 0; } }
.load-pct {
  font-family: var(--f-num);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--hv);
  text-shadow: 0 0 12px rgba(216,242,39,0.35);
}

/* ---------- Logo sign ---------- */
.sign {
  --cut: 18px;
  padding: 0 0 16px;
  overflow: hidden;
  text-align: center;
  max-width: min(760px, 94vw);
}
/* inset by the plate's 2px outline so the tape sits inside the frame instead of
   painting over it where the clipped corner cuts through */
.sign .hazard { margin: 2px 2px 14px; }
.game-title {
  font-family: var(--f-dis);
  font-size: clamp(26px, 6.4vw, 52px);
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1.02;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.45), 0 0 26px rgba(126,196,255,0.28);
  padding: 0 22px;
}
.game-subtitle {
  display: inline-block;
  margin-top: 11px;
  font-size: clamp(11px, 2.3vw, 14px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--hv);
  padding: 0 22px;
}

/* ---------- Main menu ---------- */
#screen-menu {
  z-index: 40;
  justify-content: space-between;
  padding: 4vh 0 calc(4vh + var(--safe-bottom));
}
/* readable text over any 3D framing without hiding the store */
.menu-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5,10,20,0.78) 0%, rgba(5,10,20,0.24) 28%, rgba(5,10,20,0) 46%),
    linear-gradient(0deg, rgba(5,10,20,0.86) 0%, rgba(5,10,20,0.28) 26%, rgba(5,10,20,0) 52%);
}
/* a column so a platform build can hang an extra line (e.g. the account
   greeting) under the sign without it landing beside the logo */
.menu-head {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}
.menu-buttons {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.menu-row { display: flex; gap: 12px; justify-content: center; }
.btn-play {
  font-size: 24px;
  padding: 16px 56px;
  min-height: 66px;
  --cut: 15px;
}
.menu-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 8px;
  margin-bottom: 4px;
}
.menu-stat {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: rgba(255,255,255,0.92);
  background: linear-gradient(180deg, rgba(18,32,54,0.86), rgba(9,15,27,0.9));
  border: 1px solid var(--hair);
  border-left: none;
  border-radius: 0 9px 9px 0;
  padding: 5px 10px 5px 11px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.menu-stat::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent, var(--cy));
}
.menu-stat:nth-child(1) { --accent: var(--cy); }
.menu-stat:nth-child(2) { --accent: var(--ok); }
.menu-stat:nth-child(3) { --accent: var(--gold); }
.menu-stat svg { width: 14px; height: 14px; }

/* ============================================================
   Panels
   ============================================================ */
.modal-screen {
  background: rgba(4, 8, 16, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 45;
  padding-bottom: var(--safe-bottom);
}
.panel {
  position: relative;
  --cut: 18px;
  clip-path: var(--cutpath);
  filter: drop-shadow(0 18px 40px rgba(0,0,0,0.6));
  padding: 18px 20px 20px;
  width: min(560px, 94vw);
  /* `88 * var(--app-height)` was a no-op (the variable is a px length), so the
     panel ignored the real viewport height and the platform banner. */
  max-height: calc(var(--app-height, 100vh) * 0.9 - var(--safe-bottom));
  display: flex;
  flex-direction: column;
}
.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--hair-2), rgba(146,186,255,0.10));
  clip-path: var(--cutpath);
}
.panel::after {
  content: '';
  position: absolute;
  inset: 2px;
  background:
    linear-gradient(180deg, rgba(87,216,255,0.07) 0 74px, rgba(87,216,255,0) 74px),
    linear-gradient(180deg, var(--ink-800) 0%, var(--ink-950) 100%);
  clip-path: var(--cutpath);
}
/* Absolutely positioned pseudo-elements are not grid/flex items, so the
   landscape grid layouts below are unaffected by them. */
.panel > * { position: relative; z-index: 1; }
.panel.failed::before { background: linear-gradient(180deg, rgba(255,77,97,0.55), rgba(255,77,97,0.18)); }
.panel.failed::after {
  background:
    linear-gradient(180deg, rgba(255,77,97,0.10) 0 74px, rgba(255,77,97,0) 74px),
    linear-gradient(180deg, #2a1622 0%, #120a12 100%);
}

.panel-title {
  font-family: var(--f-dis);
  font-size: 21px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 10px;
  color: #fff;
}
/* the hi-vis underscore that marks every panel head */
.panel-title::after {
  content: '';
  display: block;
  width: 54px;
  height: 3px;
  margin: 7px auto 0;
  background: var(--hv);
}
.panel-close {
  --cut: 11px;
  position: absolute;
  top: -12px;
  right: -6px;
  width: 46px;
  height: 46px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.26), rgba(255,255,255,0.02) 45%, rgba(0,0,0,0.18)),
    linear-gradient(180deg, var(--bad) 0 78%, var(--bad-lo) 78%);
  clip-path: var(--cutpath);
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.3)) drop-shadow(0 6px 14px rgba(0,0,0,0.5));
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-close:active { transform: translateY(2px); }
.panel-close svg { width: 21px; height: 21px; }
.panel-wrap { position: relative; }

.scrollable-container {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scrollable-container::-webkit-scrollbar { display: none; }
/* `button { touch-action: none }` blocks panning for any touch that STARTS on a
   button, and touch-action is decided by the hit element, not by the scroller
   above it. In the shop a full-width buy button covers a third of every card, so
   a swipe begun there simply did not scroll the list. Vertical panning is
   allowed here; double-tap zoom and horizontal panning still are not. */
.scrollable-container button,
.scrollable-container .btn,
.scrollable-container .shop-item,
.scrollable-container .summary-row,
.scrollable-container .lb-row { touch-action: pan-y; }

/* fade at the bottom of a scrollable list so it reads as "more below".
   `flex: 1 1 auto` + `min-height: 0` is what lets a list shrink instead of
   pushing itself out through the bottom of the panel on short screens. */
.list-fade { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.list-fade > .scrollable-container { flex: 1 1 auto; min-height: 0; }
.list-fade::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 26px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(9,14,26,0) 0%, rgba(9,14,26,0.92) 100%);
}

/* ============================================================
   Shop — upgrade cards read as shelf tickets: a tinted tool tile, the spec,
   and a gold price key.
   ============================================================ */
.shop-money {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--f-num);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--gold);
  margin-bottom: 12px;
}
.shop-money svg { width: 23px; height: 23px; flex: 0 0 auto; }
.shop-money span::after { content: '$'; opacity: 0.55; margin-left: 2px; }

.shop-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  background: rgba(0,0,0,0.4);
  box-shadow: inset 0 0 0 1px var(--hair);
}
.shop-tab {
  --cut: 9px;
  flex: 1;
  /* platform rule 1.8: never below 48px on a touch screen */
  min-height: 48px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dim);
  background: transparent;
  clip-path: var(--cutpath);
  transition: color 0.15s;
}
.shop-tab.active {
  color: var(--hv-ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.30), rgba(255,255,255,0.02) 45%, rgba(0,0,0,0.12)),
    linear-gradient(180deg, var(--hv) 0 80%, var(--hv-lo) 80%);
}
.shop-list { display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 22px; }
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.015));
  box-shadow: inset 0 0 0 1px var(--hair), inset 3px 0 0 var(--tint, var(--cy));
  border-radius: 0 10px 10px 0;
  padding: 10px 12px 10px 14px;
}
.shop-item-icon {
  --cut: 9px;
  width: 52px;
  height: 52px;
  min-width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(0,0,0,0.25));
  clip-path: var(--cutpath);
}
.shop-item-icon svg { width: 32px; height: 32px; }
.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name {
  font-size: 14.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.shop-item-desc { font-size: 12px; color: var(--dim); line-height: 1.3; margin-top: 3px; }
.shop-item-lvl {
  font-family: var(--f-num);
  font-size: 11px;
  color: var(--hv);
  font-weight: 700;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pips { display: inline-flex; gap: 3px; }
.pip {
  width: 13px;
  height: 6px;
  background: rgba(255,255,255,0.14);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4);
}
.pip.on { background: var(--hv); box-shadow: 0 0 6px rgba(216,242,39,0.5); }

.shop-item-btn {
  --cut: 10px;
  --face: var(--gold);
  --edge: var(--gold-lo);
  --ink: var(--gold-ink);
  min-width: 98px;
  min-height: 48px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.32), rgba(255,255,255,0.04) 42%, rgba(0,0,0,0.14)),
    linear-gradient(180deg, var(--face) 0 78%, var(--edge) 78%);
  clip-path: var(--cutpath);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.08s ease, filter 0.15s;
}
.shop-item-btn:active { transform: translateY(2px); }
.shop-item-btn:disabled { filter: grayscale(0.85) brightness(0.6); }
.shop-item-btn .price { font-family: var(--f-num); font-size: 13.5px; font-weight: 700; letter-spacing: 0; }
.shop-item-btn.maxed { --face: #3d5170; --edge: #212f45; --ink: rgba(233,240,255,0.75); font-size: 12px; }
.shop-item-btn.rewarded-btn { --face: var(--violet); --edge: var(--violet-lo); --ink: #fff; }

/* ============================================================
   Shift summary — a till receipt: dotted leaders, a boxed total, a barcode.
   ============================================================ */
.summary-head { text-align: center; }
.summary-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}
.summary-banner {
  text-align: center;
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1.3;
  padding: 7px 12px;
  margin: 6px 0 2px;
  background: rgba(255,255,255,0.05);
  box-shadow: inset 0 0 0 1px var(--hair);
  color: var(--dim);
}
.summary-banner.good { background: rgba(70,224,142,0.13); box-shadow: inset 0 0 0 1px rgba(70,224,142,0.4); color: var(--ok); }
.summary-banner.bad { background: rgba(255,77,97,0.13); box-shadow: inset 0 0 0 1px rgba(255,77,97,0.4); color: #ff93a2; }
.summary-banner.hidden { display: none; }
.summary-scroll { flex: 1 1 auto; min-height: 0; margin: 10px 0 8px; }
.summary-rows { display: flex; flex-direction: column; gap: 2px; padding-bottom: 18px; }
.summary-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 4px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(233,240,255,0.88);
}
.s-lbl { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the leader dots that turn a stat list into a printed receipt */
.s-dots {
  flex: 1 1 auto;
  min-width: 10px;
  align-self: center;
  border-bottom: 2px dotted rgba(146,186,255,0.26);
  transform: translateY(-1px);
}
.summary-row .val { font-family: var(--f-num); font-weight: 700; white-space: nowrap; }
.summary-row .val.good { color: var(--ok); }
.summary-row .val.bad { color: #ff8fa3; }
.summary-row.total {
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(255,200,74,0.14), rgba(255,200,74,0.05));
  box-shadow: inset 0 0 0 2px rgba(255,200,74,0.45);
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  flex: 0 0 auto;
  margin-bottom: 10px;
}
.summary-row.total .val { color: var(--gold); font-size: 18px; }
.summary-row.total .s-dots { border-bottom-color: rgba(255,200,74,0.35); }
/* printed tail of the receipt: pure decoration, first thing to go when short */
.receipt-code {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: -4px 0 10px;
  opacity: 0.5;
}
.receipt-bars {
  flex: 1 1 auto;
  height: 15px;
  background:
    repeating-linear-gradient(90deg,
      var(--txt) 0 2px, transparent 2px 4px,
      var(--txt) 4px 5px, transparent 5px 9px,
      var(--txt) 9px 12px, transparent 12px 14px);
}
.receipt-id { font-family: var(--f-num); font-size: 10px; letter-spacing: 1px; color: var(--dim); white-space: nowrap; }

.summary-buttons { display: flex; flex-direction: column; gap: 9px; }
.btn-sub { font-size: 12px; font-weight: 700; opacity: 0.85; display: block; letter-spacing: 0; text-transform: none; }

/* The sound toggle swaps its label for an inline SVG at runtime. Without an
   explicit size the icon stretched to the button width — 96px tall on a phone,
   289px on a tablet — and dragged the whole button row with it. */
#pause-sound {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
#pause-sound svg { width: 23px; height: 23px; flex: 0 0 auto; }

/* ============================================================
   HUD
   ============================================================ */
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  gap: 10px;
}
.hud-col-left, .hud-col-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud-col-left { align-items: flex-start; }
.hud-col-right { align-items: flex-end; }

/* Readouts are instrument panels, not bubbles: a flat left edge carrying a
   colour-coded bar, dark glass, mono numerals. */
.hud-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(19,33,55,0.90), rgba(7,12,22,0.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), 0 4px 14px rgba(0,0,0,0.5);
  border: 1px solid var(--hair);
  border-left: none;
  border-radius: 0 11px 11px 0;
  padding: 6px 12px 6px 12px;
  font-size: 15px;
  font-weight: 800;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
}
.hud-chip::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent, var(--cy));
  box-shadow: 0 0 10px var(--accent, var(--cy));
}
.hud-chip svg { width: 19px; height: 19px; flex: 0 0 auto; }
.hud-chip span { font-family: var(--f-num); font-weight: 700; letter-spacing: 0.3px; }
#hud-day { font-family: var(--f-ui); font-weight: 900; text-transform: uppercase; letter-spacing: 0.6px; font-size: 14px; }
.hud-money { --accent: var(--gold); color: var(--gold); }
.hud-money span::after { content: '$'; opacity: 0.5; margin-left: 1px; }
.hud-caught { --accent: var(--ok); color: var(--ok); }
.hud-streak {
  --accent: var(--hv);
  color: var(--hv);
  opacity: 0.4;
  transition: opacity 0.2s, transform 0.2s;
}
.hud-streak.on { opacity: 1; transform: scale(1.04); }
.hud-streak span::before { content: '×'; opacity: 0.6; }

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
/* Never wider than the centre column: with a viewport-relative width the bar
   ran underneath the side chips on short landscape screens, where the warning
   shields and the button grid eat most of the row. */
.day-timer {
  position: relative;
  width: min(250px, 100%);
  height: 22px;
  background: rgba(4,8,16,0.88);
  box-shadow: inset 0 0 0 2px var(--hair), inset 0 2px 6px rgba(0,0,0,0.8), 0 3px 10px rgba(0,0,0,0.45);
  overflow: hidden;
}
/* A horizontal gradient would compress as the bar drains and read as two
   separate blocks — the shading runs vertically instead, so the fill keeps the
   same colour at every width. */
.day-timer-fill {
  height: 100%;
  width: 100%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.45), rgba(255,255,255,0) 46%, rgba(0,0,0,0.20)),
    var(--hv);
  transition: background 0.3s;
}
.day-timer-fill.urgent {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.45), rgba(255,255,255,0) 46%, rgba(0,0,0,0.22)),
    #ff2d45;
  animation: urgentPulse 0.8s ease-in-out infinite;
}
@keyframes urgentPulse { 50% { filter: brightness(1.45); } }
/* quarter-shift ticks, so the bar reads as a clock face rather than a blob */
.day-timer::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(90deg, rgba(0,0,0,0.5) 0 2px, transparent 2px);
  background-size: 25% 100%;
}
/* The fill drains right-to-left underneath this label, so a dark-on-light
   treatment became dark-on-dark for the second half of every shift. White with
   a hard outline reads on both. */
.day-timer-text {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-num);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 0 3px rgba(0,0,0,0.95), 0 1px 2px rgba(0,0,0,0.9);
}
.hud-phase {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2.2px;
  color: rgba(255,255,255,0.72);
  text-shadow: 0 1px 4px rgba(0,0,0,0.85);
}
.hud-phase.rush { color: var(--warn); animation: rushBlink 1.1s ease-in-out infinite; }
@keyframes rushBlink { 50% { opacity: 0.4; } }
.hud-goal {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 800;
  padding: 5px 11px 5px 11px;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(180deg, rgba(19,33,55,0.88), rgba(7,12,22,0.9));
  border: 1px solid var(--hair);
  border-left: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
  /* bounded by the centre column, not by the viewport — a `vw` cap let the
     chip slide under the icon buttons and get cut mid-word */
  max-width: 100%;
  overflow: hidden;
}
.hud-goal::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold);
}
.hud-goal span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.hud-goal svg { width: 14px; height: 14px; flex: 0 0 auto; }
.hud-goal.done { color: var(--ok); }
.hud-goal.done::before { background: var(--ok); }
.hud-goal.failed { opacity: 0.4; text-decoration: line-through; }

/* the shift's margin for error, as a strip of duty shields */
.hud-warnings {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 5px 9px 5px 10px;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(180deg, rgba(19,33,55,0.82), rgba(7,12,22,0.86));
  border: 1px solid var(--hair);
  border-left: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hud-warnings::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--bad);
}
.warn-dot {
  width: 20px;
  height: 20px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
  transition: filter 0.2s, opacity 0.2s;
}
.warn-dot svg { width: 20px; height: 20px; }
.warn-dot.lost { opacity: 0.34; filter: grayscale(1) brightness(0.55); }

/* Sits inside the right-hand column so it can never be drawn on top of the
   money/streak chips, whatever their height. */
.hud-chips-row { display: flex; gap: 6px; align-items: flex-start; }
.hud-side {
  display: grid;
  grid-template-columns: repeat(2, 52px);
  gap: 8px;
  justify-items: end;
  pointer-events: auto;
}
.hud-side .btn-icon { pointer-events: auto; }

/* Above the joystick zone: both are positioned siblings and the zone comes
   later in the DOM, so without a z-index it stole every tap that landed on the
   left half of this button. */
.btn-extend {
  --cut: 12px;
  position: absolute;
  z-index: 4;
  bottom: calc(122px + var(--safe-bottom));
  /* centred by auto margins, not by a 50% offset — see .tutorial-hint */
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
  transform: scale(0.9);
  display: none;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 8px 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.03) 45%, rgba(0,0,0,0.16)),
    linear-gradient(180deg, var(--violet) 0 78%, var(--violet-lo) 78%);
  clip-path: var(--cutpath);
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.3)) drop-shadow(0 8px 18px rgba(0,0,0,0.5));
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  animation: extendPop 1.4s ease-in-out infinite;
}
.btn-extend.visible { display: flex; }
/* The two sit on top of each other on a phone. By the time the shift is nearly
   over the "swipe to walk" hint has done its job, so the button wins. */
.btn-extend.visible ~ .joystick-ghost { display: none; }
.btn-extend svg { width: 21px; height: 21px; }
@keyframes extendPop {
  0%, 100% { transform: scale(0.94); }
  50% { transform: scale(1.02); }
}

/* Action cluster (stun) */
.hud-actions {
  position: absolute;
  z-index: 4;
  right: 18px;
  bottom: calc(22px + var(--safe-bottom));
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 16px;
}
/* the stun trigger: a machined amber button seated in a dark collar, so it
   stays readable against the bright white shop floor */
.btn-zap {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 28%, rgba(255,255,255,0.7), rgba(255,255,255,0) 52%),
    conic-gradient(from 200deg at 50% 50%, #ffd85a, #ffb703 22%, #f08a00 52%, #ffc93c 78%, #ffd85a);
  box-shadow:
    0 0 0 4px rgba(6, 11, 20, 0.92),
    0 0 0 6px rgba(146, 186, 255, 0.22),
    0 7px 0 #93520a,
    0 12px 26px rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}
.btn-zap:active { transform: translateY(4px); box-shadow: 0 0 0 4px rgba(6,11,20,0.92), 0 0 0 6px rgba(146,186,255,0.22), 0 2px 0 #93520a, 0 5px 12px rgba(0,0,0,0.45); }
.btn-zap svg { width: 42px; height: 42px; }
/* An inline <svg> is a replaced element: with `inset` alone and no width/height
   it falls back to its intrinsic box instead of stretching, which drew the
   cooldown ring off to the upper left of the button. Size it explicitly. */
.btn-zap .cooldown-ring {
  position: absolute;
  left: -9px;
  top: -9px;
  width: calc(100% + 18px);
  height: calc(100% + 18px);
  border-radius: 50%;
  pointer-events: none;
}
.btn-zap.on-cd { filter: saturate(0.25) brightness(0.6); }
.btn-zap.in-range { animation: zapPulse 0.9s ease-in-out infinite; }
@keyframes zapPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(6,11,20,0.92), 0 0 0 6px rgba(216,242,39,0.55), 0 7px 0 #93520a, 0 0 0 6px rgba(216,242,39,0.5); }
  50% { box-shadow: 0 0 0 4px rgba(6,11,20,0.92), 0 0 0 6px rgba(216,242,39,0.55), 0 7px 0 #93520a, 0 0 0 24px rgba(216,242,39,0); }
}
/* While the mouse is captured there is nothing to point at. */
body.mouse-captured, body.mouse-captured #game-canvas { cursor: none; }

.capture-prompt {
  position: absolute;
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
  bottom: calc(46px + var(--safe-bottom));
  padding: 9px 18px;
  background: rgba(7, 13, 24, 0.9);
  box-shadow: inset 0 0 0 1px var(--hair-2), 0 6px 18px rgba(0,0,0,0.5);
  border-left: 3px solid var(--hv);
  font-size: 13.5px;
  font-weight: 800;
  color: rgba(255,255,255,0.92);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.capture-prompt.visible { opacity: 1; animation: promptBreathe 1.8s ease-in-out infinite; }
@keyframes promptBreathe { 50% { opacity: 0.6; } }

/* look sensitivity picker (pause menu, desktop only) */
.sens-block { margin-bottom: 14px; }
.sens-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--dim);
  text-align: center;
  margin-bottom: 8px;
}
.sens-row { display: flex; gap: 4px; padding: 4px; background: rgba(0,0,0,0.4); box-shadow: inset 0 0 0 1px var(--hair); }
.sens-btn {
  --cut: 9px;
  flex: 1;
  min-height: 44px;
  background: transparent;
  clip-path: var(--cutpath);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--dim);
}
.sens-btn.active {
  color: var(--hv-ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.02) 45%, rgba(0,0,0,0.12)),
    linear-gradient(180deg, var(--hv) 0 80%, var(--hv-lo) 80%);
}

/* Joystick */
.joystick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 45%;
  height: 55%;
  touch-action: none;
}
.joystick {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(9,15,27,0.62) 55%, rgba(9,15,27,0.3) 100%);
  box-shadow: inset 0 0 0 2px rgba(146,186,255,0.32), 0 6px 20px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.joystick.visible { opacity: 1; }
/* clear feedback that the stick is far enough out to run */
.joystick.running { box-shadow: inset 0 0 0 2px var(--hv), 0 0 0 3px rgba(216,242,39,0.24), 0 6px 20px rgba(0,0,0,0.4); }
.joystick.running .joystick-knob { background: var(--hv); }
.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255,255,255,0.88);
  box-shadow: 0 3px 10px rgba(0,0,0,0.45), inset 0 -3px 0 rgba(0,0,0,0.14);
}
/* the stick spawns wherever you touch, so hint at the zone until first use */
.joystick-ghost {
  position: absolute;
  left: 46px;
  bottom: calc(52px + var(--safe-bottom));
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  animation: ghostBreathe 2.2s ease-in-out infinite;
}
.joystick-ghost.gone { display: none !important; }
.joystick-ghost-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px dashed rgba(216,242,39,0.5);
  background: rgba(9,15,27,0.3);
}
.joystick-ghost span {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255,255,255,0.82);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  text-align: center;
  max-width: 132px;
}
@keyframes ghostBreathe { 50% { opacity: 0.5; } }

.key-hints {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.85);
  pointer-events: none;
  transition: opacity 1.2s ease;
}
.key-hints.faded { opacity: 0.16; }
.key-hints .kbd {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  font-family: var(--f-num);
  background: rgba(9, 15, 27, 0.85);
  box-shadow: inset 0 0 0 1px rgba(146,186,255,0.38), 0 2px 0 rgba(0,0,0,0.5);
  border-radius: 3px;
  padding: 1px 6px;
  margin-right: 6px;
  font-size: 11px;
  color: var(--hv);
}

/* ---------- Toasts ---------- */
.toast-area {
  position: absolute;
  top: 108px;
  left: 50%;
  max-width: 460px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 5;
  width: 94%;
}
.toast {
  position: relative;
  background: linear-gradient(180deg, rgba(13,22,38,0.94), rgba(6,11,21,0.94));
  box-shadow: inset 0 0 0 1px var(--hair), 0 6px 18px rgba(0,0,0,0.55);
  border-left: 4px solid var(--accent, var(--cy));
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  color: var(--txt);
  animation: toastIn 0.25s ease, toastOut 0.4s ease 2.2s forwards;
  max-width: 100%;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.toast.good { --accent: var(--ok); color: var(--ok); }
.toast.bad { --accent: var(--bad); color: #ff93a2; }
.toast.warn { --accent: var(--warn); color: #ffd08a; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Tutorial hint ---------- */
.tutorial-hint {
  --cut: 14px;
  position: absolute;
  bottom: calc(124px + var(--safe-bottom));
  /* `left: 50%` alone made this shrink-to-fit inside the space left of the
     screen edge, so the box could never exceed half the width however large
     max-width was — the tutorial text ran as a 160px-wide column on a phone.
     Anchoring both edges and letting the margins centre it fixes the sizing. */
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
  max-width: min(430px, 88vw);
  padding: 16px 20px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  z-index: 6;
}
.tutorial-hint::before { background: linear-gradient(180deg, var(--hv), rgba(216,242,39,0.35)); }
/* only the text breathes — the button must stay a stable tap target */
.hint-body { animation: hintBob 2.4s ease-in-out infinite; }
@keyframes hintBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.tutorial-hint .hint-ok {
  --cut: 10px;
  margin-top: 14px;
  min-height: 46px;
  padding: 6px 30px;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--hv-ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.3), rgba(255,255,255,0.03) 45%, rgba(0,0,0,0.12)),
    linear-gradient(180deg, var(--hv) 0 78%, var(--hv-lo) 78%);
  clip-path: var(--cutpath);
}
.tutorial-hint .hint-ok:active { transform: translateY(2px); }

/* HUD collapses while the camera wall is open */
.hud-screen.cctv-mode .toast-area,
.hud-screen.cctv-mode .hud-top,
.hud-screen.cctv-mode .hud-side,
.hud-screen.cctv-mode .hud-actions,
.hud-screen.cctv-mode .btn-extend,
.hud-screen.cctv-mode .capture-prompt,
.hud-screen.cctv-mode .key-hints,
.hud-screen.cctv-mode .joystick-ghost,
.hud-screen.cctv-mode .joystick-zone { display: none; }

/* ============================================================
   CCTV monitor wall — the one place that keeps green phosphor
   ============================================================ */
#screen-cctv { z-index: 30; justify-content: flex-end; background: transparent; }
.cctv-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--cctv-cols, 2), 1fr);
  grid-template-rows: repeat(var(--cctv-rows, 2), 1fr);
  pointer-events: none;
}
.cctv-cell {
  position: relative;
  border: 5px solid rgba(3, 6, 11, 0.94);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.66);
}
/* framing brackets, drawn with gradients so no extra markup is needed */
.cctv-cell::after {
  content: '';
  position: absolute;
  inset: 9px;
  pointer-events: none;
  opacity: 0.45;
  background:
    linear-gradient(#7CFC00, #7CFC00) 0 0 / 15px 2px no-repeat,
    linear-gradient(#7CFC00, #7CFC00) 0 0 / 2px 15px no-repeat,
    linear-gradient(#7CFC00, #7CFC00) 100% 0 / 15px 2px no-repeat,
    linear-gradient(#7CFC00, #7CFC00) 100% 0 / 2px 15px no-repeat,
    linear-gradient(#7CFC00, #7CFC00) 0 100% / 15px 2px no-repeat,
    linear-gradient(#7CFC00, #7CFC00) 0 100% / 2px 15px no-repeat,
    linear-gradient(#7CFC00, #7CFC00) 100% 100% / 15px 2px no-repeat,
    linear-gradient(#7CFC00, #7CFC00) 100% 100% / 2px 15px no-repeat;
}
.cctv-cell.dead { background: rgba(3, 6, 11, 0.95); }
.cctv-cell.dead::after { opacity: 0.12; filter: grayscale(1); }
.cctv-zone {
  position: absolute;
  top: 16px;
  left: 18px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--f-num);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #7CFC00;
  text-shadow: 0 0 9px rgba(124, 252, 0, 0.75), 0 1px 3px #000;
}
.cctv-cell.dead .cctv-zone { color: #5b6b80; text-shadow: none; }
.cctv-cell.dead .rec-dot { display: none; }
.cctv-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.2) 0px, rgba(0,0,0,0.2) 1px, transparent 2px, transparent 4px);
  mix-blend-mode: multiply;
}
.cctv-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 42%, rgba(0,0,0,0.55) 100%);
}
.cctv-label {
  font-family: var(--f-num);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #7CFC00;
  text-shadow: 0 0 9px rgba(124, 252, 0, 0.6);
  min-width: 62px;
}
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff3040;
  box-shadow: 0 0 8px rgba(255,48,64,0.9);
  animation: recBlink 1s step-end infinite;
  flex: 0 0 auto;
}
@keyframes recBlink { 50% { opacity: 0.15; } }
.cctv-bar {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px calc(20px + var(--safe-bottom));
  background: linear-gradient(0deg, rgba(3,6,12,0.85), rgba(3,6,12,0));
}
.cctv-controls { display: flex; align-items: center; gap: 12px; }
.cctv-arrow {
  --cut: 10px;
  width: 56px;
  height: 52px;
  background:
    linear-gradient(180deg, rgba(124,252,0,0.16), rgba(124,252,0,0.03) 45%, rgba(0,0,0,0.2)),
    linear-gradient(180deg, #0e1a12 0 80%, #060c08 80%);
  clip-path: var(--cutpath);
  color: #7CFC00;
  font-size: 22px;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(124,252,0,0.5);
  filter: drop-shadow(0 3px 10px rgba(0,0,0,0.6));
}
.cctv-arrow:active { transform: translateY(2px); }
.cctv-close {
  --cut: 11px;
  min-height: 52px;
  padding: 10px 26px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.26), rgba(255,255,255,0.02) 45%, rgba(0,0,0,0.16)),
    linear-gradient(180deg, var(--bad) 0 78%, var(--bad-lo) 78%);
  clip-path: var(--cutpath);
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.3)) drop-shadow(0 6px 14px rgba(0,0,0,0.5));
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.cctv-close:active { transform: translateY(2px); }

/* ---------- Leaderboard ---------- */
.lb-list { display: flex; flex-direction: column; gap: 4px; padding-bottom: 20px; }
.lb-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.015));
  box-shadow: inset 0 0 0 1px var(--hair);
  border-radius: 0 9px 9px 0;
  padding: 8px 12px 8px 13px;
  font-size: 14px;
  font-weight: 700;
}
.lb-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--rank-color, transparent);
}
.lb-row:nth-child(1) { --rank-color: var(--gold); }
.lb-row:nth-child(2) { --rank-color: #cbd5e1; }
.lb-row:nth-child(3) { --rank-color: #d08a4a; }
.lb-row.me {
  background: linear-gradient(180deg, rgba(216,242,39,0.18), rgba(216,242,39,0.06));
  box-shadow: inset 0 0 0 1px rgba(216,242,39,0.5);
  --rank-color: var(--hv);
}
.lb-rank { min-width: 28px; text-align: center; font-family: var(--f-num); font-weight: 700; color: var(--dim); }
.lb-row:nth-child(-n+3) .lb-rank { color: var(--rank-color); }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-family: var(--f-num); font-weight: 700; color: var(--ok); }
.lb-empty { text-align: center; color: var(--dim); padding: 18px 0; font-weight: 700; }

/* ============================================================
   Orientation / platform sidebar safety
   ============================================================ */
/* Phone landscape. Two constraints drive everything here: the platform draws a
   ~60px sidebar down the left edge, and the viewport is only 320-430px tall, so
   the modals have to be laid out sideways instead of as a tall stack. */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --safe-bottom: 36px; }
  .hud-top { padding-left: 68px; }
  .key-hints { left: 68px; }
  /* the whole zone must clear the platform sidebar, otherwise the first
     centimetre of the "walk here" area belongs to the "All games" panel */
  .joystick-zone { left: 68px; }
  .joystick-ghost { left: 76px; bottom: calc(26px + var(--safe-bottom)); }
  .joystick-ghost-ring { width: 66px; height: 66px; }
  .joystick-ghost span { font-size: 10.5px; max-width: 124px; }

  /* ---- HUD ---- */
  /* A 2x2 grid is 101px wide against 207px for a single row of four, which is
     what pushed the goal chip under the buttons on <=667px screens. It still
     clears the stun button: the right column ends ~150px down, the stun button
     starts at 176px on the shortest supported viewport. */
  .hud-side { grid-template-columns: repeat(2, 48px); gap: 7px; }
  .hud-side .btn-icon { width: 48px; height: 48px; min-width: 48px; }
  .hud-side .btn-icon svg { width: 24px; height: 24px; }
  .hud-chip { font-size: 13px; padding: 4px 10px; }
  .hud-chip svg { width: 16px; height: 16px; }
  #hud-day { font-size: 12.5px; }
  /* eight shields at full size made the left column wider than the timer */
  .hud-warnings { gap: 3px; padding: 4px 7px 4px 8px; }
  .warn-dot, .warn-dot svg { width: 17px; height: 17px; }
  .hud-phase { font-size: 10px; letter-spacing: 1.6px; }
  .hud-goal { font-size: 11.5px; padding: 3px 9px; }
  .day-timer { height: 19px; }
  .day-timer-text { font-size: 11.5px; }
  /* Below both side columns. A toast is too wide to fit between them on a
     568px screen, so the separation has to be vertical: the columns end at
     ~150px, two toasts run 158-224px, and the extend button starts below that. */
  /* 74% reached under the stun button and a toast could hide its cooldown ring
     at the exact moment the player is waiting on it */
  .toast-area { top: 158px; width: min(62%, 460px); }
  .toast { font-size: 12.5px; padding: 5px 12px; }
  /* clear of the toast stack; the z-index keeps it tappable over the joystick */
  .btn-extend { bottom: calc(6px + var(--safe-bottom)); }

  /* ---- panels ---- */
  /* 90% of a 320px screen minus the banner reserve left ~250px, most of it
     spent on chrome. Take the full height instead and clip any spill. */
  .panel {
    --cut: 14px;
    padding: 10px 14px 12px;
    max-height: calc(var(--app-height, 100vh) - var(--safe-bottom) - 12px);
    overflow: hidden;
  }
  .panel-title { font-size: 16px; margin-bottom: 4px; }
  .panel-title::after { margin-top: 5px; height: 2px; width: 44px; }
  /* the panel now fills the screen, so a close button hanging off its top-right
     corner landed above the viewport — tuck it inside instead */
  .panel-close { top: 3px; right: 3px; width: 46px; height: 46px; }
  .summary-rows { gap: 0; }
  .summary-scroll { margin: 4px 0; }
  .summary-row { padding: 4px 3px; font-size: 12.5px; }
  .summary-row.total { padding: 6px 10px; font-size: 13px; margin-bottom: 0; }
  .summary-row.total .val { font-size: 15px; }
  .receipt-code { display: none; }
  .summary-stars { margin-bottom: 0; }
  .summary-stars svg { width: 21px; height: 21px; }
  .summary-banner { font-size: 11px; padding: 4px 9px; margin: 2px 0 0; }
  .summary-buttons { gap: 7px; }
  .summary-buttons .btn { min-height: 46px; padding: 6px 8px; font-size: 14px; }
  .btn-sub { font-size: 11px; }

  /* Shift summary: stats on the left, verdict and actions on the right. Stacked
     vertically the list collapsed to a single visible row on a 320px screen. */
  #screen-summary .panel {
    width: min(760px, 96vw);
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(196px, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "head   head"
      "list   banner"
      "list   total"
      "list   buttons";
    column-gap: 14px;
  }
  .summary-head {
    grid-area: head;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
  }
  .summary-head .panel-title { margin-bottom: 0; }
  .summary-head .panel-title::after { display: none; }
  #screen-summary .summary-scroll { grid-area: list; margin: 0; }
  #screen-summary .summary-banner { grid-area: banner; margin: 0 0 6px; }
  #screen-summary #sum-total { grid-area: total; margin-bottom: 8px; }
  #screen-summary .summary-buttons {
    grid-area: buttons;
    flex-direction: column;
    justify-content: flex-end;
  }
  #screen-summary .summary-buttons .btn { flex: 0 0 auto; }

  /* Shop: title and balance share a line, upgrades run two per row. */
  #screen-shop .panel {
    width: min(880px, 96vw);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "title money"
      "tabs  tabs"
      "list  list";
    column-gap: 12px;
    /* room for the close button now that it sits inside the corner */
    padding-right: 58px;
  }
  #screen-shop .panel-title { grid-area: title; margin-bottom: 0; align-self: center; }
  #screen-shop .panel-title::after { display: none; }
  .shop-money { grid-area: money; font-size: 17px; margin-bottom: 0; align-self: center; }
  .shop-money svg { width: 20px; height: 20px; }
  .shop-tabs { grid-area: tabs; margin: 6px 0; padding: 3px; }
  /* 48px is the platform's minimum tap target, landscape phones included */
  .shop-tab { min-height: 48px; font-size: 13px; }
  #screen-shop .list-fade { grid-area: list; }
  .shop-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 8px;
    padding-bottom: 20px;
  }
  .shop-item { padding: 8px 10px 8px 12px; gap: 9px; }
  .shop-item-icon { width: 42px; height: 42px; min-width: 42px; }
  .shop-item-icon svg { width: 26px; height: 26px; }
  .shop-item-name { font-size: 12.5px; }
  /* two lines max: a four-line description doubled the card height and cut the
     number of visible upgrades in half */
  .shop-item-desc {
    font-size: 10.5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .shop-item-lvl { font-size: 10px; margin-top: 3px; }
  .shop-item-btn { min-width: 80px; min-height: 46px; font-size: 12px; }
  .shop-item-btn .price { font-size: 12.5px; }

  /* ---- CCTV ---- */
  .cctv-bar { padding: 10px 18px calc(14px + var(--safe-bottom)) 86px; }
  .cctv-arrow { min-height: 48px; height: 48px; }
  .cctv-close { min-height: 48px; }
  .cctv-zone { top: 12px; left: 14px; font-size: 11px; }
  .cctv-cell::after { inset: 7px; }

  #screen-menu { padding: 2vh 0 calc(2vh + var(--safe-bottom)); }
  /* The logo sign is sized off the viewport WIDTH, which on a landscape phone
     is the long edge — left alone it ate 40% of a 412px-tall screen. Here it is
     driven by height instead. */
  .sign { max-width: min(600px, 82vw); padding-bottom: 8px; }
  .sign .hazard { height: 5px; margin: 2px 2px 8px; }
  .game-title { font-size: clamp(18px, 5.4vh, 32px); padding: 0 16px; }
  .game-subtitle { font-size: clamp(9.5px, 2.4vh, 13px); margin-top: 6px; padding: 0 16px; }
  .load-bar { height: 15px; }
  .load-pct { font-size: 11px; }
  .boot { gap: 16px; }
  .btn-play { min-height: 56px; padding: 12px 44px; font-size: 20px; }
  .menu-buttons { gap: 9px; }
  .menu-stat { font-size: 11.5px; padding: 4px 9px 4px 10px; }
}

/* A shop card needs ~340px to keep its name on one line and its description
   readable. Below that the two-column grid degrades into wrapped stubs, so a
   narrow landscape screen gets a single column of shorter cards instead. */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 719px) {
  /* The streak chip is dead weight until a streak actually starts, and on a
     568-667px row it costs the goal chip ~70px — enough to ellipsize the
     objective down to "Заработать: …". Show it only when it is live. */
  .hud-streak:not(.on) { display: none; }
  .shop-list { grid-template-columns: minmax(0, 1fr); }
  .shop-item { padding: 7px 10px 7px 12px; }
  .shop-item-icon { width: 38px; height: 38px; min-width: 38px; }
  .shop-item-icon svg { width: 24px; height: 24px; }
  .shop-item-desc { -webkit-line-clamp: 1; }
  .shop-item-lvl { margin-top: 2px; }
}

/* Under ~340px of height the right-hand button stack needed 297px inside a
   268px panel and the last action was cut in half. Those 29px are not there to
   be won back from paddings, so the buttons get a full-width row of their own
   and the stats list keeps the flexible one. */
@media (orientation: landscape) and (max-height: 340px) {
  #screen-summary .panel {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "head    head"
      "list    banner"
      "list    total"
      "buttons buttons";
  }
  #screen-summary .summary-banner { align-self: start; }
  #screen-summary #sum-total { margin-bottom: 6px; }
  #screen-summary .summary-buttons {
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
  }
  #screen-summary .summary-buttons .btn {
    flex: 1 1 0;
    min-width: 0;
    font-size: 13px;
    line-height: 1.15;
    padding: 6px 6px;
  }
  .btn-sub { font-size: 10.5px; }
}

/* The tutorial modal freezes the game, so on short or narrow screens centre it
   instead of anchoring to the bottom, where long strings ran off the top. */
@media (max-height: 560px), (max-width: 420px) {
  .tutorial-hint {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    max-height: calc(var(--app-height, 100vh) - 90px);
    overflow-y: auto;
    font-size: 13.5px;
  }
}

@media (max-width: 380px) {
  .joystick-ghost { left: 20px; bottom: calc(40px + var(--safe-bottom)); }
  .joystick-ghost-ring { width: 74px; height: 74px; }
  .joystick-ghost span { font-size: 11px; max-width: 118px; }
  .menu-stats { padding: 0 10px; }
  .shop-item-info { overflow-wrap: anywhere; }
}

@media (max-width: 520px) {
  .hud-chip { font-size: 13.5px; padding: 5px 10px; }
  .hud-chip svg { width: 16px; height: 16px; }
  #hud-day { font-size: 13px; }
  .day-timer { height: 20px; }
  .btn-zap { width: 80px; height: 80px; }
  .btn-zap svg { width: 38px; height: 38px; }
  /* platform rule 1.8: never below 48px on a touch screen */
  .btn-icon { width: 48px; height: 48px; min-width: 48px; }
  .btn-icon svg { width: 24px; height: 24px; }
  /* narrow screens: stack the chips so the right column stays ~100px wide,
     otherwise the button grid is pushed off the right edge */
  .hud-chips-row { flex-direction: column; align-items: flex-end; }
  .hud-col-right { max-width: 42vw; }
  .hud-chip { max-width: 42vw; overflow: hidden; }
  .hud-side { grid-template-columns: repeat(2, 48px); }
  .warn-dot, .warn-dot svg { width: 18px; height: 18px; }
  /* the chip has a row of its own now, so it no longer has to shrink to fit
     between the columns — and 10px was below what is comfortable to read */
  .hud-goal { font-size: 12px; padding: 4px 11px; gap: 5px; }
  .hud-goal svg { width: 14px; height: 14px; }
  .hud-phase { font-size: 10.5px; letter-spacing: 1.4px; }
  .hud-center { gap: 4px; }
  /* clock + arrows + close + counter overflowed a 360px bar and pushed the
     page counter past the right edge */
  .cctv-controls { gap: 9px; }
  .cctv-arrow { width: 48px; height: 48px; font-size: 19px; }
  .cctv-close { padding: 10px 14px; font-size: 14px; }
  .cctv-label { font-size: 13px; min-width: 0; flex: 0 1 auto; letter-spacing: 1px; }
  /* Only reachable with a mouse (pointer lock is off on touch), but a desktop
     window can be this narrow too, and the nowrap string is 402px wide. */
  .capture-prompt { white-space: normal; max-width: calc(100% - 24px); text-align: center; }
}

/* Portrait phones: the right-hand HUD column runs ~195px down, so the toast
   stack has to start below it or it covers the money chip. */
@media (orientation: portrait) and (max-width: 520px) {
  /* below the objective chip, which now hangs under the bar */
  .toast-area { top: 240px; }

  /* Lift the objective out of the centre column and hang it under the whole bar,
     where it gets the full width. `top: 100%` tracks the bar's real height, so it
     follows the taller of the two side columns instead of a guessed offset.
     `.hud-top` is already positioned, so it is the containing block. */
  .hud-goal {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 4px auto 0;
    width: max-content;
    max-width: calc(100% - 24px);
  }

  /* ---- modals ---- */
  /* 0.9 of the height minus the banner reserve was leaving the summary list
     ~20px on a 568px phone: the stats hid behind the total row. */
  .panel {
    --cut: 15px;
    padding: 14px 14px 16px;
    max-height: calc(var(--app-height, 100vh) * 0.95 - var(--safe-bottom));
  }
  .panel-title { font-size: 18px; margin-bottom: 6px; }

  /* The breakdown is the entire point of the screen — give it a floor of about
     three rows and take the pixels out of the chrome around it. */
  #screen-summary .summary-scroll { min-height: 104px; margin: 6px 0; }
  .summary-stars { margin-bottom: 4px; }
  .summary-stars svg { width: 25px; height: 25px; }
  .summary-banner { font-size: 11.5px; padding: 6px 10px; margin: 4px 0 0; }
  .summary-row { padding: 5px 3px; font-size: 13px; }
  .summary-row.total { padding: 8px 11px; font-size: 13.5px; margin-bottom: 8px; }
  .summary-row.total .val { font-size: 16px; }
  .receipt-code { display: none; }
  .summary-buttons { gap: 8px; }
  .summary-buttons .btn { min-height: 50px; padding: 6px 10px; font-size: 15px; }
  .btn-sub { font-size: 11.5px; }

  /* ---- shop cards ---- */
  /* A 300px panel left the text column ~84px wide and "Расширение магазина"
     broke mid-syllable. Stack instead: icon and text on top, the buy button
     across the bottom — which is also a far better tap target. */
  .shop-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "icon info"
      "btn  btn";
    align-items: center;
    gap: 8px 10px;
    padding: 10px 10px 10px 12px;
  }
  .shop-item-icon { grid-area: icon; width: 46px; height: 46px; min-width: 46px; }
  .shop-item-icon svg { width: 28px; height: 28px; }
  .shop-item-info { grid-area: info; }
  .shop-item-btn {
    grid-area: btn;
    width: 100%;
    flex-direction: row;
    gap: 10px;
    min-height: 46px;
  }
}

/* Desktop-only / touch-only helpers */
.touch-only { display: none; }
@media (pointer: coarse) {
  .touch-only { display: flex; }
  .mouse-only { display: none; }
}
