/* =============================================================================
   F1 SEASON SIMULATOR — FOGLIO DI STILE GLOBALE
   Design system §11: dark mode, palette F1, tipografia Barlow/Titillium.
   ========================================================================== */

/* ----------------------------------------------------------------- TOKENS */
:root {
  --color-bg:         #0a0a0a;
  --color-bg-2:       #141414;
  --color-bg-3:       #1e1e1e;
  --color-red:        #e10600;
  --color-red-dark:   #b30000;
  --color-white:      #ffffff;
  --color-gray-light: #cccccc;
  --color-gray:       #888888;
  --color-gray-dark:  #444444;
  --color-gold:       #ffd700;
  --color-silver:     #c0c0c0;
  --color-bronze:     #cd7f32;

  /* token semantici (variano col tema) */
  --navbar-bg:  rgba(10,10,10,0.92);
  --card-glass: rgba(20,20,20,0.7);
  --card-inset: #0d0d0f;
  --shadow:     rgba(0,0,0,0.5);
  --fantasy:    #ff2d20;   /* evidenziazione piloti dell'utente (al posto della stella) */

  /* 5 livree racing per le righe di estrazione */
  --livery-1: #e10600; /* rosso */
  --livery-2: #1e6fff; /* blu */
  --livery-3: #f0b400; /* giallo */
  --livery-4: #00b35a; /* verde */
  --livery-5: #7a8088; /* grigio */

  --font-display: 'Barlow Condensed', 'Titillium Web', sans-serif;
  --font-body:    'Titillium Web', system-ui, sans-serif;

  --radius:   8px;
  --radius-s: 4px;
  --t:        0.2s ease;
  --maxw:     1280px;
}

/* ------------------------------------------------------------- TEMA CHIARO */
:root[data-theme="light"] {
  --color-bg:         #eef0f4;
  --color-bg-2:       #ffffff;
  --color-bg-3:       #d8dce3;
  --color-white:      #16181d;  /* "foreground": testo scuro su chiaro */
  --color-gray-light: #3b424c;
  --color-gray:       #6a727d;
  --color-gray-dark:  #b9bfc8;
  --color-gold:       #c79a00;

  --navbar-bg:  rgba(255,255,255,0.9);
  --card-glass: rgba(255,255,255,0.78);
  --card-inset: #f1f3f7;
  --shadow:     rgba(20,30,50,0.16);
}
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* ------------------------------------------------------------------ RESET */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--color-bg);
  color: var(--color-white);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5em;
  line-height: 1.05;
}
.label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  color: var(--color-gray);
}

/* --------------------------------------------------------------- BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  border: none;
  border-radius: var(--radius-s);
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.7em 1.4em;
  font-size: 1rem;
  transition: transform var(--t), background var(--t), opacity var(--t), box-shadow var(--t);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-red); color: #fff; }
.btn-primary:hover { background: var(--color-red-dark); box-shadow: 0 4px 18px rgba(225,6,0,0.4); }
.btn-outline {
  background: transparent;
  color: var(--color-white);
  border: 1px solid var(--color-white);
}
.btn-outline:hover { background: color-mix(in srgb, var(--color-white) 12%, transparent); }
.btn-lg { font-size: 1.4rem; padding: 0.85em 2em; }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------------------------------------------------------------- NAVBAR */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.4rem;
  background: var(--navbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-bg-3);
}
.navbar .logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.navbar .logo .logo-mark { color: var(--color-red); font-size: 1.6rem; line-height: 1; }
.nav-links { display: flex; align-items: center; gap: 1.2rem; }
.nav-links a { font-weight: 600; color: var(--color-gray-light); transition: color var(--t); }
.nav-links a:hover, .nav-links a.active { color: var(--color-white); }

