/* ===== TURBO WYŚCIGI – styl "naklejki z pudełka z zabawkami" ===== */
@font-face { font-family: 'Bungee'; src: url('../fonts/Bungee-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Bungee Shade'; src: url('../fonts/BungeeShade-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Baloo 2'; src: url('../fonts/Baloo2-var.ttf') format('truetype'); font-weight: 400 800; font-display: block; }

:root {
  --ink: #14121f;
  --cream: #fff7e6;
  --cream2: #f3e4c4;
  --dash: #e2d5b6;
  --muted: #6f6888;
  --text2: #3a344f;
  --yellow: #ffd23f;
  --red: #ff4b3e;
  --blue: #2d8cff;
  --green: #2fc25b;
  --green-d: #1d8a45;
  --purple: #9b5cff;
  --pink: #ff5fa8;
  --orange: #ff8a1f;
  --cyan: #22d3ee;
  --navy: #1b1640;
  --display: 'Bungee', Impact, 'Arial Black', sans-serif;
  --body: 'Baloo 2', 'Trebuchet MS', 'Segoe UI', sans-serif;
  --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; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; }
body {
  overflow: hidden;
  background: var(--navy);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.35;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body.racing { touch-action: none; }
button { font: inherit; color: inherit; background: none; border: none; }
ul, ol { list-style: none; }
input { user-select: text; -webkit-user-select: text; }
.hidden { display: none !important; }
.ic { width: 1em; height: 1em; flex: none; display: inline-block; vertical-align: middle; overflow: visible; }

#game { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; }
#fx { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; pointer-events: none; }
body.in-menu #fx, body.dim #fx { visibility: hidden; }

/* przyciemnienie wyścigu pokazowego za menu */
#shade {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  transition: opacity .45s ease;
  background:
    radial-gradient(rgba(255, 255, 255, .07) 1.4px, transparent 1.7px) 0 0 / 16px 16px,
    linear-gradient(100deg, rgba(27, 22, 64, .95) 0%, rgba(27, 22, 64, .84) 40%, rgba(27, 22, 64, .38) 72%, rgba(27, 22, 64, .58) 100%);
}
body.in-menu #shade, body.dim #shade { opacity: 1; }
body.dense #shade {
  background:
    radial-gradient(rgba(255, 255, 255, .06) 1.4px, transparent 1.7px) 0 0 / 16px 16px,
    linear-gradient(160deg, rgba(27, 22, 64, .93), rgba(38, 28, 92, .88));
}
body.dim #shade {
  background:
    radial-gradient(rgba(255, 255, 255, .05) 1.4px, transparent 1.7px) 0 0 / 16px 16px,
    rgba(20, 16, 50, .62);
}

/* ---------- elementy wspólne ---------- */
.sticker {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--ink);
}
.panel {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 8px 8px 0 var(--ink);
}
kbd {
  display: inline-block;
  font-family: var(--display);
  font-size: .78em;
  line-height: 1.1;
  min-width: 1.9em;
  padding: .28em .45em .2em;
  margin: 0 .1em;
  text-align: center;
  background: var(--cream);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 7px;
  box-shadow: 0 3px 0 var(--ink);
  vertical-align: middle;
}
kbd.wide { min-width: 5.4em; }

.outline-txt {
  text-shadow: 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink),
    0 2px 0 var(--ink), 0 -2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 4px 0 var(--ink);
}

