:root{
  --bg:#090c10;
  --surface:#0f141c;
  --surface-2:#151c27;
  --panel:rgba(10,14,20,0.86);
  --panel-strong:rgba(9,13,19,0.95);
  --ink:#eef6ff;
  --muted:#8fa3bc;
  --cyan:#00f0ff;
  --emerald:#00ff88;
  --red:#ff3b4e;
  --gold:#ffd23d;
  --line:rgba(255,255,255,0.11);
  --line-cyan:rgba(0,240,255,0.34);
  --font-ui:"Plus Jakarta Sans","Segoe UI",sans-serif;
  --font-hud:"Oxanium","Trebuchet MS","Segoe UI",sans-serif;
  --ctrl-scale:1;
  --hud-opacity:1;
  box-sizing:border-box;
}
*{box-sizing:inherit}
html,body{
  height:100%;
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:var(--font-ui);
  overflow:hidden;
  touch-action:none;
  -webkit-font-smoothing:antialiased;
}
canvas{display:block;width:100%;height:100%}

/* ===== VISIBILIDAD POR ESTADOS (MENÚ / INTRO FRONTAL / GARAJE / CARRERA / PAUSA) ===== */
body.state-menu #hud,
body.state-menu #minimap-wrap,
body.state-menu #spd,
body.state-menu #dh,
body.state-menu #ct,
body.state-menu #lg,
body.state-menu #pa,
body.state-menu #wm,
body.state-menu #ck,
body.state-menu #cb,
body.state-menu #race-top-acts,
body.state-menu #ex,
body.state-menu #btn-mute-race,
body.state-menu #tc,
body.state-menu #tc2,
body.state-menu #fx,
body.state-menu #pp,
body.state-menu #aud-hud-trk,
body.state-menu #lit-radio-hud,
body.state-menu #intro-track-banner,
body.state-menu #race-track-badge,
body.state-menu #vip-club,
body.state-menu #vip-panel,
body.state-menu #vip-hud,
body.state-menu #vip-badge,
body.state-menu .vip-club,
body.state-menu .vip-panel,
body.state-menu .vip-club-panel,
body.state-menu .vip-club-hud,
body.state-menu [data-vip-club]{display:none!important}

body.state-intro #hud,
body.state-intro #minimap-wrap,
body.state-intro #spd,
body.state-intro #dh,
body.state-intro #ct,
body.state-intro #lg,
body.state-intro #pa,
body.state-intro #wm,
body.state-intro #ck,
body.state-intro #cb,
body.state-intro #race-top-acts,
body.state-intro #ex,
body.state-intro #btn-mute-race,
body.state-intro #tc,
body.state-intro #tc2,
body.state-intro #fx,
body.state-intro #pp,
body.state-intro #aud-hud-trk,
body.state-intro #lit-radio-hud,
body.state-intro #race-track-badge,
body.state-intro #vip-club,
body.state-intro #vip-panel,
body.state-intro #vip-hud,
body.state-intro #vip-badge,
body.state-intro .vip-club,
body.state-intro .vip-panel,
body.state-intro .vip-club-panel,
body.state-intro .vip-club-hud,
body.state-intro [data-vip-club]{display:none!important}

body.in-garage #hud,
body.in-garage #minimap-wrap,
body.in-garage #spd,
body.in-garage #dh,
body.in-garage #ct,
body.in-garage #lg,
body.in-garage #pa,
body.in-garage #wm,
body.in-garage #ck,
body.in-garage #msg,
body.in-garage #race-top-acts,
body.in-garage #ex,
body.in-garage #btn-mute-race,
body.in-garage #tc,
body.in-garage #tc2,
body.in-garage #cb,
body.in-garage #fx,
body.in-garage #pp,
body.in-garage #aud-hud-trk,
body.in-garage #lit-radio-hud,
body.state-garage #lit-radio-hud,
body.in-garage #intro-track-banner,
body.in-garage #race-track-badge,
body.in-garage #vip-club,
body.in-garage #vip-panel,
body.in-garage #vip-hud,
body.in-garage #vip-badge,
body.in-garage .vip-club,
body.in-garage .vip-panel,
body.in-garage .vip-club-panel,
body.in-garage .vip-club-hud,
body.in-garage [data-vip-club]{display:none!important}

body.hud-mm-off #minimap-wrap{display:none!important}
body.hud-radio-off #aud-hud-trk,
body.hud-radio-off #lit-radio-hud,
body.hud-radio-off #vip-club,
body.hud-radio-off #vip-panel,
body.hud-radio-off #vip-hud,
body.hud-radio-off #vip-badge,
body.hud-radio-off .vip-club,
body.hud-radio-off .vip-panel,
body.hud-radio-off .vip-club-panel,
body.hud-radio-off .vip-club-hud,
body.hud-radio-off [data-vip-club]{display:none!important}
body.hud-rpm-off #lg{display:none!important}

body.is-autopilot #tc,
body.is-autopilot #tc2{
  opacity:calc(var(--hud-opacity) * 0.32);
  pointer-events:none;
  filter:saturate(.45);
}

[data-state-hidden="1"]{display:none!important}

/* ===== CONTROLES BASE Y BOTONES ===== */
button,input,textarea{
  font-family:inherit;
  font-size:13px;
  border-radius:10px;
  border:1px solid var(--line-cyan);
  background:rgba(15,20,28,0.92);
  color:var(--ink);
  transition:transform .16s cubic-bezier(.16,1,.3,1),background-color .16s ease,border-color .16s ease,color .16s ease,box-shadow .16s ease;
}
button{
  cursor:pointer;
  font-weight:700;
  padding:10px 16px;
  min-width:0;
  white-space:nowrap;
}
button:hover,button:focus-visible,button.kbd-focus{
  background:var(--cyan);
  color:#05080d;
  border-color:#fff;
  outline:none;
  box-shadow:0 0 0 2px rgba(0,255,136,0.55),0 0 18px rgba(0,240,255,0.35);
}
button.p{
  border-color:var(--emerald);
  background:linear-gradient(135deg,rgba(0,255,136,0.16),rgba(0,240,255,0.14));
  color:#e8fff5;
}
button.p:hover,button.p:focus-visible,button.p.kbd-focus{
  background:var(--emerald);
  color:#04120b;
  border-color:#fff;
  box-shadow:0 0 22px rgba(0,255,136,0.45);
}
button.sm{
  padding:8px 12px;
  font-size:12.5px;
  line-height:1.2;
}
button.on{
  background:var(--cyan);
  color:#05080d;
  border-color:#fff;
  box-shadow:0 0 14px rgba(0,240,255,0.32);
}

/* ===== CARTEL DE CIRCUITO EN LA INTRO ===== */
#intro-track-banner{
  position:fixed;
  top:calc(16px + env(safe-area-inset-top,0px));
  left:20px;
  transform:translateY(-8px);
  z-index:9;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  text-align:left;
  gap:1px;
  padding:0;
  border-radius:0;
  background:none;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
  border:none;
  box-shadow:none;
  pointer-events:none;
  opacity:0;
  visibility:hidden;
  transition:opacity .45s cubic-bezier(.16,1,.3,1),transform .45s cubic-bezier(.16,1,.3,1),visibility .45s ease;
}
#intro-track-banner.is-visible{
  opacity:1;
  visibility:visible;
  transform:translateY(0);
}
#intro-track-kicker{
  font-family:var(--font-hud);
  font-size:9px;
  font-weight:800;
  letter-spacing:.22em;
  text-transform:uppercase;
  color:#5cf5ff;
  text-shadow:-1px -1px 0 #05080d,1px -1px 0 #05080d,-1px 1px 0 #05080d,1px 1px 0 #05080d,0 2px 6px rgba(0,0,0,0.96);
}
#intro-track-name{
  font-family:var(--font-hud);
  font-size:clamp(16px,2.1vw,22px);
  font-weight:900;
  font-style:italic;
  letter-spacing:.05em;
  line-height:1.1;
  color:#eefcff;
  text-shadow:-1.5px -1.5px 0 #05080d,1.5px -1.5px 0 #05080d,-1.5px 1.5px 0 #05080d,1.5px 1.5px 0 #05080d,0 2px 8px rgba(0,0,0,0.96);
}

