/* RatRig — base, shell and shared components.
   Chrome direction (iteration 6): "pixel game UI". The interface is a game, not a web app:
   pixel-framed panels (a 3 px ink outline with stepped corners, a light top-left and dark
   bottom-right bevel), chunky bevelled buttons that press down 4 px, game tabs, item cards with
   tier-coloured frames, segmented pixel bars. Deep purple/indigo surfaces in three levels, brand
   violet for everything you can press, gold ONLY for Ratbit, rewards and claims, off-white text and
   a muted lavender for secondary text.
   Type: Jersey 10 (pixel display, set at 20/30/40/60 px only so it stays crisp) for headings, tabs,
   buttons, labels on plates and big numbers; Rubik for paragraphs and small labels (≥ 12 px).
   The stepped corners are drawn with box-shadow copies (no clip-path), so focus rings, tooltips and
   children are never clipped. */

:root {
  /* ---- surfaces (deep purple/indigo, 3 levels + a recessed well) ---- */
  --bg-deep: #0D0919;       /* game overlay, deepest shadow */
  --bg: #150F26;            /* page */
  --well: #0F0B1E;          /* recessed: inputs, tracks, art wells, HUD plates */
  --surface-1: #1F1838;     /* panels, the top bar, the dock */
  --surface-2: #2A2049;     /* raised inside a panel: tiles, rows, cards */
  --surface-3: #362A5C;     /* floating and hover: toasts, popovers, title bars */
  --ink: #07040F;           /* pixel outline */
  --s1-hi: #3A2E63;         /* bevel light of surface-1 (top-left) */
  --s1-lo: #120C24;         /* bevel dark of surface-1 (bottom-right) */
  --s2-hi: #45377A;
  --s2-lo: #1A1333;
  --s3-hi: #54458F;
  --s3-lo: #221941;
  --well-hi: #241B42;       /* a recessed well is lit from below */
  --drop: rgba(4, 2, 10, 0.5);
  --line: rgba(190, 170, 255, 0.10);
  --line-strong: rgba(190, 170, 255, 0.18);
  --tint: rgba(190, 170, 255, 0.05);
  --tint-2: rgba(190, 170, 255, 0.09);

  /* ---- text: one warm off-white, one muted lavender, one dimmer caption ---- */
  --text: #F4EEE6;          /* ≥ 12:1 on every surface */
  --text-2: #BDB3DA;        /* ≥ 6.5:1 on surface-3 */
  --text-3: #A69CC8;        /* ≥ 5:1 on surface-3, captions only */

  /* ---- brand violet (interactive) ---- */
  --violet: #6A45E3;        /* button face; #fff on it 6.1:1 */
  --violet-face-hi: #7B58F0;/* hover face (#fff 5.0:1) */
  --violet-hi: #9C80FF;     /* bevel light */
  --violet-lo: #4A2DB3;     /* bevel dark */
  --violet-side: #2C1878;   /* the 4 px side under a raised button */
  --violet-text: #C0ABFF;   /* links, active marks, focus ring (≥ 7:1 on bg) */
  --violet-tint: rgba(146, 118, 245, 0.16);
  --violet-tint-2: rgba(146, 118, 245, 0.26);
  --violet-line: rgba(176, 152, 255, 0.4);
  --violet-deep: #2B1D5C;   /* tinted plate (premium row, current item) */

  /* ---- gold: Ratbit, rewards and claims ONLY ---- */
  --gold: #F4C752;
  --gold-hi: #FFE28F;
  --gold-lo: #B98428;
  --gold-side: #6B4512;
  --gold-ink: #241405;      /* text on a gold face (12:1) */
  --gold-tint: rgba(244, 199, 82, 0.14);
  --gold-line: rgba(244, 199, 82, 0.55);
  --focus: #D2C2FF;

  /* ---- status (genuine success / error only, desaturated) ---- */
  --success: #9AD7B5;
  --success-tint: rgba(154, 215, 181, 0.12);
  --danger: #F2A0B0;
  --danger-fill: #A8344F;
  --danger-tint: rgba(242, 160, 176, 0.12);

  /* ---- pixel frames (literal lists; component rules add their own bevels) ---- */
  --ring: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink);
  --ring2: 0 -2px 0 var(--ink), 0 2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink);
  --bevel-1: inset 3px 3px 0 var(--s1-hi), inset -3px -3px 0 var(--s1-lo);
  --bevel-2: inset 3px 3px 0 var(--s2-hi), inset -3px -3px 0 var(--s2-lo);
  --bevel-2s: inset 2px 2px 0 var(--s2-hi), inset -2px -2px 0 var(--s2-lo);
  --bevel-3: inset 3px 3px 0 var(--s3-hi), inset -3px -3px 0 var(--s3-lo);
  --sunk: inset 3px 3px 0 var(--ink), inset -2px -2px 0 var(--well-hi);
  --sunk-2: inset 2px 2px 0 var(--ink), inset -2px -2px 0 var(--well-hi);

  /* ---- legacy names (older rules, the lair scene and other modules keep working) ---- */
  --plum-950: var(--bg-deep);
  --plum-900: var(--bg);
  --plum-850: var(--well);
  --plum-800: var(--surface-2);
  --plum-700: var(--surface-1);
  --plum-650: var(--surface-1);
  --plum-600: var(--surface-3);
  --plum-500: #54466E;
  --lilac: var(--text-2);
  --lilac-hi: #E4DBFA;
  --lilac-dim: var(--text-3);
  --violet-edge: #3A2580;
  --violet-glow: rgba(118, 85, 227, 0.4);
  --cream: var(--text);
  --butter: var(--gold);
  --butter-hi: var(--gold-hi);
  --butter-glow: rgba(244, 199, 82, 0.35);
  --peach: var(--text-2);
  --pink: var(--gold);
  --pink-glow: rgba(244, 199, 82, 0.3);
  --mint: var(--success);
  --mint-glow: rgba(154, 215, 181, 0.3);
  --rose: var(--danger-fill);
  --ink-plum: #22163A;
  --trx-lo: #7A1D17;
  --trx: #E0473A;
  --trx-hi: var(--gold);
  --soot: var(--bg);
  --iron: var(--well);
  --gunmetal: var(--surface-1);
  --gunmetal-2: var(--surface-3);
  --steel: var(--plum-500);
  --steel-hi: #8C7AAE;
  --brass-lo: var(--plum-500);
  --brass: var(--violet-text);
  --brass-hi: var(--gold);
  --verdigris-lo: #1E4A44;
  --verdigris: #4FB89A;
  --verdigris-hi: var(--success);
  --lamp: var(--gold);
  --lamp-hi: var(--gold-hi);
  --lamp-glow: var(--butter-glow);
  --danger-legacy: var(--danger-fill);
  --bone: var(--text);
  --ash: var(--text-2);
  --dust: var(--text-3);

  /* ---- type ---- */
  --f-display: 'Jersey 10', 'Rubik', system-ui, sans-serif;
  --f-body: 'Rubik', 'Segoe UI', system-ui, sans-serif;
  --f-sign: var(--f-display);
  --f-ui: var(--f-body);
  --f-pixel: var(--f-display);
  /* pixel sizes (Jersey 10 is drawn on a 10 px grid: only multiples of 10 stay sharp) */
  --px-s: 20px;   /* tabs, buttons, plate labels, panel titles, HUD numbers */
  --px-m: 30px;   /* modal titles, prices, big figures */
  --px-l: 40px;   /* screen titles, results score */
  --px-xl: 60px;  /* wordmark */
  --fs-1: 40px;
  --fs-2: 30px;
  --fs-3: 20px;
  --fs-4: 15px;   /* body (Rubik) */
  --fs-5: 14px;   /* labels, secondary */
  --fs-6: 13px;   /* captions, units (never smaller than 12) */

  /* ---- pixel palette of the sprite scenes (lair interior, rocket.css) and tier frames ---- */
  --c-ink: #120E1A;
  --c-night: #1E1726;
  --c-brick-deep: #2E2438;
  --c-brick: #45374F;
  --c-brick-light: #6B5670;
  --c-water-deep: #12403F;
  --c-pipe: #1F6E66;
  --c-teal: #36A68F;
  --c-mint: #8CF2C8;
  --c-violet-deep: #4B2A78;
  --c-violet: #A04DDB;
  --c-rind: #6E3A14;
  --c-toast: #B8661E;
  --c-cheddar: #E89B2A;
  --c-cheese: #F7C948;
  --c-cream: #FFE89A;
  --c-parchment: #F4EBDD;
  --c-fur: #8C7B75;
  --c-fur-light: #BFAFA6;
  --c-pink: #E58FA0;
  --c-alert: #D9473F;
  --c-mold: #6FA33A;
  --tier-1: #8C7B75;
  --tier-2: #B8661E;
  --tier-3: #6FA33A;
  --tier-4: #36A68F;
  --tier-5: #A04DDB;
  --tier-6: #F7C948;

  /* ---- layout: 4 px pixel grid, square corners ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --r-1: 0;
  --r-2: 0;
  --r-3: 0;
  --r-cushion: 0;
  --r-well: 0;
  --r-btn: 0;
  --gutter: 24px;
  --shell: 1240px;        /* page width (header, view, footer) including the gutters; 1500 from 1400 px */
  --header-h: 72px;       /* bottom edge of the sticky one-row game bar (≥ 1280 px) */
  --dock-h: 74px;
  --nav-h: var(--dock-h); /* legacy name */

  /* ---- motion: short, stepped ---- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --ease-soft: var(--ease-out);
  --t-fast: 90ms;
  --t: 160ms;
  --t-slow: 240ms;

  /* ---- materials ---- */
  /* sewer bricks, 2× pixels, barely there */
  --bricks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='16' shape-rendering='crispEdges'%3E%3Cg fill='%23ffffff' fill-opacity='.028'%3E%3Crect x='0' y='7' width='32' height='1'/%3E%3Crect x='0' y='15' width='32' height='1'/%3E%3Crect x='15' y='0' width='1' height='7'/%3E%3Crect x='31' y='8' width='1' height='7'/%3E%3C/g%3E%3C/svg%3E");
  --grain: var(--bricks);
  --hl: inset 0 0 0 transparent;
  --sh-1: 0 3px 0 var(--drop);
  --sh-2: 0 6px 0 var(--drop);
  --sh-3: 0 8px 0 var(--drop);
  --well-sh: var(--sunk);
  --stitch: 3px solid var(--ink);
  --knit: linear-gradient(transparent, transparent);
  --cushion: var(--surface-1);
  --noise: var(--grain);
  --brushed: linear-gradient(transparent, transparent);
  --rivet: linear-gradient(transparent, transparent);
  --brass-face: var(--gold);
  --hazard: repeating-linear-gradient(-45deg, var(--violet) 0 8px, var(--surface-3) 8px 16px);
  --plate-face: var(--surface-1);
  --plate-bg: var(--surface-1);
  --plate-edge: var(--bevel-1), var(--ring);
}
*, *::before, *::after { box-sizing: border-box; }