.user-menu { position: relative; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--color-red);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  border: none;
  text-transform: uppercase;
}
.dropdown {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  background: var(--color-bg-2);
  border: 1px solid var(--color-bg-3);
  border-radius: var(--radius);
  min-width: 170px;
  padding: 0.4rem;
  display: none;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.user-menu.open .dropdown { display: flex; }
.dropdown a, .dropdown button {
  text-align: left;
  background: none;
  border: none;
  color: var(--color-gray-light);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-s);
  font-size: 0.95rem;
  font-family: var(--font-body);
}
.dropdown a:hover, .dropdown button:hover { background: var(--color-bg-3); color: #fff; }
.dropdown .username-line { color:#fff; font-weight:700; padding:0.6rem 0.8rem; border-bottom:1px solid var(--color-bg-3); margin-bottom:0.3rem;}

/* ------------------------------------------------------------- CONTAINERS */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 1.4rem; }
.page { padding: 2.5rem 0 4rem; }
.section-title { font-size: 2rem; margin-bottom: 1.2rem; }
.muted { color: var(--color-gray); }

/* --------------------------------------------------------------- ASPHALT */
.asphalt {
  background-color: #0c0c0d;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.025) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.02) 0 1px, transparent 1px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.018) 0 1px, transparent 1px),
    linear-gradient(180deg, #101012 0%, #0a0a0a 100%);
  background-size: 7px 7px, 11px 11px, 9px 9px, 100% 100%;
}

/* --------------------------------------------------------------- HOMEPAGE */
.hero {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 2rem 1.4rem;
  position: relative;
  overflow: hidden;
}
.hero::after { /* striscia rossa diagonale d'accento */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 60%, rgba(225,6,0,0.08) 60%, rgba(225,6,0,0.08) 64%, transparent 64%);
  pointer-events: none;
}
.hero-card {
  position: relative;
  z-index: 1;
  max-width: 640px;
  text-align: center;
  background: var(--card-glass);
  border: 1px solid var(--color-bg-3);
  border-radius: 14px;
  padding: 3rem 2.5rem;
  backdrop-filter: blur(4px);
  box-shadow: 0 30px 80px var(--shadow);
}
.hero-card h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); }
.hero-card .subtitle { color: var(--color-gray-light); font-size: 1.15rem; margin-bottom: 2rem; }
.hero-actions { display: flex; flex-direction: column; gap: 0.9rem; align-items: center; }
.hero-actions .btn-lg { width: 100%; max-width: 340px; }
.kicker {
  display: inline-block;
  font-family: var(--font-display);
  letter-spacing: 0.2em;
  color: var(--color-red);
  font-weight: 700;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------- HOW IT WORKS */
.hiw-intro { max-width: 760px; color: var(--color-gray-light); font-size: 1.1rem; margin-bottom: 2.5rem; }
.hiw-section {
  background: var(--color-bg-2);
  border: 1px solid var(--color-bg-3);
  border-radius: var(--radius);
  padding: 1.8rem;
  margin-bottom: 1.6rem;
}
.hiw-section h2 { font-size: 1.5rem; color: #fff; }
.hiw-section h2 .num { color: var(--color-red); margin-right: 0.5rem; }
.hiw-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-top: 1rem; }
.hiw-step { background: var(--color-bg-3); border-radius: var(--radius); padding: 1rem; text-align: center; }
.hiw-step .big { font-family: var(--font-display); font-size: 2.4rem; color: var(--color-red); }
.formula-card {
  background: var(--card-inset);
  border: 1px dashed var(--color-gray-dark);
  border-radius: var(--radius);
  padding: 1.4rem;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  text-align: center;
  letter-spacing: 0.03em;
  margin: 1rem 0;
}
.formula-card .op { color: var(--color-red); }
.formula-card .x { color: var(--color-gold); }
.weight-demo { display: flex; align-items: flex-end; gap: 0.5rem; height: 160px; margin-top: 1rem; }
.weight-demo .bar { flex: 1; background: linear-gradient(180deg, var(--color-red), var(--color-red-dark)); border-radius: 4px 4px 0 0; position: relative; transition: height 0.6s ease; }
.weight-demo .bar span { position: absolute; top: -1.4rem; left: 0; right: 0; text-align: center; font-size: 0.7rem; color: var(--color-gray-light); }

/* --------------------------------------------------------------- GAME */
.game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.6rem;
  align-items: start;
  transition: grid-template-columns 0.6s cubic-bezier(.4,0,.2,1);
}
/* durante la simulazione la colonna di composizione si restringe */
.game-grid.simulating { grid-template-columns: 0.4fr 1.6fr; }
.game-col { min-width: 0; }
.panel-title { font-size: 1.3rem; margin-bottom: 1rem; display:flex; align-items:center; gap:0.6rem;}
.panel-title .dot { width:10px; height:10px; border-radius:50%; background:var(--color-red); display:inline-block;}