/* ===== HUD EN CARRERA (ALTO CONTRASTE CONTRA CIELOS BRILLANTES) ===== */
#hud{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:4;
  padding:calc(12px + env(safe-area-inset-top,0px)) 16px 0;
  font-family:var(--font-hud);
  font-weight:700;
  opacity:var(--hud-opacity);
  transition:opacity .18s ease;
}
#top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}
.hud-cluster{
  background:rgba(8,12,18,0.72);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border:1px solid rgba(0,240,255,0.28);
  border-radius:12px;
  padding:10px 14px;
  box-shadow:0 8px 28px rgba(0,0,0,0.48);
  text-shadow:0 2px 6px #000,0 0 10px rgba(0,0,0,0.9);
}
.hud-cluster-right{
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:186px;
}
.hud-meter-row{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.hud-meter-lbl{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:#dceaff;
}
#pos{
  font-size:40px;
  line-height:1;
  color:#fff;
  font-style:italic;
  font-variant-numeric:tabular-nums;
  letter-spacing:.02em;
}
#dist{
  margin-top:4px;
  font-size:15px;
  color:var(--cyan);
  font-variant-numeric:tabular-nums;
}
#lap{
  margin-top:2px;
  font-size:13px;
  color:var(--emerald);
  text-transform:uppercase;
  letter-spacing:.06em;
  font-variant-numeric:tabular-nums;
}
.bar{
  height:9px;
  background:rgba(0,0,0,0.68);
  border:1px solid rgba(255,255,255,0.16);
  border-radius:999px;
  overflow:hidden;
  width:168px;
}
.bar i{
  display:block;
  height:100%;
  width:0;
  border-radius:999px;
  transition:width .08s linear;
}
#bb{background:linear-gradient(90deg,#ff6b4a,var(--red))!important;box-shadow:0 0 10px rgba(255,59,78,0.65)}
#nb{background:linear-gradient(90deg,var(--cyan),var(--emerald))!important;box-shadow:0 0 10px rgba(0,240,255,0.65)}

/* ===== MINIMAPA / RADAR EN TIEMPO REAL ===== */
#minimap-wrap{
  position:fixed;
  left:16px;
  right:auto;
  top:calc(130px + env(safe-area-inset-top,0px));
  z-index:5;
  display:none;
  flex-direction:column;
  gap:4px;
  padding:7px 8px 8px;
  border-radius:12px;
  background:rgba(8,12,18,0.72);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border:1px solid rgba(0,240,255,0.3);
  box-shadow:0 8px 28px rgba(0,0,0,0.48),inset 0 1px 0 rgba(255,255,255,0.06);
  pointer-events:none;
  opacity:var(--hud-opacity);
  transition:opacity .18s ease;
}
body.hud-mm-right #minimap-wrap{
  left:auto;
  right:16px;
}
.minimap-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
  font-family:var(--font-hud);
  font-size:10px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:var(--cyan);
  text-shadow:0 1px 4px #000;
}
#minimap-pct{
  color:var(--emerald);
  font-variant-numeric:tabular-nums;
}
#minimap{
  display:block;
  width:132px;
  height:152px;
  border-radius:8px;
  background:rgba(4,8,14,0.68);
  border:1px solid rgba(255,255,255,0.08);
}

#spd{
  position:fixed;
  right:18px;
  bottom:calc(18px + env(safe-area-inset-bottom,0px));
  z-index:5;
  display:flex;
  align-items:baseline;
  gap:6px;
  padding:8px 16px;
  border-radius:12px;
  background:rgba(8,12,18,0.74);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border:1px solid rgba(0,240,255,0.32);
  box-shadow:0 8px 28px rgba(0,0,0,0.52);
  font-family:var(--font-hud);
  font-style:italic;
  font-weight:800;
  font-variant-numeric:tabular-nums;
  text-shadow:0 2px 8px #000,0 0 14px rgba(0,0,0,0.9);
  pointer-events:none;
  opacity:var(--hud-opacity);
  transition:opacity .18s ease;
}
#spd #spd-val{font-size:40px;line-height:1;color:#fff}
#spd small{font-size:14px;color:var(--cyan);font-style:normal;letter-spacing:.06em;text-transform:uppercase}
body.hud-ctrl-on #spd{
  right:auto;
  left:50%;
  transform:translateX(-50%);
  bottom:calc(16px + env(safe-area-inset-bottom,0px));
}

#msg{
  position:fixed;
  top:34%;
  left:0;
  width:100%;
  text-align:center;
  z-index:12;
  font-family:var(--font-hud);
  font-size:clamp(40px,7vw,68px);
  font-weight:900;
  font-style:italic;
  color:#fff;
  letter-spacing:.04em;
  text-shadow:0 3px 10px #000,0 0 26px rgba(0,240,255,0.65);
  pointer-events:none;
}

#cb{
  position:fixed;
  top:calc(114px + env(safe-area-inset-top,0px));
  right:16px;
  left:auto;
  z-index:6;
  padding:7px 12px;
  font-size:13px;
  background:rgba(8,12,18,0.78);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,240,255,0.38);
  text-shadow:0 1px 4px #000;
  opacity:var(--hud-opacity)!important;
  transition:opacity .18s ease;
}
body.hud-mm-right #cb{
  right:auto;
  left:16px;
}
#aud-hud-trk{
  position:fixed;
  top:calc(154px + env(safe-area-inset-top,0px));
  right:16px;
  left:auto;
  z-index:6;
  max-width:190px;
  padding:6px 11px;
  font-size:12px;
  line-height:1.2;
  background:rgba(8,12,18,0.78);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,240,255,0.38);
  color:#e8f7ff;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  text-shadow:0 1px 4px #000;
  opacity:var(--hud-opacity)!important;
  transition:opacity .18s ease;
}
body.hud-mm-right #aud-hud-trk{
  right:auto;
  left:16px;
}
#aud-hud-trk.flash{
  border-color:var(--emerald);
  box-shadow:0 0 16px rgba(0,255,136,0.55);
  color:#fff;
}
#vip-club,
#vip-panel,
#vip-hud,
#vip-badge,
.vip-club,
.vip-panel,
.vip-club-panel,
.vip-club-hud,
[data-vip-club]{
  position:fixed!important;
  top:calc(194px + env(safe-area-inset-top,0px))!important;
  right:16px!important;
  left:auto!important;
  bottom:auto!important;
  z-index:6!important;
  opacity:var(--hud-opacity)!important;
  transition:opacity .18s ease;
}
body.hud-mm-right #vip-club,
body.hud-mm-right #vip-panel,
body.hud-mm-right #vip-hud,
body.hud-mm-right #vip-badge,
body.hud-mm-right .vip-club,
body.hud-mm-right .vip-panel,
body.hud-mm-right .vip-club-panel,
body.hud-mm-right .vip-club-hud,
body.hud-mm-right [data-vip-club]{
  right:auto!important;
  left:16px!important;
}
#race-track-badge{
  position:fixed;
  top:calc(258px + env(safe-area-inset-top,0px));
  right:16px;
  left:auto;
  z-index:6;
  display:none;
  flex-direction:column;
  align-items:flex-end;
  text-align:right;
  gap:1px;
  padding:5px 10px 6px;
  border-radius:9px;
  background:rgba(8,12,18,0.64);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,240,255,0.24);
  box-shadow:0 6px 18px rgba(0,0,0,0.42);
  pointer-events:none;
  opacity:var(--hud-opacity);
  transition:opacity .2s ease;
}
#race-track-badge.is-visible{
  display:flex;
}
#race-track-kicker{
  font-family:var(--font-hud);
  font-size:8.5px;
  font-weight:800;
  letter-spacing:.18em;
  text-transform:uppercase;
  color:rgba(92,245,255,0.88);
  line-height:1.1;
}
#race-track-name{
  font-family:var(--font-hud);
  font-size:13px;
  font-weight:800;
  font-style:italic;
  letter-spacing:.04em;
  line-height:1.15;
  color:#eefcff;
  text-shadow:0 1px 4px rgba(0,0,0,0.9);
}
body.hud-mm-right #race-track-badge{
  right:auto;
  left:16px;
  align-items:flex-start;
  text-align:left;
}

/* ===== BARRA SUPERIOR DE PAUSA Y MUTE EN CARRERA ===== */
#race-top-acts{
  position:fixed;
  top:calc(14px + env(safe-area-inset-top,0px));
  left:50%;
  transform:translateX(-50%);
  display:flex;
  align-items:center;
  gap:8px;
  z-index:6;
}
#ex{
  position:relative;
  padding:7px 15px;
  font-family:var(--font-hud);
  font-size:12.5px;
  font-weight:800;
  letter-spacing:.06em;
  background:rgba(8,12,18,0.78);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,240,255,0.34);
  display:none;
}
#ex:hover,#ex:focus-visible{
  background:var(--cyan);
  border-color:#fff;
  color:#05080d;
}
#btn-mute-race{
  padding:7px 11px;
  font-size:13px;
  line-height:1.15;
  background:rgba(8,12,18,0.78);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,240,255,0.34);
}
#btn-mute-race.is-muted,
#btn-mute-quick.is-muted{
  border-color:var(--red);
  color:#ff9ba5;
  background:rgba(36,10,16,0.82);
}