html {
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
  color-scheme: dark;
  background-color: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--bricks);
  background-size: 64px 32px;
  color: var(--text);
  font-family: var(--f-body);
  font-size: var(--fs-4);
  font-weight: 400;
  line-height: 1.55;
  font-variant-numeric: lining-nums;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, canvas, .rr-sprite {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
a { color: var(--violet-text); text-underline-offset: 3px; text-decoration-thickness: 2px; }
a:hover { color: var(--text); }
strong { font-weight: 600; }
::selection { background: var(--violet); color: #fff; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 0;
}
:focus:not(:focus-visible) { outline: none; }

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

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 200;
  background: var(--surface-3);
  color: var(--text);
  font: var(--px-s)/1 var(--f-display);
  padding: 10px 16px;
  text-decoration: none;
  box-shadow: var(--bevel-3), var(--ring);
  transition: top var(--t) steps(3);
}
.skip-link:focus { top: 12px; color: var(--text); }

.muted { color: var(--text-2); }
.why { color: var(--text-2); font-size: var(--fs-6); line-height: 1.4; font-weight: 500; }
.why[role="alert"]:not(:empty), .why.is-error { color: var(--danger); }
.empty-note { color: var(--text-2); }
.hint { color: var(--text-2); font-size: var(--fs-5); }

/* ------------------------------------------------------------------ layout */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.console { display: contents; }
.view {
  flex: 1;
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter) var(--sp-7);
  outline: none;
}
.boot-msg { color: var(--text-2); padding: 40px 0; text-align: center; font: var(--px-s)/1 var(--f-display); }
.site-foot {
  max-width: var(--shell);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter) var(--sp-6);
  color: var(--text-3);
  font-size: var(--fs-6);
  line-height: 1.5;
}
.site-foot p {
  max-width: 80ch;
  padding-top: var(--sp-4);
  border-top: 3px solid var(--surface-1);
}
.site-foot a { color: var(--text-2); }
.site-foot p.site-foot-links { padding-top: 6px; border-top: 0; }

