/* BIGLIAFIL — menu e HUD. Realizzato da CGFA. */
:root { --fondo: #0b1424; --pannello: rgba(10, 18, 34, 0.9); --testo: #f4f1ea; --tenue: #b6c0d2; --oro: #ffc93a; --rosso: #ff4a1c; --mare: #39b6ff; --bordo: rgba(150, 190, 255, 0.28); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fondo); color: var(--testo); font: 16px/1.45 Barlow, system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
#scena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

.schermata { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; z-index: 5;
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 170, 60, 0.18), transparent 60%), radial-gradient(ellipse at 50% 100%, rgba(30, 140, 255, 0.25), transparent 70%), rgba(5, 10, 22, 0.55); }
.schermata.trasparente { background: rgba(5, 10, 22, 0.5); }
.schermata.basso { place-items: end end; background: linear-gradient(90deg, transparent 40%, rgba(5, 10, 22, 0.55)); }
.schermata.basso .finestra { width: min(470px, 100%); gap: 8px; padding: 16px; }
.schermata.basso .classifica.arrivo { max-height: 26vh; }
.finestra { width: min(440px, 100%); background: var(--pannello); border: 1px solid var(--bordo); border-radius: 18px; padding: 22px 20px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08); backdrop-filter: blur(6px); }
.finestra.larga { width: min(680px, 100%); }
h1, h2, h3 { font-family: "Barlow Condensed", sans-serif; font-weight: 800; letter-spacing: 0.02em; margin: 0; }
h2 { font-size: 30px; text-transform: uppercase; }
h3 { font-size: 19px; color: var(--oro); margin-top: 4px; text-transform: uppercase; }
.logo { font-family: Bungee, "Barlow Condensed", sans-serif; font-size: clamp(46px, 12vw, 74px); line-height: 1; text-align: center; }
.logo span { color: #fff; text-shadow: 0 0 24px rgba(57, 182, 255, 0.6); }
.logo b { color: var(--oro); font-weight: 400; text-shadow: 0 0 24px rgba(255, 170, 40, 0.65); }
.sotto-logo { margin: -4px 0 0; text-align: center; font: 800 18px "Barlow Condensed", sans-serif; letter-spacing: 0.32em; text-transform: uppercase; color: var(--mare); }
.tenue { color: var(--tenue); margin: 0; }
.centro { text-align: center; }
.piccolo { font-size: 13px; color: var(--tenue); text-align: center; margin: 6px 0 0; }
.piccolo a, .link { color: var(--mare); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; min-height: 0; }
button, .bottone { appearance: none; border: 1px solid var(--bordo); background: rgba(255, 255, 255, 0.06); color: var(--testo); font: 600 17px Barlow, sans-serif; padding: 12px 14px; border-radius: 12px; cursor: pointer; min-height: 48px; text-align: center; text-decoration: none; transition: transform 0.08s, background 0.15s, border-color 0.15s; }
button:hover, .bottone:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.5); }
button:active { transform: scale(0.97); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--mare); outline-offset: 2px; }
button.pri { background: linear-gradient(180deg, #ffd96a, #ffaa1c); color: #2a1400; border: 0; font-family: "Barlow Condensed", sans-serif; font-weight: 800; font-size: 22px; text-transform: uppercase; letter-spacing: 0.04em; box-shadow: 0 6px 24px rgba(255, 170, 30, 0.35); }
button:disabled { opacity: 0.5; cursor: default; }
.riga2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.msg { min-height: 1.4em; margin: 0; color: var(--oro); text-align: center; }

/* scelta pista */
.piste { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pista { text-align: left; padding: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 120px; border-width: 2px; background-size: cover; background-position: center; position: relative; overflow: hidden; }
.pista::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.75)); }
.pista > * { position: relative; }
.pista b { font: 800 19px/1.05 "Barlow Condensed", sans-serif; text-transform: uppercase; margin-top: auto; }
.pista small { color: #dfe6f2; font-size: 13px; line-height: 1.2; }
.pista .stelle { color: var(--oro); letter-spacing: 2px; font-size: 13px; }
.pista .rec { font-size: 12px; color: #c9f0ff; }
.pista.on { border-color: var(--oro); box-shadow: 0 0 0 2px rgba(255, 201, 58, 0.35), 0 0 22px rgba(255, 201, 58, 0.3); }
.biglie { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.biglia { min-height: 64px; padding: 6px 2px; display: grid; justify-items: center; gap: 4px; font-size: 11px; line-height: 1.1; }
.biglia i { width: 34px; height: 34px; border-radius: 50%; display: block; box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.45), inset 5px 6px 10px rgba(255, 255, 255, 0.55); }
.biglia.on { border: 2px solid var(--oro); background: rgba(255, 201, 58, 0.12); }
.biglie.tante { max-height: 34vh; overflow-y: auto; }
.pillole small { opacity: 0.7; font-size: 12px; }
@media (max-width: 560px) { .piste { grid-template-columns: 1fr; } .pista { min-height: 78px; } .biglie { grid-template-columns: repeat(4, 1fr); } }

.campo { display: grid; gap: 6px; font-weight: 600; }
#nome, #codice { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--bordo); color: var(--testo); border-radius: 10px; padding: 12px; font: 600 17px Barlow, sans-serif; min-height: 48px; }
input[type=range] { width: 100%; accent-color: var(--oro); }
.spunta { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.spunta input { width: 22px; height: 22px; accent-color: var(--oro); flex: none; }
.pillole { display: flex; flex-wrap: wrap; gap: 6px; }
.pillole button { min-height: 40px; padding: 6px 12px; font-size: 15px; }
.pillole button.on { background: var(--oro); color: #2a1400; border-color: var(--oro); }
.entra { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#codice { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; }
.stanza { text-align: center; font-size: 20px; margin: 0; } .stanza b { font-family: Bungee, sans-serif; color: var(--oro); letter-spacing: 0.15em; }
.classifica { margin: 0; padding: 0 0 0 30px; max-height: 40vh; overflow-y: auto; }
.classifica li { padding: 6px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.classifica li b { color: var(--oro); font-variant-numeric: tabular-nums; }
.classifica li.tu { background: rgba(255, 201, 58, 0.12); border-radius: 8px; }
.classifica .vuota { list-style: none; margin-left: -30px; color: var(--tenue); }
.classifica .pall { width: 14px; height: 14px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: -2px; box-shadow: inset -2px -3px 4px rgba(0, 0, 0, 0.4); }
.classifica.arrivo, .classifica.camp { max-height: 32vh; }

.testo-lungo { max-height: 56vh; overflow-y: auto; padding-right: 6px; color: #dfe6f2; }
.testo-lungo ul { padding-left: 20px; margin: 6px 0; } .testo-lungo li { margin: 4px 0; }
.comandi { width: 100%; border-collapse: collapse; font-size: 15px; margin: 6px 0; }
.comandi th, .comandi td { text-align: left; padding: 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); vertical-align: top; }
.comandi th { color: var(--oro); }
.riepilogo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.riepilogo div { background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 8px 10px; }
.riepilogo span { display: block; font-size: 13px; color: var(--tenue); }
.riepilogo b { font: 800 24px "Barlow Condensed", sans-serif; }
.vinto { color: var(--oro); text-shadow: 0 0 20px rgba(255, 201, 58, 0.45); text-align: center; }

/* caricamento */
.carica { position: fixed; inset: 0; z-index: 8; display: grid; place-content: center; gap: 14px; text-align: center; background: radial-gradient(ellipse at 50% 40%, #16304f, #070d18); }
.piccolo-logo { font-size: 52px; }
.barra-carica { width: min(320px, 70vw); height: 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin: 0 auto; }
.barra-carica i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mare), var(--oro)); transition: width 0.2s; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; font-family: "Barlow Condensed", sans-serif; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); }
.h-pos { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); font-weight: 800; line-height: 1; }
.h-pos b { font-size: 58px; color: var(--oro); } .h-pos span { font-size: 24px; opacity: 0.85; }
.h-tempo { position: absolute; top: max(74px, calc(env(safe-area-inset-top) + 64px)); left: max(16px, env(safe-area-inset-left)); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.h-vel { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(96px, calc(env(safe-area-inset-bottom) + 86px)); text-align: right; line-height: 1; }
.h-vel b { font-size: 48px; display: block; font-variant-numeric: tabular-nums; } .h-vel span { font-size: 16px; opacity: 0.8; }
.striscia { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(520px, 46vw); height: 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.3); }
#hStriscia { position: relative; height: 100%; }
#hStriscia i { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.6); }
#hStriscia i.tu { width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 2px solid #fff; z-index: 2; }
#hStriscia i.fant { opacity: 0.55; border-style: dashed; border-color: #fff; }
.h-lista { position: absolute; top: max(110px, calc(env(safe-area-inset-top) + 100px)); left: max(14px, env(safe-area-inset-left)); margin: 0; padding: 0; list-style: none; font-size: 16px; font-weight: 600; min-width: 150px; }
.h-lista li { display: flex; align-items: center; gap: 6px; padding: 1px 6px; border-radius: 6px; }
.h-lista li.tu { background: rgba(255, 201, 58, 0.25); }
.h-lista li i { width: 11px; height: 11px; border-radius: 50%; }
.h-lista li small { margin-left: auto; opacity: 0.75; font-variant-numeric: tabular-nums; }
.h-turbo { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(70px, calc(env(safe-area-inset-bottom) + 60px)); display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
.h-turbo .barra { width: 150px; height: 12px; border-radius: 7px; background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.4); overflow: hidden; }
.h-turbo .barra i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff4a1c, #ffc93a); }
.h-turbo.attivo .barra i { background: linear-gradient(90deg, #ffe05a, #fff); box-shadow: 0 0 12px #ffd23a; }
.h-msg { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); font: 400 clamp(44px, 9vw, 96px) Bungee, sans-serif; color: #fff; text-align: center; white-space: nowrap; opacity: 0; transition: opacity 0.2s; }
.h-msg.vis { opacity: 1; }
.h-msg.piccolo { font-size: clamp(22px, 4vw, 38px); }
.h-tratto { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); font-size: 22px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: #ffe9b0; opacity: 0; transition: opacity 0.4s; }
.h-tratto.vis { opacity: 1; }
.h-tasti { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.tondo { pointer-events: auto; width: 48px; height: 48px; min-height: 48px; border-radius: 50%; padding: 0; font: 800 18px "Barlow Condensed", sans-serif; background: rgba(0, 0, 0, 0.45); }
.touch { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 0 max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-bottom)); pointer-events: none; }
.touch div { display: flex; gap: 12px; pointer-events: auto; }
.touch button { width: 76px; height: 76px; border-radius: 50%; font: 800 26px "Barlow Condensed", sans-serif; background: rgba(0, 0, 0, 0.4); border: 2px solid rgba(255, 255, 255, 0.45); touch-action: none; user-select: none; -webkit-user-select: none; }
.touch button.giu { background: rgba(255, 201, 58, 0.45); }
.touch .t-turbo { width: 92px; height: 92px; font-size: 20px; background: rgba(255, 74, 28, 0.45); }
.touch .t-freno { font-size: 16px; }
.con-touch .h-vel { bottom: 200px; } .con-touch .h-turbo { bottom: 176px; }
#etichette { position: fixed; inset: 0; pointer-events: none; z-index: 2; font: 700 13px "Barlow Condensed", sans-serif; }
#etichette span { position: absolute; transform: translate(-50%, -100%); padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.5); white-space: nowrap; border-bottom: 2px solid var(--c, #fff); }
#etichette span.tu { background: rgba(255, 201, 58, 0.85); color: #241200; font-size: 14px; }
.gira { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: rgba(0, 0, 0, 0.6); padding: 8px 14px; border-radius: 10px; z-index: 4; pointer-events: none; font-size: 14px; text-align: center; width: max-content; max-width: 90vw; }
.credit { position: fixed; right: 10px; bottom: 6px; z-index: 6; font-size: 12px; opacity: 0.75; }
.credit a { color: #d6e2f5; text-decoration: none; }
body.in-gara .credit { bottom: auto; top: 64px; }
@media (max-height: 520px) { .finestra { padding: 14px; gap: 7px; } h2 { font-size: 24px; } button { min-height: 42px; padding: 8px 12px; } .logo { font-size: 40px; } .h-pos b { font-size: 42px; } .h-lista { top: 92px; font-size: 14px; } .h-tempo { top: 56px; font-size: 20px; } }
@media (max-width: 700px) { .h-lista { display: none; } .striscia { width: 52vw; } }
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
