/* ==========================================================================
   Gialla vs Verde - Auto Match | High-End Mobile-First Stylesheet
   ========================================================================== */

:root {
  /* Core Theme Colors */
  --bg-dark: #080B11;
  --bg-topbar: rgba(10, 14, 22, 0.92);
  --bg-card: #111724;
  --bg-card-subtle: rgba(255, 255, 255, 0.04);
  --text-main: #F3F7FA;
  --text-muted: #8E9BAE;
  --border-glass: rgba(255, 255, 255, 0.12);

  /* Team Yellow (Warm vibrant racing amber) */
  --yellow-main: #FFB703;
  --yellow-bright: #FFD166;
  --yellow-deep: #F77F00;
  --yellow-bg-grad: linear-gradient(175deg, #FFC000 0%, #FF9E00 60%, #E67E00 100%);
  --yellow-glow: rgba(255, 183, 3, 0.45);
  --yellow-text-dark: #1F1400;

  /* Team Green (Vibrant racing emerald) */
  --green-main: #06D6A0;
  --green-bright: #38EF7D;
  --green-deep: #059669;
  --green-bg-grad: linear-gradient(175deg, #10B981 0%, #059669 60%, #047857 100%);
  --green-glow: rgba(6, 214, 160, 0.45);
  --green-text-dark: #00220F;

  /* Action Colors */
  --red-stop: #EF4444;
  --red-stop-glow: rgba(239, 68, 68, 0.4);

  /* Tokens */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.6);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Setup */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  touch-action: manipulation;
}

/* Global utility */
.hidden {
  display: none !important;
}

/* App Viewport Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 540px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-dark);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* --------------------------------------------------------------------------
   TOP BAR: TUTTE LE INFO DI CONTROLLO IN ALTO
   -------------------------------------------------------------------------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  height: 56px;
  background: var(--bg-topbar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 30;
  border-bottom: 1px solid var(--border-glass);
}

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icon Buttons in Header */
.icon-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.16);
}

/* Match Timer Badge (In Alto a Sinistra) */
.match-timer-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  padding: 6px 11px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.timer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10B981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
  animation: timerPulse 2s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Tasto STOP / Termina (In Alto a Destra) */
.btn-finish-top {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: #FFFFFF;
  border: none;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 8px 12px;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: 0 3px 12px var(--red-stop-glow);
  transition: all var(--transition-fast);
}

.btn-finish-top:active {
  transform: scale(0.92);
  filter: brightness(0.9);
}

/* --------------------------------------------------------------------------
   SPLIT SCREEN DINAMICO (DIMENSIONE CONQUISTATA DA CHI STA VINCENDO)
   -------------------------------------------------------------------------- */
.screen-game {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  --split-pos: 50%; /* 50% in parità, si sposta verso l'alto o verso il basso in base a chi vince */
}

.counter-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  will-change: height;
}

/* Zone Gialla dinamica */
.zone-yellow {
  height: var(--split-pos, 50%);
  background: var(--yellow-bg-grad);
  color: var(--yellow-text-dark);
  transition: height 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Zone Verde dinamica */
.zone-green {
  height: calc(100% - var(--split-pos, 50%));
  background: var(--green-bg-grad);
  color: #FFFFFF;
  transition: height 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Effetto conquista territorio quando una fazione è in testa */
.zone-yellow.is-winning {
  filter: saturate(1.15) brightness(1.05);
}

.zone-green.is-winning {
  filter: saturate(1.15) brightness(1.05);
}

/* Bagliore dinamico per vincitore */
.zone-yellow.is-winning .zone-glow {
  opacity: 1;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 75%);
}

.zone-green.is-winning .zone-glow {
  opacity: 1;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0%, transparent 75%);
}

/* Subtle Glowing Lights in Corners */
.zone-glow {
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 60%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.zone-green .zone-glow {
  top: auto;
  bottom: -20%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
}

.zone-grid-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image: radial-gradient(circle at 2px 2px, currentColor 1.2px, transparent 0);
  background-size: 20px 20px;
  pointer-events: none;
}

/* Zone Content Layout - PERFETTAMENTE CENTRATO CON RESPIRO ARMONIOSO */
.zone-content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 24px;
  pointer-events: none; /* Touches trigger zone tap directly */
}

/* Header di zona posizionato in modo pulito ai margini esterni */
.zone-header {
  position: absolute;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 40px);
  pointer-events: auto;
  z-index: 10;
}

.zone-yellow .zone-header {
  top: 16px;
}

.zone-green .zone-header {
  bottom: 16px;
}

/* Player Pill Badge */
.player-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.yellow-pill {
  background: rgba(31, 20, 0, 0.18);
  color: #1F1400;
  border: 1px solid rgba(31, 20, 0, 0.2);
}