body[data-route="portada"] .console,
body[data-route="portada"] .site-foot { display: none; }
body[data-route="portada"] .view { max-width: none; padding: 0; }

/* ------------------------------------------------------------------ panels: the pixel window */

.panel {
  position: relative;
  background: var(--surface-1);
  border: 0;
  border-radius: 0;
  box-shadow: var(--bevel-1), var(--ring), 0 6px 0 var(--drop);
  padding: var(--sp-5);
}

.screen { display: flex; flex-direction: column; gap: var(--sp-5); }
.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
  flex-wrap: wrap;
}
.screen-head-text { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.screen-title {
  max-width: 100%;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-l);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text);
  text-shadow: 0 3px 0 var(--ink);
  outline: none;
  overflow-wrap: anywhere;
}
.screen-title:focus, .wordmark:focus { outline: none; } /* focused by the router for screen readers only */
.screen-sub { color: var(--text-2); max-width: 70ch; }
.panel-title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: var(--sp-4);
}
/* a panel header: title on the left, a quiet fact or action on the right */
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-3);
}
.panel-head .panel-title { margin-bottom: 0; }
.panel-meta { font-size: var(--fs-6); font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.panel-sub {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  color: var(--text);
  margin: var(--sp-5) 0 var(--sp-3);
}

.kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
}
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* number + unit pair: the number in the text colour, the unit muted */
.nu { white-space: nowrap; font-variant-numeric: tabular-nums; }
.nu-u { margin-left: 0.25em; font-size: 0.82em; font-weight: 500; color: var(--text-2); letter-spacing: 0.02em; }

/* ------------------------------------------------------------------ buttons
   Chunky pixel buttons: a 3 px ink outline with stepped corners, a light top and dark bottom
   bevel and a 4 px side underneath. Pressing drops the face onto its side (4 px) in two steps.
   Kinds: primary (violet), secondary (purple plate), ghost (dark socket), danger (red). */

.btn {
  --face: #3A2D63;
  --face-hover: #45377A;
  --hi: #5E4E96;
  --lo: #271D47;
  --side: #160F2C;
  --fg: var(--text);
  --d: 4px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 3px 18px 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-align: center;
  color: var(--fg);
  background-color: var(--face);
  border: 0;
  border-radius: 0;
  box-shadow:
    inset 0 3px 0 var(--hi),
    inset 0 -3px 0 var(--lo),
    0 var(--d) 0 var(--side),
    0 -3px 0 var(--ink),
    -3px 0 0 var(--ink), 3px 0 0 var(--ink),
    -3px var(--d) 0 var(--ink), 3px var(--d) 0 var(--ink),
    0 calc(var(--d) + 3px) 0 var(--ink);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--t-fast) steps(2),
    box-shadow 70ms steps(2),
    transform 70ms steps(2);
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) { color: var(--fg); background-color: var(--face-hover); }
.btn:active:not(:disabled):not([aria-disabled="true"]) { --d: 0px; transform: translateY(4px); }
.btn:focus-visible { outline-offset: 6px; }
.btn-primary {
  --face: var(--violet);
  --face-hover: var(--violet-face-hi);
  --hi: var(--violet-hi);
  --lo: var(--violet-lo);
  --side: var(--violet-side);
  --fg: #FFFFFF;
}
.btn-secondary {
  --face: #3A2D63;
  --face-hover: #45377A;
  --hi: #5E4E96;
  --lo: #271D47;
  --side: #160F2C;
  --fg: var(--text);
}
.btn-ghost {
  --face: #1C1534;
  --face-hover: #281F47;
  --hi: #2E2452;
  --lo: #120D24;
  --side: #0B0818;
  --fg: var(--text);
}
.btn-danger {
  --face: var(--danger-fill);
  --face-hover: #B93E5B;
  --hi: #D8657F;
  --lo: #7A2036;
  --side: #4A1020;
  --fg: #FFFFFF;
}
/* gold: claiming a reward (pase) — gold marks rewards only */
.btn-gold,
.btn.pass-claim,
.btn.pass-claim-all {
  --face: var(--gold);
  --face-hover: #FAD470;
  --hi: var(--gold-hi);
  --lo: var(--gold-lo);
  --side: var(--gold-side);
  --fg: var(--gold-ink);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  --face: #241C3E;
  --face-hover: #241C3E;
  --hi: #31285A;
  --lo: #1A1430;
  --side: #110C20;
  --fg: var(--text-3);
  cursor: not-allowed;
}
.btn-small { min-height: 36px; padding: 3px 12px 0; }
.btn-big { min-height: 56px; padding: 4px 28px 0; font-size: var(--px-m); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-4); }

/* square icon button (settings gear) */
.btn-icon {
  --d: 3px;
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  color: var(--text);
  background: #3A2D63;
  border: 0;
  border-radius: 0;
  box-shadow:
    inset 0 3px 0 #5E4E96, inset 0 -3px 0 #271D47,
    0 var(--d) 0 #160F2C,
    0 -2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink),
    -2px var(--d) 0 var(--ink), 2px var(--d) 0 var(--ink),
    0 calc(var(--d) + 2px) 0 var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast) steps(2), box-shadow 70ms steps(2), transform 70ms steps(2);
}
.btn-icon svg { transition: transform var(--t-slow) steps(3); }
.btn-icon:hover { background: #45377A; }
.btn-icon:hover svg { transform: rotate(45deg); }
.btn-icon:active { --d: 0px; transform: translateY(3px); }
.btn-icon:focus-visible { outline-offset: 5px; }

/* ------------------------------------------------------------------ fields */

.input {
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--text);
  background: var(--well);
  border: 0;
  border-radius: 0;
  box-shadow: var(--sunk), var(--ring);
  transition: box-shadow var(--t-fast) steps(2);
}
.input:hover { background: #130E26; }
.input:focus {
  outline: none;
  box-shadow: var(--sunk), 0 -3px 0 var(--violet-text), 0 3px 0 var(--violet-text), -3px 0 0 var(--violet-text), 3px 0 0 var(--violet-text);
}
.input::placeholder { color: var(--text-3); }
.input.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; font-weight: 400; resize: vertical; }
.label { display: block; font: var(--px-s)/1 var(--f-display); color: var(--text); margin-bottom: var(--sp-3); }
.inline { display: flex; gap: var(--sp-3); align-items: flex-start; }
.inline .btn { flex: none; min-height: 44px; }