/* ===== CONTROLES ESTILO NEED FOR SPEED EN PANTALLA ===== */
body.hud-size-sm{--ctrl-scale:.82}
body.hud-size-md{--ctrl-scale:1}
body.hud-size-lg{--ctrl-scale:1.18}

#tc,#tc2{
  position:fixed;
  bottom:calc(18px + env(safe-area-inset-bottom,0px));
  z-index:7;
  display:none;
  align-items:flex-end;
  gap:10px;
  transform-origin:bottom center;
  user-select:none;
  -webkit-user-select:none;
  opacity:var(--hud-opacity);
  transition:opacity .2s ease,filter .25s ease;
}
body.hud-layout-standard #tc{left:18px;right:auto}
body.hud-layout-standard #tc2{right:18px;left:auto}
body.hud-layout-inverted #tc{right:18px;left:auto}
body.hud-layout-inverted #tc2{left:18px;right:auto;flex-direction:row-reverse}

.nfs-btn{
  position:relative;
  display:inline-flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  color:#eaf4ff;
  background:rgba(9,13,19,0.74);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border:1.5px solid rgba(0,240,255,0.42);
  box-shadow:0 8px 24px rgba(0,0,0,0.55),inset 0 1px 0 rgba(255,255,255,0.08);
  cursor:pointer;
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;
  transition:transform .1s cubic-bezier(.16,1,.3,1),border-color .1s ease,background-color .1s ease,box-shadow .1s ease,color .1s ease;
}
.nfs-btn svg{width:24px;height:24px;pointer-events:none;flex-shrink:0}
.nfs-btn span{
  font-family:var(--font-hud);
  font-size:10px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
  pointer-events:none;
  text-shadow:0 1px 3px #000;
}
.nfs-steer{
  width:calc(68px * var(--ctrl-scale));
  height:calc(68px * var(--ctrl-scale));
  border-radius:14px;
}
.nfs-steer.is-active,
.nfs-steer:active{
  transform:scale(.94);
  background:rgba(0,240,255,0.28);
  border-color:var(--cyan);
  color:#fff;
  box-shadow:0 0 24px rgba(0,240,255,0.65),inset 0 0 14px rgba(0,240,255,0.35);
}

.nfs-pedals{
  display:flex;
  align-items:flex-end;
  gap:10px;
}
.nfs-brake{
  width:calc(64px * var(--ctrl-scale));
  height:calc(82px * var(--ctrl-scale));
  border-radius:12px 12px 16px 16px;
  border-color:rgba(255,59,78,0.52);
  background:linear-gradient(180deg,rgba(25,14,18,0.78),rgba(10,13,18,0.86));
}
.nfs-brake.is-active,
.nfs-brake:active{
  transform:scale(.95) translateY(2px);
  background:rgba(255,59,78,0.34);
  border-color:var(--red);
  color:#fff;
  box-shadow:0 0 24px rgba(255,59,78,0.65),inset 0 0 14px rgba(255,59,78,0.35);
}
.nfs-gas{
  width:calc(66px * var(--ctrl-scale));
  height:calc(108px * var(--ctrl-scale));
  border-radius:14px 14px 16px 16px;
  border-color:rgba(0,255,136,0.56);
  background:linear-gradient(180deg,rgba(10,28,24,0.78),rgba(9,13,19,0.88));
}
.nfs-gas.is-active,
.nfs-gas:active{
  transform:scale(.95) translateY(2px);
  background:rgba(0,255,136,0.3);
  border-color:var(--emerald);
  color:#fff;
  box-shadow:0 0 26px rgba(0,255,136,0.7),inset 0 0 16px rgba(0,255,136,0.38);
}
.nfs-nitro{
  width:calc(64px * var(--ctrl-scale));
  height:calc(64px * var(--ctrl-scale));
  border-radius:50%;
  border-color:rgba(0,240,255,0.62);
  background:radial-gradient(circle at 30% 30%,rgba(0,240,255,0.24),rgba(9,13,19,0.88));
}
.nfs-nitro.is-active,
.nfs-nitro:active{
  transform:scale(.93);
  background:linear-gradient(135deg,rgba(0,240,255,0.45),rgba(0,255,136,0.45));
  border-color:#fff;
  color:#fff;
  box-shadow:0 0 28px rgba(0,240,255,0.85),0 0 16px rgba(0,255,136,0.65);
}

/* ===== MENÚ PRINCIPAL INMERSIVO A PANTALLA COMPLETA ===== */
#menu{
  position:fixed;
  inset:0;
  width:100vw;
  height:100vh;
  z-index:20;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  padding:calc(14px + env(safe-area-inset-top,0px)) 24px calc(14px + env(safe-area-inset-bottom,0px));
  background:radial-gradient(circle at 70% 50%,rgba(8,14,28,0.35) 0%,rgba(5,9,18,0.78) 100%);
  backdrop-filter:blur(3px);
  -webkit-backdrop-filter:blur(3px);
  pointer-events:none;
}
.menu-shell{
  pointer-events:auto;
  width:min(472px,100%);
  max-height:calc(100vh - 28px);
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:10px 8px;
  border-radius:0;
  background:transparent;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
  border:none;
  box-shadow:none;
  overflow-y:visible;
  text-align:left;
}
.menu-shell:has(#panel-settings.active){
  overflow-y:auto;
  padding-right:10px;
}
.menu-head{
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
  gap:4px;
  padding-bottom:9px;
  border-bottom:1px solid rgba(0,240,255,0.2);
}
.menu-title-row{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  gap:10px;
}
h1{
  margin:0;
  padding:3px 10px;
  width:100%;
  text-align:center;
  font-family:var(--font-hud);
  font-size:clamp(25px,3vw,31px);
  font-weight:900;
  font-style:italic;
  letter-spacing:.04em;
  line-height:1.15;
  background:linear-gradient(95deg,#00f0ff 0%,#38bdf8 48%,#00ff88 100%);
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
  filter:drop-shadow(0 0 14px rgba(0,240,255,0.48)) drop-shadow(0 3px 10px rgba(0,0,0,0.9));
}
.menu-sub{
  font-size:12px;
  color:#cce0f5;
  line-height:1.35;
  text-align:center;
  text-shadow:0 2px 8px rgba(0,0,0,0.9);
}

.menu-tabs{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px;
  padding:4px;
  border-radius:11px;
  background:rgba(7,12,22,0.48);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  border:1px solid rgba(0,240,255,0.22);
}
.menu-tab{
  padding:8px 8px;
  font-size:12px;
  font-weight:800;
  letter-spacing:.03em;
  border-radius:8px;
  border:1px solid transparent;
  background:transparent;
  color:#b6cbe3;
  overflow:hidden;
  text-overflow:ellipsis;
}
.menu-tab:hover,.menu-tab:focus-visible,.menu-tab.kbd-focus{
  background:rgba(0,240,255,0.16);
  color:#fff;
  border-color:rgba(0,240,255,0.52);
  box-shadow:0 0 0 2px rgba(0,240,255,0.35);
}
.menu-tab.active{
  background:linear-gradient(135deg,var(--cyan),var(--emerald));
  color:#041014;
  border-color:transparent;
  box-shadow:0 4px 18px rgba(0,240,255,0.34);
}
.menu-tab.active:focus-visible,.menu-tab.active.kbd-focus{
  color:#041014;
  box-shadow:0 0 0 2px #fff,0 4px 18px rgba(0,255,136,0.45);
}

.tab-panel{
  display:none;
  flex-direction:column;
  gap:9px;
}
.tab-panel.active{display:flex}

.menu-sec{
  display:flex;
  flex-direction:column;
  gap:7px;
  padding:10px 12px;
  margin-bottom:0;
  border-radius:12px;
  background:linear-gradient(95deg,rgba(8,13,24,0.44) 0%,rgba(8,13,24,0.2) 100%);
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
  border:1px solid rgba(0,240,255,0.16);
}
.menu-sec-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.menu-sec-lbl{
  font-size:11px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--cyan);
  text-shadow:0 1px 6px rgba(0,0,0,0.88);
}
.row{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  justify-content:flex-start;
}
.row.seg{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(88px,1fr));
  gap:6px;
}
#panel-play .sm{
  padding:7px 10px;
  font-size:12px;
  background:rgba(10,16,28,0.66);
}
#panel-play .sm:hover,
#panel-play .sm:focus-visible,
#panel-play .sm.kbd-focus{
  background:var(--cyan);
  color:#05080d;
}
#panel-play .sm.on{
  background:var(--cyan);
  color:#05080d;
}
.hint{
  font-size:12px;
  color:#bfd2e8;
  line-height:1.3;
  min-height:15px;
  text-shadow:0 1px 6px rgba(0,0,0,0.88);
}