.green-pill {
  background: rgba(0, 0, 0, 0.25);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Minimalist Minus Button (In alto/basso a destra, mai d'intralcio) */
.btn-sub-minimal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.16);
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all var(--transition-fast);
}

.btn-sub-minimal:active {
  transform: scale(0.85);
  background: rgba(0, 0, 0, 0.35);
}

/* Center score wrap: Spaziato, Centrato con eleganza lontano dal divisore */
.score-center-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
  margin: auto;
  pointer-events: none;
}

/* Standalone Cut-Out Real Cars - FIAT PANDA & PORSCHE 911 GT3 RS */
.car-standalone-wrap {
  position: relative;
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible;
  animation: carEngineFloat 3.2s ease-in-out infinite;
}

/* Floating engine idle vibration */
@keyframes carEngineFloat {
  0%, 100% {
    transform: translateY(0) scale(1, 1);
  }
  50% {
    transform: translateY(-4px) scale(1.015, 0.985);
  }
}

.match-car-img,
.pixar-car-img {
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.32));
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  user-select: none;
}

/* Bilanciamento proporzionale perfetto tra Panda e Porsche */
.car-panda-img {
  width: clamp(140px, 21vh, 195px);
  max-height: 115px;
}

.car-porsche-img {
  width: clamp(165px, 25vh, 235px);
  max-height: 105px;
}

/* Ombra di contatto a terra sotto le gomme */
.car-ground-shadow {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 82%;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.18) 45%, transparent 70%);
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Scatto e reattività al tocco del punteggio */
.car-rev {
  animation: carTapRev 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

@keyframes carTapRev {
  0% { transform: scale(1, 1) rotate(0deg); }
  25% { transform: scale(1.08, 0.92) translateY(3px) rotate(-1.5deg); }
  50% { transform: scale(0.96, 1.08) translateY(-12px) rotate(2deg); }
  75% { transform: scale(1.03, 0.98) translateY(-1px) rotate(-0.5deg); }
  100% { transform: scale(1, 1) rotate(0deg); }
}

/* Big Numbers with Arcade Depth & Fluid Scaling */
.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-number {
  font-size: clamp(3.2rem, 9.5vh, 5.8rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -2px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 10px 28px rgba(0, 0, 0, 0.28);
  font-variant-numeric: tabular-nums;
  transition: font-size 0.3s ease;
}

.score-bump {
  animation: scoreBounce 0.28s ease-out;
}

@keyframes scoreBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.score-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 2px;
  opacity: 0.8;
  margin-top: 3px;
}

/* Tap Hint */
.tap-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  opacity: 0.7;
}

.pulse-plus {
  font-size: 1.15rem;
  font-weight: 900;
}

/* --------------------------------------------------------------------------
   DIVISORE CENTRALE: STRADA ASFALTO CHE SCORRE IN ALTO/BASSO CON IL VANTAGGIO
   -------------------------------------------------------------------------- */
.center-divider {
  position: absolute;
  top: var(--split-pos, 50%);
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  height: 36px;
  transition: top 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: top;
}

/* Striscia di asfalto con tratteggio autostradale */
.road-asphalt-strip {
  position: absolute;
  inset: 0;
  background: #090D15;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-around;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.road-dash {
  width: 32px;
  height: 3px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  animation: roadSpeed 1.2s linear infinite;
}

@keyframes roadSpeed {
  0% { transform: translateX(50px); opacity: 0.2; }
  50% { opacity: 0.5; }
  100% { transform: translateX(-50px); opacity: 0.2; }
}

