/* Turbo Royale — tema da gara, sopra a style.css: asfalto scuro, strisce di velocità, rosso e giallo da paddock, bandiera a scacchi,
   scritte inclinate. Le schermate e la logica sono le stesse; qui si cambia l'aspetto e si toglie quello che non serve. */

:root {
  --font-title: 'Racing Sans One', 'Lilita One', 'Arial Black', system-ui, sans-serif;
  --asphalt: #14161d;
  --asphalt-1: #1c1f28;
  --asphalt-2: #262a35;
  --asphalt-3: #343a48;
  --line: #0a0b10;
  --race-red: #ff3b2f;
  --race-red-lo: #c5180f;
  --race-yellow: #ffd23f;
  --race-amber: #f7a411;
  --chalk: #f4f2ea;
  --muted: #b6bcc9;
  --checker: repeating-conic-gradient(var(--chalk) 0 25%, #15171e 0 50%);
}

body {
  background-color: var(--asphalt);
  background-image: radial-gradient(120% 55% at 50% 0%, rgba(255, 150, 60, 0.13), transparent 62%),
    repeating-linear-gradient(112deg, rgba(255, 255, 255, 0.022) 0 3px, transparent 3px 58px),
    linear-gradient(180deg, #1b1e27, var(--asphalt));
  background-size: auto;
}

/* ------------------------------------------------------------------ bottoni */
.btn {
  border: 2px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, #3f4656, #2a2f3b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 3px 0 var(--line);
  transform: skewX(-6deg);
}

.btn:active {
  transform: skewX(-6deg) translateY(2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 0 var(--line);
}

.btn-gold {
  border-color: #5e3b00;
  background: linear-gradient(180deg, #ffe066, var(--race-yellow) 45%, var(--race-amber));
  color: #2a1b00;
  text-shadow: none;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 3px 0 #5e3b00;
}

.btn-gold:active {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), 0 1px 0 #5e3b00;
}

.btn-red {
  border-color: #5c0a05;
  background: linear-gradient(180deg, #ff6a5c, var(--race-red) 50%, var(--race-red-lo));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 3px 0 #5c0a05;
}

.btn-play {
  position: relative;
  overflow: hidden;
  width: min(100%, 460px);
  flex: none;
  margin-top: 2px;
  padding: 9px 44px 11px;
  border: 3px solid #5c0a05;
  border-radius: 12px;
  background: linear-gradient(180deg, #ff6a5c, var(--race-red) 48%, var(--race-red-lo));
  color: #fff;
  font-size: 36px;
  letter-spacing: 1px;
  text-shadow: 0 3px 0 rgba(90, 8, 2, 0.85);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.4), 0 5px 0 #5c0a05;
  animation: none;
}

.btn-play:active {
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.4), 0 2px 0 #5c0a05;
  transform: skewX(-6deg) translateY(3px);
}

/* bandiera a scacchi ai due capi del tasto principale */
.btn-play::before,
.btn-play::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 26px;
  background: var(--checker);
  background-size: 13px 13px;
}

.btn-play::before {
  left: 0;
}

.btn-play::after {
  right: 0;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, #3f4656, #2a2f3b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 0 var(--line);
}

.close-btn {
  border-color: #5c0a05;
  background: linear-gradient(180deg, #ff6a5c, var(--race-red-lo));
}

.info-btn {
  border-color: var(--line);
  background: var(--asphalt-3);
  color: #fff;
}

/* ------------------------------------------------------------------ pannelli */
.frame {
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--asphalt-1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.frame-head {
  margin: 0 0 12px;
  padding: 0 0 8px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.frame-head::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  top: 40px;
  height: 2px;
  background: linear-gradient(90deg, var(--race-red), rgba(255, 59, 47, 0));
}

.frame-head h2 {
  font-size: 23px;
  color: #fff;
  text-shadow: none;
  transform: skewX(-4deg);
}

.frame-head .sub {
  color: var(--muted);
  text-shadow: none;
}

.pill {
  border: 0;
  background: var(--asphalt-3);
  text-shadow: none;
}

/* ------------------------------------------------------------------ barra alta e barra delle pagine */
.player-name {
  text-shadow: none;
  font-size: 20px;
}

.player-league {
  color: var(--muted);
  text-shadow: none;
}

.league-badge {
  font-size: 42px;
  filter: none;
}

.trophy-pill {
  border: 0;
  border-radius: 8px;
  background: var(--asphalt-2);
  box-shadow: none;
  color: var(--race-yellow);
  text-shadow: none;
  transform: skewX(-8deg);
}

.tabbar {
  position: relative;
  padding-top: 7px;
  background: #101218;
  border-top: 0;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.35);
}

/* cordolo a scacchi sopra la barra */
.tabbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7px;
  background: var(--checker);
  background-size: 7px 7px;
  opacity: 0.85;
}

.tab {
  height: 60px;
  border-radius: 0;
}

.tab-icon {
  position: relative;
  z-index: 1;
  font-size: 30px;
  opacity: 0.72;
  filter: grayscale(0.25);
}

.tab-label {
  position: relative;
  z-index: 1;
}

.tab.active {
  height: 60px;
  margin-top: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

.tab.active::before {
  content: '';
  position: absolute;
  inset: 5px 3px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe066, var(--race-amber));
  transform: skewX(-9deg);
  box-shadow: 0 3px 0 #5e3b00;
}

.tab.active .tab-icon {
  opacity: 1;
  filter: none;
  transform: scale(0.92) translateY(-1px);
}

.tab.active .tab-label {
  color: #2a1b00;
  text-shadow: none;
  font-size: 13px;
  margin-top: -2px;
}

.tab-badge {
  z-index: 2;
  border-color: #5c0a05;
  background: var(--race-red);
}

/* ------------------------------------------------------------------ Gioca: l'essenziale */
.arena-name {
  border: 0;
  border-radius: 7px;
  background: var(--asphalt-2);
  color: #fff;
  font-size: 22px;
  text-shadow: none;
  box-shadow: 0 3px 0 var(--race-red);
  transform: translateX(-50%) skewX(-8deg);
}

.trophy-bar .tb-track {
  border: 0;
  border-radius: 5px;
  background: var(--asphalt-2);
  transform: skewX(-10deg);
  overflow: hidden;
}

/* contagiri: tacche sopra il riempimento, che passa dal giallo al rosso */
.trophy-bar .tb-track i {
  background: linear-gradient(90deg, var(--race-yellow), var(--race-amber) 60%, var(--race-red));
  box-shadow: none;
}

.trophy-bar .tb-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(0, 0, 0, 0.45) calc(10% - 2px) 10%);
  pointer-events: none;
}