/* ===== FILA DE UTILIDADES COMPACTAS (TUTORIAL / IDIOMA / MUTE) ===== */
.util-row{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px;
  padding:6px 8px;
  border-radius:11px;
  background:linear-gradient(95deg,rgba(8,13,24,0.44) 0%,rgba(8,13,24,0.2) 100%);
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
  border:1px solid rgba(0,240,255,0.18);
}
.util-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:7px 8px;
  font-size:12px;
  font-weight:700;
  overflow:hidden;
  text-overflow:ellipsis;
}

.car-strip{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 11px;
  border-radius:11px;
  background:rgba(8,16,28,0.44);
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
  border:1px solid rgba(0,240,255,0.24);
}
#grg-menu-info{
  color:#e4f9ff;
  font-size:12.5px;
  font-weight:700;
  min-height:0;
  text-shadow:0 1px 6px rgba(0,0,0,0.9);
}
.link-btn{
  padding:7px 12px;
  font-size:12px;
  border-color:rgba(0,255,136,0.48);
  color:var(--emerald);
  background:rgba(0,255,136,0.1);
}
.link-btn:hover,.link-btn:focus-visible,.link-btn.kbd-focus{
  background:var(--emerald);
  color:#04120b;
}

.w3-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
#demo.on,#conn.on{
  background:rgba(0,240,255,0.22);
  color:#fff;
  border-color:var(--cyan);
}
#play{
  width:100%;
  padding:12px 18px;
  font-family:var(--font-hud);
  font-size:15.5px;
  font-weight:900;
  letter-spacing:.08em;
  text-transform:uppercase;
  border-radius:11px;
  border:none;
  background:linear-gradient(95deg,var(--cyan),var(--emerald));
  color:#041214;
  box-shadow:0 10px 28px rgba(0,240,255,0.34);
}
#play:hover,#play:focus-visible,#play.kbd-focus{
  transform:translateY(-1px);
  filter:brightness(1.08);
  box-shadow:0 0 0 2px #fff,0 12px 32px rgba(0,255,136,0.5);
  color:#020b0d;
}
#st{
  font-size:12px;
  color:#cfefff;
  min-height:15px;
  line-height:1.35;
  text-shadow:0 1px 6px rgba(0,0,0,0.9);
}

/* ===== SUBMENÚ AJUSTES & EDITOR DE HUD ===== */
.set-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
.set-sliders{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.hud-toggle-list{
  display:flex;
  flex-direction:column;
  gap:7px;
}
.hud-switch{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  font-size:12.5px;
  font-weight:600;
  color:#e4effc;
  cursor:pointer;
}
.hud-switch input{
  width:18px;
  height:18px;
  margin:0;
  accent-color:var(--emerald);
  cursor:pointer;
}
.hud-opacity-wrap{
  margin-top:4px;
  padding-top:6px;
  border-top:1px solid rgba(255,255,255,0.08);
}
.hud-preview-box{
  position:relative;
  height:108px;
  border-radius:10px;
  background:linear-gradient(180deg,rgba(6,10,16,0.92),rgba(14,22,32,0.92));
  border:1px dashed rgba(0,240,255,0.3);
  overflow:hidden;
  margin-top:4px;
}
.hp-layer{
  position:absolute;
  inset:0;
  transition:opacity .15s ease;
}
.hp-top-cluster{
  position:absolute;
  top:7px;
  padding:2px 6px;
  border-radius:5px;
  background:rgba(8,14,22,0.85);
  border:1px solid rgba(0,240,255,0.35);
  font-family:var(--font-hud);
  font-size:9px;
  font-weight:800;
  color:#eaf6ff;
}
.hp-top-cluster.left{left:10px}
.hp-top-cluster.right{right:10px;color:var(--emerald)}
.hp-radar{
  position:absolute;
  top:26px;
  width:38px;
  height:28px;
  border-radius:5px;
  background:rgba(8,14,22,0.88);
  border:1px solid rgba(0,240,255,0.55);
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:var(--font-hud);
  font-size:8px;
  font-weight:800;
  letter-spacing:.06em;
  color:var(--cyan);
}
.hp-radar.left{left:10px}
.hp-radar.right{right:10px}
.hp-radio{
  position:absolute;
  top:26px;
  padding:3px 7px;
  border-radius:5px;
  background:rgba(8,14,22,0.88);
  border:1px solid rgba(0,255,136,0.45);
  font-family:var(--font-hud);
  font-size:8px;
  font-weight:800;
  letter-spacing:.05em;
  color:var(--emerald);
}
.hp-radio.left{left:10px}
.hp-radio.right{right:10px}
.hp-rpm{
  position:absolute;
  bottom:26px;
  left:50%;
  transform:translateX(-50%);
  width:84px;
  height:7px;
  border-radius:999px;
  background:rgba(12,18,28,0.92);
  border:1px solid rgba(255,255,255,0.62);
  overflow:hidden;
}
.hp-rpm i{
  display:block;
  height:100%;
  width:68%;
  border-radius:999px;
  background:linear-gradient(90deg,var(--cyan),var(--emerald));
}
.hp-zone{
  position:absolute;
  bottom:8px;
  display:flex;
  align-items:center;
  gap:4px;
  font-size:10px;
  font-weight:800;
  color:var(--ink);
  transition:all .18s ease;
}
.hp-zone.left{left:10px}
.hp-zone.right{right:10px}
.hp-chip{
  padding:4px 7px;
  border-radius:6px;
  background:rgba(0,240,255,0.16);
  border:1px solid rgba(0,240,255,0.45);
}
.hp-chip.gas{
  background:rgba(0,255,136,0.18);
  border-color:rgba(0,255,136,0.55);
}
.hp-chip.brk{
  background:rgba(255,59,78,0.18);
  border-color:rgba(255,59,78,0.55);
}
.hp-spd{
  position:absolute;
  bottom:8px;
  left:50%;
  transform:translateX(-50%);
  font-family:var(--font-hud);
  font-size:11px;
  font-weight:800;
  color:#e2f3ff;
  white-space:nowrap;
}

/* ===== ELEMENTOS EXTRA DE CARRERA, DRAG, COAST Y RESULTADOS ===== */
#dh{
  position:fixed;
  left:16px;
  top:max(336px,52%);
  display:none;
  z-index:5;
  padding:10px 14px;
  border-radius:12px;
  background:rgba(8,12,18,0.74);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,240,255,0.3);
  font-family:var(--font-hud);
  font-weight:700;
  text-shadow:0 2px 6px #000;
  pointer-events:none;
  opacity:var(--hud-opacity);
  transition:opacity .18s ease;
}
#gr{font-size:52px;font-style:italic;color:#fff;line-height:1}
#fl{display:block;font-size:16px;color:var(--emerald);min-height:20px}
#dh .bar{display:none}
#rg{position:relative;width:200px;height:16px;border-radius:8px;border:2px solid #fff;margin-top:6px;overflow:visible}
#rg i{position:absolute;top:-5px;width:4px;height:22px;margin-left:-2px;background:#fff;border-radius:2px;box-shadow:0 0 6px #000}
#sh{min-height:24px;margin-top:6px;font-size:20px;font-style:italic;color:var(--emerald);text-shadow:0 2px 6px #000}
#sh.b{color:var(--cyan)}
#sh.r{color:var(--red);animation:bl .25s steps(2) infinite}

