/* ==========================================================================
   RABLA — css/style.css
   Owner: group E. The class contract is TECH_SPEC §10.2; markup is §10.1.
   The whole UI lives inside #stage (1280×720 logical px) which main/render scale
   with a CSS transform, so every value below is in stage pixels: no media queries.
   Look: bold cartoony sci-fi. Dark space blue, neon alien green, robot orange,
   3 px ink outlines (#1A1030), chunky buttons with an offset shadow.
   No external resources (file:// rule). System font stack only.
   ========================================================================== */

:root {
  --font: "Trebuchet MS", "Arial Rounded MT Bold", "Arial Black", sans-serif;

  --ink: #1A1030;            /* outlines, shadows (DESIGN §12.1) */
  --ink-2: #0B0F24;
  --space: #0B1D3A;          /* dark space blue */
  --space-2: #16254D;
  --space-3: #22305E;
  --panel-a: #243467;
  --panel-b: #141C3D;

  --text: #F3F0FF;
  --muted: #B9B3D6;
  --dim: #7F78A8;

  --green: #76FF03;          /* neon alien green */
  --green-dk: #64DD17;
  --green-ink: #1B5E20;
  --orange: #FF6D00;         /* robot orange */
  --orange-lt: #FFA040;
  --rust: #C8511A;           /* RABLA rust-orange brand accent (logo, subtitle, footer) */
  --rust-lt: #F08A3C;
  --rust-dk: #7A2E0E;
  --rust-glow: rgba(240, 138, 60, .45);
  --cyan: #00E5FF;
  --yellow: #FFD600;
  --purple: #C77DFF;
  --pink: #FFB3E6;
  --red: #FF1744;
  --steel: #B0BEC5;
  --steel-dk: #78909C;

  --bronze: #CD7F32;
  --silver: #C9D1D9;
  --gold: #FFC107;

  --z1-a: #FFB3E6; --z1-b: #7B3FA0;
  --z2-a: #1E3A8A; --z2-b: #0B1D3A;
  --z3-a: #B71C1C; --z3-b: #3A0A0A;

  --radius: 16px;
  --radius-sm: 10px;
  --topbar-h: 64px;
}

/* --------------------------------------------------------------------------
   Stage / letterboxing (§10.2 contract)
   -------------------------------------------------------------------------- */
html, body {
  margin: 0;
  background: #1A1030;
  overflow: hidden;
}
html { height: 100%; }
body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }

#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  transform-origin: 0 0;
  overflow: hidden;
  background: var(--space);
}
#game {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  display: block;
}
#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: var(--font);
}
#toasts, #debug-panel { pointer-events: auto; }

.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   Screens
   -------------------------------------------------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: auto;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }
.screen.modal { background: rgba(26, 16, 48, .55); }

/* Full-page (non-modal) screens sit on an opaque starfield so the attract
   level only shimmers through on the menu. */
#screen-map, #screen-garage, #screen-achievements, #screen-credits, #screen-error,
#screen-settings:not(.modal) {
  background:
    radial-gradient(circle at 20% 15%, rgba(199, 125, 255, .18), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(118, 255, 3, .10), transparent 45%),
    linear-gradient(180deg, #0B1D3A 0%, #141C3D 60%, #1A1030 100%);
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.1;
}
h2 {
  font-size: 34px;
  color: var(--green);
  text-shadow: 3px 3px 0 var(--ink);
}
h3 { font-size: 20px; color: var(--orange-lt); }
h4 { font-size: 18px; color: var(--text); }
p { margin: 0; }

/* --------------------------------------------------------------------------
   Panel
   -------------------------------------------------------------------------- */
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow:
    0 8px 0 var(--ink-2),
    0 14px 40px rgba(0, 0, 0, .55),
    inset 0 2px 0 rgba(255, 255, 255, .12);
  padding: 26px 34px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1180px;
  max-height: 680px;
}
.panel > h2 { text-align: center; }

/* --------------------------------------------------------------------------
   Top bar (map / garage / achievements)
   -------------------------------------------------------------------------- */
