/* Magnetic Scrap Rush — playful industrial UI */
:root {
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --line: #0c0f16;
  --panel: rgba(27, 33, 48, 0.92);
  --panel-solid: #1b2130;
  --card: #252d40;
  --text: #f4f1e8;
  --muted: #a9b0c0;
  --yellow: #ffcf3a;
  --yard-accent: #ffb347;
  --drop: 0 4px 0 rgba(0, 0, 0, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.08);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1b2130;
  color: var(--text);
  font-family: var(--font);
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

#app { position: fixed; inset: 0; overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }
#vignette { position: absolute; inset: 0; pointer-events: none; }

.hidden { display: none !important; }

button { font-family: inherit; -webkit-tap-highlight-color: transparent; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; }

.hud-bar {
  position: absolute;
  top: max(10px, var(--safe-t));
  left: max(10px, var(--safe-l));
  right: max(10px, var(--safe-r));
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px 0 8px;
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--drop);
  font-weight: 900;
  font-size: 20px;
  white-space: nowrap;
}
.money { color: #ffe066; min-width: 100px; transform-origin: 30px 50%; }
.coin-icon {
  position: relative;
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b8 0 16%, #ffc93a 17% 62%, #d98f12 63%);
  border: 2.5px solid #8a5a08;
}
.coin-icon::after {
  content: "$";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 900; color: #8a5a08;
}

.cargo { font-size: 16px; }
.cargo .ico { width: 22px; height: 22px; color: #d9b27a; flex: none; }
.meter {
  position: relative;
  height: 12px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid var(--line);
  overflow: hidden;
}
.meter > i {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(180deg, #8ff0a6, #3fbf62);
  transition: transform 0.25s ease-out;
}
.cargo .meter { width: 84px; }
.cargo.warn .meter > i { background: linear-gradient(180deg, #ffe08a, #f2a91c); }
.cargo.full { animation: pulseRed 0.9s ease-in-out infinite; }
.cargo.full .meter > i { background: linear-gradient(180deg, #ff9a7a, #e8452e); }
.full-tag {
  position: absolute; inset: 0;
  display: none; place-items: center;
  font-size: 9px; font-weight: 900; letter-spacing: 1px; line-height: 1;
  color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.cargo.full .full-tag { display: grid; }
#cargoText { min-width: 4.6em; text-align: right; font-variant-numeric: tabular-nums; }
#moneyText { font-variant-numeric: tabular-nums; }

.quota {
  flex: 1 1 180px;
  max-width: 400px;
  min-width: 180px;
  margin: 0 auto;
  padding: 6px 14px 8px;
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--drop);
}
.quota-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 14px; margin-bottom: 5px; white-space: nowrap; }
#yardName { color: var(--yard-accent); text-transform: uppercase; letter-spacing: 0.6px; overflow: hidden; text-overflow: ellipsis; }
.quota .meter > i { background: linear-gradient(180deg, #ffe58a, #ffb81c); }
.quota.cleared .meter > i { background: linear-gradient(90deg, #7be07b, #3fbf62); }
.quota.cleared #quotaText { color: #8ff0a6; }

.icon-btn {
  pointer-events: auto;
  width: 46px; height: 46px;
  padding: 0;
  display: grid; place-items: center;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--drop);
  cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: #2a3550; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.sound-btn .cross { display: none; }
.sound-btn.muted { color: #ff9a7a; }
.sound-btn.muted .cross { display: inline; }
.sound-btn.muted .waves { display: none; }

.side-dock-open .hud-stack { right: calc(var(--dock-w, 350px) + 24px); }
.hud-stack {
  position: absolute;
  top: var(--stack-top, 70px);
  left: max(12px, var(--safe-l));
  right: max(12px, var(--safe-r));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.starter-goal {
  width: min(330px, 100%);
  padding: 9px 12px 10px;
  background: linear-gradient(145deg, rgba(37, 48, 72, 0.97), rgba(21, 27, 40, 0.97));
  border: 3px solid var(--yellow);
  border-radius: 14px;
  box-shadow: var(--drop), 0 0 24px rgba(255, 207, 58, 0.2);
  text-align: left;
}
.starter-goal-copy { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.starter-goal b { color: #ffe066; font-size: 11px; letter-spacing: 0.9px; white-space: nowrap; }
.starter-goal span { overflow: hidden; color: #eef3fa; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.starter-goal .meter { margin-top: 7px; height: 7px; }
.starter-goal .meter i { background: linear-gradient(90deg, #ff9f2f, #ffe066); transition: transform 0.25s ease-out; }

.hint {
  display: none;
  max-width: min(520px, 100%);
  padding: 10px 16px;
  background: rgba(255, 250, 235, 0.97);
  color: #2a2016;
  border: 3px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}
.hint.show { display: block; animation: dropIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.hint b { color: #c2410c; }

.challenge {
  display: none;
  width: min(var(--ch-w, 250px), 100%);
  padding: 8px 12px 10px;
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--drop);
}
.challenge.show { display: block; animation: dropIn 0.3s ease-out; }
.challenge.done { border-color: #3fbf62; }
.challenge.done .ch-title::after { content: " ✓"; color: #8ff0a6; }
.challenge.fail { opacity: 0.7; }
.ch-head { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 800; }
.ch-reward { color: #ffe066; font-size: 13px; letter-spacing: 0; }
.ch-title { font-weight: 800; font-size: 15px; margin: 3px 0 6px; }
.ch-row { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 13px; }
.ch-row .meter { flex: 1; height: 8px; }
.ch-row .meter > i { background: linear-gradient(90deg, #5fc8ff, #8fe0ff); transform: scaleX(1); transition: none; }

/* The optional challenge sits at the left edge under the cash/cargo pills. While it is
   visible, the centred column (first-haul goal, hints, toasts, event banner) moves right
   by the card's width, so the two can never overlap — also with the upgrade terminal open. */
@media (min-width: 600px) {
  .challenge { position: absolute; left: 0; top: 0; }
  .hud-stack.has-challenge { padding-left: calc(var(--ch-w, 250px) + 12px); }
}

/* ---------- upgrade terminal ---------- */
.dock {
  pointer-events: auto;
  position: absolute;
  right: max(12px, var(--safe-r));
  bottom: max(12px, var(--safe-b));
  width: 350px;
  max-height: calc(100% - var(--stack-top, 70px) - 20px);
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transform: translateX(calc(100% + 40px));
  visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15), visibility 0s linear 0.32s;
}
.dock.open { transform: none; visibility: visible; transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15), visibility 0s; }
.dock-head {
  flex: none;
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px;
  background: repeating-linear-gradient(-45deg, #f2c230 0 12px, #26211a 12px 24px);
  border-bottom: 3px solid var(--line);
}
.dock-title, .dock-status {
  padding: 4px 10px;
  border-radius: 8px;
  border: 2px solid var(--line);
  font-weight: 900;
  font-size: 13px;
}
.dock-title { background: var(--line); color: var(--yellow); letter-spacing: 0.6px; text-transform: uppercase; }
.dock-status { background: #2b3448; color: var(--muted); }
.dock-status.active { color: #8ff0a6; }
.upgrades { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; touch-action: pan-y; }

.upg {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
}
.upg-range { --c: #5fc8ff; }
.upg-strength { --c: #ff6b5a; }
.upg-cargo { --c: #ffcf3a; }
.upg-speed { --c: #7be07b; }
.upg-sell { --c: #ffd24d; }
.upg-drops { --c: #c08cff; }
.upg.afford { box-shadow: inset 0 0 0 2px rgba(255, 207, 58, 0.35); }
.upg-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--line);
  color: var(--c);
}
.upg-icon svg { width: 26px; height: 26px; }
.upg-info { min-width: 0; }
.upg-name { font-weight: 900; font-size: 14px; }
.upg-pips { display: flex; gap: 3px; margin: 3px 0 4px; }
.upg-pips i { width: 12px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); }
.upg-pips i.on { background: var(--c); }
.upg-effect { font-size: 12.5px; color: var(--muted); font-weight: 700; line-height: 1.3; }
.upg-effect b { color: #fff; }
.upg-effect .arrow { color: var(--c); }
/* the extra note drops to its own line as a unit when the terminal is narrow, and wraps inside if still too long */
.upg-effect small { display: inline-block; max-width: 100%; color: var(--c); font-size: 11px; font-weight: 800; }
.upg-buy {
  min-width: 78px; height: 42px;
  padding: 0 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 11px;
  border: 3px solid var(--line);
  background: #3a4358;
  color: #c9cfdb;
  font-weight: 900; font-size: 15px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.upg.afford .upg-buy { background: linear-gradient(180deg, #ffe066, #f2a91c); color: #2a1d0a; }
.upg.afford .upg-buy:hover { filter: brightness(1.08); }
.upg-buy:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4); }
.upg.maxed .upg-buy { background: #2b3448; color: #7be07b; cursor: default; transform: none; }
.upg-buy kbd { font-family: inherit; font-size: 10px; padding: 1px 4px; border-radius: 4px; background: rgba(0, 0, 0, 0.22); }
.upg.maxed .upg-buy kbd { display: none; }
.upg.deny { animation: shake 0.35s; }

/* ---------- prompts ---------- */
.move-hint {
  position: absolute;
  left: 50%;
  bottom: calc(26px + var(--safe-b));
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--drop);
  font-weight: 800; font-size: 16px;
  white-space: nowrap;
  animation: bob 1.6s ease-in-out infinite;
}
.keys { display: flex; gap: 3px; }
.move-hint kbd {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 2px solid var(--line);
  background: #f4f1e8; color: #1b2130;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  font-family: inherit; font-weight: 900; font-size: 14px;
}
.finger {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--yellow);
  border: 3px solid var(--line);
  box-shadow: 0 0 0 6px rgba(255, 207, 58, 0.25);
  animation: drag 1.6s ease-in-out infinite;
}

.toasts {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  max-width: 380px;
  padding: 8px 14px;
  background: var(--panel-solid);
  border: 3px solid var(--line);
  border-left: 7px solid #5fc8ff;
  border-radius: 12px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  font-weight: 800; font-size: 14px;
  text-align: center;
  animation: dropIn 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.good { border-left-color: #3fbf62; }
.toast.gem { border-left-color: #ff9a3c; color: #ffe0b0; }
.toast.warn { border-left-color: #ff6b4a; }
.toast.out { opacity: 0; transform: translateY(8px); }

.banner {
  position: absolute;
  left: 12px; right: 12px; top: calc(var(--stack-top, 70px) + 92px);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}
.banner.show { animation: bannerIn 3.4s ease forwards; }
.banner small { display: block; font-size: 13px; font-weight: 900; letter-spacing: 3px; color: var(--yard-accent); text-shadow: 0 2px 0 #000; }
.banner b {
  display: block;
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 2px #10131b;
  text-shadow: 0 5px 0 #10131b, 0 10px 24px rgba(0, 0, 0, 0.45);
}
.banner span { display: inline-block; margin-top: 8px; padding: 5px 12px; background: rgba(16, 19, 27, 0.78); border-radius: 10px; font-weight: 700; font-size: 14px; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  align-items: safe center; justify-content: safe center;
  min-width: 0; min-height: 0;
  padding: max(20px, var(--safe-t)) max(16px, var(--safe-r)) max(20px, var(--safe-b)) max(16px, var(--safe-l));
  background: rgba(12, 15, 22, 0.6);
  z-index: 50;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#garage, #shop, #scrapbook, #map { overflow: hidden; }
.title-screen { background: radial-gradient(ellipse at center, rgba(12, 15, 22, 0.2), rgba(12, 15, 22, 0.78)); }

.panel {
  width: min(420px, 100%);
  margin: auto;
  padding: 22px 22px 20px;
  background: var(--panel-solid);
  border: 3px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.4), 0 30px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
  animation: popIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.panel.wide { width: min(620px, 100%); }
.panel h2 { margin: 0 0 14px; font-size: 30px; font-weight: 900; color: var(--yellow); text-shadow: 0 3px 0 #000; }

.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.btn {
  padding: 12px 20px;
  border-radius: 14px;
  border: 3px solid var(--line);
  background: #3a4358;
  color: var(--text);
  font-weight: 900; font-size: 18px; letter-spacing: 0.3px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); }
.btn.primary { background: linear-gradient(180deg, #ffe066, #f2a91c); color: #2a1d0a; }
.btn.big { font-size: 24px; padding: 15px 26px; }
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(255, 255, 255, 0.18); color: var(--muted); }
.btn.danger { background: #4a2a2e; color: #ff9a8a; }
.btn.danger.armed { background: #c23b2e; color: #fff; }
.btn.small { font-size: 14px; padding: 8px 12px; border-radius: 11px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45); }
.btn:disabled { opacity: 0.55; cursor: default; filter: none; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, .upg-buy:focus-visible, .toggle:focus-visible { outline: 3px solid #5fc8ff; outline-offset: 2px; }

.title-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; animation: popIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.92; transform: rotate(-3deg); }
.logo-top {
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 900;
  letter-spacing: 0.35em;
  padding-left: 0.35em;
  color: #5fc8ff;
  -webkit-text-stroke: 2px #10131b;
  text-shadow: 0 4px 0 #10131b;
}
.logo-main {
  font-size: clamp(50px, 12.5vw, 112px);
  font-weight: 900;
  color: var(--yellow);
  white-space: nowrap;
  -webkit-text-stroke: 3px #10131b;
  text-shadow: 0 6px 0 #10131b, 0 12px 0 rgba(0, 0, 0, 0.25), 0 20px 40px rgba(0, 0, 0, 0.5);
}
.logo-main em { font-style: normal; color: #ff6b4a; }
.tagline { margin: 8px 0 0; font-size: clamp(15px, 3.6vw, 20px); font-weight: 800; text-shadow: 0 2px 0 #000; }
.title-notice { margin: 0; max-width: 420px; padding: 8px 14px; background: rgba(120, 30, 20, 0.85); border: 2px solid #ff8a6a; border-radius: 10px; font-weight: 700; font-size: 14px; }
.title-info { margin: 0; padding: 6px 14px; background: rgba(16, 19, 27, 0.75); border-radius: 10px; font-weight: 700; color: #ffe8a8; }
.title-goal { margin: -2px 0 0; max-width: min(440px, 90vw); color: #bfeaff; font-size: 12px; font-weight: 800; text-align: center; }
.title-screen .btn-col { width: min(300px, 80vw); }
.controls-note { margin: 12px 0 0; font-size: 13px; font-weight: 700; color: var(--muted); text-shadow: 0 1px 0 #000; }

.daily-card {
  width: min(340px, 88vw);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px 9px 13px;
  border: 2px solid #8f7130;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(50, 60, 82, 0.96), rgba(27, 33, 48, 0.96));
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  text-align: left;
}
.daily-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.daily-copy > span { color: #ffe066; font-size: 10px; font-weight: 900; letter-spacing: 1.1px; text-transform: uppercase; }
.daily-copy > b { font-size: 15px; line-height: 1.15; }
.daily-copy > small { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.daily-card.claimed { border-color: rgba(255, 255, 255, 0.18); }
.daily-card.claimed .btn { color: #b9c1ce; background: #343c50; }

.setting {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px;
  border-bottom: 2px dashed rgba(255, 255, 255, 0.08);
  font-weight: 800; font-size: 17px;
}
.toggle {
  position: relative;
  width: 62px; height: 34px;
  padding: 0;
  border-radius: 99px;
  border: 3px solid var(--line);
  background: #3a4358;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #c9cfdb; transition: transform 0.2s, background 0.2s; }
.toggle.on { background: #3fbf62; }
.toggle.on i { transform: translateX(28px); background: #fff; }
.note { font-size: 13px; color: #ffb38a; font-weight: 700; }

.map-list { display: flex; flex-direction: column; gap: 10px; max-height: min(62vh, 520px); overflow-y: auto; text-align: left; padding: 2px; touch-action: pan-y; }
.yard-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 14px;
}
.yard-card.current { border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(255, 207, 58, 0.25); }
.yard-card.locked { opacity: 0.62; }
.yard-swatch { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 12px; border: 3px solid var(--line); }
.yard-swatch span { font-size: 26px; font-weight: 900; color: #fff; -webkit-text-stroke: 1.5px #10131b; text-shadow: 0 3px 0 #10131b; }
.yard-name { font-weight: 900; font-size: 17px; }
.yard-tag { margin: 2px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.yard-status { margin-top: 4px; font-size: 12px; font-weight: 800; color: #e8e2d0; }
.yard-card .meter { height: 8px; }
.yard-card .meter > i { background: linear-gradient(90deg, #ffe066, #f2a91c); transition: none; }

.celebrate { border-color: var(--yellow); }
.badge-big {
  width: 84px; height: 84px;
  margin: -62px auto 10px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b8, #ffc93a 55%, #d98f12);
  border: 4px solid var(--line);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.4);
  font-size: 38px; font-weight: 900; color: #2a1d0a;
  animation: spinIn 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.celebrate p { font-size: 16px; line-height: 1.45; font-weight: 700; color: #e8e2d0; }
#complete .panel { margin-top: 70px; }
.fade { position: absolute; inset: 0; background: #0c0f16; opacity: 0; pointer-events: none; transition: opacity 0.36s; z-index: 80; }
.fade.on { opacity: 1; pointer-events: auto; }

.flash { animation: flash 0.5s ease-in-out 4; }

/* ---------- animations ---------- */
@keyframes dropIn { from { opacity: 0; transform: translateY(-10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes spinIn { from { transform: rotate(-200deg) scale(0.3); } to { transform: none; } }
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }
@keyframes drag { 0%, 100% { transform: translateX(-10px); } 50% { transform: translateX(10px); } }
@keyframes pulseRed { 50% { background: rgba(150, 32, 20, 0.95); } }
@keyframes flash { 50% { box-shadow: 0 0 0 4px var(--yellow), 0 0 26px var(--yellow); } }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateY(16px) scale(0.96); }
  10% { opacity: 1; transform: none; }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-12px); }
}

@media (pointer: coarse) {
  .upg-buy kbd { display: none; }
  .icon-btn, .offer-x { min-width: 44px; min-height: 44px; }
  .btn, .upg-buy, .dock-garage, .toggle { min-height: 44px; }
}

/* ---------- small screens ---------- */
@media (max-width: 960px) {
  .quota { order: 3; flex: 1 0 100%; max-width: none; }
}
@media (max-width: 700px) {
  .pill { height: 38px; font-size: 17px; padding: 0 10px 0 6px; gap: 6px; }
  .money { min-width: 0; }
  .coin-icon { width: 22px; height: 22px; }
  .coin-icon::after { font-size: 11px; }
  .cargo { font-size: 14px; }
  .cargo .ico { display: none; }
  .cargo .meter { width: 52px; }
  #cargoText { min-width: 0; }
  .icon-btn { width: 40px; height: 40px; min-width: 44px; min-height: 44px; border-radius: 12px; }
  .icon-btn svg { width: 21px; height: 21px; }
  .quota { padding: 5px 12px 7px; }
  .hint { font-size: 14px; padding: 8px 12px; }
  .starter-goal { padding: 7px 10px 8px; }
  .starter-goal-copy { display: block; }
  .starter-goal b, .starter-goal span { display: block; }
  .starter-goal span { margin-top: 2px; }
  .hud-stack { --ch-w: 220px; }
  .panel { padding: 18px 16px 16px; }
  .panel h2 { font-size: 26px; }
  .yard-card { grid-template-columns: 48px 1fr; }
  .yard-card .btn { grid-column: 1 / -1; }
  .yard-swatch { width: 48px; height: 48px; }
}
@media (max-width: 420px) {
  #btnSound { display: none; }
  .hud-left, .hud-right { gap: 6px; }
  .pill { font-size: 15px; padding: 0 9px 0 5px; gap: 5px; }
  .cargo .meter { width: 40px; }
  .cargo .full-tag { display: none !important; }
  .cargo.full #cargoText { color: #ffb3a0; }
}

/* phones in portrait: the upgrade terminal becomes a bottom sheet */
@media (max-width: 700px) and (orientation: portrait) {
  .dock {
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 54%;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding-bottom: var(--safe-b);
    transform: translateY(calc(100% + 20px));
  }
  .upgrades { gap: 5px; padding: 6px 8px 8px; }
  .upg { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; padding: 5px 7px; }
  .upg-icon { width: 34px; height: 34px; }
  .upg-icon svg { width: 22px; height: 22px; }
  .upg-buy { height: 38px; min-width: 70px; }
}

/* short landscape screens */
@media (max-height: 520px) and (orientation: landscape) {
  .screen {
    padding: max(6px, var(--safe-t)) max(8px, var(--safe-r)) max(6px, var(--safe-b)) max(8px, var(--safe-l));
  }
  .pill { height: 36px; font-size: 16px; }
  .icon-btn { width: 38px; height: 38px; }
  .quota { padding: 4px 12px 6px; }
  .dock { width: 310px; }
  .upgrades { gap: 4px; padding: 6px; }
  .upg { padding: 4px 7px; gap: 8px; grid-template-columns: 32px minmax(0, 1fr) auto; }
  .upg-icon { width: 32px; height: 32px; }
  .upg-icon svg { width: 20px; height: 20px; }
  .upg-pips { margin: 1px 0 2px; }
  .upg-buy { height: 34px; }
  .banner { top: 14%; }
  .move-hint { bottom: calc(14px + var(--safe-b)); }
  .logo-main { font-size: clamp(40px, 10vw, 80px); }
  .title-card { gap: 6px; }

  /* CrazyGames' embedded player can be wide but only ~320 CSS px tall.
     Collapse the pause menu vertically instead of making the iframe scroll. */
  #pause .panel {
    width: min(520px, 100%);
    max-height: calc(100dvh - 12px);
    margin: 0 auto;
    padding: 7px 10px 6px;
    border-radius: 14px;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4), 0 14px 30px rgba(0, 0, 0, 0.4);
  }
  #pause .panel h2 { margin: 0 0 3px; font-size: 20px; line-height: 1.05; }
  #pause .btn-col { gap: 4px; margin-top: 2px; }
  #pause .btn-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  #pause .btn {
    min-height: 0;
    padding: 5px 8px;
    border-width: 2px;
    border-radius: 9px;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-size: 14px;
    line-height: 1.1;
  }
  #pause .controls-note { margin-top: 5px; font-size: 10px; line-height: 1.15; }
}

/* Runtime viewport mode. The iframe can be rendered at a high device-pixel ratio,
   so JavaScript classifies its real CSS-pixel viewport on every resize/fullscreen change. */
#app.viewport-short .hud-bar {
  top: max(4px, var(--safe-t));
  left: max(5px, var(--safe-l));
  right: max(5px, var(--safe-r));
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}
#app.viewport-short .hud-left,
#app.viewport-short .hud-right { flex: none; gap: 3px; }
#app.viewport-short .pill {
  height: 32px;
  padding: 0 7px 0 4px;
  gap: 4px;
  border-width: 2px;
  font-size: 14px;
}
#app.viewport-short .money { min-width: 0; }
#app.viewport-short .coin-icon { width: 19px; height: 19px; border-width: 2px; }
#app.viewport-short .coin-icon::after { font-size: 9px; }
#app.viewport-short .cargo .meter { width: 40px; height: 9px; border-width: 1px; }
#app.viewport-short .cargo { font-size: 12px; }
#app.viewport-short .icon-btn {
  width: 34px; height: 34px;
  border-width: 2px;
  border-radius: 10px;
}
#app.viewport-short .icon-btn svg { width: 19px; height: 19px; }
#app.viewport-short .shop-btn .badge { right: -4px; bottom: -4px; min-width: 17px; height: 15px; font-size: 9px; }
#app.viewport-short .quota {
  order: initial;
  flex: 1 1 105px;
  min-width: 90px;
  max-width: none;
  margin: 0;
  padding: 3px 7px 4px;
  border-width: 2px;
  border-radius: 10px;
}
#app.viewport-short .quota-top { gap: 4px; margin-bottom: 2px; font-size: 10px; }
#app.viewport-short .quota .meter { height: 7px; border-width: 1px; }

#app.viewport-short .title-screen {
  padding: max(5px, var(--safe-t)) max(8px, var(--safe-r)) max(5px, var(--safe-b)) max(8px, var(--safe-l));
  overflow: hidden;
}
#app.viewport-short .title-card { gap: 3px; justify-content: center; }
#app.viewport-short .logo-top {
  font-size: clamp(14px, 5.5vh, 20px);
  -webkit-text-stroke-width: 1px;
  text-shadow: 0 2px 0 #10131b;
}
#app.viewport-short .logo-main {
  font-size: clamp(34px, 16vh, 62px);
  -webkit-text-stroke-width: 2px;
  text-shadow: 0 3px 0 #10131b, 0 6px 0 rgba(0, 0, 0, 0.25), 0 10px 20px rgba(0, 0, 0, 0.45);
}
#app.viewport-short .tagline { margin: 2px 0 0; font-size: clamp(12px, 4vh, 15px); }
#app.viewport-short .title-info { padding: 3px 9px; border-radius: 7px; font-size: 12px; }
#app.viewport-short .title-goal { margin: 0; font-size: 10px; line-height: 1.1; }
#app.viewport-short .title-notice { padding: 4px 9px; font-size: 11px; }
#app.viewport-short .daily-card { width: min(360px, 80vw); gap: 8px; padding: 4px 6px 4px 9px; border-radius: 9px; }
#app.viewport-short .daily-copy > span { display: none; }
#app.viewport-short .daily-copy > b { font-size: 12px; }
#app.viewport-short .daily-copy > small { font-size: 10px; }
#app.viewport-short .daily-card .btn { padding: 5px 9px; font-size: 12px; border-width: 2px; }
#app.viewport-short .title-screen .btn-col {
  width: min(300px, 70vw);
  gap: 4px;
  margin-top: 3px;
}
#app.viewport-short .title-screen .btn {
  padding: 6px 12px;
  border-width: 2px;
  border-radius: 10px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  font-size: 14px;
  line-height: 1.1;
}
#app.viewport-short .title-screen .btn.big { padding: 8px 14px; font-size: 18px; }
#app.viewport-short .title-screen .btn-row { gap: 4px; }
#app.viewport-short .title-screen .controls-note { margin-top: 3px; font-size: 10px; line-height: 1.15; }

#app.viewport-short .banner { top: calc(var(--stack-top, 40px) + 5px); }
#app.viewport-short .banner small { font-size: 10px; letter-spacing: 2px; }
#app.viewport-short .banner b { font-size: clamp(24px, 9vh, 34px); -webkit-text-stroke-width: 1px; text-shadow: 0 3px 0 #10131b, 0 6px 12px rgba(0, 0, 0, 0.4); }
#app.viewport-short .banner span { margin-top: 2px; padding: 3px 8px; border-radius: 7px; font-size: 11px; }
#app.viewport-short .nitro-btn { width: 50px; height: 50px; right: max(8px, var(--safe-r)); bottom: calc(8px + var(--safe-b)); }

@media (prefers-reduced-motion: reduce) {
  .move-hint, .finger, .cargo.full { animation: none; }
  .move-hint { transform: translateX(-50%); }
}

/* =====================================================================
   Menus, garage, shop, scrapbook, boosts and events
   ===================================================================== */
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-sub { margin: -4px 0 12px; color: var(--muted); font-weight: 700; font-size: 14px; line-height: 1.4; }
.title-screen.loading .btn-col { opacity: 0.4; pointer-events: none; }
.title-screen.loading .tagline::after { content: " · loading…"; color: var(--muted); }

/* HUD extras */
.shop-btn { position: relative; }
.cars-btn {
  width: auto;
  min-width: 82px;
  padding: 0 9px;
  display: flex;
  gap: 5px;
  background: linear-gradient(180deg, #ffe066, #f2a91c);
  color: #2a1d0a;
  border-color: #0c0f16;
}
.cars-btn:hover { background: linear-gradient(180deg, #fff0a3, #ffc42d); }
.cars-btn svg { width: 30px; height: 23px; flex: none; }
.cars-btn span { font-size: 12px; font-weight: 900; letter-spacing: 0.6px; }
.garage-main-btn {
  border-color: #ffcf3a;
  background: linear-gradient(135deg, #3b4b68, #29344b);
  color: #ffe78d;
}
.shop-btn .badge {
  position: absolute; right: -6px; bottom: -6px;
  min-width: 20px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 9px; border: 2px solid var(--line);
  background: var(--yellow); color: #2a1d0a;
  font-size: 11px; font-weight: 900;
}
.boost-tag {
  margin-left: 2px; padding: 2px 7px;
  border-radius: 8px; border: 2px solid var(--line);
  background: #3fbf62; color: #0c1a0f;
  font-size: 12px; font-weight: 900;
}
.nitro-btn {
  pointer-events: auto;
  position: absolute;
  right: max(16px, var(--safe-r));
  bottom: calc(18px + var(--safe-b));
  width: 72px; height: 72px;
  display: grid; place-items: center; align-content: center; gap: 0;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: radial-gradient(circle at 35% 30%, #ffd27a, #ff8a2a 60%, #c2410c);
  color: #fff6c0;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(255, 138, 42, 0.25);
  cursor: pointer;
  font-family: inherit;
}
.nitro-btn svg { width: 28px; height: 28px; }
.nitro-btn span { font-weight: 900; font-size: 15px; color: #2a1206; line-height: 1; }
.nitro-btn kbd { position: absolute; top: -12px; padding: 1px 6px; border-radius: 6px; background: var(--panel-solid); border: 2px solid var(--line); color: var(--muted); font: 800 10px var(--font); }
.nitro-btn:active { transform: translateY(2px) scale(0.97); }
.nitro-btn.active { animation: nitroPulse 0.25s ease-in-out infinite alternate; }
.nitro-btn.empty { filter: grayscale(0.9) brightness(0.7); }
@media (pointer: coarse) { .nitro-btn kbd { display: none; } }
@keyframes nitroPulse { to { box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4), 0 0 0 10px rgba(255, 170, 60, 0.45); } }

.event-pill {
  display: none;
  width: min(300px, 100%);
  padding: 7px 12px 9px;
  background: var(--panel);
  border: 3px solid var(--ev, var(--yellow));
  border-radius: 14px;
  box-shadow: var(--drop), 0 0 18px var(--ev, transparent);
}
.event-pill.show { display: block; animation: dropIn 0.3s ease-out; }
.ev-head { display: flex; justify-content: space-between; font-size: 15px; }
.ev-head b { color: var(--ev, var(--yellow)); text-transform: uppercase; letter-spacing: 0.6px; }
.ev-text { font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 2px 0 6px; }
.event-pill .meter { height: 7px; }
.event-pill .meter > i { background: var(--ev, var(--yellow)); transform: scaleX(1); transition: none; }
#app[data-event="golden"] #vignette { box-shadow: inset 0 0 140px rgba(255, 200, 40, 0.45); }
#app[data-event="storm"] #vignette { box-shadow: inset 0 0 140px rgba(120, 210, 255, 0.45); animation: stormFlicker 2.4s steps(1) infinite; }
#app[data-event="rush"] #vignette { box-shadow: inset 0 0 120px rgba(90, 220, 120, 0.35); }
#app[data-event="shower"] #vignette { box-shadow: inset 0 0 120px rgba(255, 170, 70, 0.35); }
@keyframes stormFlicker { 0%, 100% { filter: none; } 47% { filter: brightness(1.6); } 49% { filter: none; } }

/* upgrade terminal extras */
.dock-head { gap: 8px; }
.dock-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-garage {
  padding: 4px 9px; border-radius: 8px; border: 2px solid var(--line);
  background: var(--yellow); color: #2a1d0a; font-weight: 900; font-size: 13px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
.dock-garage:active { transform: translateY(1px); }
.dock-cta {
  flex: none;
  display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center;
  margin: 0 8px 8px; padding: 6px 8px;
  background: linear-gradient(90deg, rgba(255, 207, 58, 0.18), rgba(255, 207, 58, 0.04));
  border: 2px solid var(--yellow); border-radius: 12px;
  animation: dropIn 0.3s ease-out;
}
.dock-cta img { width: 70px; height: auto; }
.dock-cta b { display: block; font-size: 14px; }
.dock-cta span { font-size: 12px; color: var(--muted); font-weight: 700; }

/* shared list styles */
.card-list { display: flex; flex-direction: column; gap: 8px; max-height: min(540px, calc(100vh - 300px)); overflow-y: auto; text-align: left; padding: 2px; touch-action: pan-y; }
.list-head { margin-top: 6px; font-weight: 900; font-size: 15px; color: var(--yellow); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.list-head small { flex-basis: 100%; color: var(--muted); font-size: 12px; font-weight: 700; }
.bolt-icon {
  display: inline-block; width: 18px; height: 18px; margin-right: 4px; vertical-align: -4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l8.7 5v10L12 22l-8.7-5V7z' fill='%23ffcf3a' stroke='%230c0f16' stroke-width='2' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='12' r='3.8' fill='%230c0f16'/%3E%3C/svg%3E") center / contain no-repeat;
}
.btn .bolt-icon { width: 14px; height: 14px; }

/* garage */
.garage-guide {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin: -3px 0 12px; padding: 8px 10px;
  border: 2px solid #4e6388; border-radius: 12px;
  background: linear-gradient(135deg, #27344b, #20283a);
  color: #dfe8fa; font-size: 12px; font-weight: 900;
}
.garage-guide span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.garage-guide b {
  width: 20px; height: 20px; display: inline-grid; place-items: center;
  border-radius: 50%; background: var(--yellow); color: #2a1d0a;
}
.garage-guide i { color: var(--yellow); font-style: normal; font-size: 18px; }
.veh-card {
  display: grid; grid-template-columns: 112px 1fr auto; gap: 12px; align-items: center;
  padding: 8px 10px; background: var(--card); border: 3px solid var(--line); border-radius: 14px;
}
.veh-card.active { border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(255, 207, 58, 0.25); }
.veh-card.buy { border-color: #63e780; box-shadow: 0 0 0 2px rgba(99, 231, 128, 0.18), 0 0 22px rgba(99, 231, 128, 0.14); }
.veh-card.buy .veh-status { color: #8ff0a6; font-size: 13px; }
.veh-card.buy > .btn { animation: garageBuyPulse 1.4s ease-in-out infinite alternate; }
.veh-card.locked { opacity: 0.7; }
.veh-card.premium { background: linear-gradient(135deg, #2b2a3d, #252d40); }
.veh-img { width: 112px; height: auto; }
.veh-img.dim { filter: grayscale(1) brightness(0.55); }
.veh-name { font-weight: 900; font-size: 16px; }
.veh-desc { font-size: 12.5px; color: var(--muted); font-weight: 700; margin: 2px 0; }
.veh-stats { font-size: 11.5px; color: #c9d3e6; font-weight: 700; }
.veh-status { font-size: 12px; font-weight: 800; color: #e8e2d0; margin-top: 3px; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 6px; background: #2f6b3e; color: #b8f5c6; font-size: 11px; font-weight: 900; vertical-align: 2px; }
.tag.gold { background: #6b5214; color: #ffe08a; }
@keyframes garageBuyPulse { to { filter: brightness(1.18); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), 0 0 14px rgba(255, 207, 58, 0.45); } }

/* shop */
.bolts-bar {
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  margin: -4px 0 10px; padding: 8px 12px;
  background: #252d40; border: 2px solid var(--line); border-radius: 12px; font-weight: 800;
}
.bolts-bar b { font-size: 22px; color: var(--yellow); }
.bolts-bar small { flex-basis: 100%; text-align: center; color: var(--muted); font-size: 12px; }
.test-note { margin: 0 0 10px; padding: 6px 10px; border-radius: 10px; background: #5a3a10; color: #ffd27a; font-weight: 800; font-size: 13px; }
.shop-card {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; background: var(--card); border: 2px solid var(--line); border-radius: 12px;
}
.shop-icon { width: 54px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: rgba(0, 0, 0, 0.3); font-size: 20px; font-weight: 900; color: var(--yellow); }
.shop-icon img { width: 54px; height: auto; }
.shop-info b { display: block; font-size: 15px; }
.shop-info span { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.shop-card.ad { border-color: #3f7fb8; }
.shop-card.crew { border-color: #3f8a55; background: linear-gradient(135deg, #243b35, var(--card)); }
.shop-card.crew.hired { box-shadow: inset 0 0 0 1px rgba(143, 240, 166, 0.16); }
/* the CrazyGames banner renders straight into this div: no frame, background or label of our own */
.cg-ad-slot {
  flex: none;
  width: 320px;
  height: 50px;
  margin: 8px auto 0;
  overflow: hidden;
}
/* an unfilled slot keeps its size so the next timed refresh can still fill it */
.cg-ad-slot.ad-unfilled { visibility: hidden; }
#shopAdBanner.test-banner { display: grid; place-items: center; border: 1px dashed #5fc8ff; color: #8fdcff; font-size: 10px; font-weight: 900; letter-spacing: 0.7px; }
.crew-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.crew-actions .btn { white-space: nowrap; }
.crew-actions .ad-btn { border-color: #3f7fb8; color: #bfe4ff; }

/* scrapbook */
.scrap-list { display: flex; flex-direction: column; gap: 12px; max-height: min(560px, calc(100vh - 290px)); overflow-y: auto; text-align: left; padding: 2px; touch-action: pan-y; }
.relic-set { padding: 10px; background: var(--card); border: 3px solid var(--line); border-radius: 14px; }
.relic-set.done { border-color: #3fbf62; }
.relic-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 15px; }
.relic-head span { color: var(--muted); font-weight: 800; font-size: 13px; }
.relic-set.done .relic-head span { color: #8ff0a6; }
.relic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.relic { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 8px 6px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); }
.relic img { width: 56px; height: 56px; }
.relic .q { width: 56px; height: 56px; display: grid; place-items: center; font-size: 30px; font-weight: 900; color: #4b5570; }
.relic b { font-size: 12.5px; }
.relic small { font-size: 11px; color: var(--muted); font-weight: 700; line-height: 1.3; }
.relic.found { background: radial-gradient(circle at 50% 30%, rgba(127, 232, 255, 0.18), rgba(0, 0, 0, 0.25) 70%); }

/* relic found card: a short notice along the bottom edge, away from the rover and the HUD column */
.find-card {
  position: absolute; left: 50%; bottom: calc(18px + var(--safe-b));
  display: flex; gap: 12px; align-items: center;
  width: min(420px, calc(100% - 24px));
  padding: 10px 14px;
  background: linear-gradient(135deg, #1d3448, #1b2130);
  border: 3px solid #7fe8ff; border-radius: 16px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35), 0 0 30px rgba(127, 232, 255, 0.35);
  opacity: 0; pointer-events: none; transform: translate(-50%, 14px) scale(0.95);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 45;
}
.find-card.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.side-dock-open .find-card { left: calc((100% - var(--dock-w, 350px) - 24px) / 2); }
.sheet-open .find-card { bottom: calc(var(--dock-h, 0px) + 10px); }
.find-card img { width: 64px; height: 64px; flex: none; }
.find-card small { display: block; color: #7fe8ff; font-weight: 900; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.find-card b { display: block; font-size: 19px; }
.find-card span { display: block; font-size: 12.5px; color: var(--muted); font-weight: 700; }
.find-card em { display: block; font-style: normal; font-size: 12.5px; font-weight: 800; color: #ffe066; margin-top: 3px; }

/* credits */
.credits { padding: 4px 0 8px; }
.credit-logo { font-weight: 900; font-size: 15px; letter-spacing: 4px; color: #5fc8ff; }
.credit-logo b { display: block; font-size: 30px; letter-spacing: 1px; color: var(--yellow); -webkit-text-stroke: 1px #10131b; }
.credit-role { margin: 16px 0 0; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 2px; font-size: 12px; }
.credit-name { margin: 2px 0 6px; font-size: 40px; font-weight: 900; color: #fff; text-shadow: 0 4px 0 #000; }
.credit-small { margin: 6px 0; color: var(--muted); font-weight: 700; font-size: 13.5px; line-height: 1.4; }
.credit-thanks { margin: 14px 0 0; font-weight: 900; color: #8ff0a6; }

/* platform test overlay (only with ?shoptest) */
.test-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(5, 8, 14, 0.85); }
.test-card { width: min(360px, calc(100% - 32px)); padding: 20px; text-align: center; background: #1b2130; border: 3px dashed #ffcf3a; border-radius: 16px; color: var(--text); }
.test-card b { font-size: 20px; color: #ffcf3a; }
.test-card p { color: var(--muted); font-weight: 700; }
.test-count { display: block; margin-bottom: 10px; font-weight: 900; }
.test-actions { display: flex; gap: 10px; justify-content: center; }

@media (max-width: 700px) {
  .cars-btn { min-width: 70px; padding: 0 7px; }
  .cars-btn span { font-size: 10px; }
  .cars-btn svg { width: 26px; }
  .veh-card { grid-template-columns: 84px 1fr; }
  .veh-card > .btn { grid-column: 1 / -1; }
  .veh-img { width: 84px; }
  .veh-stats { display: none; }
  .shop-card { grid-template-columns: 44px 1fr auto; }
  .shop-card.crew { grid-template-columns: 44px 1fr; }
  .shop-card.crew .crew-actions { grid-column: 1 / -1; }
  .shop-card.crew .crew-actions .btn { flex: 1; }
  .shop-icon { width: 44px; }
  .shop-icon img { width: 44px; }
  .nitro-btn { width: 64px; height: 64px; right: max(12px, var(--safe-r)); bottom: calc(14px + var(--safe-b)); }
  .move-hint { bottom: calc(96px + var(--safe-b)); }
  .relic-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .btn-grid { gap: 8px; }
  .garage-guide { gap: 4px; padding: 6px; font-size: 10px; }
  .garage-guide b { width: 17px; height: 17px; }
  .garage-guide i { font-size: 14px; }
  .credit-name { font-size: 34px; }
  .cg-ad-slot { display: none !important; }
}
@media (max-height: 599px) {
  .cg-ad-slot { display: none !important; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .nitro-btn { width: 58px; height: 58px; }
  .card-list, .scrap-list { max-height: calc(100vh - 150px); }
  .panel h2 { margin-bottom: 8px; }
}

#shopList { max-height: min(540px, calc(100vh - 360px)); }
.scrollable { scrollbar-width: thin; scrollbar-color: #4b5570 transparent; }

/* menus fill the available height and scroll their lists inside */
.panel.wide { display: flex; flex-direction: column; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); }
.panel.wide > h2, .panel.wide > .panel-sub, .panel.wide > .bolts-bar, .panel.wide > .test-note, .panel.wide > .cg-ad-slot, .panel.wide > .btn-col { flex: none; }
.panel.wide .card-list, .panel.wide .scrap-list, .panel.wide .map-list, #shopList { flex: 1 1 auto; min-height: 120px; max-height: none; }

@media (max-width: 700px) {
  .challenge { padding: 5px 10px 7px; }
  .challenge .ch-tag { display: none; }
  .ch-head { justify-content: flex-end; margin-bottom: -18px; }
  .ch-title { font-size: 13.5px; margin: 0 60px 4px 0; }
  .ch-row { font-size: 12px; }
  .event-pill { padding: 5px 10px 7px; }
  .event-pill .ev-text { display: none; }
  .event-pill .ev-head { margin-bottom: 4px; font-size: 13.5px; }
  .relic-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .relic { padding: 6px 2px; }
  .relic img, .relic .q { width: 44px; height: 44px; }
  .relic small { display: none; }
  .relic b { font-size: 11px; }
  .find-card img { width: 48px; height: 48px; }
  .find-card b { font-size: 16px; }
}
@media (max-width: 420px) {
  #btnMap { display: none; }
  .bt-time { display: none; }
  .boost-tag { padding: 2px 5px; }
}
@media (max-width: 380px) {
  .pill { font-size: 14px; padding: 0 8px 0 5px; gap: 4px; }
  .cargo .meter { width: 36px; }
  .coin-icon { width: 20px; height: 20px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .panel.wide { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .panel.wide > .panel-sub { display: none; }
  .bolts-bar { margin: -4px 0 6px; padding: 4px 10px; }
  .bolts-bar small { display: none; }
  .test-note { margin-bottom: 6px; padding: 4px 8px; font-size: 12px; }
  .panel.wide .btn-col { margin-top: 6px; }
  .panel.wide .btn-col .btn { padding: 8px 16px; font-size: 16px; }
  .panel { padding: 12px 16px 12px; }
  .panel h2 { font-size: 24px; }
}

/* pop-up reward offers (rewarded ads, optional and only visible on paused/menu screens) */
.offer {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  right: max(18px, var(--safe-r));
  width: 286px;
  transform: translateY(-50%);
  display: none;
  grid-template-columns: 58px 1fr;
  gap: 8px 10px;
  align-items: center;
  padding: 12px 13px 11px;
  background: linear-gradient(145deg, #303f61, #1b2130 68%);
  border: 4px solid var(--yellow);
  border-radius: 18px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.48), 0 0 34px rgba(255, 207, 58, 0.5);
  z-index: 70;
}
.offer.show { display: grid; animation: offerIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.offer-kicker {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  color: #ffe066; font-size: 11px; font-weight: 900; letter-spacing: 1px;
}
.offer-kicker em { padding: 2px 5px; border-radius: 5px; background: #111722; color: #b8c3d8; font-size: 9px; font-style: normal; letter-spacing: 0.5px; }
.offer-icon {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: 12px; border: 2px solid var(--line);
  background: radial-gradient(circle at 35% 30%, #fff1a0, #ffcf3a 60%, #e09a10);
  color: #2a1d0a; font-weight: 900; font-size: 19px;
}
.offer-icon svg { width: 26px; height: 26px; }
.offer-body b { display: block; color: #fff3bd; font-size: 17px; line-height: 1.1; }
.offer-body span { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.3; color: #d1d8e6; font-weight: 700; }
.offer-go { grid-column: 1 / -1; }
.offer-alt { grid-column: 1 / -1; margin-top: -2px; border-color: rgba(255, 255, 255, 0.2); color: #dbe2ee; }
.offer-x {
  position: absolute; top: -11px; right: -11px;
  width: 28px; height: 28px; padding: 0;
  border-radius: 50%; border: 2px solid var(--line);
  background: #3a4358; color: #fff; font-size: 17px; font-weight: 900; line-height: 1;
  cursor: pointer;
}
.offer-timer { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.offer-timer i { display: block; height: 100%; background: var(--yellow); transform-origin: left center; }
.offer.kind-rip { border-color: #ff6b4a; box-shadow: var(--drop), 0 0 24px rgba(255, 107, 74, 0.4); }
.offer.kind-rip .offer-icon { background: radial-gradient(circle at 35% 30%, #ffc2a8, #ff6b4a 60%, #c2410c); color: #fff; }
.offer.kind-surge { border-color: #ff7ad9; }
.offer.kind-surge .offer-icon { background: radial-gradient(circle at 35% 30%, #ffd1f1, #ff7ad9 60%, #b0389a); color: #fff; }
.offer.kind-nitro .offer-icon { background: radial-gradient(circle at 35% 30%, #ffd27a, #ff8a2a 60%, #c2410c); color: #fff6c0; }
.offer-x:disabled { opacity: 0.55; cursor: default; }
@keyframes offerIn { from { opacity: 0; transform: translate(30px, -50%) scale(0.9); } to { opacity: 1; transform: translateY(-50%); } }
#app[data-event="surge"] #vignette { box-shadow: inset 0 0 140px rgba(255, 120, 220, 0.4); }

@media (max-width: 1099px) {
  .offer {
    top: auto; right: max(12px, var(--safe-r)); bottom: calc(12px + var(--safe-b));
    width: min(286px, calc(100vw - 24px));
    transform: none;
  }
  .offer.show { animation-name: offerInCompact; }
}
@keyframes offerInCompact { from { opacity: 0; transform: translateX(30px) scale(0.9); } to { opacity: 1; transform: none; } }

#app.viewport-short .cars-btn { width: 60px; min-width: 60px; padding: 0 4px; }
#app.viewport-short .cars-btn span { font-size: 8px; }
#app.viewport-short .cars-btn svg { width: 22px; }
#app.viewport-short .offer { width: 248px; padding: 7px 9px; grid-template-columns: 42px 1fr; gap: 4px 7px; }
#app.viewport-short .offer-kicker { font-size: 9px; }
#app.viewport-short .offer-icon { width: 42px; height: 42px; }
#app.viewport-short .offer-body b { font-size: 14px; }
#app.viewport-short .offer-body span { font-size: 10.5px; }
#app.viewport-short .offer .btn { padding: 5px 8px; border-width: 2px; font-size: 11px; }

.ad-gate {
  display: none;
  pointer-events: auto;
  position: absolute;
  inset: 0;
  z-index: 190;
  place-items: center;
  background: rgba(8, 11, 17, 0.62);
  backdrop-filter: blur(2px);
}
.ad-gate span {
  padding: 12px 18px;
  border: 3px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--drop);
  color: #ffe066;
  font-size: 15px;
  font-weight: 900;
}
.ad-request-busy .ad-gate { display: grid; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Shop & Crew: one window with two tabs ---------- */
.tabs {
  flex: none;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin: 0 0 12px; padding: 5px;
  background: #151a26; border: 2px solid var(--line); border-radius: 14px;
}
.tab {
  padding: 8px 10px;
  border: 2px solid transparent; border-radius: 10px;
  background: transparent; color: var(--muted);
  font: 900 20px var(--font); letter-spacing: 0.3px;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.tab.on {
  background: linear-gradient(180deg, #ffe066, #f2a91c); color: #2a1d0a;
  border-color: var(--line); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}
.tab:focus-visible { outline: 3px solid #5fc8ff; outline-offset: 2px; }
.crew-level {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center;
  padding: 7px 10px; background: rgba(0, 0, 0, 0.22); border: 2px solid var(--line); border-radius: 11px;
  font-size: 13px; font-weight: 800;
}
.crew-lv {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: #343c50; color: #c9d3e6; font-weight: 900;
}
.crew-stats { color: #dfe6f3; }
.crew-level em { font-style: normal; color: var(--muted); white-space: nowrap; }
.crew-level.done .crew-lv { background: #2f6b3e; color: #b8f5c6; }
.crew-level.done em { color: #8ff0a6; }
.crew-level.current { border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(255, 207, 58, 0.2); }
.crew-level.current .crew-lv { background: var(--yellow); color: #2a1d0a; }
.crew-level.current em { color: #ffe066; }
.crew-level.next em { color: #e8e2d0; }
.crew-level.locked { opacity: 0.6; }
@media (max-width: 700px) {
  .tab { font-size: 17px; padding: 6px 8px; }
  .crew-level { grid-template-columns: 26px 1fr; gap: 3px 8px; font-size: 12px; }
  .crew-level em { grid-column: 2; }
  .crew-lv { width: 24px; height: 24px; grid-row: span 2; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .tabs { margin-bottom: 6px; padding: 3px; }
  .tab { padding: 4px 8px; font-size: 15px; }
  .crew-level { padding: 4px 8px; font-size: 12px; }
}

/* pause menu: Cars & Garage leads, the other five entries fill the grid evenly */
.btn-grid .garage-main-btn { grid-column: span 2; }

/* ---------- main menu: always a single screen ---------- */
.title-screen { overflow: hidden; }
.title-screen.fit-scaled { align-items: flex-start; }
.title-card { transform-origin: 50% 0; }
.title-screen .btn-col { width: min(340px, 86vw); }
.title-row .btn { min-width: 0; padding: 10px 6px; font-size: 15px; }
@media (max-height: 760px) {
  .title-card { gap: 7px; }
  .logo-top { font-size: clamp(20px, min(5vw, 5.2vh), 36px); }
  .logo-main { font-size: clamp(46px, min(12.5vw, 15vh), 112px); }
  .tagline { margin-top: 4px; }
  .title-screen .btn.big { padding: 12px 22px; font-size: 22px; }
  .title-screen .btn-col { gap: 8px; margin-top: 4px; }
  .controls-note { margin-top: 4px; }
}
#app.viewport-short .title-screen .title-row .btn { padding: 6px 4px; font-size: 13px; }

/* ---------- small screens: HUD pop-ups stay compact and out of the middle ---------- */
#app.viewport-short .hud-stack { --ch-w: 196px; gap: 5px; }
#app.viewport-short .challenge { padding: 4px 9px 6px; border-width: 2px; border-radius: 11px; }
#app.viewport-short .challenge .ch-tag { display: none; }
#app.viewport-short .ch-head { justify-content: flex-end; margin-bottom: -16px; }
#app.viewport-short .ch-reward { font-size: 12px; }
#app.viewport-short .ch-title { margin: 0 52px 3px 0; overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
#app.viewport-short .ch-row { gap: 7px; font-size: 11px; }
#app.viewport-short .ch-row .meter { height: 6px; }
#app.viewport-short .event-pill { width: min(240px, 100%); padding: 4px 9px 6px; border-width: 2px; border-radius: 11px; }
#app.viewport-short .event-pill .ev-text { display: none; }
#app.viewport-short .event-pill .ev-head { margin-bottom: 3px; font-size: 12.5px; }
#app.viewport-short .event-pill .meter { height: 5px; }
#app.viewport-short .hint { max-width: min(440px, 100%); padding: 5px 10px; border-width: 2px; border-radius: 10px; font-size: 12.5px; }
#app.viewport-short .starter-goal { width: min(300px, 100%); padding: 5px 9px 6px; border-width: 2px; border-radius: 11px; }
#app.viewport-short .toast { max-width: 300px; padding: 5px 10px; border-width: 2px; border-left-width: 5px; border-radius: 9px; font-size: 12px; }

#app.viewport-short .find-card,
#app.viewport-compact .find-card {
  width: min(310px, calc(100% - 24px));
  gap: 8px; padding: 6px 10px;
  border-width: 2px; border-radius: 12px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 16px rgba(127, 232, 255, 0.3);
}
#app.viewport-short .find-card img,
#app.viewport-compact .find-card img { width: 34px; height: 34px; }
#app.viewport-short .find-card small,
#app.viewport-compact .find-card small { font-size: 9.5px; }
#app.viewport-short .find-card b,
#app.viewport-compact .find-card b { font-size: 14px; line-height: 1.15; }
#app.viewport-short .find-card span,
#app.viewport-compact .find-card span { display: none; }
#app.viewport-short .find-card em,
#app.viewport-compact .find-card em { margin-top: 1px; font-size: 11px; }
#app.viewport-short .find-card { bottom: calc(8px + var(--safe-b)); }
/* portrait phones: clear the nitro button in the bottom-right corner */
#app.viewport-compact[data-orientation="portrait"] .find-card { bottom: calc(92px + var(--safe-b)); }
#app.viewport-compact[data-orientation="portrait"].sheet-open .find-card { bottom: calc(var(--dock-h, 0px) + 10px); }