/* SLOTS */
.slot {
  background: var(--color-bg-2);
  border: 1px solid var(--color-bg-3);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  transition: border-color var(--t), opacity var(--t);
}
.slot.locked { opacity: 0.5; }
.slot.confirmed { border-color: var(--color-red); }
.slot-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.8rem; }
.slot-header h3 { margin: 0; font-size: 1.1rem; }
/* lo stato dello slot è comunicato da colore/opacità, non da testo */
.slot.ready { border-color: color-mix(in srgb, var(--color-red) 35%, var(--color-bg-3)); }

/* bandierine reali (flag-icons) */
.flag-ico { width: 1.5em; height: 1.125em; border-radius: 2px; box-shadow: 0 0 0 1px var(--color-bg-3); flex: none; background-size: cover; }
.flag-ph { font-size: 1.2em; }

/* OPZIONI DI ESTRAZIONE — righe livrea, eleganti */
.options { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.7rem; }
.option-row {
  --livery: var(--color-gray-dark);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--livery) 16%, var(--color-bg-2)), var(--color-bg-2) 78%);
  border: 1px solid var(--color-bg-3);
  border-left: 3px solid var(--livery);
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t), background var(--t);
  animation: rowIn 0.3s ease both;
}
.option-row:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--livery) 60%, var(--color-bg-3));
  box-shadow: 0 8px 22px var(--shadow);
}
.option-row .flag-ico { width: 1.9em; height: 1.42em; }
.option-row .opt-main { flex: 1; min-width: 0; }
.option-row .opt-name { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.option-row .opt-stats { font-size: 0.8rem; color: var(--color-gray-light); }
.option-row .opt-stats b { color: var(--color-white); font-weight: 700; }
.option-row .chev { color: var(--color-gray); transition: transform var(--t), color var(--t); flex: none; }
.option-row:hover .chev { transform: translateX(3px); color: var(--color-red); }

@keyframes rowIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }

/* CARD COMPATTA SCELTA */
.chosen { display: flex; align-items: center; gap: 0.85rem; padding: 0.5rem 0.2rem; }
.chosen .flag-ico { width: 2.1em; height: 1.57em; }
.chosen .c-name { font-weight: 700; }
.chosen .c-sub { font-size: 0.82rem; color: var(--color-gray); }

/* ======================= IL TUO BOX — vista dall'alto ===================== */
.pit-scene {
  position: relative;
  border-radius: var(--radius);
  padding: 1rem;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--color-white) 4%, var(--color-bg)) 0%, var(--color-bg) 100%);
  border: 1px solid var(--color-bg-3);
  display: flex; flex-direction: column; gap: 0;
}
.pit-icon { width: 40px; height: 40px; display: block; }
.pit-icon svg { width: 100%; height: 100%; }
.pit-label { font-weight: 700; font-size: 0.95rem; line-height: 1.1; }
.pit-sub { font-size: 0.76rem; color: var(--color-gray); display: flex; align-items: center; gap: 0.35rem; justify-content: center; }
.pit-role { font-family: var(--font-display); letter-spacing: 0.1em; font-size: 0.66rem; color: var(--color-gray); text-transform: uppercase; }