#wm{position:fixed;top:max(25.5%,calc(200px + env(safe-area-inset-top,0px)));width:100%;text-align:center;z-index:8;font-family:var(--font-hud);font-size:34px;font-weight:900;font-style:italic;color:#ff3d3d;text-shadow:0 2px 8px #000,0 0 18px #ff0000;pointer-events:none;letter-spacing:2px}
#wm.blink{animation:bl .5s steps(2) infinite}
@keyframes bl{50%{opacity:.25}}
#ck{position:fixed;inset:0;pointer-events:none;display:none;z-index:2;background:linear-gradient(to bottom,#05060a 0,#05060a 7%,transparent 7.5%),linear-gradient(to top,#07080c 0,#101218 15%,transparent 31%)}
#ck .mir{position:absolute;top:7%;left:50%;width:150px;height:34px;margin-left:-75px;border-radius:8px;background:linear-gradient(#1b222b,#0b0f14);border:3px solid #050608;box-shadow:0 2px 6px #000}
#ck .wheel{position:absolute;bottom:-90px;left:50%;width:300px;height:300px;margin-left:-150px;border-radius:50%;border:26px solid #0a0b0e;box-shadow:inset 0 0 0 3px #1e222a}

#fx{position:fixed;top:max(29.5%,calc(238px + env(safe-area-inset-top,0px)));left:0;width:100%;text-align:center;font-family:var(--font-hud);font-size:clamp(28px,6vw,52px);font-weight:900;font-style:italic;letter-spacing:2px;pointer-events:none;z-index:8;opacity:0;text-shadow:0 2px 10px #000,0 4px 20px #000}
#fx.show{animation:fxp 1.25s ease-out forwards}
@keyframes fxp{0%{opacity:0;transform:scale(.6)}12%{opacity:1;transform:scale(1.15)}22%{transform:scale(1)}78%{opacity:1}100%{opacity:0;transform:translateY(-18px) scale(1)}}
#pp{position:fixed;left:50%;top:50%;width:0;height:0;pointer-events:none;z-index:8}
.pop{position:absolute;left:0;top:0;transform:translateX(-50%);white-space:nowrap;font-family:var(--font-hud);font-size:clamp(22px,5vw,32px);font-weight:900;font-style:italic;color:var(--gold);text-shadow:0 2px 8px #000,0 2px 14px #000;animation:pp 1.1s ease-out forwards}
.pop small{display:block;font-size:.6em;color:#fff;text-align:center}
.pop.hot{color:var(--emerald);font-size:clamp(28px,6vw,42px)}
@keyframes pp{0%{opacity:0;transform:translate(-50%,20px) scale(.7)}15%{opacity:1;transform:translate(-50%,0) scale(1.15)}100%{opacity:0;transform:translate(-50%,-90px) scale(1)}}

#ct{
  position:fixed;
  top:calc(62px + env(safe-area-inset-top,0px));
  left:50%;
  transform:translateX(-50%);
  display:none;
  padding:8px 16px;
  border-radius:12px;
  background:rgba(8,12,18,0.72);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,240,255,0.3);
  text-align:center;
  pointer-events:none;
  z-index:5;
  font-family:var(--font-hud);
  font-weight:800;
  text-shadow:0 2px 6px #000;
  opacity:var(--hud-opacity);
  transition:opacity .18s ease;
}
#ct b{display:block;font-size:40px;font-style:italic;line-height:1;color:#fff;font-variant-numeric:tabular-nums}
#ct b.low{color:var(--red);animation:bl .5s steps(2) infinite}
#ct small{font-size:13px;color:var(--cyan)}

#lg{position:fixed;left:50%;bottom:calc(88px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);width:min(320px,80vw);display:none;text-align:center;pointer-events:none;z-index:8;text-shadow:0 2px 6px #000;opacity:var(--hud-opacity);transition:opacity .18s ease}
.lgb{height:16px;border-radius:8px;border:2px solid #fff;overflow:hidden;position:relative;box-shadow:0 4px 16px rgba(0,0,0,0.48)}
.lgb i{position:absolute;left:0;top:0;height:100%;width:0;background:var(--cyan);opacity:.92;border-right:3px solid #fff}
#lg small{display:block;margin-top:6px;font-size:13px;font-weight:700}

#pa{position:fixed;top:max(19.5%,calc(160px + env(safe-area-inset-top,0px)));width:100%;text-align:center;z-index:8;font-family:var(--font-hud);font-size:26px;font-weight:900;color:#fff;display:none;pointer-events:none;text-shadow:0 2px 8px #000,0 0 16px #00a2ff;letter-spacing:2px}
#pa.blink{animation:bl .5s steps(2) infinite}
#pa.u{color:var(--red);font-size:32px;text-shadow:0 2px 8px #000,0 0 18px #ff0000;animation-duration:.25s}

/* ===== MODAL DE TUTORIAL / CONTROLES ===== */
#tutorial-modal{
  position:fixed;
  inset:0;
  z-index:65;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
}
#tutorial-modal.is-open{display:flex!important}
.tut-backdrop{
  position:absolute;
  inset:0;
  background:rgba(4,7,12,0.82);
  backdrop-filter:blur(7px);
  -webkit-backdrop-filter:blur(7px);
}
.tut-panel{
  position:relative;
  z-index:1;
  width:min(490px,100%);
  max-height:88vh;
  overflow-y:auto;
  background:var(--panel-strong);
  border:1.5px solid rgba(0,240,255,0.52);
  border-radius:16px;
  padding:18px 20px;
  box-shadow:0 24px 64px rgba(0,0,0,0.82),0 0 32px rgba(0,240,255,0.16);
  display:flex;
  flex-direction:column;
  gap:12px;
  text-align:left;
}
.tut-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding-bottom:10px;
  border-bottom:1px solid var(--line);
}
.tut-head h2{
  margin:0;
  font-family:var(--font-hud);
  font-size:20px;
  font-style:italic;
  letter-spacing:.04em;
  background:linear-gradient(90deg,var(--cyan),var(--emerald));
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}
#tut-close{
  padding:6px 11px;
  border-color:rgba(255,255,255,0.3);
}
.tut-sub{
  margin:0;
  font-size:12.5px;
  color:var(--muted);
  line-height:1.4;
}
.tut-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.tut-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:9px 12px;
  border-radius:10px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(0,240,255,0.14);
}
.tut-action{
  font-size:13px;
  font-weight:700;
  color:var(--ink);
}
.tut-keys{
  display:flex;
  align-items:center;
  gap:5px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.tut-kbd{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:4px 9px;
  border-radius:6px;
  font-family:var(--font-hud);
  font-size:11.5px;
  font-weight:800;
  color:var(--cyan);
  background:rgba(0,240,255,0.11);
  border:1px solid rgba(0,240,255,0.42);
  box-shadow:0 2px 0 rgba(0,0,0,0.65);
  white-space:nowrap;
}
#tut-ok{
  width:100%;
  padding:11px 16px;
  font-family:var(--font-hud);
  font-size:13.5px;
  font-weight:900;
  letter-spacing:.06em;
  text-transform:uppercase;
}

/* ===== MODAL DE PAUSA EN CARRERA ===== */
#pause-modal{
  position:fixed;
  inset:0;
  z-index:75;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
}
#pause-modal.is-open{display:flex!important}
.pause-backdrop{
  position:absolute;
  inset:0;
  background:rgba(4,7,14,0.78);
  backdrop-filter:blur(9px);
  -webkit-backdrop-filter:blur(9px);
}
.pause-panel{
  position:relative;
  z-index:1;
  width:min(380px,100%);
  background:var(--panel-strong);
  border:1.5px solid rgba(0,240,255,0.52);
  border-radius:16px;
  padding:22px 22px 20px;
  box-shadow:0 24px 64px rgba(0,0,0,0.84),0 0 36px rgba(0,240,255,0.18);
  display:flex;
  flex-direction:column;
  gap:10px;
  text-align:center;
}
#pause-title{
  margin:0;
  font-family:var(--font-hud);
  font-size:28px;
  font-weight:900;
  font-style:italic;
  letter-spacing:.08em;
  background:linear-gradient(95deg,var(--cyan),var(--emerald));
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}
.pause-sub{
  margin:0 0 6px;
  font-size:12.5px;
  color:var(--muted);
}
.pause-actions{
  display:flex;
  flex-direction:column;
  gap:9px;
}
.pause-actions button{
  width:100%;
  padding:12px 16px;
  font-family:var(--font-hud);
  font-size:13.5px;
  font-weight:800;
  letter-spacing:.05em;
  text-transform:uppercase;
}
.pause-actions button:focus-visible,.pause-actions button.kbd-focus{
  outline:none;
  transform:translateY(-1px);
}
.pause-actions button.p:focus-visible,.pause-actions button.p.kbd-focus{
  box-shadow:0 0 0 2px rgba(255,255,255,0.9),0 0 24px rgba(0,255,136,0.55);
}
.pause-actions button:not(.p):not(.pause-danger):focus-visible,.pause-actions button:not(.p):not(.pause-danger).kbd-focus{
  box-shadow:0 0 0 2px rgba(255,255,255,0.9),0 0 22px rgba(0,240,255,0.5);
}
.pause-danger{
  border-color:rgba(255,59,78,0.55);
  color:#ffb2ba;
  background:rgba(44,12,20,0.72);
}
.pause-actions .pause-danger:hover,.pause-actions .pause-danger:focus-visible,.pause-actions .pause-danger.kbd-focus{
  background:var(--red);
  border-color:#fff;
  color:#fff;
  box-shadow:0 0 0 2px rgba(255,255,255,0.88),0 0 22px rgba(255,59,78,0.55);
}