/* tier tag: a dark plate with a gem in the tier colour (text never sits on the tier colour) */
.tier-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  gap: 5px;
  height: 22px;
  padding: 2px 6px 0 4px;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  color: var(--text);
  background: var(--well);
  box-shadow: var(--ring2);
}
.tier-badge::before {
  content: '';
  flex: none;
  width: 10px; height: 10px;
  margin-top: -2px;
  background: var(--tier, var(--steel-hi));
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35), inset -2px -2px 0 rgba(0, 0, 0, 0.35);
}
.amount { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; vertical-align: middle; }
.amount-num { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.amount-unit { font-size: var(--fs-6); font-weight: 500; color: var(--text-2); letter-spacing: 0.02em; }
.amount-qso .amount-num { color: var(--gold); }
.amount-power .amount-num { color: var(--text); }

/* segmented pixel bar (generic): a well with a fill, cut into blocks by the track colour */
.px-bar {
  --seg: 10px;
  position: relative;
  height: 14px;
  background: var(--well);
  box-shadow: var(--sunk-2), var(--ring2);
  overflow: hidden;
}
.px-bar-fill {
  position: absolute;
  left: 2px; top: 2px; bottom: 2px;
  width: 0;
  max-width: calc(100% - 4px);
  background: var(--violet-text);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.px-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(var(--seg) - 2px), var(--well) calc(var(--seg) - 2px) var(--seg));
  pointer-events: none;
}

/* ------------------------------------------------------------------ toggle switches (pixel) */

.settings-list { display: flex; flex-direction: column; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.setting-row { position: relative; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-label { display: flex; gap: 16px; align-items: flex-start; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.switch {
  flex: none;
  position: relative;
  width: 48px; height: 26px;
  margin: 3px 0 0 3px;
  background: var(--well);
  box-shadow: var(--sunk-2), var(--ring);
  transition: background-color var(--t-fast) steps(2);
}
.switch::after {
  content: '';
  position: absolute;
  top: 4px; left: 4px;
  width: 18px; height: 18px;
  background: var(--text-3);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35), inset -2px -2px 0 rgba(0, 0, 0, 0.35), 0 0 0 2px var(--ink);
  transition: transform var(--t) steps(3), background-color var(--t-fast) steps(2);
}
.switch-label:hover .switch { background: #17112C; }
.switch-input:checked + .switch-label .switch { background: var(--violet); box-shadow: inset 2px 2px 0 var(--violet-lo), var(--ring); }
.switch-input:checked + .switch-label .switch::after { transform: translateX(22px); background: #fff; }
.switch-input:focus-visible + .switch-label .switch { outline: 3px solid var(--focus); outline-offset: 5px; }
.setting-text { display: flex; flex-direction: column; gap: 2px; }
.setting-name { font: var(--px-s)/1.1 var(--f-display); }
.setting-hint, .setting-note { font-size: var(--fs-5); color: var(--text-2); }

/* ------------------------------------------------------------------ the game bar (header)
   Desktop ≥ 1280 px — ONE sticky row:  brand · game tabs · RBIT · RPS · next block · level · ajustes
   1024–1279 px     — two rows in the same bar (status row, then the tabs across the width)
   640–1023 px      — three rows (brand + player, chips, tabs)
   < 640 px         — status rows on top, tabs as a bottom dock
   The nav (#nav) is a child of .hud-inner (hud.js adopts it right after the brand). */

.hud {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0 var(--gutter);
  background: var(--surface-1);
  box-shadow: inset 0 -3px 0 var(--s1-lo), 0 3px 0 var(--ink), 0 7px 0 var(--drop);
}
.hud.is-scrolled { background: var(--surface-1); }
.hud-inner {
  max-width: calc(var(--shell) - 2 * var(--gutter));
  min-height: 69px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto auto auto;
  grid-template-areas: "brand nav qso power block player settings";
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: 10px 0 13px;
}
.hud-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: var(--sp-2);
  color: var(--text);
  text-decoration: none;
}
.hud-brand > .rr-sprite { transition: transform var(--t-slow) steps(3); } /* logo_small is 48×48: drawn 1:1, crisp */
.hud-brand:hover { color: var(--text); }
.hud-brand:hover > .rr-sprite { transform: translateY(-2px); }
.hud-brand-text {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-m);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text);
  text-shadow: 0 2px 0 var(--ink);
}
.wm-rat, .wm-rig { color: inherit; }

.hud-player { grid-area: player; display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.hud-player-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.hud-name {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* level: a raised violet plate "Nv 12" */
.lvl-badge {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  min-width: 52px;
  height: 40px;
  padding: 7px 8px 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-m);
  line-height: 1;
  color: #fff;
  background: var(--violet);
  box-shadow: inset 0 3px 0 var(--violet-hi), inset 0 -3px 0 var(--violet-lo), var(--ring2);
  font-variant-numeric: tabular-nums;
}
.lvl-badge::before { content: 'Nv'; font-size: var(--px-s); color: #E2D8FF; }
.lvl-badge.pop { animation: lvl-pop 600ms steps(6) 1; }
@keyframes lvl-pop {
  0% { transform: translateY(0); }
  30% { transform: translateY(-4px); background: var(--violet-face-hi); }
  100% { transform: translateY(0); }
}

.xp-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.xp-bar {
  position: relative;
  flex: 1 1 auto;
  min-width: 70px;
  max-width: 180px;
  height: 10px;
  background: var(--well);
  box-shadow: var(--ring2);
  overflow: hidden;
}
.xp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  min-width: 4px;
  background: var(--violet-text);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: width 600ms steps(8);
}
.xp-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, transparent 0 8px, var(--well) 8px 10px);
}
.xp-fill.is-empty { min-width: 0; }
.xp-text { font-size: var(--fs-6); font-weight: 500; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

/* HUD plates: RBIT balance and power — recessed sockets in the bar */
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 42px;
  padding: 0 12px 0 5px;
  color: var(--text);
  background: var(--well);
  border: 0;
  border-radius: 0;
  box-shadow: var(--sunk-2), var(--ring2);
}
.chip-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  line-height: 0;
}
.inst-label {
  font-family: var(--f-body);
  font-weight: 500;
  font-size: var(--fs-6);
  line-height: 1.1;
  color: var(--text-2);
}