.topbar {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(34, 48, 94, .97), rgba(20, 28, 61, .97));
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .35);
  z-index: 5;
}
.topbar h2 { font-size: 28px; white-space: nowrap; }
.topbar .shopline {
  flex: 1;
  color: var(--muted);
  font-style: italic;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .counter {
  color: var(--yellow);
  font-weight: 900;
  font-size: 20px;
  text-shadow: 2px 2px 0 var(--ink);
}
.topbar > .btn:first-of-type { margin-left: auto; }

/* Cores badge: "{n} ◆" */
.cores {
  display: inline-flex;
  align-items: center;
  min-width: 96px;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--cyan);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 1px;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--ink-2), inset 0 0 0 2px rgba(0, 229, 255, .25);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
button { font: inherit; }
.btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 26px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: linear-gradient(180deg, #ECEFF1, var(--steel));
  color: var(--ink);
  font-family: var(--font);
  font-weight: 900;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink), 0 6px 12px rgba(0, 0, 0, .35);
  transition: transform .08s ease-out, box-shadow .08s ease-out, filter .12s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink), 0 10px 16px rgba(0, 0, 0, .4);
  filter: brightness(1.08);
}
.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink), 0 3px 6px rgba(0, 0, 0, .35);
}
.btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.btn.primary {
  background: linear-gradient(180deg, #B2FF59, var(--green-dk));
  color: var(--green-ink);
  font-size: 24px;
  min-height: 56px;
  padding: 12px 36px;
}
.btn.danger {
  background: linear-gradient(180deg, #FF8A65, #E64A19);
  color: #FFF;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .35);
}
.btn.small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 9px;
  box-shadow: 0 3px 0 var(--ink), 0 4px 8px rgba(0, 0, 0, .3);
}
.btn.small:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink), 0 6px 10px rgba(0, 0, 0, .35); }
.btn.small:active { transform: translateY(1px); box-shadow: 0 2px 0 var(--ink); }

.btn[disabled], .btn.disabled {
  cursor: default;
  filter: grayscale(.7) brightness(.75);
  opacity: .7;
  transform: none;
  box-shadow: 0 2px 0 var(--ink);
}
.btn[disabled]:hover, .btn.disabled:hover { transform: none; filter: grayscale(.7) brightness(.75); }