/* ===== MODAL FLOTANTE DE RESULTADOS (2 BOTONES LADO A LADO) ===== */
#resultsModal{
  position:fixed;
  inset:0;
  z-index:70;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
}
#resultsModal.show-results{display:flex!important}
.rs-backdrop{
  position:absolute;
  inset:0;
  background:rgba(4,7,12,0.82);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}
.rs-modal-panel{
  position:relative;
  z-index:1;
  width:min(460px,100%);
  max-height:90vh;
  overflow-y:auto;
  background:var(--panel-strong);
  border:1.5px solid rgba(0,240,255,0.52);
  border-radius:16px;
  padding:20px 22px;
  box-shadow:0 24px 64px rgba(0,0,0,0.8),0 0 32px rgba(0,240,255,0.14);
  display:flex;
  flex-direction:column;
  gap:14px;
  text-align:left;
}
#rs{
  width:100%;
  text-align:left;
}
#rs h2{
  margin:0 0 10px;
  text-align:center;
  font-family:var(--font-hud);
  font-style:italic;
  font-size:24px;
  letter-spacing:.05em;
  background:linear-gradient(90deg,var(--cyan),var(--emerald));
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}
#rs table{width:100%;border-collapse:collapse;font-size:14px}
#rs td{padding:7px 0;border-bottom:1px solid rgba(255,255,255,0.08);color:var(--muted)}
#rs td+td{text-align:right;font-weight:700;color:var(--ink);font-variant-numeric:tabular-nums}
#rs tr.g td+td{color:var(--emerald)}
#rs .nr{text-align:center;font-weight:900;font-style:italic;font-size:13.5px;color:var(--gold);margin:0 0 8px;animation:bl .6s steps(2) 4}
#rs-status{
  text-align:center;
  color:#bfe8ff;
  font-size:12.5px;
  min-height:0;
}
#rs-status:empty{display:none}
.rs-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  width:100%;
}
.rs-actions button{
  width:100%;
  padding:12px 12px;
  font-family:var(--font-hud);
  font-size:13px;
  font-weight:900;
  letter-spacing:.05em;
  text-transform:uppercase;
}

/* ===== PANTALLA DE CARGA PRE-CARRERA ===== */
#loadingOverlay{
  position:fixed;
  inset:0;
  z-index:90;
  display:none;
  align-items:center;
  justify-content:center;
  padding:20px;
  background:rgba(5,8,14,0.82);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
}
#loadingOverlay.is-loading{display:flex!important}
.loading-box{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:16px;
  min-width:min(280px,86vw);
  padding:28px 34px;
  border-radius:16px;
  background:var(--panel-strong);
  border:1.5px solid rgba(0,240,255,0.42);
  box-shadow:0 24px 64px rgba(0,0,0,0.8),0 0 36px rgba(0,240,255,0.16);
}
@keyframes loadingSpin{to{transform:rotate(360deg)}}
.loading-spinner{
  width:48px;
  height:48px;
  border-radius:50%;
  border:4px solid rgba(0,240,255,0.16);
  border-top-color:var(--cyan);
  border-right-color:var(--emerald);
  box-shadow:0 0 20px rgba(0,240,255,0.3);
  animation:loadingSpin .78s linear infinite;
}
.loading-text{
  font-family:var(--font-hud);
  font-size:16px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:#eef8ff;
  text-shadow:0 0 12px rgba(0,240,255,0.55);
}

/* ===== GARAJE / SELECTOR DE 8 AUTOS + 26 PINTURAS ===== */
#garage-ui{
  position:fixed;
  inset:0;
  z-index:40;
  display:none;
  flex-direction:column;
  justify-content:space-between;
  padding:calc(14px + env(safe-area-inset-top,0px)) 16px calc(14px + env(safe-area-inset-bottom,0px));
  pointer-events:none;
}
#garage-ui button{pointer-events:auto;touch-action:manipulation}
#grg-top{position:relative;z-index:42;display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;max-width:980px;margin:0 auto;pointer-events:none}
#grg-back{position:relative;z-index:43;padding:9px 16px;border:1.5px solid var(--cyan);background:rgba(9,13,19,0.92);color:#fff;font-size:13.5px;font-weight:700;box-shadow:0 4px 18px rgba(0,0,0,0.55);pointer-events:auto}
#grg-back:hover,#grg-back:focus-visible{background:var(--cyan);color:#05080d;border-color:#fff}
#grg-top-meta{position:relative;z-index:42;display:flex;align-items:center;gap:10px;padding:7px 14px;border-radius:10px;border:1px solid rgba(0,240,255,0.35);background:rgba(9,13,19,0.88);backdrop-filter:blur(10px);font-size:13px;font-weight:700;pointer-events:auto}
#grg-mode-badge{color:var(--cyan)}
#grg-count{color:#fff;font-variant-numeric:tabular-nums;border-left:1px solid rgba(255,255,255,0.18);padding-left:10px}