.trophy-bar .tb-track b {
  z-index: 1;
  text-shadow: 0 1px 2px #000;
}

.play-note {
  display: none;
}

.play-record {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.friends-btn {
  background: transparent;
  border: 2px solid var(--asphalt-3);
  box-shadow: none;
}

.chest-row-head {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: none;
}

/* ------------------------------------------------------------------ Garage e Carte */
.level-tab {
  border: 0;
  border-radius: 7px;
  background: var(--asphalt-2);
  box-shadow: none;
  transform: skewX(-8deg);
  text-shadow: none;
}

.level-tab.active {
  background: var(--race-yellow);
  color: #2a1b00;
  box-shadow: 0 2px 0 #5e3b00;
}

[data-note] {
  display: none;
}

.vehicle-tile {
  border: 0;
  border-radius: 10px;
  background: var(--asphalt-2);
  box-shadow: inset 0 -3px 0 var(--rarity, transparent);
}

.vehicle-tile.selected {
  background: var(--asphalt-3);
  box-shadow: inset 0 0 0 2px var(--race-yellow), inset 0 -3px 0 var(--rarity, transparent);
}

.deck-hint {
  color: var(--muted);
  text-shadow: none;
}

/* ------------------------------------------------------------------ Leghe e Classifica */
.league-card {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.league-card.current {
  border: 0;
  box-shadow: inset 0 0 0 2px var(--race-yellow);
}

/* il bordo giallo dice già dove sei */
.league-card.current .league-state {
  display: none;
}

/* il riepilogo della lega: i dettagli degli sblocchi stanno nella finestra che si apre toccandola */
button.league-card {
  width: 100%;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.league-summary {
  min-width: 0;
}

.league-more {
  margin-top: 6px;
  color: var(--race-yellow);
  font-size: 13px;
  font-weight: 800;
}

.league-more b {
  font-size: 16px;
}

.league-progress small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.unlock-intro {
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.unlock-head {
  margin: 14px 0 8px;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: 18px;
  transform: skewX(-4deg);
}

.unlock-head span {
  color: var(--muted);
  font-size: 14px;
}

.unlock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.unlock-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 8px;
  border-radius: 10px;
  background: var(--asphalt-2);
  box-shadow: inset 0 -3px 0 var(--rarity, transparent);
  text-align: center;
}

.unlock-tile canvas {
  width: 100%;
  height: 58px;
}

.unlock-tile.locked canvas {
  filter: brightness(0.35) grayscale(0.5);
}

.unlock-tile b {
  font-size: 12px;
  line-height: 1.15;
}

.unlock-art {
  display: block;
  font-size: 72px;
  line-height: 1;
}

.league-vehicle {
  border: 0;
  border-radius: 7px;
  background: var(--asphalt-2);
  box-shadow: inset 0 -2px 0 var(--rarity, transparent);
}

.league-title {
  text-shadow: none;
}

.league-map {
  color: var(--muted);
  text-shadow: none;
}

/* ------------------------------------------------------------------ finestre */
.popup {
  border: 0;
  border-radius: 14px;
  background: var(--asphalt-1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 18px 40px rgba(0, 0, 0, 0.55);
}

.popup-head {
  border: 0;
  background: none;
  box-shadow: inset 0 -2px 0 var(--race-red);
}

.popup-head h2 {
  text-shadow: none;
}

.segmented {
  border: 0;
  background: var(--asphalt-2);
  border-radius: 8px;
}

.seg.active {
  background: var(--race-yellow);
  color: #2a1b00;
  text-shadow: none;
  box-shadow: none;
}

.field input {
  border: 2px solid var(--asphalt-3);
  border-radius: 8px;
  background: var(--asphalt);
  color: #fff;
}

/* ------------------------------------------------------------------ gara */
.hud-panel {
  border: 0;
  border-radius: 8px;
  background: rgba(14, 16, 22, 0.74);
  backdrop-filter: none;
}

.lapbox {
  transform: skewX(-8deg);
  box-shadow: inset 0 -2px 0 var(--race-red);
}

.lap,
.timer {
  text-shadow: none;
}

.bottom-bar {
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, rgba(14, 16, 22, 0.55), rgba(14, 16, 22, 0.92));
  box-shadow: none;
}

.chip {
  border-radius: 6px;
  background: rgba(14, 16, 22, 0.85);
  transform: skewX(-8deg);
}

.fuel-bar {
  border: 0;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.6);
  transform: skewX(-10deg);
}

.warning {
  border-radius: 7px;
  transform: translateX(-50%) skewX(-6deg);
}

/* giro TV: sottopancia da diretta */
.flyover-card {
  border: 0;
  border-radius: 6px;
  background: rgba(14, 16, 22, 0.86);
  box-shadow: inset 4px 0 0 var(--race-red);
  transform: skewX(-6deg);
}

.flyover-card span {
  color: var(--race-yellow);
  text-shadow: none;
}

.flyover-card b {
  text-shadow: none;
}

.flyover-tagged span {
  color: #2a1b00;
}

/* ------------------------------------------------------------------ accesso */
.auth-panel {
  background: var(--asphalt-1);
}

/* ------------------------------------------------------------------ Garage: il salone a tutta larghezza */
.garage-stage {
  position: relative;
  overflow: hidden;
  gap: 0;
  margin-bottom: 12px;
  padding: 0;
  border-radius: 14px;
  background: var(--asphalt-1);
}

.garage-canvas {
  height: min(46vh, 400px);
  min-height: 250px;
  border: 0;
  border-radius: 0;
  background: #07080c;
  cursor: grab;
}

.garage-canvas:active {
  cursor: grabbing;
}

.garage-caption {
  position: absolute;
  top: 12px;
  left: 14px;
  justify-content: flex-start;
  gap: 8px;
  pointer-events: none;
}

.garage-caption b {
  font-size: 30px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  transform: skewX(-6deg);
}

.garage-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 12px;
}

.garage-info .garage-level {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.vehicle-tile canvas {
  max-width: none;
  height: 74px;
}

.vehicle-tile.locked b,
.vehicle-tile.locked .car-lock {
  color: var(--muted);
}

/* illustrazioni delle carte: oggetti 3D su fondo trasparente */
img.card-art {
  display: block;
  width: 1em;
  height: 1em;
  pointer-events: none;
  user-select: none;
}

.card .card-icon {
  font-size: clamp(46px, 13vw, 74px);
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.35));
}