/* garage con due bay piloti */
.garages { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.driver-bay {
  background: var(--color-bg-2);
  border: 1px solid var(--color-bg-3);
  border-top: 3px solid var(--color-gray-dark);
  border-radius: 8px 8px 4px 4px;
  padding: 0.9rem 0.6rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  transition: border-color var(--t), opacity var(--t), transform var(--t);
}
.driver-bay .pit-icon { color: var(--color-gray-light); }
.driver-bay.filled { border-top-color: var(--color-red); }
.driver-bay.filled .pit-icon { color: var(--color-red); }
.driver-bay.empty { opacity: 0.45; border-style: dashed; }
.driver-bay.pop, .pit-box.pop, .pit-wall.pop { animation: pop 0.4s ease; }
@keyframes pop { 0%{transform:scale(0.94);} 60%{transform:scale(1.03);} 100%{transform:scale(1);} }

/* corsia box con piazzola di sosta e vettura */
.pitlane {
  position: relative; margin: 0.7rem 0;
  padding: 1rem 0.6rem;
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, color-mix(in srgb, var(--color-white) 8%, transparent) 22px 26px),
    color-mix(in srgb, var(--color-white) 3%, var(--color-bg-2));
  border-top: 2px dashed color-mix(in srgb, var(--color-gold) 55%, transparent);
  border-bottom: 2px dashed color-mix(in srgb, var(--color-gold) 55%, transparent);
}
.pit-box {
  max-width: 240px; margin: 0 auto;
  border: 2px dashed color-mix(in srgb, var(--color-white) 55%, transparent);
  border-radius: 6px;
  padding: 0.7rem 0.6rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  transition: border-color var(--t), opacity var(--t), transform var(--t);
}
.pit-box .pit-icon { width: 58px; height: 84px; color: var(--color-gray-light); }
.pit-box.filled { border-color: color-mix(in srgb, var(--color-red) 70%, transparent); }
.pit-box.filled .pit-icon { color: var(--color-red); }
.pit-box.empty { opacity: 0.5; }

/* muretto box (TP) */
.pit-wall {
  background: linear-gradient(180deg, var(--color-bg-3), var(--color-bg-2));
  border: 1px solid var(--color-bg-3);
  border-radius: 4px 4px 8px 8px;
  padding: 0.7rem 0.9rem;
  display: flex; align-items: center; gap: 0.8rem;
  transition: border-color var(--t), opacity var(--t), transform var(--t);
}
.pit-wall .pit-icon { width: 34px; height: 34px; color: var(--color-gray-light); flex: none; }
.pit-wall.filled { border-color: var(--color-red); }
.pit-wall.filled .pit-icon { color: var(--color-red); }
.pit-wall.empty { opacity: 0.45; border-style: dashed; }
.pit-wall .pit-sub { justify-content: flex-start; }
.pit-wall .wall-text { text-align: left; }

/* ----------------------------------------------------- SEMAFORI / INTRO */
.sim-stage { position: relative; min-height: 420px; }
.lights {
  display: flex; gap: 0.8rem; justify-content: center; margin-bottom: 1.6rem;
}
.light {
  width: 34px; height: 34px; border-radius: 50%;
  background: #2a0000; border: 2px solid #1a0000;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.light.on { background: var(--color-red); box-shadow: 0 0 18px rgba(225,6,0,0.9); }
.sim-intro { text-align: center; padding: 2rem 1rem; }
.sim-intro h2 { font-size: 1.8rem; }

/* FRAME GARA */
.race-frame {
  background: var(--color-bg-2);
  border: 1px solid var(--color-bg-3);
  border-radius: var(--radius);
  overflow: hidden;
  animation: frameIn 0.25s ease;
}
@keyframes frameIn { from { opacity: 0.2; } to { opacity: 1; } }
.race-frame-head {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--color-bg-3);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, rgba(225,6,0,0.12), transparent);
}
.race-frame-head .rf-gp { font-family: var(--font-display); font-size: 1.2rem; letter-spacing: 0.04em; }
.race-frame-head .rf-round { color: var(--color-gray); font-weight: 600; }
.race-frame-head .rf-circuit { font-size: 0.85rem; color: var(--color-gray-light); }
.podium-row {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--color-bg-3);
  font-weight: 600;
}
.podium-row:last-child { border-bottom: none; }
.podium-row .medal { font-size: 1.3rem; width: 1.6rem; }
.podium-row .pr-name { flex: 1; }
.podium-row .pr-team { color: var(--color-gray); font-size: 0.85rem; }
.podium-row.fantasy {
  background: rgba(225,6,0,0.14);
  border-left: 4px solid var(--color-red);
  animation: pulse 0.9s ease infinite;
}
@keyframes pulse { 0%,100%{ background: rgba(225,6,0,0.14);} 50%{ background: rgba(225,6,0,0.28);} }
.race-progress { height: 6px; background: var(--color-bg-3); border-radius: 999px; overflow: hidden; margin-top: 1.2rem; }
.race-progress > i { display: block; height: 100%; background: var(--color-red); width: 0; transition: width 0.2s linear; }