.btn.confirm {
  background: linear-gradient(180deg, #FFF176, var(--yellow));
  color: var(--ink);
  animation: pulse .6s ease-in-out infinite;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   Keyframes
   -------------------------------------------------------------------------- */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes stamp {
  0%   { transform: scale(3) rotate(-25deg); opacity: 0; }
  60%  { transform: scale(.92) rotate(-8deg); opacity: 1; }
  80%  { transform: scale(1.06) rotate(-10deg); }
  100% { transform: scale(1) rotate(-8deg); opacity: 1; }
}
@keyframes slideup {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(118, 255, 3, .55), 0 4px 0 var(--ink); }
  50% { box-shadow: 0 0 0 10px rgba(118, 255, 3, 0), 0 4px 0 var(--ink); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.shake { animation: shake .35s ease-in-out; }

/* --------------------------------------------------------------------------
   Controls card (menu / pause / settings)
   -------------------------------------------------------------------------- */
.controls-card {
  background: rgba(11, 29, 58, .75);
  border: 2px solid rgba(0, 229, 255, .45);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4);
}
.controls-card h3 {
  font-size: 15px;
  color: var(--cyan);
  margin-bottom: 4px;
}
.controls-card p { margin: 0; }

/* --------------------------------------------------------------------------
   MENU
   -------------------------------------------------------------------------- */
.panel.menu {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: linear-gradient(180deg, rgba(11, 29, 58, .55) 0%, rgba(11, 29, 58, 0) 35%, rgba(26, 16, 48, .55) 100%);
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 34px 40px 60px;
  align-items: center;
  gap: 10px;
}
.logo {
  width: 720px;
  height: 160px;
  animation: bob 3.2s ease-in-out infinite;
  /* RABLA brand: rust-orange glow under the welded logo; the letters themselves are drawn on the
     canvas by js/ui/menu.js, which reads --rust / --rust-lt / --rust-dk from this stylesheet. */
  filter: drop-shadow(0 0 18px var(--rust-glow)) drop-shadow(0 6px 0 var(--rust-dk));
}
.logo canvas { display: block; width: 720px; height: 160px; }
.subtitle {
  font-size: 20px;
  font-weight: 700;
  color: var(--rust-lt);
  text-shadow: 2px 2px 0 var(--ink);
  margin-bottom: 14px;
  letter-spacing: .5px;
  text-transform: none;
  font-style: italic;
}
.subtitle::before, .subtitle::after {
  content: "\2014";            /* em dash, rust-coloured, framing the tagline */
  color: var(--rust);
  margin: 0 8px;
  font-style: normal;
}
.panel.menu .btn {
  width: 320px;
}
.panel.menu .btn + .btn { margin-top: 2px; }
.panel.menu .footer {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.panel.menu .footer #menu-version {
  color: var(--dim);
  font-size: 14px;
  font-weight: 700;
}
.panel.menu .footer .cores { margin-left: 12px; }
.panel.menu .footer .phase {
  color: var(--rust-lt);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 2px solid var(--rust-dk);
  border-radius: 999px;
  background: rgba(122, 46, 14, .35);
}
.panel.menu .footer .mute {
  margin-left: auto;
  cursor: pointer;
  color: var(--cyan);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(11, 29, 58, .8);
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .08s;
}
.panel.menu .footer .mute:hover { transform: translateY(-1px); filter: brightness(1.15); }
#menu-controls {
  position: absolute;
  right: 28px;
  bottom: 76px;
  width: 330px;
  animation: slideup .35s ease-out;
}

/* --------------------------------------------------------------------------
   MAP (DESIGN §9.1)
   -------------------------------------------------------------------------- */
#screen-map { overflow: hidden; }
.map-bands {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--topbar-h);
  bottom: 0;
  display: flex;
}
.band {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.band::after {
  /* ground silhouette at the bottom of every band */
  content: "";
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: -40px;
  height: 160px;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: rgba(26, 16, 48, .55);
}
.band.z1 { background: linear-gradient(180deg, var(--z1-a) 0%, #C77DFF 45%, var(--z1-b) 100%); }
.band.z2 { background: linear-gradient(180deg, var(--z2-a) 0%, #162B5B 50%, var(--z2-b) 100%); }
.band.z3 { background: linear-gradient(180deg, var(--z3-a) 0%, #7F1515 50%, var(--z3-b) 100%); }
.band.fog {
  filter: grayscale(.85) brightness(.45);
}
.band.fog::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .06) 0 14px, rgba(255, 255, 255, 0) 14px 28px),
    rgba(26, 16, 48, .55);
}
.fog-text {
  display: none;
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) rotate(-6deg);
  padding: 10px 18px;
  border: 3px dashed rgba(255, 255, 255, .55);
  border-radius: var(--radius-sm);
  background: rgba(26, 16, 48, .8);
  color: #FFF;
  font-weight: 900;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  z-index: 2;
  filter: none;
}
.band.fog .fog-text { display: block; }

.map-road {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  pointer-events: none;
  overflow: visible;
  stroke: var(--yellow);
  stroke-width: 6;
  stroke-dasharray: 18 14;
  stroke-linecap: round;
  fill: none;
  filter: drop-shadow(0 3px 0 var(--ink));
}
.map-road path, .map-road line, .map-road polyline {
  stroke: inherit;
  stroke-width: inherit;
  fill: none;
}
#map-nodes {
  position: absolute;
  inset: 0;
}

/* Level node: a 56 px round button. map.js writes left/top = node centre minus half the
   element size (28/28 here, 26/24 for .map-shop, 22 for .map-machine; the tooltip is
   centred by its measured width), so no CSS margin/transform centring is needed. */
.map-node {
  position: absolute;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF 0%, var(--steel) 45%, var(--steel-dk) 100%);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--ink), 0 6px 12px rgba(0, 0, 0, .4);
  transition: transform .1s, box-shadow .1s;
  z-index: 2;
}
.map-node:hover { transform: translateY(-2px) scale(1.06); z-index: 3; }
.map-node .num { position: relative; z-index: 1; }
.map-node .medal-icon {
  position: absolute;
  right: -8px;
  top: -8px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: none;
  box-shadow: 0 2px 0 var(--ink);
}