.grg-arrow{position:fixed;z-index:42;top:44%;transform:translateY(-50%);width:48px;height:68px;padding:0;font-size:32px;line-height:1;display:flex;align-items:center;justify-content:center;border-radius:10px;border:1.5px solid rgba(0,240,255,0.55);background:rgba(9,13,19,0.84);color:#fff}
.grg-arrow:hover,.grg-arrow:focus-visible{transform:translateY(-50%) scale(1.06);background:var(--cyan);color:#05080d;border-color:#fff}
#grg-prev{left:16px}
#grg-next{right:16px}

#grg-dock{
  position:relative;
  z-index:42;
  width:min(860px,100%);
  margin:0 auto;
  background:rgba(9,13,19,0.9);
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
  border:1px solid rgba(0,240,255,0.38);
  border-radius:14px;
  padding:13px 18px;
  box-shadow:0 16px 44px rgba(0,0,0,0.62);
  pointer-events:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.grg-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.grg-title-wrap{min-width:0;text-align:left}
.grg-name-row{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
#grg-name{margin:0;font-family:var(--font-hud);font-size:clamp(20px,3vw,26px);font-style:italic;color:#fff;line-height:1.15}
#grg-tagline{margin:4px 0 0;font-size:13px;color:var(--muted);line-height:1.35}

.grg-cat{font-size:11px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;padding:3px 8px;border-radius:6px;border:1px solid transparent;white-space:nowrap}
.grg-cat.free{background:rgba(0,255,136,0.14);color:var(--emerald);border-color:rgba(0,255,136,0.42)}
.grg-cat.pro{background:rgba(255,210,61,0.14);color:var(--gold);border-color:rgba(255,210,61,0.45)}
.grg-cat.exclusive{background:rgba(0,240,255,0.16);color:var(--cyan);border-color:rgba(0,240,255,0.52)}

.grg-state-tag{font-size:11px;font-weight:700;padding:3px 8px;border-radius:6px;background:rgba(255,255,255,0.08);color:#d7e3ff;white-space:nowrap}
.grg-state-tag.eq{background:rgba(0,240,255,0.18);color:var(--cyan);border:1px solid rgba(0,240,255,0.48)}
.grg-state-tag.lk{background:rgba(255,59,78,0.16);color:#ff9ba5;border:1px solid rgba(255,59,78,0.42)}

.grg-price{font-family:var(--font-hud);font-size:15px;font-weight:800;font-variant-numeric:tabular-nums;color:var(--gold);white-space:nowrap;padding-top:2px}
.grg-price.is-free{color:var(--emerald)}

#grg-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.grg-stat{display:flex;flex-direction:column;gap:5px}
.grg-stat-lbl{display:flex;justify-content:space-between;align-items:baseline;font-size:12px;font-weight:700;color:rgba(238,244,255,0.86)}
.grg-stat-lbl b{font-size:13px;font-variant-numeric:tabular-nums;color:#fff}
.grg-stat-track{height:8px;border-radius:999px;background:rgba(255,255,255,0.1);overflow:hidden;border:1px solid rgba(255,255,255,0.08)}
.grg-stat-track i{display:block;height:100%;width:0%;border-radius:999px;background:linear-gradient(90deg,var(--cyan),var(--emerald));transition:width .48s cubic-bezier(.16,1,.3,1)}
#grg-bar-acc{background:linear-gradient(90deg,var(--emerald),var(--cyan))}
#grg-bar-han{background:linear-gradient(90deg,#38bdf8,var(--emerald))}

#grg-dock .grg-foot{display:flex;flex-direction:column;align-items:stretch;gap:10px;padding-top:8px;border-top:1px solid rgba(255,255,255,0.1)}
.grg-paint-columns{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr);gap:10px 18px;align-items:start}
.grg-col-body,.grg-col-accent{min-width:0;display:flex;flex-direction:column;gap:6px}
.grg-col-accent{padding-left:16px;border-left:1px solid rgba(255,255,255,0.1)}
.grg-paint-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.grg-color-lbl{font-size:12px;font-weight:700;color:rgba(232,240,255,0.88)}
.grg-color-lbl.is-vip{color:#f3cf65}
.grg-paint-active{font-size:11px;font-weight:600;color:#cbd5e1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:210px}
.grg-paint-tiers{display:flex;flex-direction:column;align-items:flex-start;gap:7px}
.grg-paint-tier{display:flex;flex-direction:column;gap:4px;width:100%}
.grg-tier-head{display:flex;align-items:center;justify-content:space-between;gap:6px}
.grg-tier-lbl{font-size:10px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:#94a3b8}
.grg-tier-lbl.is-vip{color:#f3cf65}
.grg-tier-cnt{font-size:10px;font-weight:700;color:#64748b;font-variant-numeric:tabular-nums}
.grg-tier-cnt.is-vip{color:#eab308}
.grg-tier-cnt.is-vip.unlocked{color:var(--emerald)}
#grg-dock .grg-colors.grg-grid-std{display:grid;grid-template-columns:repeat(8,22px);gap:5px;margin:0;padding:0}
#grg-dock .grg-colors.grg-grid-vip{display:grid;grid-template-columns:repeat(9,22px);gap:5px;margin:0;padding:0}
#grg-dock .grg-colors.grg-grid-accent{display:grid;grid-template-columns:repeat(6,24px);gap:6px;margin:0;padding:0}
.grg-accent-parts{font-size:10.5px;font-weight:600;color:#94a3b8;line-height:1.25}
#grg-dock .grg-swatch{position:relative;width:22px;height:22px;min-width:22px;min-height:22px;padding:0;border-radius:6px;border:1px solid rgba(255,255,255,0.22);display:inline-flex;align-items:center;justify-content:center;background:var(--swatch,transparent);cursor:pointer}
#grg-dock .grg-grid-accent .grg-swatch{width:24px;height:24px;min-width:24px;min-height:24px}
#grg-dock .grg-swatch:hover{transform:translateY(-1px) scale(1.06);background:var(--swatch,transparent)}
#grg-dock .grg-swatch.active{border-color:#fff;box-shadow:0 0 0 2px #090d16,0 0 0 3.5px var(--cyan)}
#grg-dock .grg-swatch.is-vip{border-color:rgba(212,175,55,0.45)}
#grg-dock .grg-swatch.is-vip-locked{border-color:rgba(212,175,55,0.78);box-shadow:inset 0 0 0 1px rgba(251,191,36,0.2)}
#grg-dock .grg-swatch.is-vip-locked.active.is-preview{border-color:#fbbf24;box-shadow:0 0 0 2px #090d16,0 0 0 3.5px #fbbf24}
.grg-swatch-lock{font-size:9px;line-height:1;pointer-events:none;filter:drop-shadow(0 1px 2px rgba(0,0,0,0.95));user-select:none}

.grg-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;width:100%}
.grg-nav-sm{padding:9px 12px;font-size:13px;background:rgba(15,20,28,0.92)}
#grg-action{min-width:215px;padding:10px 18px;font-size:13.5px}
#grg-action.equipped{border-color:var(--emerald);background:rgba(0,255,136,0.16);color:#a7ffd4}
#grg-action.equipped:hover{background:var(--emerald);color:#04120b}
#grg-action.unlock-demo{border-color:var(--gold);background:rgba(255,210,61,0.14);color:#ffe98a}
#grg-action.unlock-demo:hover{background:var(--gold);color:#140d02}
#grg-action.unlock-web3{border-color:var(--cyan);background:linear-gradient(135deg,rgba(0,240,255,0.2),rgba(0,255,136,0.2));color:#dcfdff}
#grg-action.unlock-web3:hover{background:var(--cyan);color:#041214}
#grg-action:disabled{opacity:.65;cursor:wait}
#grg-msg{margin:0;min-height:16px;text-align:center;color:var(--cyan);font-size:12px;font-weight:700}
#grg-msg.is-vip-warn{color:#fbbf24;font-weight:600}

/* ===== MODAL DE AUDIO Y PLAYLIST WEB3 ===== */
#btn-mute.is-muted{border-color:var(--red);color:#ff9ba5}
#audio-modal{position:fixed;inset:0;z-index:60;display:none;align-items:center;justify-content:center;padding:16px}
.aud-backdrop{position:absolute;inset:0;background:rgba(4,7,12,0.8);backdrop-filter:blur(6px)}
.aud-panel{
  position:relative;
  z-index:1;
  width:min(510px,100%);
  max-height:88vh;
  overflow-y:auto;
  background:var(--panel-strong);
  border:1.5px solid var(--cyan);
  border-radius:14px;
  padding:16px 18px;
  box-shadow:0 20px 55px rgba(0,0,0,0.75);
  display:flex;
  flex-direction:column;
  gap:14px;
  text-align:left;
}
.aud-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding-bottom:10px;border-bottom:1px solid var(--line)}
.aud-head h2{margin:0;font-family:var(--font-hud);font-size:19px;font-style:italic;color:#fff}
.aud-head-acts{display:flex;align-items:center;gap:8px}
#aud-close{border-color:rgba(255,255,255,0.3);padding:6px 11px}
.aud-section{display:flex;flex-direction:column;gap:8px}
.aud-sec-title{font-size:11.5px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--cyan)}
.aud-sliders{display:flex;flex-direction:column;gap:10px}
.aud-slider-row{display:flex;flex-direction:column;gap:4px}
.aud-slider-lbl{display:flex;justify-content:space-between;align-items:center;font-size:12.5px;font-weight:700;color:#e8f0ff}
.aud-slider-lbl b{font-variant-numeric:tabular-nums;color:var(--emerald)}
input.aud-range{width:100%;height:7px;padding:0;border:none;border-radius:999px;background:rgba(255,255,255,0.14);accent-color:var(--cyan);cursor:pointer}

.aud-stations{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.aud-station-btn{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:8px 10px;text-align:left;background:#101722;border-color:rgba(0,240,255,0.38);color:#d7e3ff;overflow:hidden}
.aud-station-btn strong{font-size:12.5px;line-height:1.2;max-width:100%;overflow:hidden;text-overflow:ellipsis}
.aud-station-btn small{font-size:10.5px;font-weight:600;opacity:.78;max-width:100%;overflow:hidden;text-overflow:ellipsis}
.aud-station-btn.aud-station-custom{grid-column:1 / -1}
.aud-station-btn.active{background:linear-gradient(135deg,var(--cyan),var(--emerald));color:#041014;border-color:#fff}
.aud-status{font-size:12px;font-weight:700;color:var(--cyan);min-height:16px}
.aud-status.warn{color:var(--gold)}

.aud-pl-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.aud-pl-badge{font-size:11px;font-weight:700;padding:2px 8px;border-radius:5px;background:rgba(0,240,255,0.14);color:var(--cyan);border:1px solid rgba(0,240,255,0.35)}
.aud-pl-badge.locked{background:rgba(245,158,11,0.14);color:#fbbf24;border-color:rgba(245,158,11,0.4)}
.aud-pl-badge.unlocked{background:rgba(0,255,136,0.16);color:var(--emerald);border-color:rgba(0,255,136,0.4)}
.aud-pl-controls{display:flex;align-items:center;justify-content:space-between;gap:6px}
.aud-pl-now{flex:1;min-width:0;font-size:12px;color:#e2e8f0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}
.aud-pl-count{font-size:11px;font-weight:700;color:#94a3b8;white-space:nowrap}
#aud-pl-urls{width:100%;resize:vertical;min-height:76px;padding:8px 10px;border-radius:8px;border:1px solid rgba(148,163,184,0.28);background:#0a0f18;color:#f8fafc;font:12px/1.4 monospace}

.aud-custom-form{display:flex;flex-direction:column;gap:8px}
.aud-custom-form input{width:100%;padding:9px 12px;border:1px solid rgba(0,240,255,0.4);background:#0a0f18;color:#fff}
.aud-custom-form input:focus{border-color:var(--cyan);outline:none}
#aud-unlock-btn,#aud-pl-unlock-btn{width:100%;padding:10px 14px;font-size:13px}
#aud-unlock-btn.is-web3{border-color:var(--emerald);background:linear-gradient(135deg,rgba(0,240,255,0.18),rgba(0,255,136,0.18));color:#e6fff5}
.aud-msg{margin:0;min-height:16px;font-size:12px;font-weight:700;color:var(--emerald)}
.aud-msg.err{color:#ff8a96}

.aud-track-list{display:flex;flex-direction:column;gap:6px;max-height:150px;overflow-y:auto}
.aud-empty{font-size:12px;color:var(--muted);padding:6px 0}
.aud-track-item{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border-radius:8px;background:rgba(255,255,255,0.04);border:1px solid var(--line)}
.aud-track-item.active{border-color:var(--cyan);background:rgba(0,240,255,0.1)}
.aud-track-info{min-width:0;display:flex;flex-direction:column;gap:2px}
.aud-track-info strong{font-size:13px;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.aud-track-info small{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.aud-track-acts{display:flex;align-items:center;gap:6px;flex-shrink:0}
.aud-use-btn{padding:5px 10px;font-size:12px}
.aud-del-btn{padding:5px 8px;font-size:12px;border-color:rgba(255,59,78,0.55);color:#ff9ba5}
.aud-del-btn:hover{background:var(--red);color:#fff;border-color:var(--red)}

/* ===== RESPONSIVO ===== */
@media(max-width:860px),(max-height:700px){
  .menu-shell{
    overflow-y:auto;
  }
}
@media(max-width:860px){
  #menu{
    align-items:flex-end;
    justify-content:center;
    padding:12px;
    background:radial-gradient(circle at 50% 25%,rgba(8,14,28,0.28) 0%,rgba(5,9,18,0.84) 100%);
  }
  .menu-shell{
    width:min(540px,100%);
    max-height:66vh;
    padding:10px;
    overflow-y:auto;
  }
}
@media(max-width:680px){
  .grg-arrow{display:none}
  #grg-dock{padding:12px 13px;gap:9px}
  #grg-stats{grid-template-columns:1fr;gap:7px}
  .grg-paint-columns{grid-template-columns:1fr;gap:9px}
  .grg-col-accent{padding-left:0;border-left:none;padding-top:8px;border-top:1px solid rgba(255,255,255,0.1)}
  .grg-foot{flex-direction:column;align-items:stretch}
  .grg-actions{margin-left:0;width:100%}
  #grg-action{flex:1;min-width:0}
  #grg-dock .grg-colors.grg-grid-std{grid-template-columns:repeat(8,20px);gap:4px}
  #grg-dock .grg-colors.grg-grid-vip{grid-template-columns:repeat(9,20px);gap:4px}
  #grg-dock .grg-colors.grg-grid-accent{grid-template-columns:repeat(6,22px);gap:5px}
  #grg-dock .grg-swatch{width:20px;height:20px;min-width:20px;min-height:20px;border-radius:5px}
  #grg-dock .grg-grid-accent .grg-swatch{width:22px;height:22px;min-width:22px;min-height:22px}
  .grg-swatch-lock{font-size:8px}
  .aud-stations,.set-grid,.w3-actions,.rs-actions{grid-template-columns:1fr}
  .util-row{grid-template-columns:1fr}
  #pos{font-size:32px}
  .hud-cluster-right{min-width:146px}
  .bar{width:130px}
  #minimap-wrap{
    left:12px;
    right:auto;
    top:calc(110px + env(safe-area-inset-top,0px));
    padding:5px 6px 6px;
  }
  body.hud-mm-right #minimap-wrap{
    left:auto;
    right:12px;
  }
  #race-track-badge{
    right:12px;
    left:auto;
  }
  body.hud-mm-right #cb,
  body.hud-mm-right #aud-hud-trk,
  body.hud-mm-right #race-track-badge{
    left:12px;
    right:auto;
  }
  #minimap{
    width:98px;
    height:114px;
  }
  #dh{
    top:auto;
    bottom:calc(132px + env(safe-area-inset-bottom,0px));
  }
  #spd #spd-val{font-size:32px}
  #lg{bottom:calc(80px + env(safe-area-inset-bottom,0px));width:min(280px,76vw)}
  body.hud-ctrl-on #spd{bottom:calc(130px + env(safe-area-inset-bottom,0px))}
  body.hud-ctrl-on #lg{bottom:calc(194px + env(safe-area-inset-bottom,0px))}
}

/* ===== BOTÓN FLOTANTE WEB3 CONNECT WALLET (MENÚ / GARAJE) ===== */
#wallet-pill-btn{
  position:fixed;
  top:18px;
  right:22px;
  z-index:50;
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 14px;
  border-radius:999px;
  background:rgba(10,18,28,0.75);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border:1px solid rgba(0,229,255,0.45);
  box-shadow:0 8px 24px rgba(0,0,0,0.42),0 0 14px rgba(0,229,255,0.12);
  color:#eef6ff;
  font-family:var(--font-ui);
  font-size:12.5px;
  font-weight:700;
  letter-spacing:.02em;
  line-height:1.2;
  white-space:nowrap;
  cursor:pointer;
}
#wallet-pill-btn:hover,
#wallet-pill-btn:focus-visible{
  background:rgba(12,24,38,0.9);
  color:#fff;
  border-color:#00e5ff;
  box-shadow:0 0 0 1px rgba(0,229,255,0.35),0 8px 24px rgba(0,229,255,0.24);
  transform:translateY(-1px);
}
#wallet-pill-btn.is-connected{
  border-color:rgba(0,230,118,0.58);
  box-shadow:0 8px 24px rgba(0,0,0,0.45),0 0 16px rgba(0,230,118,0.16);
}
#wallet-pill-btn.is-connected:hover,
#wallet-pill-btn.is-connected:focus-visible{
  background:rgba(10,22,30,0.92);
  color:#fff;
  border-color:#00e676;
  box-shadow:0 0 0 1px rgba(0,230,118,0.42),0 8px 24px rgba(0,230,118,0.28);
}
.wallet-pill-dot{
  display:none;
  width:8px;
  height:8px;
  border-radius:50%;
  background:#00e676;
  box-shadow:0 0 8px #00e676;
  flex-shrink:0;
}
#wallet-pill-btn.is-connected .wallet-pill-dot{
  display:inline-block;
}
.wallet-pill-ico{
  width:15px;
  height:15px;
  color:#00e5ff;
  flex-shrink:0;
}
#wallet-pill-btn.is-connected .wallet-pill-ico{
  color:#00e676;
}
#wallet-pill-label{
  overflow:hidden;
  text-overflow:ellipsis;
}
#wallet-pill-btn.is-connected #wallet-pill-label{
  font-family:var(--font-hud);
  font-variant-numeric:tabular-nums;
  letter-spacing:.03em;
}
.wallet-pill-bal{
  padding-left:8px;
  border-left:1px solid rgba(0,229,255,0.28);
  font-family:var(--font-hud);
  font-size:11.5px;
  font-weight:700;
  font-variant-numeric:tabular-nums;
  color:#00e5ff;
}
body.state-intro #wallet-pill-btn,
body.state-race #wallet-pill-btn,
body:not(.state-menu):not(.state-garage) #wallet-pill-btn{
  display:none!important;
}
@media(max-width:1480px){
  body.in-garage #wallet-pill-btn,
  body.state-garage #wallet-pill-btn{
    top:calc(58px + env(safe-area-inset-top,0px));
    right:16px;
  }
}
@media(max-width:680px){
  #wallet-pill-btn{
    top:calc(12px + env(safe-area-inset-top,0px));
    right:12px;
    padding:7px 11px;
    font-size:11.5px;
    gap:6px;
    max-width:calc(100vw - 24px);
  }
  body.in-garage #wallet-pill-btn,
  body.state-garage #wallet-pill-btn{
    top:calc(56px + env(safe-area-inset-top,0px));
    right:12px;
  }
  .wallet-pill-bal{
    padding-left:6px;
    font-size:10.5px;
  }
}