/* ----------------------------------------------------------- RISULTATI */
.results { animation: frameIn 0.4s ease; }
.results-hero { text-align: center; padding: 1.5rem 0 0.5rem; }
.results-hero .big-count {
  font-family: var(--font-display);
  font-size: clamp(4rem, 16vw, 8rem);
  line-height: 0.9;
  color: var(--color-white);
}
.results-hero .big-count .slash { color: var(--color-gray); }
.results-hero .big-count .of { color: var(--color-gray); font-size: 0.4em; }
.results-verdict { font-family: var(--font-display); font-size: 1.3rem; color: var(--color-gold); letter-spacing: 0.03em; }
.progress-wide { height: 16px; background: var(--color-bg-3); border-radius: 999px; overflow: hidden; margin: 1.2rem auto; max-width: 520px; }
.progress-wide > i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--color-red), var(--color-gold) 60%, var(--color-green, #00b35a)); transition: width 1.4s cubic-bezier(.2,.8,.2,1); }

.stats-table, .races-table, .standings-table, .order-table { width: 100%; border-collapse: collapse; margin-top: 0.6rem; }
.stats-table th, .stats-table td,
.races-table th, .races-table td,
.standings-table th, .standings-table td,
.order-table th, .order-table td { padding: 0.5rem 0.7rem; text-align: left; border-bottom: 1px solid var(--color-bg-3); }
.stats-table th, .races-table th, .standings-table th, .order-table th {
  font-family: var(--font-display); letter-spacing: 0.05em; color: var(--color-gray);
  font-weight: 700; text-transform: uppercase; font-size: 0.78rem;
  position: sticky; top: 0; background: var(--color-bg-2); z-index: 1;
}
.races-table td.num, .standings-table td.num, .order-table td.num { color: var(--color-gray); }
.standings-table td.pts, .order-table td.pts { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* righe gara cliccabili */
.races-table tbody tr.race-row { cursor: pointer; transition: background var(--t); }
.races-table tbody tr.race-row:hover { background: color-mix(in srgb, var(--color-red) 10%, transparent); }
.races-table tr.race-row.win { background: color-mix(in srgb, var(--color-red) 20%, transparent); }
.races-table tr.race-row.podium { background: color-mix(in srgb, var(--color-red) 8%, transparent); }
.races-table tr.race-row .rr-toggle { color: var(--color-gray); transition: transform var(--t); display: inline-block; }
.races-table tr.race-row.open .rr-toggle { transform: rotate(90deg); color: var(--color-red); }
.race-detail > td { padding: 0 !important; background: var(--card-inset); }
.race-detail-inner { padding: 0.4rem 0.8rem 0.9rem; }
.race-detail .order-table th { background: var(--card-inset); }

/* evidenziazione piloti dell'utente (al posto della stella) */
.drv-fantasy { color: var(--fantasy); font-weight: 700; }
.drv-fantasy::before { content: "▸ "; color: var(--fantasy); }
tr.drv-fantasy-row { background: color-mix(in srgb, var(--fantasy) 12%, transparent); }
tr.drv-fantasy-row td { border-bottom-color: color-mix(in srgb, var(--fantasy) 25%, var(--color-bg-3)); }

/* classifica accanto alle gare */
.results-cols { display: grid; grid-template-columns: 1.45fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .results-cols { grid-template-columns: 1fr; } }

/* layout risultati a sezioni */
.results-top, .results-mid { display: grid; gap: 1.4rem; margin-bottom: 1.4rem; }
.results-top { grid-template-columns: 1fr 1fr; align-items: stretch; }
.results-mid { grid-template-columns: 1fr 1fr; align-items: start; }
.results-top .block { margin: 0; height: 100%; }
.results-mid .block { margin: 0; }
.summary-block { display: flex; flex-direction: column; }
.summary-block .results-hero { padding-bottom: 0.4rem; }
.summary-count { font-size: clamp(3rem, 8vw, 5rem) !important; }
.team-recap h3, .summary-block .label { margin-bottom: 0.6rem; }
@media (max-width: 900px) {
  .results-top, .results-mid { grid-template-columns: 1fr; }
  .results-top .block { height: auto; }
}

/* grafico andamento mondiale */
.trend-chart { width: 100%; color: var(--color-gray-light); margin-top: 0.4rem; }
.trend-chart svg { width: 100%; height: auto; display: block; overflow: visible; }

.results-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; margin: 1.8rem 0; }
.block { background: var(--color-bg-2); border: 1px solid var(--color-bg-3); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1.4rem; }
.block h3 { font-size: 1.2rem; }
.table-scroll { max-height: 520px; overflow: auto; }

/* --------------------------------------------------------------- MODALS */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--color-bg-2);
  border: 1px solid var(--color-bg-3);
  border-radius: 12px;
  width: 100%; max-width: 400px;
  padding: 2rem;
  position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: pop 0.25s ease;
}
.modal h2 { font-size: 1.6rem; }
.modal .close {
  position: absolute; top: 0.8rem; right: 0.9rem;
  background: none; border: none; color: var(--color-gray); font-size: 1.4rem;
}
.modal .close:hover { color: var(--color-white); }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; color: var(--color-gray-light); margin-bottom: 0.3rem; font-weight: 600; }
.field input {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-bg-3);
  border-radius: var(--radius-s);
  color: var(--color-white);
  padding: 0.7rem 0.8rem;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--t);
}
.field input:focus { outline: none; border-color: var(--color-red); }
.modal-error { color: #ff6b6b; font-size: 0.88rem; min-height: 1.2em; margin-bottom: 0.6rem; }
.modal-switch { text-align: center; margin-top: 1rem; font-size: 0.9rem; color: var(--color-gray); }
.modal-switch a { color: var(--color-red); font-weight: 700; cursor: pointer; }

/* --------------------------------------------------------------- TOAST */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--color-bg-2); border: 1px solid var(--color-red); color: var(--color-white);
  padding: 0.8rem 1.2rem; border-radius: var(--radius); z-index: 2000;
  transition: transform 0.3s ease; box-shadow: 0 12px 40px var(--shadow); max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--livery-4); }