.map-node.locked {
  background: radial-gradient(circle at 35% 30%, #90A4AE 0%, #607D8B 50%, #455A64 100%);
  color: rgba(26, 16, 48, .45);
  cursor: default;
}
.map-node.locked:hover { transform: none; }
/* padlock: body (::after) + shackle (::before) */
.map-node.locked::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 12px;
  border-radius: 3px;
  background: var(--ink);
  bottom: 8px;
}
.map-node.locked::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 11px;
  border: 3px solid var(--ink);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  bottom: 17px;
}
.map-node.locked .num { opacity: .35; transform: translateY(-9px); font-size: 14px; }

.map-node.available {
  background: radial-gradient(circle at 35% 30%, #DCFFB3 0%, var(--green) 45%, var(--green-dk) 100%);
  color: var(--green-ink);
  animation: glow 1.4s ease-out infinite;
}
.map-node.done {
  background: radial-gradient(circle at 35% 30%, #FFE0B2 0%, var(--orange-lt) 45%, var(--orange) 100%);
  color: var(--ink);
}
.map-node.done .medal-icon { display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; }
.map-node.done .medal-icon {
  background: radial-gradient(circle at 35% 30%, #FFF 0%, var(--steel) 60%);
}
/* no-medal completion: a check mark drawn with borders */
.map-node.done:not(.bronze):not(.silver):not(.gold) .medal-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--green-ink);
  border-width: 0 3px 3px 0;
  transform: rotate(40deg);
}
.map-node.bronze .medal-icon { background: radial-gradient(circle at 35% 30%, #FFCC80 0%, var(--bronze) 55%, #8D4F15 100%); }
.map-node.silver .medal-icon { background: radial-gradient(circle at 35% 30%, #FFF 0%, var(--silver) 55%, #8A96A3 100%); }
.map-node.gold   .medal-icon { background: radial-gradient(circle at 35% 30%, #FFF59D 0%, var(--gold) 55%, #C78C00 100%); }
.map-node.bronze { box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--bronze); }
.map-node.silver { box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--silver); }
.map-node.gold   { box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--gold), 0 0 14px rgba(255, 193, 7, .7); }

.map-node.selected {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
  transform: scale(1.12);
  z-index: 4;
}
.map-node.selected:hover { transform: translateY(-2px) scale(1.14); }

/* Shop: a little house (clip-path), positioned like a node. */
.map-shop {
  position: absolute;
  width: 52px;
  height: 48px;
  padding: 0;
  border: none;
  cursor: pointer;
  background: var(--ink);
  clip-path: polygon(50% 0, 100% 42%, 100% 100%, 0 100%, 0 42%);
  z-index: 2;
  transition: transform .1s;
}
.map-shop::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 3px;
  bottom: 3px;
  clip-path: polygon(50% 0, 100% 42%, 100% 100%, 0 100%, 0 42%);
  background: linear-gradient(180deg, var(--orange-lt), var(--orange));
}
.map-shop::after {
  /* door */
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 12px;
  height: 16px;
  margin-left: -6px;
  background: var(--ink);
  border-radius: 6px 6px 0 0;
}
.map-shop:hover { transform: translateY(-2px) scale(1.06); }
.map-shop.locked { cursor: default; filter: grayscale(1) brightness(.6); }
.map-shop.locked:hover { transform: none; }
.map-shop.open::before { background: linear-gradient(180deg, #FFE0B2, var(--orange)); }
.map-shop.open { filter: drop-shadow(0 0 6px rgba(255, 160, 64, .9)); }

/* The war-machine marker: a small orange hull with two wheels (map.js positions it). */
.map-machine {
  position: absolute;
  width: 44px;
  height: 26px;
  pointer-events: none;
  z-index: 5;
  animation: bob 1.2s ease-in-out infinite;
}
.map-machine::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18px;
  border: 3px solid var(--ink);
  border-radius: 6px 10px 4px 4px;
  background: linear-gradient(180deg, var(--orange-lt), var(--orange));
}
.map-machine::after {
  content: "";
  position: absolute;
  left: 4px;
  bottom: 0;
  width: 12px;
  height: 12px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--steel);
  box-shadow: 24px 0 0 -3px var(--steel), 24px 0 0 0 var(--ink);
}

/* Tooltip (map hover + part-card reasons) */
.tooltip {
  position: absolute;
  z-index: 20;
  max-width: 280px;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: rgba(26, 16, 48, .96);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 0 4px 0 var(--ink-2), 0 8px 20px rgba(0, 0, 0, .5);
  pointer-events: none;
  white-space: pre-line;
}
.tooltip:empty { display: none; }

/* --------------------------------------------------------------------------
   GARAGE / SHOP (DESIGN §11.3)
   -------------------------------------------------------------------------- */
.garage-left {
  position: absolute;
  left: 0;
  top: var(--topbar-h);
  bottom: 0;
  width: 576px;
  padding: 14px 8px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#garage-preview {
  display: block;
  width: 552px;
  height: 414px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #C77DFF 0%, #7B3FA0 70%, #5C2E82 100%);
  box-shadow: 0 6px 0 var(--ink-2), inset 0 0 40px rgba(0, 0, 0, .25);
}
#btn-testfire {
  position: absolute;
  left: 32px;
  top: 92px;
  background: linear-gradient(180deg, #FFE082, var(--yellow));
}
.garage-right {
  position: absolute;
  left: 576px;
  right: 0;
  top: var(--topbar-h);
  bottom: 0;
  display: flex;
  flex-direction: column;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
  flex: 0 0 auto;
}
.tabs .tab {
  flex: 1;
  min-height: 40px;
  padding: 8px 6px;
  border: 2px solid var(--ink);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, var(--space-3), var(--space-2));
  color: var(--muted);
  font-family: var(--font);
  font-weight: 900;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .12s, color .12s, transform .08s;
}
.tabs .tab:hover { color: var(--text); transform: translateY(-2px); }
.tabs .tab.active {
  background: linear-gradient(180deg, #B2FF59, var(--green-dk));
  color: var(--green-ink);
  transform: translateY(0);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15);
}

/* Part list */
.part-list {
  flex: 1;
  margin: 0 16px 16px;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 2px solid var(--ink);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: rgba(11, 29, 58, .7);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--green) rgba(0, 0, 0, .3);
}
.part-list::-webkit-scrollbar { width: 10px; }
.part-list::-webkit-scrollbar-track { background: rgba(0, 0, 0, .3); border-radius: 5px; }
.part-list::-webkit-scrollbar-thumb { background: var(--green); border-radius: 5px; border: 2px solid var(--ink); }
.part-list h3, .part-list .list-header {
  margin: 6px 0 0;
  padding: 4px 8px;
  font-size: 15px;
  color: var(--cyan);
  border-bottom: 2px dashed rgba(0, 229, 255, .35);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Part card */
.part-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--space-3), var(--panel-b));
  box-shadow: 0 3px 0 var(--ink-2);
  transition: transform .08s, box-shadow .08s;
}
.part-card:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink-2), 0 8px 16px rgba(0, 0, 0, .35); }
.part-icon {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: radial-gradient(circle at 40% 30%, #2D3D73, #141C3D);
}
.part-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.part-name {
  font-size: 18px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.part-card .desc {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  line-height: 1.35;
}
.part-btn {
  flex: 0 0 auto;
  min-width: 128px;
}

.part-card.owned .part-icon { box-shadow: inset 0 0 0 2px rgba(176, 190, 197, .35); }
.part-card.equipped {
  border-color: var(--green);
  box-shadow: 0 3px 0 var(--ink-2), 0 0 0 2px rgba(118, 255, 3, .35), 0 0 16px rgba(118, 255, 3, .25);
}
.part-card.equipped .part-name { color: var(--green); }
.part-card.equipped .part-btn { filter: saturate(.6); }
.part-card.locked { filter: grayscale(.8); opacity: .75; }
.part-card.locked .part-icon { filter: brightness(.6); }
.part-card.unaffordable .part-btn {
  background: linear-gradient(180deg, #FF8A80, #D32F2F);
  color: #FFF;
}
.part-card.hire .part-icon { background: radial-gradient(circle at 40% 30%, #5C2E82, #1A1030); }

/* Part-card reason tooltip: shown while non-empty on hover, or when .show is set. */
.part-card .part-tip {
  display: none;
  position: absolute;
  right: 12px;
  bottom: calc(100% - 6px);
  max-width: 260px;
}
.part-card:hover .part-tip:not(:empty),
.part-card .part-tip.show:not(:empty) { display: block; }

/* Stat bars (shared: garage left-hand bars and part-card pip rows) */
.statbars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.statbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 16px;
  font-size: 13px;
  font-weight: 700;
}
.statbar .label {
  flex: 0 0 90px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
  white-space: nowrap;
}
.statbar .bar, .statbar .track, .statbar .meter {
  flex: 1;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: rgba(0, 0, 0, .45);
  overflow: hidden;
}
.statbar .fill {
  display: block;
  height: 100%;
  min-height: 10px;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--green-dk), var(--green));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
  transition: width .25s ease-out;
}
/* a bare .fill (no track element) still reads as a bar */
.statbar > .fill {
  flex: 0 1 auto;
  max-width: 100%;
  height: 12px;
  border: 2px solid var(--ink);
  box-sizing: content-box;
}
.statbar .value {
  flex: 0 0 auto;
  color: var(--text);
  min-width: 36px;
  text-align: right;
}

/* Garage left-hand loadout bars are bigger */
#garage-stats {
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: rgba(11, 29, 58, .7);
  gap: 6px;
}
#garage-stats .statbar { min-height: 20px; }
#garage-stats .statbar .label { flex-basis: 84px; font-size: 13px; color: var(--text); }
#garage-stats .statbar .fill { background: linear-gradient(90deg, var(--orange), var(--orange-lt)); }

/* Pips */
.pips {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.pips .pip {
  display: inline-block;
  width: 14px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: rgba(0, 0, 0, .45);
}
.pips .pip.on {
  background: linear-gradient(180deg, #B2FF59, var(--green-dk));
  box-shadow: 0 0 4px rgba(118, 255, 3, .6);
}

/* Deltas vs the equipped part */
.delta {
  min-width: 34px;
  font-weight: 900;
  font-size: 13px;
  text-align: left;
}
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta:empty { display: none; }

/* --------------------------------------------------------------------------
   LEVEL INTRO (DESIGN §11.4)
   -------------------------------------------------------------------------- */
.panel.intro {
  width: 800px;
  gap: 12px;
}
.intro-head {
  display: flex;
  align-items: center;
  gap: 16px;
}
.zone-icon {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #C77DFF, #5C2E82);
}
.intro-head h2 { flex: 1; text-align: left; font-size: 32px; }
.intro-head .zone {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--purple);
  color: var(--ink);
  font-weight: 900;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 2px dashed rgba(255, 255, 255, .18);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .2);
  min-height: 60px;
}
.roster-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 86px;
  padding: 6px 2px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--space-3), var(--space-2));
}
.roster-item canvas { width: 48px; height: 48px; display: block; }
.roster-item .name {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  line-height: 1.15;
  max-width: 80px;
}
.new-tag {
  display: none;
  position: absolute;
  right: -10px;
  top: -10px;
  padding: 3px 7px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  transform: rotate(10deg);
  box-shadow: 0 2px 0 var(--ink);
}
.roster-item.new { border-color: var(--yellow); }
.roster-item.new .new-tag { display: inline-block; animation: pulse 1s ease-in-out infinite; }
.panel.intro .line {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.panel.intro .tip {
  padding: 8px 14px;
  border-left: 4px solid var(--cyan);
  border-radius: 6px;
  background: rgba(0, 229, 255, .08);
  color: var(--cyan);
  font-size: 15px;
  font-weight: 700;
}
.loadout {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.loadout-icon {
  width: 48px;
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: radial-gradient(circle at 40% 30%, #2D3D73, #141C3D);
}
.panel.intro .best {
  text-align: center;
  color: var(--yellow);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 1px;
}

/* --------------------------------------------------------------------------
   PAUSE (DESIGN §11.6)
   -------------------------------------------------------------------------- */
.panel.pause {
  width: 420px;
  align-items: stretch;
}
.panel.pause .btn { width: 100%; }
.panel.pause .controls-card { margin-top: 6px; white-space: pre-line; }

/* --------------------------------------------------------------------------
   RESULTS (DESIGN §11.7)
   -------------------------------------------------------------------------- */
.panel.results {
  width: 760px;
  gap: 10px;
  padding-top: 20px;
}
.panel.results h2 { font-size: 40px; }
/* Five buttons (NEXT LEVEL / RETRY / GARAGE / LAUNCH / MAP) on ONE row at 1280×720 (Phase 2). */
.panel.results .buttons { flex-wrap: nowrap; gap: 10px; }
.panel.results .buttons .btn { padding: 10px 16px; font-size: 15px; white-space: nowrap; }
.panel.results .sub {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  font-size: 15px;
  min-height: 1.2em;
}
.results-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .25);
}
.results-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 3px 4px;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
}
.results-row.shown { animation: slideup .22s ease-out forwards; }
.results-row .label { color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 15px; }
.results-row .value { color: var(--text); font-variant-numeric: tabular-nums; }
.results-row[data-row="total"] {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 2px dashed rgba(255, 255, 255, .25);
  font-size: 24px;
}
.results-row[data-row="total"] .label { color: var(--green); font-size: 18px; }
.results-row[data-row="total"] .value { color: var(--yellow); text-shadow: 2px 2px 0 var(--ink); }
.results-row[data-row="kills"] .label { color: var(--dim); font-size: 13px; }
.results-row[data-row="kills"] .value { color: var(--muted); font-size: 15px; }