#hud .card .card-icon {
  font-size: clamp(46px, 12vw, 68px);
}

.card.mini .card-icon,
#hud .card.mini .card-icon {
  font-size: clamp(28px, 7vw, 42px);
}

.card.big-card .card-icon {
  font-size: 122px;
}

.ctile-icon {
  font-size: clamp(44px, 14vw, 70px);
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.35));
}

.card-grid .ctile-icon {
  font-size: clamp(40px, 12vw, 64px);
}

/* sul podio il riquadro dei risultati entra dopo l'arrivo del vincitore: prima si godono le auto */
#results.celebrate .results-card {
  animation: podiumCard 0.4s cubic-bezier(0.2, 1.3, 0.4, 1) 0.6s both;
}

/* ------------------------------------------------------------------ bauli: immagini 3D negli slot, scena 3D all'apertura */
.chest-art {
  display: block;
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.4));
}

.chest-art img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.chest-art.small {
  width: 58px;
  height: 58px;
  transform: none;
  margin: 0;
}

.cslot .chest-art {
  width: min(72px, 17vw);
  height: min(72px, 17vw);
  margin: 0;
  transform: none;
}

.reward-chest .chest-art {
  width: 54px;
  height: 54px;
  margin: 0;
  transform: none;
}

.chest-open {
  background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--chest) 32%, #0b0c11), #07080c 72%);
}