/* RBIT balance chip with count-up */
.hud-qso { grid-area: qso; justify-self: start; transition: background-color var(--t-fast) steps(2); }
.hud-qso.is-link:hover { background: #17112D; }
.qso-num {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  white-space: nowrap;
}
.chip-unit { font-weight: 600; font-size: 12px; line-height: 1; letter-spacing: 0.04em; color: var(--text-2); }
.hud-qso.bump { animation: chip-glow 800ms steps(4) 1; }
.hud-qso.bump .qso-num { animation: num-pop 420ms steps(3) 1; }
.hud-qso.spend { animation: chip-squish 320ms steps(3) 1; }
@keyframes chip-glow {
  25% { box-shadow: var(--sunk-2), 0 -2px 0 var(--gold), 0 2px 0 var(--gold), -2px 0 0 var(--gold), 2px 0 0 var(--gold); }
}
@keyframes num-pop { 35% { transform: translateY(-2px); } }
@keyframes chip-squish {
  0% { transform: none; }
  35% { transform: translateY(2px); }
  100% { transform: none; }
}
.qso-delta {
  position: absolute;
  right: 8px;
  top: calc(100% + 8px);
  z-index: 2;
  padding: 4px 8px 2px;
  font-family: var(--f-display);
  font-size: var(--px-s);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--gold);
  background: var(--surface-3);
  box-shadow: var(--ring2), 0 4px 0 var(--drop);
  pointer-events: none;
  animation: delta-float 1100ms steps(8) both;
}
.qso-delta.minus { color: var(--text-2); }
@keyframes delta-float {
  0% { opacity: 0; transform: translateY(-6px); }
  18% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(6px); }
}

/* RPS chip: opens the power breakdown; a little spark blinks while something mines */
.hud-power-wrap { grid-area: power; position: relative; }
.hud-power {
  cursor: pointer;
  padding-right: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast) steps(2), transform 70ms steps(2);
}
.hud-power:hover { background: #17112D; }
.hud-power:active { transform: translateY(2px); }
.hud-power[aria-expanded="true"] { background: #1A1335; box-shadow: var(--sunk-2), 0 -2px 0 var(--violet-text), 0 2px 0 var(--violet-text), -2px 0 0 var(--violet-text), 2px 0 0 var(--violet-text); }
.hud-power:focus-visible { outline-offset: 4px; }
.hud-power .chip-icon { position: relative; width: 28px; height: 28px; }
.hud-power .chip-icon::after {
  content: '';
  position: absolute;
  right: 0; top: 2px;
  width: 4px; height: 4px;
  background: var(--success);
  opacity: 0;
}
.hud-power.is-live .chip-icon::after { opacity: 1; animation: spark 1.6s steps(1) infinite; }
@keyframes spark { 50% { opacity: 0.15; } }
.hud-power.bump { animation: chip-squish 360ms steps(3) 1; }
.gauge-read { display: flex; align-items: baseline; gap: 5px; padding-top: 2px; }
.gauge-read .hud-num { font-family: var(--f-display); font-weight: 400; font-size: var(--px-s); line-height: 1; font-variant-numeric: tabular-nums; color: var(--text); }
.gauge-read .hud-unit { font-weight: 600; font-size: 12px; letter-spacing: 0.04em; color: var(--text-2); }
.chip-caret {
  width: 8px; height: 8px;
  margin-left: 2px;
  background:
    linear-gradient(var(--text-2), var(--text-2)) 0 0 / 8px 2px no-repeat,
    linear-gradient(var(--text-2), var(--text-2)) 2px 2px / 4px 2px no-repeat,
    linear-gradient(var(--text-2), var(--text-2)) 3px 4px / 2px 2px no-repeat;
  transition: transform var(--t) steps(2);
}
.hud-power[aria-expanded="true"] .chip-caret { transform: rotate(180deg); }

.power-pop {
  position: absolute;
  top: calc(100% + 14px);
  right: -60px;
  width: 320px;
  max-width: calc(100vw - 24px);
  z-index: 50;
  padding: var(--sp-4) 18px;
  background: var(--surface-3);
  box-shadow: var(--bevel-3), var(--ring), 0 8px 0 var(--drop);
  animation: pop-in 160ms steps(3) both;
}
.power-pop[hidden] { display: none; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px); } }
.power-pop-title { font: var(--px-s)/1 var(--f-display); color: var(--text); margin-bottom: var(--sp-3); }
.power-list { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2) var(--sp-3); margin: 0; font-size: 15px; }
.power-list dt { color: var(--text-2); }
.power-list dd { margin: 0; text-align: right; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.power-list .pb-total { border-top: 3px solid var(--ink); padding-top: 10px; margin-top: 2px; color: var(--text); font-weight: 700; }

/* next-block timer: a segmented pixel ring in a socket */
.hud-block {
  grid-area: block;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 2px;
  background: var(--well);
  box-shadow: var(--sunk-2), var(--ring2);
}
.dial {
  position: relative;
  flex: none;
  width: 40px; height: 40px;
}
.dial-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; shape-rendering: crispEdges; }
.d-track { fill: none; stroke: #2A2049; stroke-width: 7; }
.d-ring {
  fill: none;
  stroke: var(--violet-text);
  stroke-width: 7;
  stroke-linecap: butt;
  transition: stroke-dashoffset 1s steps(2), stroke var(--t);
}
.d-ticks { fill: none; stroke: var(--well); stroke-width: 9; }
.hud-block.soon .d-ring { stroke: var(--gold); }
.dial-face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-top: 3px; }
.dial-secs { font-family: var(--f-display); font-size: var(--px-s); line-height: 1; font-variant-numeric: tabular-nums; color: var(--text); }
.dial-unit { display: none; }
.hud-block-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-right: 10px; }
.hud-block-label { font: var(--px-s)/1 var(--f-display); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-block.flash .dial { animation: ring-pop 650ms steps(4) 1; }
@keyframes ring-pop {
  0% { transform: none; }
  30% { transform: translateY(-3px); }
  100% { transform: none; }
}

.hud-settings { grid-area: settings; justify-self: end; margin-bottom: 3px; }

/* ------------------------------------------------------------------ navigation: game tabs
   Inactive tabs are dark sockets; the current one is a raised violet plate. (The sliding
   .nav-indicator placed by js/ui/nav.js is not drawn: each tab paints its own state.) */

.nav {
  grid-area: nav;
  position: relative;
  min-width: 0;
  padding: 0;
}
.nav-track {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 0;
}
.nav-list { display: flex; gap: 8px; }
.nav-list li { flex: 0 0 auto; min-width: 0; }
.nav-indicator { display: none !important; }
.nav-link {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 2px 12px 0 7px;
  color: var(--text-2);
  text-decoration: none;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-s);
  line-height: 1;
  letter-spacing: 0.02em;
  background: #17112C;
  box-shadow: var(--sunk-2), var(--ring2);
  -webkit-tap-highlight-color: transparent;
  transition: color var(--t-fast) steps(2), background-color var(--t-fast) steps(2), transform 70ms steps(2);
}
.nav-link:hover { color: var(--text); background: #241B42; }
.nav-link:active { transform: translateY(2px); }
.nav-link[aria-current="page"] {
  color: #FFFFFF;
  background: var(--violet);
  box-shadow: inset 0 3px 0 var(--violet-hi), inset 0 -3px 0 var(--violet-lo), var(--ring2), 0 5px 0 var(--violet-side), -2px 3px 0 var(--ink), 2px 3px 0 var(--ink), 0 7px 0 var(--ink);
  transform: translateY(-3px);
}
.nav-link:focus-visible { outline-offset: 4px; }
.nav-lamp { display: none; }
.nav-icon {
  display: grid;
  place-items: center;
  line-height: 0;
  transition: transform var(--t) steps(2);
}
.nav-icon .rr-sprite { opacity: 0.72; transition: opacity var(--t-fast) steps(2); }
.nav-link:hover .nav-icon .rr-sprite,
.nav-link[aria-current="page"] .nav-icon .rr-sprite { opacity: 1; }
.nav-link[aria-current="page"] .nav-icon .rr-sprite { filter: drop-shadow(0 2px 0 rgba(7, 4, 15, 0.55)); }
.nav-link:hover .nav-icon { transform: translateY(-2px); }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-top: 1px; }