.medal-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 104px;
}
.medal {
  width: 100px;
  height: 100px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  font-weight: 900;
  font-size: 15px;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink);
  transform: rotate(-8deg);
  box-shadow: 0 5px 0 var(--ink-2), inset 0 0 0 4px rgba(255, 255, 255, .35);
}
.medal.none {
  border-style: dashed;
  border-color: rgba(255, 255, 255, .35);
  background: transparent;
  color: var(--dim);
  box-shadow: none;
  transform: none;
  font-size: 13px;
}
.medal.bronze { background: radial-gradient(circle at 35% 30%, #FFCC80 0%, var(--bronze) 55%, #8D4F15 100%); }
.medal.silver { background: radial-gradient(circle at 35% 30%, #FFF 0%, var(--silver) 55%, #8A96A3 100%); }
.medal.gold {
  background: radial-gradient(circle at 35% 30%, #FFF59D 0%, var(--gold) 55%, #C78C00 100%);
  box-shadow: 0 5px 0 var(--ink-2), 0 0 24px rgba(255, 193, 7, .75), inset 0 0 0 4px rgba(255, 255, 255, .45);
}
.medal.stamp { animation: stamp .5s cubic-bezier(.2, 1.2, .4, 1) both; }
.newbest {
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  font-size: 16px;
  text-transform: uppercase;
  transform: rotate(4deg);
  animation: pulse 1s ease-in-out infinite;
  box-shadow: 0 3px 0 var(--ink);
}

.cores-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: rgba(0, 229, 255, .08);
}
#results-cores-breakdown {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  white-space: pre-line;
}
.cores-row .cores { font-size: 24px; min-width: 140px; justify-content: center; }

.ach-strip, .unlock-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 0;
}
.ach-strip:empty, .unlock-strip:empty { display: none; }
.ach-strip > *, .unlock-strip > * {
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 900;
  font-size: 14px;
  animation: slideup .3s ease-out both;
  box-shadow: 0 2px 0 var(--ink);
}
.unlock-strip > * { background: var(--green); color: var(--green-ink); }
.ach-strip > * { background: var(--gold); color: var(--ink); }
.ach-strip canvas { width: 24px; height: 24px; vertical-align: middle; margin-right: 6px; }
.credits-line {
  text-align: center;
  color: var(--pink);
  font-weight: 700;
  font-style: italic;
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   ACHIEVEMENTS (DESIGN §11.8): 7 × 3 grid
   -------------------------------------------------------------------------- */
.ach-grid {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--topbar-h);
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 16px;
  align-content: stretch;
}
.ach-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 8px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--space-3), var(--panel-b));
  box-shadow: 0 3px 0 var(--ink-2);
  text-align: center;
  min-height: 0;
  overflow: hidden;
}
.ach-icon {
  width: 56px;
  height: 56px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #2D3D73, #141C3D);
}
.ach-name {
  font-size: 14px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.1;
}
.ach-desc {
  flex: 1;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
}
.ach-card.done {
  border-color: var(--gold);
  box-shadow: 0 3px 0 var(--ink-2), 0 0 0 2px rgba(255, 193, 7, .35), 0 0 14px rgba(255, 193, 7, .25);
}
.ach-card.done .ach-name { color: var(--gold); }
.ach-card.done .ach-icon { background: radial-gradient(circle at 40% 30%, #FFE082, #FF8F00); }
.ach-card.locked { filter: grayscale(.6); }
.ach-card.locked .ach-icon { filter: brightness(.55); }

.progress {
  position: relative;
  width: 100%;
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(0, 0, 0, .45);
  overflow: hidden;
  flex: 0 0 auto;
}
.progress .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--green-dk), var(--green));
  transition: width .3s ease-out;
}
.ach-card.done .progress .fill { background: linear-gradient(90deg, #FFB300, var(--gold)); }
.progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 900;
  color: #FFF;
  text-shadow: 1px 1px 0 var(--ink);
  letter-spacing: .5px;
}

/* --------------------------------------------------------------------------
   SETTINGS (DESIGN §11.9)
   -------------------------------------------------------------------------- */
.panel.settings {
  width: 520px;
  gap: 8px;
}
.panel.settings label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 9px 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, .14);
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}
.panel.settings label > span { text-transform: uppercase; letter-spacing: 1px; font-size: 15px; color: var(--muted); }
.panel.settings input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--green);
  cursor: pointer;
}
.panel.settings input[type="range"] {
  width: 240px;
  margin: 0;
  accent-color: var(--green);
  cursor: pointer;
}
.panel.settings select,
#debug-panel select {
  min-width: 150px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--space);
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.panel.settings .controls-card { margin: 8px 0 4px; }
.panel.settings .btn { align-self: center; min-width: 240px; }
.panel.settings .btn.danger { margin-top: 4px; }