.chest-open-3d {
  position: absolute;
  inset: 0;
}

.chest-open-3d .stage-3d {
  display: block;
  width: 100%;
  height: 100%;
}

.chest-open-stage {
  z-index: 1;
}

.chest-title {
  position: absolute;
  top: -38vh;
  left: 50%;
  transform: translateX(-50%) skewX(-6deg);
  white-space: nowrap;
  font-family: var(--font-title);
  font-size: 34px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.8);
}

.chest-open-hint {
  z-index: 1;
}

/* la ricompensa esce dal baule e vola al centro */
.chest-open .reward.pop {
  animation: rewardFly 0.5s cubic-bezier(0.2, 1.25, 0.4, 1) both;
}

@keyframes rewardFly {
  from {
    opacity: 0;
    transform: translateY(30vh) scale(0.15) rotate(-14deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* con la ricompensa sopra, il baule resta sullo sfondo e il testo si legge */
.chest-open.rewarding .chest-open-3d {
  filter: brightness(0.55) saturate(0.9);
  transition: filter 0.4s;
}

.cslot.ready .cslot-bottom {
  color: #2a1b00;
  text-shadow: none;
}

/* ------------------------------------------------------------------ Gioca: tutto in uno schermo, senza scorrere
   L'isola prende lo spazio che resta sopra barra dei trofei, Gioca e bauli */
.page[data-page='play'].active {
  height: 100%;
}

#pages:has(.page[data-page='play'].active) {
  overflow: hidden;
  padding-bottom: 6px;
}

.play-page {
  height: 100%;
  min-height: 0;
  padding-top: 0;
  gap: clamp(4px, 1vh, 12px);
}

.play-page .arena-stage {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  padding: 0 0 20px;
}

.play-page .arena-3d {
  width: 100%;
  height: 100%;
  margin: 0;
  aspect-ratio: auto;
}

.play-page > *:not(.arena-stage) {
  flex: none;
}

.play-page .btn-play {
  padding: clamp(5px, 1vh, 9px) 44px clamp(6px, 1.1vh, 11px);
  font-size: clamp(26px, 4.4vh, 36px);
}

.play-page .play-record {
  margin: 0;
  font-size: 12px;
}

.play-page .friends-btn {
  margin: 0;
  padding-block: 4px;
}

.play-page .chest-row-head {
  margin: 0;
}

.play-page .chest-row {
  gap: 6px;
}

.play-page .cslot {
  min-height: 0;
  height: clamp(84px, 14.5vh, 128px);
  padding-block: 2px;
}

.play-page .cslot .chest-art {
  width: clamp(46px, 8.6vh, 72px);
  height: clamp(46px, 8.6vh, 72px);
}

.auth-language {
  width: min(100%, 260px);
  margin: 10px auto 0;
}

.auth-language .segmented,
.language-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* ------------------------------------------------------------------ tutorial: schermate iniziali */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px max(24px, calc(50vw - 240px));
  text-align: center;
  background: radial-gradient(circle at 50% 38%, #3a2a2a, #0b0c11 70%);
}

.onboarding-skip {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 14px var(--font-body, Nunito), system-ui, sans-serif;
  cursor: pointer;
}

.onboarding-art {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(84vw, 380px);
  height: min(42vh, 320px);
  animation: onboardingIn 0.45s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

.onboarding-art canvas {
  width: 100%;
  height: 100%;
}

.onboarding-art img {
  width: 58%;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.5));
}

.onboarding-art .fan {
  position: absolute;
  width: 46%;
}

.onboarding-art .fan:nth-child(1) {
  transform: translateX(-52%) rotate(-14deg);
}

.onboarding-art .fan:nth-child(2) {
  z-index: 1;
  width: 54%;
  transform: translateY(-10px);
}

.onboarding-art .fan:nth-child(3) {
  transform: translateX(52%) rotate(14deg);
}

.onboarding-fuel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.onboarding-fuel .tank {
  width: 100%;
  height: 24px;
  overflow: hidden;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.6);
  transform: skewX(-10deg);
}