/* ------------------------------------------------------------------ toasts: little pixel windows */

.toasts {
  position: fixed;
  top: calc(var(--header-h) + 16px); /* below the sticky bar, so its instruments stay readable */
  right: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  --tone: var(--text-3);
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: var(--sp-2);
  column-gap: var(--sp-3);
  margin-bottom: 16px;
  padding: 12px 8px 12px 20px;
  background: var(--surface-3);
  box-shadow: inset 8px 0 0 var(--tone), inset 0 3px 0 var(--s3-hi), inset -3px -3px 0 var(--s3-lo), var(--ring), 0 6px 0 var(--drop);
  transform-origin: 100% 0;
  animation: toast-in 180ms steps(3) both;
}
.toast::before { content: none; }
.toast > .rr-sprite { flex: none; }
.toast-out { pointer-events: none; }
@keyframes toast-in {
  0% { opacity: 0; transform: translateX(16px); }
  100% { opacity: 1; transform: none; }
}
.toast-qso { --tone: var(--gold); }
.toast-level, .toast-ach { --tone: var(--violet-text); }
.toast-info { --tone: #6F6496; }
.toast-error { --tone: var(--danger-fill); }
.toast-body { flex: 1 1 190px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.toast-title { font: var(--px-s)/1.1 var(--f-display); color: var(--text); }
.toast-qso .toast-title { color: var(--gold); }
.toast-text { font-size: var(--fs-5); color: var(--text-2); line-height: 1.4; }
/* the action drops to its own row under the text, the close button stays top-right */
.toast-close { order: 1; }
.toast-action { order: 2; flex: none; margin: 0 8px 6px auto; }
.toast-close {
  align-self: flex-start;
  flex: none;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  background: none;
  border: none;
  color: var(--text-2);
  font: var(--px-m)/1 var(--f-display);
  cursor: pointer;
  padding: 0 0 2px;
  transition: background-color var(--t-fast) steps(2), color var(--t-fast) steps(2);
}
.toast-close:hover { color: var(--text); background: var(--tint-2); }
.toast-close:active { transform: translateY(2px); }

/* ------------------------------------------------------------------ modals: pixel windows with a title bar */

.modal-veil {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 5, 18, 0.78);
  animation: veil-in var(--t) steps(3) both;
}
@keyframes veil-in { from { opacity: 0; } }
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: 0 var(--sp-5) var(--sp-5);
  outline: none;
  background: var(--surface-1);
  box-shadow: inset -3px -3px 0 var(--s1-lo), inset 3px 0 0 var(--s1-hi), var(--ring), 0 8px 0 var(--drop);
  scrollbar-color: var(--s3-hi) var(--surface-1);
  animation: modal-in var(--t-slow) steps(4) both;
}
@keyframes modal-in { from { transform: translateY(12px); opacity: 0; } }
.modal-veil.is-closing { pointer-events: none; animation: veil-out 150ms steps(2) both; }
.modal-veil.is-closing .modal { animation: modal-out 150ms steps(2) both; }
@keyframes veil-out { to { opacity: 0; } }
@keyframes modal-out { to { transform: translateY(8px); opacity: 0; } }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: 0 calc(-1 * var(--sp-5));
  min-height: 56px;
  padding: 8px 10px 8px var(--sp-5);
  background: var(--surface-3);
  box-shadow: inset 3px 3px 0 var(--s3-hi), inset 0 -3px 0 var(--ink);
}
.modal-head > .rr-sprite { flex: none; }
.modal-title {
  flex: 1;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--px-m);
  line-height: 1;
  padding-top: 3px;
  color: var(--text);
  text-shadow: 0 2px 0 var(--ink);
  overflow-wrap: anywhere;
}
.modal-x {
  --d: 3px;
  flex: none;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin-bottom: 3px;
  padding: 0 0 3px;
  color: var(--text);
  font: var(--px-m)/1 var(--f-display);
  background: #3A2D63;
  border: 0;
  box-shadow:
    inset 0 3px 0 #5E4E96, inset 0 -3px 0 #271D47,
    0 var(--d) 0 #160F2C,
    0 -2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink),
    -2px var(--d) 0 var(--ink), 2px var(--d) 0 var(--ink),
    0 calc(var(--d) + 2px) 0 var(--ink);
  cursor: pointer;
  transition: background-color var(--t-fast) steps(2), box-shadow 70ms steps(2), transform 70ms steps(2);
}
.modal-x:hover { background: #45377A; }
.modal-x:active { --d: 0px; transform: translateY(3px); }
.modal-x:focus-visible { outline-offset: 5px; }
.modal-body { display: flex; flex-direction: column; gap: var(--sp-3); color: var(--text); padding-top: var(--sp-2); }
.modal-body p { max-width: 62ch; }
.modal-body .kv { padding: var(--sp-3) var(--sp-4); background: var(--well); box-shadow: var(--sunk-2); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-4); padding: var(--sp-2) 3px 4px; }
body.has-modal { overflow: hidden; }