/* --------------------------------------------------------------- PROFILE */
.profile-head { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 2rem; flex-wrap: wrap; }
.profile-head .avatar-lg { width: 72px; height: 72px; font-size: 2rem; border-radius: 50%; background: var(--color-red); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; }
.profile-head .p-email { color: var(--color-gray); }
.sims-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.sim-card { background: var(--color-bg-2); border: 1px solid var(--color-bg-3); border-radius: var(--radius); padding: 1.2rem; transition: transform var(--t), border-color var(--t); }
.sim-card:hover { transform: translateY(-3px); border-color: var(--color-red); }
.sim-card .sim-date { font-size: 0.8rem; color: var(--color-gray); }
.sim-card .sim-team { font-size: 0.9rem; color: var(--color-gray-light); margin: 0.5rem 0; }
.sim-card .sim-wins { font-family: var(--font-display); font-size: 2.4rem; }
.sim-card .sim-wins .of { color: var(--color-gray); font-size: 0.5em; }
.empty-state { text-align: center; color: var(--color-gray); padding: 3rem 1rem; }

/* --------------------------------------------------------------- UTIL */
.hidden { display: none !important; }
.center { text-align: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--color-bg-3); border-top-color: var(--color-red); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 1rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: frameIn 0.4s ease; }

/* --------------------------------------------------------------- RESPONSIVE */
@media (max-width: 768px) {
  .game-grid, .game-grid.simulating { grid-template-columns: 1fr; }
  .nav-links { gap: 0.8rem; }
  .nav-links a.hide-mobile { display: none; }
  .hero-card { padding: 2rem 1.3rem; }
  .pitbox { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .navbar .logo { font-size: 1.1rem; }
  .results-hero .big-count { font-size: 4.5rem; }
  .brand .brand-text { font-size: 1.25rem; }
}

/* ===================== LOGO F1CHAMPS (stile racing) ===================== */
.brand { display: inline-flex; align-items: center; gap: 0.5rem; line-height: 1; }
.brand-flag {
  width: 22px; height: 18px; flex: none; transform: skewX(-12deg);
  border-radius: 2px; box-shadow: 0 0 0 1px var(--color-bg-3);
  background-color: var(--color-bg);
  background-image:
    linear-gradient(45deg, var(--color-white) 25%, transparent 25%),
    linear-gradient(-45deg, var(--color-white) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--color-white) 75%),
    linear-gradient(-45deg, transparent 75%, var(--color-white) 75%);
  background-size: 9px 9px;
  background-position: 0 0, 0 4.5px, 4.5px -4.5px, -4.5px 0;
}
.brand-text {
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
  letter-spacing: 0.01em; transform: skewX(-8deg); display: inline-flex; align-items: baseline;
  text-transform: lowercase;
}
.brand-text .b-f1 {
  color: var(--color-red); text-transform: uppercase; font-size: 1.08em;
  margin-right: 1px; text-shadow: 0 1px 0 color-mix(in srgb, var(--color-red) 40%, #000);
}
.brand-text .b-champs { color: var(--color-white); }
.brand-lg .brand-text { font-size: 2.6rem; }
.brand-lg .brand-flag { width: 34px; height: 27px; background-size: 13.5px 13.5px; background-position: 0 0, 0 6.75px, 6.75px -6.75px, -6.75px 0; }

/* ===================== TOGGLE TEMA (sole / luna) ===================== */
.theme-toggle {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%; border: 1px solid var(--color-bg-3);
  background: var(--color-bg-2); color: var(--color-white);
  display: grid; place-items: center; transition: transform var(--t), border-color var(--t), color var(--t);
}
.theme-toggle:hover { border-color: var(--color-red); color: var(--color-red); transform: rotate(18deg); }
.theme-toggle svg { width: 19px; height: 19px; display: block; }
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: block; }
:root[data-theme="light"] .theme-toggle .ic-sun { display: block; }
:root[data-theme="light"] .theme-toggle .ic-moon { display: none; }