.onboarding-fuel .tank i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ffd23f, #f7a411);
  animation: onboardingFuel 2.6s ease-in-out infinite alternate;
}

.onboarding h1 {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(28px, 7.5vw, 40px);
  line-height: 1.1;
  transform: skewX(-5deg);
}

.onboarding p {
  max-width: 420px;
  min-height: 3.6em;
  margin: 0;
  color: #dfe2ea;
  font-size: 17px;
  line-height: 1.35;
}

.onboarding-dots {
  display: flex;
  gap: 8px;
}

.onboarding-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

.onboarding-dots i.on {
  background: var(--race-yellow);
}

.onboarding-next {
  width: min(100%, 340px);
  padding-block: 14px;
  font-size: 22px;
}

@keyframes onboardingIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes onboardingFuel {
  from {
    width: 8%;
  }
  to {
    width: 100%;
  }
}

/* ------------------------------------------------------------------ tutorial: guida in gara */
.tutorial-guide {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.tg-hole {
  position: absolute;
  border-radius: 14px;
  box-shadow: 0 0 0 200vmax rgba(5, 6, 10, 0.5), 0 0 0 3px var(--race-yellow), 0 0 22px 6px rgba(255, 210, 63, 0.7);
  animation: tgPulse 1s ease-in-out infinite, tgFade 0.35s ease both;
  transition: left 0.2s, top 0.2s, width 0.2s, height 0.2s;
}

.tg-hand {
  position: absolute;
  font-size: 44px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6));
  animation: tgHand 0.8s ease-in-out infinite;
}

.tg-bubble {
  position: absolute;
  left: 0;
  right: 0;
  width: min(88vw, 420px);
  margin-inline: auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--asphalt-1);
  box-shadow: inset 0 0 0 2px var(--race-yellow), 0 10px 30px rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  pointer-events: auto;
  animation: onboardingIn 0.3s ease both;
}

.tg-bubble p {
  margin: 0;
}

.tg-bubble .btn {
  margin-top: 10px;
}