/* przyciski-naklejki */
.btn {
  --c: var(--yellow);
  --tx: var(--ink);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font-family: var(--display); font-size: 22px; line-height: 1; letter-spacing: .02em;
  color: var(--tx);
  background: var(--c);
  border: 4px solid var(--ink);
  border-radius: 14px;
  padding: .66em 1.05em .56em;
  box-shadow: 6px 6px 0 var(--ink);
  transform: skewX(-7deg);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn > * { transform: skewX(7deg); }
.btn::before {
  content: ''; position: absolute; left: 10px; right: 26%; top: 5px; height: 5px;
  border-radius: 3px; background: rgba(255, 255, 255, .5); pointer-events: none;
}
.btn:hover { transform: skewX(-7deg) translate(-2px, -3px); box-shadow: 9px 9px 0 var(--ink); filter: brightness(1.05); }
.btn:active { transform: skewX(-7deg) translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); transition-duration: .04s; }
.btn:focus-visible, .btn-back:focus-visible, .track-card:focus-visible, .car-tile:focus-visible, .sw:focus-visible {
  outline: 4px dashed #fff; outline-offset: 4px;
}
.btn .ic { width: 1.3em; height: 1.3em; margin: -.2em 0; }
.btn-big { font-size: 32px; }
.btn-small { font-size: 16px; border-width: 3px; border-radius: 11px; box-shadow: 4px 4px 0 var(--ink); padding: .6em .85em .5em; }
.btn-small:hover { box-shadow: 6px 6px 0 var(--ink); }
.btn-small::before { top: 4px; height: 4px; }
.btn-yellow { --c: var(--yellow); }
.btn-red { --c: var(--red); --tx: #fff; }
.btn-green { --c: var(--green); --tx: #fff; }
.btn-blue { --c: var(--blue); --tx: #fff; }
.btn-purple { --c: var(--purple); --tx: #fff; }
.btn-pink { --c: var(--pink); --tx: #fff; }
.btn-red, .btn-green, .btn-blue, .btn-purple, .btn-pink {
  text-shadow: 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink),
    0 2px 0 var(--ink), 0 -2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 4px 0 var(--ink);
}
.btn.off, .btn:disabled {
  --c: #c4bdd3; --tx: #6d6780; text-shadow: none; cursor: not-allowed;
  filter: none; transform: skewX(-7deg); box-shadow: 4px 4px 0 var(--ink);
}
.btn.poor { --c: #c4bdd3; --tx: #5d5770; text-shadow: none; }
.btn.done { --c: #fff; --tx: var(--green-d); text-shadow: none; cursor: default; transform: skewX(-7deg); box-shadow: 4px 4px 0 var(--ink); }
.btn.shake, .shake { animation: shake .42s ease; }
@keyframes shake {
  0%, 100% { translate: 0 0; }
  20% { translate: -9px 0; } 40% { translate: 8px 0; } 60% { translate: -6px 0; } 80% { translate: 4px 0; }
}

.btn-back {
  width: 60px; height: 60px; flex: none;
  border-radius: 50%;
  background: var(--yellow);
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-back .ic { width: 34px; height: 34px; }
.btn-back:hover { transform: translate(-2px, -2px) rotate(-10deg); box-shadow: 6px 6px 0 var(--ink); }
.btn-back:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }

.title {
  font-family: var(--display);
  font-weight: normal;
  font-size: clamp(30px, 4.6vw, 54px);
  line-height: 1;
  color: #fff;
  letter-spacing: .02em;
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 var(--tc, var(--red)), 8px 8px 0 var(--ink);
  transform: rotate(-2deg);
}

/* pasek monet */
#coinbar {
  position: fixed; z-index: 30;
  top: max(14px, var(--safe-t)); right: max(16px, var(--safe-r));
  display: flex; align-items: center; gap: 8px;
  padding: 5px 18px 4px 7px;
  font-family: var(--display); font-size: 26px; line-height: 1.2;
  border-radius: 999px;
  transform: rotate(2deg);
  font-variant-numeric: tabular-nums;
}
#coinbar .ic { width: 36px; height: 36px; }
#coinbar.bump { animation: bump .5s cubic-bezier(.2, 1.8, .4, 1); }
#coinbar.shake { animation: shake .42s ease; }
body:not(.in-menu) #coinbar { display: none; }
@keyframes bump { 0% { scale: 1; } 30% { scale: 1.25; } 100% { scale: 1; } }

/* ---------- ekrany ---------- */
.screen {
  position: fixed; inset: 0; z-index: 5;
  display: none;
  overflow-y: auto; overflow-x: hidden;
  padding: max(18px, var(--safe-t)) max(24px, var(--safe-r)) max(28px, var(--safe-b)) max(24px, var(--safe-l));
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.screen.active { display: block; animation: scr-in .38s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes scr-in { from { opacity: 0; transform: translateY(20px) scale(.985); } to { opacity: 1; transform: none; } }
.scr-head { display: flex; align-items: center; gap: 20px; margin: 4px 0 22px; padding-right: 200px; }
.scr-sub { color: #ddd7ff; margin: -6px 0 20px; font-size: 18px; font-weight: 600; max-width: 780px; }

/* ---------- menu główne ---------- */
#scr-menu.active { display: flex; align-items: flex-start; }
.menu-wrap { padding-left: clamp(4px, 4vw, 72px); padding-bottom: 30px; margin: auto 0; }
.logo {
  display: inline-flex; flex-direction: column;
  margin: 6px 0 30px;
  line-height: .86;
  font-weight: normal;
  transform: rotate(-4deg);
  transform-origin: left center;
  animation: logo-in .7s cubic-bezier(.2, 1.5, .4, 1) both;
}
.logo-top {
  font-family: 'Bungee Shade', var(--display);
  font-size: clamp(56px, 9.4vw, 124px);
  color: var(--yellow);
  text-shadow: 6px 7px 0 var(--ink);
}
.logo-bot {
  font-family: var(--display);
  font-size: clamp(42px, 7.4vw, 96px);
  color: #fff;
  margin-left: .42em;
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  text-shadow: 6px 6px 0 var(--red), 10px 10px 0 var(--ink);
}
.logo::after {
  content: '';
  display: block;
  height: 18px; width: 72%;
  margin: 16px 0 0 .3em;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: repeating-conic-gradient(var(--ink) 0 25%, #fff 0 50%) 0 0 / 18px 18px;
  box-shadow: 4px 4px 0 var(--ink);
  transform: skewX(-18deg);
}
@keyframes logo-in { from { opacity: 0; transform: rotate(-14deg) scale(.6) translateX(-60px); } to { opacity: 1; transform: rotate(-4deg); } }
.menu-btns { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
.menu-btns > * { animation: slide-in .55s cubic-bezier(.2, 1.4, .4, 1) both; }
.menu-btns > :nth-child(1) { animation-delay: .1s; }
.menu-btns > :nth-child(2) { animation-delay: .17s; margin-left: 22px; }
.menu-btns > :nth-child(3) { animation-delay: .24s; margin-left: 44px; }
.menu-btns > :nth-child(4) { animation-delay: .31s; margin-left: 66px; }
.menu-btns > :nth-child(5) { animation-delay: .38s; margin-left: 88px; }
.menu-row { display: flex; gap: 16px; }
@keyframes slide-in { from { opacity: 0; translate: -120px 0; } to { opacity: 1; translate: 0 0; } }
.menu-car {
  position: absolute;
  right: clamp(16px, 5vw, 90px);
  bottom: clamp(70px, 12vh, 120px);
  width: 270px;
  padding: 12px 14px 12px;
  transform: rotate(3deg);
  animation: card-in .6s .35s cubic-bezier(.2, 1.4, .4, 1) both;
  cursor: pointer;
}
.menu-car:hover { transform: rotate(0deg) scale(1.03); }
@keyframes card-in { from { opacity: 0; translate: 0 60px; } to { opacity: 1; translate: 0 0; } }
.menu-car canvas { display: block; width: 100%; height: 150px; }
.mc-label {
  display: inline-block;
  font-family: var(--display); font-size: 13px;
  background: var(--ink); color: var(--yellow);
  padding: 4px 10px 2px; border-radius: 7px;
  transform: rotate(-3deg);
}
.mc-name { font-family: var(--display); font-size: 26px; line-height: 1.1; text-align: center; }
.mc-stats { display: flex; justify-content: center; gap: 14px; margin-top: 4px; font-weight: 800; font-size: 15px; color: var(--text2); }
.mc-stats span { display: inline-flex; align-items: center; gap: 4px; }
.mc-stats .ic { width: 22px; height: 22px; }
.menu-hint {
  position: absolute; left: 50%; bottom: max(12px, var(--safe-b));
  transform: translateX(-50%);
  color: #cfc8ff; font-size: 15px; font-weight: 700; white-space: nowrap;
}

/* ---------- wybór toru ---------- */
.tracks-car {
  display: flex; align-items: center; gap: 14px;
  width: fit-content;
  padding: 8px 12px 8px 8px;
  margin: -4px 0 26px;
  transform: rotate(-1deg);
}
.tracks-car canvas { width: 92px; height: 50px; display: block; }
.tracks-car small { display: block; font-family: var(--display); font-size: 11px; color: var(--muted); }
.tracks-car b { font-family: var(--display); font-size: 21px; font-weight: normal; line-height: 1; }
.tracks-car .btn { margin-left: 8px; }
.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
  max-width: 1200px;
  padding-bottom: 20px;
}
.track-card {
  position: relative;
  display: block;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  transform: rotate(var(--rot, 0deg));
  transition: transform .15s ease, box-shadow .15s ease;
  animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1) both;
  animation-delay: var(--d, 0s);
}
.track-card:hover { transform: rotate(0deg) translate(-3px, -5px); box-shadow: 13px 13px 0 var(--ink); }
.track-card:active { transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--ink); }
@keyframes pop-in { from { opacity: 0; scale: .8; } to { opacity: 1; scale: 1; } }
.track-card.shake { animation: shake .42s ease; }
.no-anim > *, .no-anim > * > * { animation: none !important; }
.track-card canvas { display: block; width: 100%; aspect-ratio: 16 / 10; border-bottom: 4px solid var(--ink); }
.tc-num {
  position: absolute; top: 10px; left: 10px;
  font-family: var(--display); font-size: 18px;
  background: var(--yellow);
  border: 3px solid var(--ink); border-radius: 10px;
  padding: 3px 10px 1px;
  box-shadow: 3px 3px 0 var(--ink);
}
.tc-theme {
  position: absolute; top: 12px; right: 10px;
  font-family: var(--display); font-size: 12px;
  background: var(--ink); color: #fff;
  border-radius: 8px; padding: 4px 9px 2px;
}
.tc-body { padding: 10px 16px 14px; }
.tc-name { font-family: var(--display); font-size: 23px; line-height: 1.05; }
.tc-desc { font-size: 15.5px; line-height: 1.25; margin: 6px 0 12px; color: var(--text2); font-weight: 600; min-height: 2.5em; }
.tc-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tc-reward { display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-size: 19px; }
.tc-reward .ic { width: 26px; height: 26px; }
.tc-reward small { font-family: var(--body); font-weight: 800; font-size: 13px; color: var(--muted); margin-right: 2px; }
.tc-best { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 14px; color: var(--muted); }
.medal {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--ink);
  font-family: var(--display); font-size: 14px; color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
.medal.m1 { background: #ffd23f; }
.medal.m2 { background: #dfe3ec; }
.medal.m3 { background: #e7a066; }
.medal.mx { background: #fff; }
.track-card.locked { cursor: not-allowed; }
.track-card.locked canvas { filter: grayscale(1) brightness(.5); }
.track-card.locked .tc-name, .track-card.locked .tc-desc, .track-card.locked .tc-meta { opacity: .55; }
.tc-lock {
  position: absolute; left: 0; right: 0; top: 0;
  aspect-ratio: 16 / 10;
  display: grid; place-items: center; align-content: center; gap: 8px;
  padding: 14px;
  text-align: center;
  color: #fff;
  font-family: var(--display); font-size: 15px; line-height: 1.2;
  text-shadow: 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink), 0 3px 0 var(--ink);
}
.tc-lock .ic { width: 62px; height: 62px; filter: drop-shadow(3px 3px 0 var(--ink)); }
.track-card.new::after {
  content: 'NOWY!';
  position: absolute; top: 46px; left: -36px;
  width: 150px; padding: 4px 0 2px;
  text-align: center;
  font-family: var(--display); font-size: 14px;
  background: var(--pink); color: #fff;
  border-block: 3px solid var(--ink);
  transform: rotate(-35deg);
}

/* ---------- garaż ---------- */
.garage { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; max-width: 1260px; align-items: start; }
.car-list { display: flex; flex-direction: column; gap: 12px; padding: 4px 14px 14px 0; }
.car-tile {
  display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--cream);
  border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform .12s ease, background .12s ease;
}
.car-tile:hover { transform: translateX(5px); }
.car-tile.sel { background: var(--yellow); transform: translateX(12px) rotate(-1.2deg); box-shadow: 6px 6px 0 var(--ink); }
.car-tile canvas { width: 100px; height: 54px; display: block; }
.ct-name { font-family: var(--display); font-size: 17px; line-height: 1.1; }
.ct-sub { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: 14.5px; color: var(--text2); }
.ct-sub .ic { width: 19px; height: 19px; }
.ct-sub.owned { color: var(--green-d); }
.ct-sub.cur { color: var(--ink); }
.ct-sub.poor { color: #9a93ad; }
.car-detail { padding: 22px; min-width: 0; }
.cd-top { display: grid; grid-template-columns: minmax(220px, 330px) minmax(0, 1fr); gap: 24px; }
.cd-stage {
  position: relative;
  aspect-ratio: 1;
  border: 4px solid var(--ink); border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 52%, #fffdf3 0, #ffe9a6 34%, #ffc63a 68%, #ff9b1c 100%);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .12);
}
.cd-stage::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(rgba(20, 18, 31, .14) 1.6px, transparent 1.8px) 0 0 / 13px 13px;
}
.cd-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cd-lock { position: absolute; top: 10px; right: 10px; display: none; }
.cd-lock.show { display: block; }
.cd-lock .ic { width: 46px; height: 46px; filter: drop-shadow(3px 3px 0 var(--ink)); }
#cd-name { font-family: var(--display); font-weight: normal; font-size: clamp(28px, 3.4vw, 42px); line-height: 1; margin-bottom: 6px; }
#cd-desc { font-size: 17.5px; line-height: 1.3; color: var(--text2); font-weight: 600; margin-bottom: 10px; }
.cd-perks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.perk {
  display: inline-flex; flex-direction: column;
  background: var(--purple); color: #fff;
  border: 3px solid var(--ink); border-radius: 12px;
  padding: 3px 12px 3px;
  box-shadow: 3px 3px 0 var(--ink);
  line-height: 1.15;
}
.perk b { font-family: var(--display); font-weight: normal; font-size: 14px; }
.perk small { font-size: 13px; font-weight: 700; opacity: .95; }
.stat { display: grid; grid-template-columns: 128px minmax(0, 1fr) 44px; align-items: center; gap: 10px; margin: 8px 0; }
.stat-l { font-weight: 800; font-size: 15.5px; }
.stat-bar { display: flex; height: 20px; border: 3px solid var(--ink); border-radius: 10px; background: #eadfc4; overflow: hidden; }
.stat-base { height: 100%; background: var(--sc); transition: width .35s cubic-bezier(.2, 1.3, .4, 1); }
.stat-bonus {
  height: 100%;
  background: repeating-linear-gradient(-45deg, var(--sc) 0 6px, #fff 6px 10px);
  border-left: 2px solid var(--ink);
  transition: width .35s cubic-bezier(.2, 1.3, .4, 1);
}
.stat-bonus[style*="width: 0"] { border-left: none; }
.stat-v { font-family: var(--display); font-size: 15px; text-align: right; }
.cd-bottom { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; margin-top: 20px; }
.cd-block h4 { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: normal; font-size: 17px; margin-bottom: 10px; }
.cd-block h4 .ic { width: 26px; height: 26px; }
.upg {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 8px 10px 8px 12px; margin-bottom: 10px;
  background: #fff;
  border: 3px solid var(--ink); border-radius: 14px;
}
.upg-name { font-weight: 800; font-size: 16.5px; line-height: 1.1; }
.upg-name small { display: block; font-weight: 600; font-size: 13px; color: var(--muted); }
.pips { display: flex; gap: 4px; }
.pip { width: 14px; height: 20px; border: 2.5px solid var(--ink); border-radius: 4px; background: #eadfc4; transform: skewX(-10deg); }
.pip.on { background: var(--green); }
.pip.pop { animation: pip-pop .5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes pip-pop { 0% { scale: 1; } 40% { scale: 1.6; background: #fff; } 100% { scale: 1; } }
.upg .btn { min-width: 104px; }
.cd-paints { display: flex; flex-wrap: wrap; gap: 10px; }
.sw {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--sw);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .1s ease;
}
.sw:hover { transform: scale(1.14); }
.sw.sel { box-shadow: 0 0 0 3px var(--cream), 0 0 0 6px var(--ink); transform: scale(1.08); }
.sw .ic { position: absolute; right: -8px; bottom: -6px; width: 20px; height: 20px; }
.sw.dis { cursor: default; }
.cd-paint-name { margin-top: 10px; font-weight: 800; font-size: 15.5px; min-height: 1.4em; display: flex; align-items: center; gap: 6px; }
.cd-paint-name .ic { width: 20px; height: 20px; }
.cd-action { display: flex; gap: 16px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 3px dashed var(--dash); }
.cd-note { margin-right: auto; font-weight: 800; color: var(--muted); font-size: 16px; }

/* ---------- sklep ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 26px; max-width: 1260px; padding-bottom: 20px; }
.gcard {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 18px 18px;
  transform: rotate(var(--rot, 0deg));
  animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1) both;
  animation-delay: var(--d, 0s);
}
.gc-top { display: flex; gap: 14px; align-items: center; }
.gc-icon {
  width: 74px; height: 74px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gc);
  border: 4px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.gc-icon .ic { width: 46px; height: 46px; filter: drop-shadow(2px 2px 0 rgba(20, 18, 31, .35)); }
.gc-name { font-family: var(--display); font-size: 24px; line-height: 1; }
.gc-key { margin-top: 6px; font-weight: 800; font-size: 14px; color: var(--muted); }
.gc-desc { font-size: 16.5px; line-height: 1.3; color: var(--text2); font-weight: 600; min-height: 2.6em; }
.gc-info { font-size: 14.5px; font-weight: 800; background: #fff; border: 2.5px dashed #cdbf9f; border-radius: 12px; padding: 6px 10px; line-height: 1.35; }
.gc-info .now { color: var(--ink); }
.gc-info .next { color: var(--green-d); }
.gc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 4px; }
.gc-lvl { display: flex; flex-direction: column; gap: 4px; font-family: var(--display); font-size: 12px; color: var(--muted); }
.gcard.owned .gc-icon { animation: none; }
.gcard .stamp {
  position: absolute; top: -17px; right: 18px; z-index: 1;
  font-family: var(--display); font-size: 13px;
  color: var(--green-d);
  border: 3px solid var(--green-d); border-radius: 8px;
  padding: 3px 8px 1px;
  transform: rotate(8deg);
  background: var(--cream);
  box-shadow: 2px 2px 0 var(--green-d);
}
.gcard .stamp.max { box-shadow: 2px 2px 0 #b8860b; }
.gcard .stamp.max { color: #b8860b; border-color: #b8860b; }

/* ---------- opcje ---------- */
.options { max-width: 760px; padding: 10px 26px 14px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 3px dashed var(--dash); flex-wrap: wrap; }
.opt-l { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 19px; }
.opt-l .ic { width: 34px; height: 34px; }
.toggle {
  position: relative;
  width: 80px; height: 42px;
  border-radius: 999px;
  border: 4px solid var(--ink);
  background: #d6cdb6;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: background .2s ease;
}
.toggle span {
  position: absolute; top: 3px; left: 3px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink);
  transition: left .22s cubic-bezier(.3, 1.6, .5, 1);
}
.toggle.on { background: var(--green); }
.toggle.on span { left: 40px; }
.seg { display: flex; border: 4px solid var(--ink); border-radius: 12px; overflow: hidden; box-shadow: 3px 3px 0 var(--ink); }
.seg button { font-family: var(--display); font-size: 14px; padding: 9px 14px 7px; background: #fff; border-left: 3px solid var(--ink); cursor: pointer; }
.seg button:first-child { border-left: none; }
.seg button.on { background: var(--yellow); }
#opt-name {
  width: 240px; max-width: 100%;
  font-family: var(--display); font-size: 18px;
  padding: 9px 12px 7px;
  border: 4px solid var(--ink); border-radius: 12px;
  background: #fff; color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  outline: none;
}
#opt-name:focus { background: #fffbe0; }
.opt-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 16px 0; border-bottom: 3px dashed var(--dash); }
.ost { text-align: center; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 4px 6px; }
.ost b { display: block; font-family: var(--display); font-weight: normal; font-size: 24px; line-height: 1.1; }
.ost span { font-size: 13px; font-weight: 800; color: var(--muted); }
.opt-danger { border-bottom: none; }

/* ---------- jak grać ---------- */
.help-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 26px; max-width: 1160px; align-items: start; }
.help-box { padding: 18px 24px 20px; }
.help-box h3 { font-family: var(--display); font-weight: normal; font-size: 22px; margin-bottom: 10px; }
.keys li { display: flex; align-items: center; gap: 12px; padding: 5px 0; font-weight: 700; font-size: 17px; }
.keys .kk { min-width: 158px; display: inline-flex; gap: 2px; }
.tips li { display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; font-size: 17px; line-height: 1.3; font-weight: 600; }
.tips .ic { width: 34px; height: 34px; margin-top: -2px; }
.tips b { font-weight: 800; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-family: var(--display); }
.hud-tl { position: absolute; top: max(12px, var(--safe-t)); left: max(12px, var(--safe-l)); display: flex; gap: 10px; align-items: flex-start; }
.h-posbox { padding: 4px 14px 5px; text-align: center; background: var(--yellow); transform: rotate(-3deg); }
.h-pos { font-size: 48px; line-height: 1; }
.h-pos small { font-size: 22px; }
.h-poslabel { font-size: 11px; letter-spacing: .12em; margin-top: -2px; }
.h-posbox.up { animation: pos-up .5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes pos-up { 0% { scale: 1; } 35% { scale: 1.3; background: #7dff9a; } 100% { scale: 1; } }
.h-lapbox { padding: 6px 12px 5px; }
.h-lap { font-size: 13px; line-height: 1.1; }
.h-lap b { font-size: 23px; font-weight: normal; }
.h-time { font-size: 18px; color: #5a5470; font-variant-numeric: tabular-nums; line-height: 1.2; }
.hud-coins {
  position: absolute; top: max(12px, var(--safe-t)); left: 50%;
  transform: translateX(-50%) rotate(1.5deg);
  display: flex; align-items: center; gap: 8px;
  padding: 3px 16px 2px 5px;
  font-size: 26px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.hud-coins .ic { width: 34px; height: 34px; }
.hud-coins.bump { animation: bump .35s cubic-bezier(.2, 1.8, .4, 1); }
.hud-tr { position: absolute; top: max(12px, var(--safe-t)); right: max(12px, var(--safe-r)); display: flex; gap: 10px; align-items: flex-start; }
.hud-map { padding: 4px; border-radius: 14px; background: rgba(255, 247, 230, .86); }
.hud-map canvas { display: block; width: 200px; height: 146px; }
.h-btn {
  pointer-events: auto;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--yellow);
  border: 4px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  touch-action: none;
}
.h-btn .ic { width: 26px; height: 26px; }
.h-btncol { display: flex; flex-direction: column; gap: 10px; }
.h-cam { background: var(--blue); }
.h-cam .ic { width: 30px; height: 30px; }
.h-btn.on { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.hud-bl { position: absolute; left: max(16px, var(--safe-l)); bottom: max(16px, var(--safe-b)); }
.h-speed {
  font-size: 52px; line-height: 1;
  color: #fff;
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.h-speed small { font-size: 17px; margin-left: 6px; -webkit-text-stroke: 5px var(--ink); }
.h-speed.turbo { color: #ffb02e; }
.h-hp { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.h-hp .ic { width: 36px; height: 36px; filter: drop-shadow(2px 2px 0 var(--ink)); }
.h-hptrack { width: 220px; height: 24px; border: 4px solid var(--ink); border-radius: 12px; background: rgba(20, 18, 31, .65); overflow: hidden; box-shadow: 3px 3px 0 var(--ink); }
.h-hpfill { height: 100%; width: 100%; background: var(--green); border-right: 3px solid var(--ink); transition: width .15s ease, background .3s ease; }
.h-hp.mid .h-hpfill { background: var(--yellow); }
.h-hp.low .h-hpfill { background: var(--red); }
.h-hp.low .ic { animation: beat .45s ease-in-out infinite alternate; }
@keyframes beat { from { scale: 1; } to { scale: 1.25; } }
.hud-gadgets { position: absolute; left: 50%; bottom: max(22px, var(--safe-b)); transform: translateX(-50%); display: flex; gap: 12px; }
.gslot {
  pointer-events: auto;
  position: relative;
  width: 66px; height: 66px;
  border-radius: 18px;
  background: var(--cream);
  border: 4px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  touch-action: none;
  transition: transform .06s ease, opacity .2s ease;
}
.gslot .ic { position: relative; width: 40px; height: 40px; }
.gslot .cnt {
  position: absolute; top: -12px; right: -12px;
  min-width: 30px; height: 30px; padding: 0 6px;
  border-radius: 15px;
  background: var(--ink); color: #fff;
  border: 3px solid var(--cream);
  font-size: 14px; font-weight: normal; line-height: 24px; text-align: center;
}
.gslot kbd { position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); font-size: 10px; padding: 3px 5px 1px; min-width: 0; box-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
.gslot .lvl { position: absolute; left: 0; right: 0; bottom: 0; height: var(--f, 100%); background: #ffc98a; border-radius: 0 0 13px 13px; }
.gslot.empty { opacity: .55; filter: grayscale(.9); }
.gslot.live { background: #c8f7ff; box-shadow: 0 0 0 4px var(--cyan), 3px 3px 0 var(--ink); }
.gslot.on { transform: translate(2px, 2px) scale(.95); box-shadow: 1px 1px 0 var(--ink); }
.gslot.used { animation: slot-used .3s ease; }
@keyframes slot-used { 0% { scale: 1; } 40% { scale: 1.22; } 100% { scale: 1; } }
.gslot.passive { cursor: default; background: #ffe0dc; }
.h-big {
  position: absolute; left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  font-size: clamp(50px, 9vw, 124px); line-height: 1;
  color: var(--yellow);
  -webkit-text-stroke: 11px var(--ink);
  paint-order: stroke fill;
  text-shadow: 7px 7px 0 var(--ink);
  white-space: nowrap;
  opacity: 0;
}
.h-big.show { animation: big-pop 1s cubic-bezier(.2, 1.6, .4, 1) both; }
.h-big.small { font-size: clamp(30px, 5.2vw, 66px); -webkit-text-stroke: 9px var(--ink); }
.h-big.red { color: var(--red); }
.h-big.green { color: #4dff7a; }
.h-big.white { color: #fff; }
.h-big.pink { color: var(--pink); }
@keyframes big-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-12deg); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.14) rotate(3deg); }
  24% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  82% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.25) rotate(-2deg); }
}
.h-wrong {
  position: absolute; left: 50%; top: 21%;
  transform: translateX(-50%) rotate(-2deg);
  display: none;
  text-align: center;
  font-size: clamp(26px, 4vw, 44px); line-height: 1.05;
  color: #fff;
  background: var(--red);
  border: 4px solid var(--ink); border-radius: 16px;
  padding: 10px 22px 8px;
  box-shadow: 6px 6px 0 var(--ink);
}
.h-wrong small { display: block; font-family: var(--body); font-weight: 800; font-size: 16px; margin-top: 2px; }
.h-wrong.show { display: block; animation: wobble .5s ease-in-out infinite alternate; }
@keyframes wobble { from { rotate: -2deg; } to { rotate: 2deg; } }
.h-hit {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(255, 40, 40, .55) 100%);
  opacity: 0;
  transition: opacity .4s ease;
}
.h-hit.on { opacity: 1; transition: none; }

/* ---------- sterowanie dotykowe ---------- */
#touch { position: fixed; inset: 0; z-index: 11; pointer-events: none; }
#t-steer { position: absolute; left: 0; bottom: 0; width: 46%; height: 64%; pointer-events: auto; touch-action: none; }
.t-ar {
  position: absolute; bottom: max(24px, var(--safe-b));
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(255, 247, 230, .32);
  border: 4px solid rgba(20, 18, 31, .75);
  box-shadow: 3px 3px 0 rgba(20, 18, 31, .5);
  transition: background .08s ease;
}
.t-ar::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 38px; height: 44px;
  background: var(--ink);
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
  translate: -3px 0;
}
.t-left { left: max(22px, var(--safe-l)); }
.t-right { left: calc(max(22px, var(--safe-l)) + 124px); }
.t-right::after { clip-path: polygon(0 0, 100% 50%, 0 100%); translate: 3px 0; }
#t-steer.left .t-left, #t-steer.right .t-right { background: rgba(255, 210, 63, .95); scale: .94; }
.t-btn {
  position: absolute;
  pointer-events: auto; touch-action: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 4px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--display);
}
.t-btn.on { scale: .92; filter: brightness(1.15); }
.t-brake {
  right: max(22px, var(--safe-r)); bottom: max(24px, var(--safe-b));
  width: 108px; height: 108px;
  background: rgba(255, 75, 62, .92); color: #fff; font-size: 16px;
  text-shadow: 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink);
}
.t-reset { right: max(22px, var(--safe-r)); bottom: calc(max(24px, var(--safe-b)) + 126px); width: 54px; height: 54px; background: rgba(255, 247, 230, .92); }
.t-reset .ic { width: 28px; height: 28px; }
body.touch-mode .hud-gadgets {
  left: auto; transform: none;
  right: calc(max(22px, var(--safe-r)) + 124px);
  bottom: max(24px, var(--safe-b));
  width: 240px;
  flex-wrap: wrap-reverse; justify-content: flex-end; gap: 12px;
}
body.touch-mode .gslot { width: 68px; height: 68px; border-radius: 50%; }
body.touch-mode .gslot .lvl { border-radius: 0 0 34px 34px; }
body.touch-mode .gslot kbd { display: none; }
body.touch-mode .gslot.passive { display: none; }
body.touch-mode .hud-bl { bottom: auto; top: calc(max(12px, var(--safe-t)) + 88px); }
body.touch-mode .h-speed { font-size: 34px; }
body.touch-mode .h-hptrack { width: 160px; }
body.touch-mode #h-wrong-hint { display: none; }

/* ---------- pauza ---------- */
#scr-pause.active, #scr-results.active { display: grid; place-items: center; }
.center-box { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 26px 36px 28px; min-width: 330px; }
.pause-box .title { margin-bottom: 8px; }
.pause-box .btn { width: 100%; }
.pause-toggles { display: flex; gap: 12px; margin-top: 4px; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--display); font-size: 13px;
  padding: 6px 14px 4px 8px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}
.chip-toggle .ic { width: 24px; height: 24px; }
.chip-toggle.on { background: var(--green); color: #fff; }
.chip-toggle:not(.on) span { text-decoration: line-through; opacity: .6; }

/* ---------- wyniki ---------- */
.res-wrap { width: min(1080px, 100%); display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 6px 0 10px; }
.res-place { display: flex; align-items: center; gap: 20px; animation: big-in .7s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes big-in { from { opacity: 0; transform: scale(.4) rotate(-10deg); } to { opacity: 1; transform: none; } }
.rp-medal {
  width: 112px; height: 112px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 5px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  font-family: var(--display); font-size: 58px; line-height: 1;
  background: var(--mc, #fff);
  position: relative;
  animation: medal-spin 1s .2s cubic-bezier(.2, 1.4, .4, 1) both;
}
.rp-medal::before {
  content: ''; position: absolute; inset: 9px;
  border-radius: 50%;
  border: 3px dashed rgba(20, 18, 31, .4);
}
@keyframes medal-spin { from { transform: rotateY(540deg) scale(.5); } to { transform: none; } }
.rp-text { font-family: var(--display); font-size: clamp(40px, 6vw, 78px); line-height: 1; color: var(--yellow); -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; text-shadow: 6px 6px 0 var(--ink); transform: rotate(-2deg); }
.rp-sub { font-weight: 800; font-size: 21px; color: #fff; margin-top: 8px; text-shadow: 2px 2px 0 var(--ink); }
.res-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; width: 100%; }
.res-box { padding: 16px 20px 18px; }
.res-box h3 { font-family: var(--display); font-weight: normal; font-size: 20px; margin-bottom: 8px; }
.res-list li {
  display: grid; grid-template-columns: 34px 66px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 3px 8px; border-radius: 12px;
  font-weight: 800; font-size: 16px;
  border: 3px solid transparent;
  animation: rew-in .4s ease both;
}
.res-list li.me { background: var(--yellow); border-color: var(--ink); }
.rl-pos { font-family: var(--display); font-size: 19px; text-align: center; }
.res-list canvas { width: 66px; height: 36px; display: block; }
.rl-name { line-height: 1.08; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-name small { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.res-list li.me .rl-name small { color: var(--text2); }
.rl-time { font-family: var(--display); font-size: 14px; font-variant-numeric: tabular-nums; }
.rl-time.dnf { color: var(--muted); font-size: 12px; }
.rew-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 2px;
  border-bottom: 3px dashed var(--dash);
  font-weight: 800; font-size: 17px;
  animation: rew-in .4s ease both;
}
.rew-row span { display: flex; align-items: center; gap: 8px; }
.rew-row .ic { width: 24px; height: 24px; }
.rew-row b { font-family: var(--display); font-weight: normal; color: var(--green-d); white-space: nowrap; }
.rew-row.zero b { color: var(--muted); }
@keyframes rew-in { from { opacity: 0; translate: 30px 0; } to { opacity: 1; translate: 0 0; } }
.res-total {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px;
  padding: 8px 14px 6px;
  font-family: var(--display); font-size: 25px;
  background: var(--ink); color: var(--yellow);
  border-radius: 14px;
}
.res-total b { display: flex; align-items: center; gap: 8px; font-weight: normal; font-variant-numeric: tabular-nums; }
.res-total .ic { width: 32px; height: 32px; }
.xnote {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px;
  padding: 8px 12px;
  border: 3px solid var(--ink); border-radius: 14px;
  font-weight: 800; font-size: 16px; line-height: 1.25;
  background: #d7ffe3;
  box-shadow: 3px 3px 0 var(--ink);
  animation: pop-in .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.xnote .ic { width: 32px; height: 32px; }
.xnote.gold { background: #fff1b3; }
.xnote.pink { background: #ffd9ec; }
.res-btns { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; }

/* ---------- gra sieciowa ---------- */
.online { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 26px; max-width: 1160px; align-items: start; }
.net-box { padding: 16px 22px 20px; }
.net-box h3 { font-family: var(--display); font-weight: normal; font-size: 20px; margin: 4px 0 10px; display: flex; align-items: center; gap: 10px; }
.net-new { display: flex; flex-direction: column; align-items: flex-start; }
.net-new .btn { margin-top: 16px; align-self: stretch; }
.net-field { display: flex; flex-direction: column; gap: 8px; width: 100%; padding-bottom: 16px; margin-bottom: 12px; border-bottom: 3px dashed var(--dash); }
.name-input {
  width: 100%;
  font-family: var(--display); font-size: 18px;
  padding: 9px 12px 7px;
  border: 4px solid var(--ink); border-radius: 12px;
  background: #fff; color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  outline: none;
}
.name-input:focus { background: #fffbe0; }
.net-hint { font-size: 15px; font-weight: 700; color: var(--muted); line-height: 1.25; }
.net-bots button { display: inline-flex; align-items: center; gap: 6px; }
.net-bots .ic { width: 22px; height: 22px; margin: -4px 0 -2px; }
.net-bots.locked button { cursor: default; }
.net-bots.locked button:not(.on) { color: var(--muted); }
#net-bots-hint { margin-top: 10px; min-height: 2.5em; }
.net-status { font-weight: 800; font-size: 16px; color: var(--text2); display: flex; align-items: center; gap: 10px; }
.net-status:empty { display: none; }
.net-status .ld-wheel { width: 26px; height: 26px; border-width: 5px; }
.net-status.bad { color: #c22d22; }
.room-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.room-list li {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 8px 12px 8px 8px;
  background: #fff;
  border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 3px 3px 0 var(--ink);
  animation: rew-in .35s ease both;
}
.room-list li.busy { background: #ece6f5; }
.room-list canvas { width: 112px; height: 70px; display: block; border-radius: 10px; border: 2px solid var(--ink); background: #fff; }
.rm-host { font-family: var(--display); font-size: 19px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-host small { display: block; font-family: var(--body); font-size: 13px; font-weight: 800; color: var(--muted); }
.rm-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-weight: 800; font-size: 15px; color: var(--text2); }
.rm-meta span { display: inline-flex; align-items: center; gap: 5px; }
.rm-meta .ic { width: 20px; height: 20px; }
.rm-state { font-family: var(--display); font-size: 13px; color: var(--muted); text-align: center; line-height: 1.15; }
.room-list li.room-empty { display: block; background: none; border: none; box-shadow: none; animation: none; font-weight: 700; font-size: 17px; color: var(--text2); padding: 10px 2px; line-height: 1.3; }

.lobby { display: grid; grid-template-columns: minmax(0, 430px) minmax(0, 1fr); gap: 26px; max-width: 1160px; align-items: start; }
.lobby-set { display: flex; flex-direction: column; align-items: flex-start; }
.lt-stage { display: flex; align-items: center; gap: 10px; width: 100%; }
.lt-stage canvas { flex: 1; min-width: 0; width: 100%; aspect-ratio: 480 / 300; height: auto; display: block; border-radius: 14px; border: 3px solid var(--ink); background: #fff; }
.lt-arrow {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  background: var(--yellow);
  border: 4px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
}
.lt-arrow .ic { width: 24px; height: 24px; }
.lt-next .ic { transform: scaleX(-1); }
.lt-arrow:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.lobby-set.guest .lt-arrow { visibility: hidden; }
.lt-name { font-family: var(--display); font-size: 24px; line-height: 1.1; margin: 10px 0 14px; align-self: center; text-align: center; }
.lt-name small { display: block; font-family: var(--body); font-size: 15px; font-weight: 800; color: var(--muted); }
.lobby-count { font-size: 16px; color: var(--muted); }
.lobby-list { display: flex; flex-direction: column; gap: 8px; }
.lobby-list li {
  display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 4px 12px 4px 6px; min-height: 50px;
  background: #fff;
  border: 3px solid var(--ink); border-radius: 14px;
  font-weight: 800;
}
.lobby-list li.me { background: var(--yellow); }
.lobby-list li.slot { background: transparent; border-style: dashed; border-color: #b9ab8c; color: var(--muted); }
.lobby-list li.slot.bot { color: var(--text2); }
.lobby-list canvas { width: 74px; height: 40px; display: block; }
.lobby-list .slot-ic { display: grid; place-items: center; }
.lobby-list .slot-ic .ic { width: 30px; height: 30px; }
.lobby-list li.slot:not(.bot) .slot-ic { opacity: .35; }
.ll-name { line-height: 1.1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
.ll-name small { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.lobby-list li.me .ll-name small { color: var(--text2); }
.ll-tags { display: flex; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--body); font-weight: 800; font-size: 14px; line-height: 1; letter-spacing: .04em;
  padding: 4px 9px 3px; border-radius: 8px;
  background: var(--ink); color: #fff;
}
.tag .ic { width: 16px; height: 16px; margin: -3px 0 -1px; }
.tag.host { background: var(--purple); }
.tag.you { background: var(--green-d); }
.tag.racing { background: var(--orange); color: var(--ink); }
.lobby-cars { margin-top: 16px; padding-top: 12px; border-top: 3px dashed var(--dash); }
.lobby-cars-row { display: flex; gap: 10px; overflow-x: auto; padding: 10px 4px 6px; }
.lobby-cars-row button {
  flex: none; width: 118px;
  padding: 4px 6px 6px;
  background: #fff;
  border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--display); font-size: 12px; line-height: 1.1;
  cursor: pointer;
}
.lobby-cars-row button.sel { background: var(--yellow); transform: translateY(-3px); }
.lobby-cars-row canvas { width: 100%; height: 44px; display: block; }
.lobby-foot { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 14px 26px; max-width: 1160px; margin-top: 24px; }
.lobby-note { flex: 1; min-width: 240px; color: #fff; font-weight: 800; font-size: 19px; text-shadow: 2px 2px 0 var(--ink); line-height: 1.3; }
.lobby-cd { display: inline-block; min-width: 1.5em; text-align: center; font-family: var(--display); font-weight: normal; font-size: 1.35em; color: var(--yellow); }
.rl-bot { display: inline-block; vertical-align: 2px; margin-left: 6px; font-family: var(--display); font-size: 10px; padding: 3px 5px 1px; border-radius: 6px; background: var(--ink); color: #fff; }

/* ---------- okno, komunikaty, ładowanie ---------- */
#modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(14, 10, 36, .62); }
.modal-box { max-width: 480px; padding: 24px 30px 28px; text-align: center; animation: big-in .4s cubic-bezier(.2, 1.5, .4, 1) both; }
.modal-text { font-size: 21px; font-weight: 800; line-height: 1.3; margin-bottom: 22px; }
.modal-text canvas { display: block; margin: 0 auto 8px; width: 180px; height: 96px; }
.modal-text .mt-price { display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-weight: normal; }
.modal-text .mt-price .ic { width: 26px; height: 26px; }
.modal-btns { display: flex; gap: 18px; justify-content: center; }
#toasts {
  position: fixed; z-index: 60;
  left: 50%; bottom: 96px;
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 10px;
  pointer-events: none;
}
body.racing #toasts { bottom: auto; top: 96px; flex-direction: column; }
.toast {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-size: 18px; line-height: 1.2;
  color: #fff;
  background: var(--ink);
  border: 3px solid var(--yellow);
  border-radius: 14px;
  padding: 8px 16px 6px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .35);
  white-space: nowrap;
  animation: toast-in .3s cubic-bezier(.2, 1.5, .4, 1) both, toast-out .4s ease 2.3s forwards;
}
.toast .ic { width: 26px; height: 26px; }
.toast.bad { border-color: var(--red); }
.toast.good { border-color: var(--green); }
@keyframes toast-in { from { opacity: 0; translate: 0 20px; scale: .7; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes toast-out { to { opacity: 0; translate: 0 -14px; } }
#loading {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  background: rgba(14, 10, 36, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
}
#loading.show { opacity: 1; pointer-events: auto; }
.ld-box { display: flex; align-items: center; gap: 14px; padding: 14px 22px 12px; font-family: var(--display); font-size: 22px; }
.ld-wheel { width: 42px; height: 42px; border-radius: 50%; border: 7px dashed var(--ink); background: var(--yellow); animation: spin .9s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; }

/* DOM-owe konfetti po zakupie */
.conf { position: fixed; z-index: 65; width: 10px; height: 14px; pointer-events: none; border: 2px solid var(--ink); border-radius: 2px; }

/* ---------- mniejsze ekrany ---------- */
@media (max-width: 1100px) {
  .garage { grid-template-columns: 250px minmax(0, 1fr); }
  .cd-top { grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); }
  .cd-bottom { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .garage { grid-template-columns: minmax(0, 1fr); }
  .car-list { flex-direction: row; overflow-x: auto; padding: 4px 4px 14px; }
  .car-tile { min-width: 210px; }
  .car-tile.sel { transform: translateY(-4px) rotate(-1deg); }
  .help-cols, .res-cols { grid-template-columns: minmax(0, 1fr); }
  .online, .lobby { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 16px; }
  .menu-car { display: none; }
  .scr-head { padding-right: 160px; }
  .opt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cd-top { grid-template-columns: minmax(0, 1fr); }
  .cd-stage { max-width: 300px; }
  .scr-head { padding-right: 0; padding-top: 52px; }
  .btn-big { font-size: 24px; }
  .menu-hint { display: none; }
  .hud-map canvas { width: 130px; height: 95px; }
  .online, .lobby { grid-template-columns: minmax(0, 1fr); }
  .lobby-list li { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px; }
  .lobby-list canvas { width: 56px; height: 30px; }
  .tag { font-size: 12px; padding: 3px 6px 2px; }
}
@media (max-height: 620px) {
  .logo { margin-bottom: 18px; }
  .logo-top { font-size: clamp(44px, 8vw, 76px); }
  .logo-bot { font-size: clamp(34px, 6.4vw, 60px); }
  .logo::after { height: 12px; margin-top: 10px; background-size: 12px 12px; }
  .btn { font-size: 18px; }
  .btn-big { font-size: 24px; }
  .menu-btns { gap: 14px; }
  .menu-car { width: 220px; bottom: 54px; }
  .menu-car canvas { height: 110px; }
  .menu-hint { display: none; }
  .hud-map canvas { width: 150px; height: 110px; }
  .h-pos { font-size: 36px; }
  .h-speed { font-size: 38px; }
  .gslot { width: 56px; height: 56px; }
  .gslot .ic { width: 34px; height: 34px; }
  .t-ar { width: 88px; height: 88px; }
  .t-right { left: calc(max(22px, var(--safe-l)) + 106px); }
  .t-brake { width: 92px; height: 92px; }
  body.touch-mode .hud-gadgets { right: calc(max(22px, var(--safe-r)) + 106px); width: 210px; gap: 10px; }
  body.touch-mode .gslot { width: 58px; height: 58px; }
  .t-reset { bottom: calc(max(24px, var(--safe-b)) + 106px); }
  .rp-medal { width: 84px; height: 84px; font-size: 42px; }
  .lobby-list { gap: 6px; }
  .lobby-list li { min-height: 0; grid-template-columns: 64px minmax(0, 1fr) auto; }
  .lobby-list canvas { width: 64px; height: 34px; }
  /* poczekalnia: START i podpowiedź zawsze widoczne na dole ekranu */
  .lobby-foot {
    position: sticky; bottom: calc(-1 * max(28px, var(--safe-b))); z-index: 2;
    margin: 8px calc(-1 * max(24px, var(--safe-r))) calc(-1 * max(28px, var(--safe-b))) calc(-1 * max(24px, var(--safe-l)));
    padding: 10px max(24px, var(--safe-r)) max(14px, var(--safe-b)) max(24px, var(--safe-l));
    max-width: none;
    background: linear-gradient(to top, rgba(27, 22, 64, .97) 62%, rgba(27, 22, 64, 0));
  }
}
@media (max-height: 460px) {
  .hud-map { display: none; }
  body.touch-mode .hud-bl { top: calc(max(10px, var(--safe-t)) + 74px); }
  /* menu główne na niskim ekranie (telefon poziomo): logo obok przycisków */
  .menu-wrap { display: flex; align-items: center; gap: clamp(14px, 3vw, 36px); padding-bottom: 0; }
  .logo { margin: 0; }
  .logo-top { font-size: clamp(38px, 6.6vw, 64px); }
  .logo-bot { font-size: clamp(29px, 5vw, 50px); }
  .menu-btns { gap: 10px; }
  .menu-btns > :nth-child(2) { margin-left: 12px; }
  .menu-btns > :nth-child(3) { margin-left: 24px; }
  .menu-btns > :nth-child(4) { margin-left: 36px; }
  .menu-btns > :nth-child(5) { margin-left: 48px; }
  .menu-car { display: none; }
  /* gra sieciowa: ciaśniej */
  .net-box { padding: 10px 14px 12px; }
  .net-box h3 { font-size: 17px; margin: 2px 0 6px; }
  .net-field { gap: 6px; padding-bottom: 10px; margin-bottom: 8px; }
  .name-input { font-size: 16px; padding: 6px 10px 4px; border-width: 3px; }
  .net-hint { font-size: 13px; }
  #net-bots-hint { min-height: 0; margin-top: 6px; }
  .net-new .btn { margin-top: 10px; }
  .room-list { gap: 7px; }
  .room-list li { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 6px 10px 6px 12px; }
  .room-list canvas { display: none; }
  .rm-host { font-size: 16px; }
  .rm-meta { font-size: 13px; margin-top: 2px; }
  .lt-arrow { width: 38px; height: 38px; border-width: 3px; }
  .lt-arrow .ic { width: 20px; height: 20px; }
  .lt-name { font-size: 18px; margin: 6px 0 8px; }
  .lobby-list { gap: 5px; }
  .lobby-list li { min-height: 36px; grid-template-columns: 56px minmax(0, 1fr) auto; padding: 1px 8px 1px 4px; border-width: 2px; }
  .lobby-list canvas { width: 56px; height: 30px; }
  .lobby-list .slot-ic .ic { width: 24px; height: 24px; }
  .ll-name { font-size: 15px; }
  .ll-name small { font-size: 11px; }
  .lobby-cars { margin-top: 10px; padding-top: 8px; }
  .lobby-cars-row canvas { height: 34px; }
  .lobby-note { font-size: 16px; }
  .lobby-foot .btn-big { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .h-big.show { animation: none !important; opacity: 1; }
  .toast { animation: none !important; }
}