/* Barra Tiro alla Fune dal Vivo (Tug of War) */
.tug-of-war-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  display: flex;
  z-index: 2;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.tug-bar-yellow {
  background: var(--yellow-main);
  box-shadow: 0 0 8px var(--yellow-glow);
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tug-bar-green {
  background: var(--green-main);
  box-shadow: 0 0 8px var(--green-glow);
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.live-leader-pill {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  background: #0C111C;
  color: #FFFFFF;
  padding: 5px 16px;
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: all 0.25s ease;
  pointer-events: auto;
}

.leader-icon {
  font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   EFFETTI ONDA / RIPPLE & NUMERO FLUTTUANTE
   -------------------------------------------------------------------------- */
.ripple-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.tap-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: translate(-50%, -50%) scale(0);
  animation: rippleSpread 0.48s ease-out forwards;
}

@keyframes rippleSpread {
  0% { width: 0; height: 0; opacity: 0.8; }
  100% { width: 260px; height: 260px; opacity: 0; }
}

.tap-float-tag {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 2.2rem;
  font-weight: 900;
  color: #FFFFFF;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  animation: floatUp 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  z-index: 10;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, -20%) scale(0.6); }
  40% { transform: translate(-50%, -60%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

/* --------------------------------------------------------------------------
   MODALI: NUOVA PARTITA & RIEPILOGO
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  animation: modalPop 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}

@keyframes modalPop {
  0% { transform: scale(0.9) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  text-align: center;
  margin-bottom: 16px;
}

/* Arena Face-Off Hero: Fiat Panda vs Porsche 911 GT3 RS */
.faceoff-cars-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 8px 14px;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, 0.05) 0%, transparent 75%);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.faceoff-car-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  position: relative;
  transition: transform 0.25s ease;
}

.faceoff-car-box:hover {
  transform: translateY(-2px);
}

.faceoff-img {
  width: 95px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
  transition: transform 0.25s ease;
}

.yellow-faceoff .faceoff-img {
  filter: drop-shadow(0 6px 12px rgba(255, 183, 3, 0.25));
}

.green-faceoff .faceoff-img {
  filter: drop-shadow(0 6px 12px rgba(6, 214, 160, 0.25));
}

.faceoff-label {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.faceoff-label.yellow {
  background: rgba(255, 183, 3, 0.18);
  color: var(--yellow-main);
  border: 1px solid rgba(255, 183, 3, 0.35);
}

.faceoff-label.green {
  background: rgba(6, 214, 160, 0.18);
  color: var(--green-main);
  border: 1px solid rgba(6, 214, 160, 0.35);
}

.faceoff-vs-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0B0E14;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.3);
  position: relative;
  z-index: 2;
}

.vs-glow-text {
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #FFF 0%, #AAA 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.vs-bolt {
  font-size: 0.55rem;
  line-height: 1;
  margin-top: -1px;
}

.new-game-title {
  font-size: 1.45rem;
  font-weight: 900;
  color: #FFF;
  letter-spacing: -0.5px;
  margin-bottom: 2px;
}

.new-game-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Modulo Nuova Partita */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.input-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot-yellow {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow-main);
  box-shadow: 0 0 6px var(--yellow-main);
}

.dot-green {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-main);
  box-shadow: 0 0 6px var(--green-main);
}

.input-group input, 
.input-group select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: #FFF;
  font-size: 0.92rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
}

.yellow-border input:focus {
  border-color: var(--yellow-main);
  box-shadow: 0 0 14px rgba(255, 183, 3, 0.25);
}

.green-border input:focus {
  border-color: var(--green-main);
  box-shadow: 0 0 14px rgba(6, 214, 160, 0.25);
}

/* Target Chips Selector */
.target-chips-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 6px;
}

.target-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  font-size: 0.74rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all var(--transition-fast);
  user-select: none;
}

.target-chip:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #FFF;
  border-color: rgba(255, 255, 255, 0.22);
}

.target-chip.active {
  background: rgba(255, 255, 255, 0.18);
  color: #FFF;
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

/* Pulsante Start con Shimmer Neon */
.btn-start-glow {
  background: linear-gradient(135deg, #FFB703 0%, #06D6A0 100%) !important;
  color: #0A0E17 !important;
  font-weight: 900 !important;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  box-shadow: 0 4px 20px rgba(255, 183, 3, 0.35) !important;
  transition: all var(--transition-fast) !important;
}

.btn-start-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(6, 214, 160, 0.45) !important;
}

.btn-start-glow:active {
  transform: translateY(1px);
}
  border: 1px solid var(--border-glass);
  color: #FFFFFF;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.input-group input:focus,
.input-group select:focus {
  border-color: #3B82F6;
  background: rgba(255, 255, 255, 0.1);
}

.yellow-border input:focus {
  border-color: var(--yellow-main);
  box-shadow: 0 0 10px var(--yellow-glow);
}

.green-border input:focus {
  border-color: var(--green-main);
  box-shadow: 0 0 10px var(--green-glow);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  color: white;
  border: none;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  transition: all var(--transition-fast);
}

.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:active { background: rgba(255, 255, 255, 0.14); }

/* --------------------------------------------------------------------------
   WINNER / SUMMARY MODAL
   -------------------------------------------------------------------------- */
.winner-card {
  text-align: center;
  position: relative;
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.winner-trophy {
  font-size: 3.4rem;
  margin-bottom: 8px;
  animation: trophyFloat 2s ease-in-out infinite;
}

@keyframes trophyFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.08); }
}

.winner-headline {
  font-size: 1.55rem;
  font-weight: 900;
  color: #FFF;
  margin-bottom: 4px;
}

.winner-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.vs-result-board {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--border-glass);
}