.tg-banner {
  position: absolute;
  top: 16%;
  left: 0;
  right: 0;
  width: fit-content;
  max-width: 90vw;
  margin-inline: auto;
  padding: 9px 18px;
  border-radius: 9px;
  background: rgba(14, 16, 22, 0.9);
  box-shadow: inset 4px 0 0 var(--race-yellow);
  color: #fff;
  font-family: var(--font-title);
  font-size: 20px;
  text-align: center;
  animation: onboardingIn 0.3s ease both;
}

@keyframes tgFade {
  from {
    opacity: 0;
  }
}

@keyframes tgPulse {
  50% {
    transform: scale(1.04);
  }
}

@keyframes tgHand {
  50% {
    transform: translateY(-12px);
  }
}

/* riepilogo del baule: griglia compatta, il pulsante resta sempre in vista */
.summary {
  max-height: 86vh;
  width: min(92vw, 520px);
  overflow-y: auto;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: rgba(20, 22, 29, 0.94);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  border-radius: 10px;
  background: var(--asphalt-2);
  box-shadow: inset 0 -3px 0 var(--rarity, transparent);
  text-align: center;
}

.summary-item b {
  font-size: 12px;
  line-height: 1.15;
}

.summary-item span:not(.summary-icon) {
  color: var(--muted);
  font-size: 11px;
}

.summary-icon {
  font-size: 54px;
  line-height: 1;
}

.summary-actions {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
}

/* ---------------------------------------------------------------- caricamenti */

.wheel-loader {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: repeating-conic-gradient(#15171e 0 15deg, #343a48 15deg 30deg);
  animation: spin 0.9s linear infinite;
}

.wheel-loader::after {
  content: '';
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  border: 5px solid var(--asphalt-1);
  background: conic-gradient(var(--race-yellow) 0 25%, var(--asphalt-3) 0 50%, var(--race-yellow) 0 75%, var(--asphalt-3) 0);
}

.stage-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: loader-in 0.2s 0.15s both;
}

.race-loader {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 32px;
  background: var(--asphalt);
  color: var(--chalk);
  text-align: center;
}

.race-loader.hidden {
  display: none;
}

.race-loader b {
  font-family: var(--font-title);
  font-size: 30px;
  font-weight: 400;
}

.race-loader span,
.vs-loading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.race-loader-bar {
  width: min(260px, 70vw);
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--asphalt-3);
}

.race-loader-bar i {
  display: block;
  height: 100%;
  background: var(--race-yellow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s;
}

/* il conto alla rovescia sta per partire: resta solo un avviso in alto, la strada e le carte si vedono */
.race-loader.compact {
  inset: calc(70px + env(safe-area-inset-top)) auto auto 50%;
  flex-direction: row;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(10, 11, 16, 0.75);
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}

.race-loader.compact .wheel-loader {
  width: 20px;
  height: 20px;
}

.race-loader.compact .wheel-loader::after {
  inset: 4px;
  border-width: 2px;
}

.race-loader.compact b,
.race-loader.compact .race-loader-bar {
  display: none;
}

.vs-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.vs-loading.hidden {
  display: none;
}

canvas.thumb-loading {
  border-radius: 10px;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.12) 50%, transparent 70%) 0 0 / 250% 100%;
  animation: thumb-shimmer 1.2s linear infinite;
}

@keyframes thumb-shimmer {
  to {
    background-position: -250% 0;
  }
}

@keyframes loader-in {
  from {
    opacity: 0;
  }
}

/* tutorial: la gara continua a rallentatore sotto un filtro che toglie un po' di colore */
.slow-motion #world {
  filter: saturate(0.55);
}

/* collezione: una sezione per ogni utilità delle carte */
.card-section + .card-section {
  margin-top: 14px;
}

.card-section-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 7px;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--asphalt-3);
  color: var(--chalk);
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 400;
}

.card-section-title svg {
  align-self: center;
  width: 16px;
  height: 16px;
}