/* ------------------------------------------------------------------ tutorial: Abuela Gouda's speech window */

.tutorial {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  width: min(410px, calc(100vw - 40px));
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  padding: var(--sp-4);
  background: var(--surface-3);
  box-shadow: var(--bevel-3), var(--ring), 0 6px 0 var(--drop);
  transform-origin: 100% 100%;
}
.tutorial.tut-pop { animation: tut-in 220ms steps(3) both; }
@keyframes tut-in { from { opacity: 0; transform: translateY(10px); } }
.tutorial[hidden] { display: none; }
.tutorial.collapsed { width: auto; padding: 6px 12px 6px 6px; }
.tut-portrait {
  flex: none;
  display: grid;
  place-items: end center;
  width: 70px; height: 70px;
  background: var(--well);
  box-shadow: var(--sunk-2), var(--ring2);
  overflow: hidden;
}
.tut-body { position: relative; z-index: 1; display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.tut-who { font: var(--px-s)/1 var(--f-display); color: var(--violet-text); }
.tut-text { line-height: 1.5; font-size: 15px; color: var(--text); }
.tut-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); }
.tut-skip {
  background: none;
  border: none;
  color: var(--text-2);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: var(--fs-5);
  padding: 8px 6px;
  min-height: 36px;
}
.tut-skip:hover { color: var(--text); }
.tut-mini {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font: var(--px-s)/1 var(--f-display);
  padding: 2px 6px 2px 2px;
  min-height: 44px;
}
.tut-mini:hover { color: var(--text); }
.tut-mini:active { transform: translateY(2px); }
.tut-mini > .rr-sprite { background: var(--well); box-shadow: var(--ring2); }
.tut-hl {
  outline: 3px solid var(--gold) !important;
  outline-offset: 6px;
  animation: tut-glow 1.2s steps(2) infinite;
}
@keyframes tut-glow {
  50% { outline-color: rgba(244, 199, 82, 0.25) !important; }
}
/* inside the lair scene the targets sit edge to edge: keep the ring tight so they don't overlap */
.lair-scene .tut-hl { outline-offset: -3px; animation-name: tut-glow-tight; }
@keyframes tut-glow-tight { 50% { outline-color: rgba(244, 199, 82, 0.25) !important; } }

/* ------------------------------------------------------------------ mini-game host */

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-deep);
  background-image: var(--bricks);
  background-size: 64px 32px;
  animation: veil-in var(--t) steps(3) both;
}
.game-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 14px 11px 16px;
  background: var(--surface-1);
  box-shadow: inset 0 -3px 0 var(--ink);
}
.game-bar-title { font: var(--px-s)/1 var(--f-display); color: var(--text); padding-top: 2px; }
.game-bar-diff {
  margin-right: auto;
  padding: 4px 8px 2px;
  font: var(--px-s)/1 var(--f-display);
  color: var(--text-2);
  background: var(--well);
  box-shadow: var(--ring2);
}
.game-stage-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
}
.game-stage {
  position: relative;
  /* definite width AND height, 16:9, max 960×540 (contracts §3.2) */
  /* --ad-w / --ad-h: room for the round's banner beside or under the stage (js/ui/games.js placeAd) */
  --gw: min(960px, calc(100vw - 32px - var(--ad-w, 0px)), calc((100vh - 96px - var(--ad-h, 0px)) * 16 / 9));
  width: var(--gw);
  height: calc(var(--gw) * 9 / 16);
  background: var(--c-ink);
  border: none; /* the bezel is drawn outside so the games get the full 960×540 */
  border-radius: 0;
  box-shadow: var(--ring), 0 0 0 7px var(--surface-2), 0 0 0 10px var(--ink), 0 14px 0 4px var(--drop);
  overflow: hidden;
  outline: none;
}
@supports (height: 100dvh) {
  .game-stage { --gw: min(960px, calc(100vw - 32px - var(--ad-w, 0px)), calc((100dvh - 96px - var(--ad-h, 0px)) * 16 / 9)); }
}
.game-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 16px;
  padding: 16px;
  text-align: center;
}
body.in-game { overflow: hidden; }

/* ------------------------------------------------------------------ desktop one-row bar (≥ 1280 px) */