/* ===================== RIFINITURE BOTTONI ===================== */
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--color-red) 92%, #fff 8%), var(--color-red));
  box-shadow: 0 1px 0 color-mix(in srgb, var(--color-white) 18%, transparent) inset, 0 2px 8px color-mix(in srgb, var(--color-red) 30%, transparent);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--color-red), var(--color-red-dark)); box-shadow: 0 6px 22px color-mix(in srgb, var(--color-red) 45%, transparent); }
.btn { border-radius: 6px; }

/* ===================== TEMA CHIARO: superfici specifiche ===================== */
:root[data-theme="light"] .asphalt {
  background-color: #e8eaef;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,0.025) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,0.02) 0 1px, transparent 1px),
    radial-gradient(circle at 40% 80%, rgba(0,0,0,0.018) 0 1px, transparent 1px),
    linear-gradient(180deg, #eef0f4 0%, #e4e7ed 100%);
  background-size: 7px 7px, 11px 11px, 9px 9px, 100% 100%;
}
:root[data-theme="light"] .race-frame-head { background: linear-gradient(90deg, rgba(225,6,0,0.10), transparent); }
:root[data-theme="light"] .light { background: #e8c9c9; border-color: #d8b0b0; }
:root[data-theme="light"] .light.on { background: var(--color-red); border-color: var(--color-red-dark); }
:root[data-theme="light"] .modal-error { color: #c0261d; }