.card-section-title small {
  color: var(--muted);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

/* suggerimento sull'isola della home, solo finché non è stata girata la prima volta */
.spin-hint {
  position: absolute;
  left: 50%;
  bottom: 12%;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(10, 11, 16, 0.6);
  color: var(--chalk);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  animation: spin-hint 2.4s ease-in-out infinite;
}

.spun .spin-hint {
  display: none;
}

@keyframes spin-hint {
  50% {
    opacity: 0.55;
  }
}

/* installazione come app */
.auth-install {
  width: min(100%, 260px);
  margin: 10px auto 0;
}

.install-btn {
  width: 100%;
}

.install-steps {
  margin: 0;
  padding-left: 22px;
  color: var(--chalk);
  font-size: 16px;
  line-height: 1.5;
}

.install-steps li + li {
  margin-top: 8px;
}

/* home: sfida e download affiancati, sulla stessa riga che occupava solo la sfida */
.play-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.play-page .play-actions {
  flex: none;
}

#home-install:empty {
  display: none;
}

#home-install .install-btn {
  height: 100%;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.play-actions .friends-btn {
  white-space: nowrap;
}

/* ------------------------------------------------------------------ monete */
.coin-img {
  width: 1.2em;
  height: 1.2em;
  object-fit: contain;
  vertical-align: -0.25em;
}

.coin-pill {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 5px;
  border-radius: 8px;
  background: var(--asphalt-2);
  color: var(--race-yellow);
  font-family: var(--font-title);
  font-size: 16px;
  cursor: pointer;
}

.coin-pill .coin-img {
  width: 22px;
  height: 22px;
}

.coin-price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.tab-icon .coin-img {
  width: 30px;
  height: 30px;
  vertical-align: middle;
}

/* contatore in gara: le monete 3D arrivano sull'immagine */
.coin-hud {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 46px);
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 2px 4px;
  border-radius: 99px;
  background: rgba(10, 11, 16, 0.72);
  color: var(--race-yellow);
  font-family: var(--font-title);
  font-size: 16px;
  transform: translateX(-50%);
  pointer-events: none;
}

.coin-hud .coin-img {
  width: 22px;
  height: 22px;
}

.coin-hud.bump {
  animation: coinBump 0.18s ease-out;
}

.coin-gain {
  position: absolute;
  left: 100%;
  margin-left: 6px;
  color: var(--race-yellow);
  font-size: 18px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  opacity: 0;
  white-space: nowrap;
}

.coin-gain.show {
  animation: coinGain 1.4s ease-out;
}

@keyframes coinBump {
  40% {
    transform: translateX(-50%) scale(1.18);
  }
}

@keyframes coinGain {
  15%,
  70% {
    opacity: 1;
    transform: translateY(-4px);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.reward-coins {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--race-yellow);
  font-family: var(--font-title);
  font-size: 20px;
}

/* carte e auto pronte da migliorare */
.ctile.upgradable .ctile-bar {
  background: #1d6b3a;
  box-shadow: 0 0 0 2px var(--race-yellow);
}

.ctile.upgradable .ctile-bar b::before {
  content: '▲ ';
  color: var(--race-yellow);
}

.upgrade-btn:disabled {
  opacity: 0.55;
}

.upgrade-popup {
  text-align: center;
}

.upgrade-popup canvas {
  width: min(100%, 300px);
  aspect-ratio: 3 / 2;
}

/* ------------------------------------------------------------------ store */
.store-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.store-balance {
  color: var(--race-yellow);
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.store-offer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--asphalt-2);
  box-shadow: inset 0 0 0 2px var(--rarity);
  color: var(--chalk);
  text-align: center;
}

.store-offer.bought {
  opacity: 0.55;
}

.store-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  overflow: hidden;
  border-radius: 10px;
}

.store-card img,
.store-card svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.store-car {
  width: 110px;
  height: 84px;
}

.store-note-line {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.store-buy {
  width: 100%;
  padding: 6px;
  font-size: 16px;
}

.store-buy:disabled {
  opacity: 0.55;
}

.store-bought {
  padding: 8px 0;
  color: var(--muted);
  font-weight: 800;
}

/* con sei schede la barra in basso resta su una riga */
.tabbar .tab {
  min-width: 0;
}