/* --------------------------------------------------------------------------
   CREDITS / ERROR
   -------------------------------------------------------------------------- */
.panel.credits {
  width: 560px;
  align-items: center;
  text-align: center;
}
#credits-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
#credits-lines p:nth-child(odd) { color: var(--pink); }
#credits-lines p:first-child { color: var(--green); font-size: 20px; }

.panel.error {
  width: 560px;
  align-items: center;
  text-align: center;
  border-color: var(--red);
  box-shadow: 0 8px 0 var(--ink-2), 0 0 0 3px rgba(255, 23, 68, .35), 0 14px 40px rgba(0, 0, 0, .55);
}
#error-text {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
#toasts {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 50;
  pointer-events: auto;
}
.toast {
  max-width: 640px;
  padding: 10px 20px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: .5px;
  color: var(--ink);
  background: var(--cyan);
  box-shadow: 0 4px 0 var(--ink), 0 8px 20px rgba(0, 0, 0, .45);
  animation: slideup .25s ease-out;
  transition: opacity .3s, transform .3s;
  cursor: pointer;
  text-align: center;
}
.toast.info { background: linear-gradient(180deg, #84FFFF, var(--cyan)); }
.toast.ach {
  background: linear-gradient(180deg, #FFF59D, var(--gold));
  text-transform: uppercase;
  font-size: 18px;
}
.toast.warn {
  background: linear-gradient(180deg, var(--orange-lt), var(--orange));
  color: #FFF;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .35);
}
.toast.out { opacity: 0; transform: translateY(-10px); }

/* --------------------------------------------------------------------------
   Debug panel (built by WM.ui.debug when ?debug=1)
   -------------------------------------------------------------------------- */
#debug-panel {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 60;
  width: 250px;
  padding: 10px 12px;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: rgba(0, 0, 0, .85);
  color: var(--green);
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 0 12px rgba(118, 255, 3, .35);
}
#debug-panel h4 {
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--green);
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(118, 255, 3, .4);
  padding-bottom: 4px;
}
#debug-panel .dbg-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
#debug-panel .dbg-row label { flex: 0 0 auto; }
#debug-panel select {
  flex: 1;
  min-width: 0;
  padding: 3px 4px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 4px;
  border-color: var(--green);
  color: var(--green);
}
#debug-panel button {
  flex: 1;
  padding: 5px 6px;
  border: 1px solid var(--green);
  border-radius: 4px;
  background: rgba(118, 255, 3, .12);
  color: var(--green);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
#debug-panel button:hover { background: rgba(118, 255, 3, .3); }
#debug-panel .dbg-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
#debug-panel input[type="checkbox"] { accent-color: var(--green); margin: 0; }