.result-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-player {
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.yellow-side .result-player { color: var(--yellow-main); }
.green-side .result-player { color: var(--green-main); }

.result-score {
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
  color: #FFF;
}

.result-pct {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 4px;
}

.vs-badge {
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.match-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  padding: 9px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: #FFF;
}

/* --------------------------------------------------------------------------
   PANNELLO CRONOLOGIA
   -------------------------------------------------------------------------- */
.history-drawer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  justify-content: flex-end;
  transition: visibility 0.3s;
}

.history-drawer.hidden {
  visibility: hidden;
  pointer-events: none;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.history-drawer.hidden .drawer-backdrop { opacity: 0; }

.drawer-content {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  background: var(--bg-card);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.history-drawer.hidden .drawer-content { transform: translateX(100%); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.drawer-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #FFF;
}

.drawer-icon-glow {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--yellow-main);
  box-shadow: 0 0 12px rgba(255, 183, 3, 0.2);
}

.drawer-title-wrap h3 {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.15;
}

.drawer-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Statistiche All-Time globali con Card Prestige */
.alltime-stats-card {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 14px 18px 8px;
  padding: 14px 12px;
  background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.08) 0%, rgba(15, 22, 35, 0.6) 100%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.alltime-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.alltime-stat-top {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-stat-img {
  width: 32px;
  height: 18px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.alltime-num {
  font-size: 1.45rem;
  font-weight: 900;
  color: #FFF;
  line-height: 1;
}

.alltime-lbl {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.yellow-accent .alltime-num { color: var(--yellow-main); }
.green-accent .alltime-num { color: var(--green-main); }

.alltime-divider {
  width: 1px;
  height: 28px;
  background: var(--border-glass);
}

/* Barra di Dominanza All-Time */
.alltime-dominance-wrap {
  margin: 4px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.alltime-dominance-bar {
  height: 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.dominance-fill-yellow {
  background: var(--yellow-main);
  box-shadow: 0 0 8px var(--yellow-main);
  transition: width 0.4s ease;
}

.dominance-fill-green {
  background: var(--green-main);
  box-shadow: 0 0 8px var(--green-main);
  transition: width 0.4s ease;
}

.dominance-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 800;
}

.dom-lbl-y { color: var(--yellow-main); }
.dom-lbl-g { color: var(--green-main); }
.dom-center-dot { font-size: 0.65rem; opacity: 0.6; }

.history-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 18px;
  display: flex;
  flex-direction: column;
}

.history-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-list-header h4 {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn-text-danger {
  background: transparent;
  border: none;
  color: #EF4444;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-text-danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.history-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.history-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: #FFF;
}

.history-trip-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.history-winner-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.pill-yellow {
  background: rgba(255, 183, 3, 0.2);
  color: var(--yellow-main);
  border: 1px solid rgba(255, 183, 3, 0.35);
}

.pill-green {
  background: rgba(6, 214, 160, 0.2);
  color: var(--green-main);
  border: 1px solid rgba(6, 214, 160, 0.35);
}

.pill-tie {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-del-single {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-del-single:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #EF4444;
}

.history-card-scores {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.card-score-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-player-label {
  font-size: 0.78rem;
  font-weight: 700;
}

.card-score-val {
  font-size: 1.15rem;
  font-weight: 900;
}

/* Empty State Vetrina con le due auto */
.history-empty {
  text-align: center;
  padding: 32px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-showcase-cars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
  padding: 12px 16px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, transparent 70%);
  border-radius: var(--radius-md);
}

.empty-car-y {
  width: 64px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(255, 183, 3, 0.3));
}

.empty-car-g {
  width: 68px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(6, 214, 160, 0.3));
}

.empty-vs-spark {
  font-size: 1rem;
  color: #FFF;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.empty-main-text {
  font-size: 0.95rem;
  font-weight: 800;
  color: #FFF;
  line-height: 1.2;
}

.empty-sub-text {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
  max-width: 260px;
}

/* --------------------------------------------------------------------------
   ORIENTAMENTO ORIZZONTALE (CRUSCOTTO AUTO)
   -------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 520px) {
  .screen-game {
    flex-direction: row;
  }

  .zone-yellow {
    height: 100% !important;
    width: var(--split-pos, 50%);
    transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .zone-green {
    height: 100% !important;
    width: calc(100% - var(--split-pos, 50%));
    transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .center-divider {
    top: 0;
    bottom: 0;
    left: var(--split-pos, 50%);
    transform: translateX(-50%);
    flex-direction: column;
    width: 36px;
    height: 100%;
    padding: 10px 0;
    transition: left 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .road-asphalt-strip {
    flex-direction: column;
    border-top: none;
    border-bottom: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }

  .road-dash {
    width: 3px;
    height: 32px;
  }

  .tug-of-war-track {
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    height: 100%;
    flex-direction: column;
  }

  .score-number {
    font-size: clamp(2.8rem, 16vh, 4.2rem);
  }
}