@media (min-width: 1280px) {
  .view { padding-top: 20px; } /* the room starts right under the sticky bar */
  .hud-block-text { display: none; } /* ring only; "Bloque #N" is in its tooltip */
  /* level: just the plate, with the XP progress as a slim segmented bar inside it. The name, XP
     bar and numbers stay for screen readers (and in the tooltip). */
  .hud-player { gap: 0; }
  .hud-player-text {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .lvl-badge { height: 42px; padding-top: 5px; padding-bottom: 8px; }
  .lvl-badge::after {
    content: '';
    position: absolute;
    left: 6px; right: 6px; bottom: 5px;
    height: 4px;
    background:
      linear-gradient(90deg, var(--gold) 0 calc(var(--xp, 0) * 100%), var(--violet-lo) 0);
  }

  /* the tabs take the space the instruments leave; if numbers grow, the tabs tighten and, as a
     last resort, keep only their icons (names stay in the tooltip and for screen readers) */
  .nav { container: rr-nav / inline-size; }
}
@container rr-nav (max-width: 660px) {
  .nav-list { gap: 6px; }
  .nav-link { gap: 5px; padding: 2px 9px 0 5px; }
}
@container rr-nav (max-width: 560px) {
  .nav-link { padding: 0 8px; }
  .nav-label {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
  }
}
@media (min-width: 1280px) and (max-width: 1439.98px) {
  .hud-brand-text { display: none; }
  .hud-brand { padding-right: 0; }
}
/* from 1400 px the page widens so the Guarida fits the room (×2) plus a side column */
@media (min-width: 1400px) {
  :root { --shell: 1500px; }
}
/* Guarida on big screens: wide enough for the room at a crisp ×2 (1024 px) next to the side column. */
@media (min-width: 1600px) {
  body[data-route="guarida"] { --shell: 1700px; }
}
/* wide screens: the block label comes back next to the ring */
@media (min-width: 1600px) {
  .hud-block-text { display: flex; }
}

/* ------------------------------------------------------------------ below 1280 px: the bar scrolls away */

@media (max-width: 1279.98px) {
  html { scroll-padding-top: 16px; }
  .hud { position: relative; }
  .toasts { top: 16px; }
  .nav-track { width: 100%; }
  .nav-list li { flex: 1 1 0; }
  .nav-link { padding: 2px 10px 0; }
}
/* 1024–1279 px: two rows in one bar — the instruments, then the tabs across the whole width */
@media (min-width: 1024px) and (max-width: 1279.98px) {
  .hud-inner {
    grid-template-columns: auto minmax(0, 1fr) auto auto auto auto auto;
    grid-template-areas:
      "brand . qso power block player settings"
      "nav nav nav nav nav nav nav";
    row-gap: var(--sp-4);
    padding: 12px 0 16px;
  }
  .hud-player { gap: 10px; }
  .xp-text { display: none; } /* the numbers live in the tooltip; the bar keeps the progress */
  .xp-bar { width: 110px; flex: none; }
}
@media (max-width: 1099.98px) {
  .hud-brand-text { display: none; }
  .hud-brand { padding-right: 0; }
}
/* 640–1023 px: brand + player, chips, then the tabs */
@media (max-width: 1023.98px) {
  .hud-inner {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand player player settings"
      "qso qso power block"
      "nav nav nav nav";
    row-gap: var(--sp-4);
    padding: 12px 0 16px;
  }
}
@media (max-width: 899.98px) {
  .nav-list { gap: 6px; }
  .nav-link { flex-direction: column; gap: 3px; min-height: 58px; padding: 6px 2px 4px; }
}

/* ------------------------------------------------------------------ phones: bottom dock */

@media (max-width: 639.98px) {
  :root { --gutter: 16px; }
  .app { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px)); }
  body[data-route="portada"] .app { padding-bottom: 0; }
  .view { padding-top: var(--sp-5); }

  .hud { z-index: auto; } /* no stacking context: the dock (z 40) and popover keep their own levels */
  .hud-inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "player player settings"
      "qso power block";
    gap: 12px var(--sp-3);
    padding: 12px 0 15px;
    min-height: 0;
  }
  .hud-brand { display: none; }
  .hud-qso { justify-self: stretch; min-width: 0; padding-right: 10px; }
  .qso-num { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .chip { gap: 6px; }
  .hud-power { padding-right: 10px; }
  .chip-caret { display: none; }
  .hud-block-text { display: none; }
  .xp-bar { max-width: none; }
  /* the breakdown hangs from the whole tray, edge to edge, so it never leaves the screen */
  .hud-inner { position: relative; }
  .hud-power-wrap { position: static; }
  .power-pop { left: 3px; right: 3px; width: auto; max-width: none; top: calc(100% + 6px); }

  .nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-width: none;
    z-index: 40;
    padding: 0;
  }
  .nav-track {
    width: 100%;
    padding: 9px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface-1);
    box-shadow: inset 0 3px 0 var(--s1-hi), 0 -3px 0 var(--ink), 0 -7px 0 var(--drop);
  }
  .nav-list { gap: 3px; }
  .nav-link {
    flex-direction: column;
    gap: 2px;
    min-height: 56px;
    padding: 5px 0 3px;
    font-size: var(--px-s);
    letter-spacing: 0;
  }
  .nav-link[aria-current="page"] { transform: translateY(-2px); }
  .nav-link:hover { background: #17112C; }
  .nav-link[aria-current="page"]:hover { background: var(--violet); }

  .screen-title { font-size: var(--px-m); }
  .panel { padding: 18px 16px; }
  .tutorial {
    left: 12px; right: 12px;
    bottom: calc(var(--dock-h) + 14px + env(safe-area-inset-bottom, 0px));
    width: auto;
    padding: 12px;
    gap: var(--sp-3);
  }
  .tutorial.collapsed { left: auto; }
  .tut-portrait { width: 56px; height: 56px; }
  .toasts { top: 12px; right: 12px; left: 12px; width: auto; }
  .modal-veil { padding: 12px; }
  .modal { padding: 0 16px 18px; max-height: calc(100dvh - 24px); }
  .modal-head { margin: 0 -16px; padding: 8px 8px 8px 16px; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1 1 auto; }
  .game-bar { padding: 6px 8px 9px 12px; gap: var(--sp-2); }
}

@media (max-width: 479.98px) {
  .hud-qso .chip-unit { display: none; } /* the coin says RBIT; screen readers keep the word */
}
/* the narrowest phones: six tabs leave ~56 px each, too little for "Almacén" in the 20 px pixel
   face, so the dock labels switch to the text face at 12 px (the tabs keep their pixel plates) */
@media (max-width: 373.98px) {
  .nav-link { font: 600 12px/1.1 var(--f-body); }
}

/* ------------------------------------------------------------------ reduced motion
   No travel, no blinking; presses still change state instantly. */

html[data-reduced-motion="true"] *,
html[data-reduced-motion="true"] *::before,
html[data-reduced-motion="true"] *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
html[data-reduced-motion="true"] .btn-icon:hover svg,
html[data-reduced-motion="true"] .hud-brand:hover > .rr-sprite,
html[data-reduced-motion="true"] .nav-link:hover .nav-icon { transform: none !important; }
html[data-reduced-motion="true"] .qso-delta { display: none; }
/* reduced motion for sprites is handled in js/assets.js */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
  .btn-icon:hover svg, .hud-brand:hover > .rr-sprite, .nav-link:hover .nav-icon { transform: none !important; }
  .qso-delta { display: none; }
}

/* ------------------------------------------------------------------ offerwall.me banners (iteration 23, js/ui/ads.js) */
.ad-box { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 100%; margin: 0 auto; }
.ad-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.ad-box > div { background: rgba(7, 4, 15, 0.35); }
.ad-games { margin-block: 2px 6px; }
.ad-results { margin-top: var(--sp-3); }
/* in a round (js/ui/games.js adFit/placeAd): in the overlay's flow, a band under the stage or a column
   beside it, so it never covers the game or its controls; hidden (not rebuilt) if a resize leaves no room */
.game-overlay[data-ad="below"] .game-stage-wrap,
.game-overlay[data-ad="side"] .game-stage-wrap { display: flex; align-items: center; justify-content: space-evenly; }
.game-overlay[data-ad="below"] .game-stage-wrap { flex-direction: column; gap: 26px; }
@media (pointer: coarse) { .game-overlay[data-ad="below"] .game-stage-wrap { gap: 48px; } } /* clear of the touch buttons */
.game-overlay[data-ad="side"] .game-stage-wrap { flex-direction: row; justify-content: center; gap: 24px; }
.game-overlay[data-ad] .game-stage { flex: none; }
.game-overlay[data-ad="off"] .ad-ingame { display: none; }
.ad-ingame { flex: none; margin: 0; }
