/* base.css — fundação visual do Oftalmo Kart, no mesmo sistema do site da clínica
   (Site_oftalmo/index.html): fonte Inter, azul #0071E3, cartões brancos de cantos
   bem redondos, botões em pílula, vidro fosco e bastante respiro.

   Folhas de estilo do jogo:
     base.css   tokens, tema claro/escuro, palco e COMPONENTES (cartão, botões, pílulas,
                seletor segmentado, interruptor, vidro escuro do HUD)
     menu.css   tela inicial (piloto, circuito, modo, adversários) e seus formatos
     hud.css    HUD de corrida, avisos, contagem, minimapa e controles de toque
     telas.css  diálogos (como jogar, opções, recordes), pausa, pódio e tabela final

   SISTEMA VISUAL (use estes tokens; não espalhe valores soltos)
     cor       --blue (ação), --grad (destaque em degradê do site), --text / --text-2 / --text-3,
               --card (vidro do cartão), --tile (peças dentro do cartão), --line (fios)
     raios     --r-card 28 · --r-tile 20 · --r-ctl 14 · pílula 980
     sombras   --shadow-card (cartões sobre a pista) · --shadow-tile (peça em destaque)
     tipos     Inter 400–800; títulos −0,025em; rótulos em caixa-alta 12 px/700/+0,08em
     HUD       vidro ESCURO (--hud-glass) com texto branco: contraste AA sobre céu claro,
               pôr do sol ou grama; números em itálico 800 (a "letra de corrida" do jogo)

   Tema: `html.night` (escuro, acentos dourados) segue o critério do site — das 18:00 às
   06:30 de Brasília — ou a escolha do jogador em Opções (js/ui/theme.js). */

/* ------------------------------------------------------------- 1. tokens */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../assets/fonts/inter-latin.woff2') format('woff2');
}

:root {
  --blue: #0071E3;
  --blue-hov: #0077ED;
  --blue-soft: rgba(0, 113, 227, 0.1);
  --blue-ring: rgba(0, 113, 227, 0.26);
  --on-blue: #fff;
  --blue-text: #004E9E;         /* azul para TEXTO sobre o vidro claro e sobre o azul suave: ≥ 4,5:1 (o #0071E3 dá ~3:1) */
  --grad: linear-gradient(100deg, #2563EB 10%, #06B6D4 90%);
  --text: #1D1D1F;
  --text-2: #4E4E54;            /* mais escuro que o #6E6E73 do site: AA (≥ 4,5:1) mesmo sobre o trilho cinza do seletor, em cima do vidro */
  --text-3: #6E6E73;
  --bg: #F5F5F7;
  --dark: #0B0D12;
  --card: rgba(255, 255, 255, 0.8);
  --glass-tint: rgba(250, 251, 253, 0.78);   /* véu do vidro fosco (js/ui/glass.js) */
  --tile: rgba(255, 255, 255, 0.94);
  --tile-hov: #fff;
  --track: rgba(118, 118, 128, 0.14);        /* trilho do seletor segmentado e dos interruptores */
  --line: rgba(0, 0, 0, 0.08);
  --card-line: rgba(255, 255, 255, 0.7);
  --good: #0f5f2d;
  --bad: #b3261e;
  --gold: #F5B623;

  --r-card: 28px;
  --r-tile: 20px;
  --r-ctl: 14px;
  --shadow-card: 0 30px 80px rgba(8, 20, 40, 0.3), 0 2px 10px rgba(8, 20, 40, 0.12);
  --shadow-tile: 0 10px 26px rgba(8, 20, 40, 0.12);
  --shadow-sm: 0 4px 24px rgba(0, 0, 0, 0.06);

  /* HUD: vidro escuro, sempre igual nos dois temas */
  --hud-glass: rgba(11, 13, 18, 0.7);        /* branco sobre isto dá ≥ 7:1 mesmo com uma nuvem branca atrás */
  --hud-glass-strong: rgba(11, 13, 18, 0.82);
  --hud-line: rgba(255, 255, 255, 0.16);
  /* SEM desfoque de propósito: sobre o canvas (que muda 60×/s) cada sombra esfumada é refeita a cada
     quadro quando não há GPU — medido: o HUD com sombras custava ~2 fps no Entardecer */
  --hud-shadow: 0 1.5px 0 rgba(8, 20, 40, 0.22);
  --hud-accent: #4db2ff;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --pop: cubic-bezier(0.2, 1.4, 0.4, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* tema escuro: os mesmos tokens do `html.night` do site (fundo #0B0D12, acentos dourados) */
html.night {
  --blue: #CA8A04;
  --blue-hov: #EAB308;
  --blue-soft: rgba(234, 179, 8, 0.14);
  --blue-ring: rgba(234, 179, 8, 0.3);
  --on-blue: #1D1D1F;           /* texto escuro sobre o dourado: 6:1 (branco dava 2,9:1) */
  --blue-text: #FDE047;
  --grad: linear-gradient(100deg, #EAB308 10%, #FACC15 90%);
  --text: #F5F5F7;
  --text-2: #C4C9D3;
  --text-3: #9299A6;
  --bg: #0B0D12;
  --card: rgba(21, 24, 31, 0.84);
  --glass-tint: rgba(17, 20, 27, 0.8);
  --tile: rgba(36, 41, 53, 0.92);
  --tile-hov: rgba(44, 50, 64, 0.96);
  --track: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.1);
  --card-line: rgba(255, 255, 255, 0.12);
  --good: #4ade80;
  --bad: #ff8a80;
  --shadow-card: 0 30px 80px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-tile: 0 10px 26px rgba(0, 0, 0, 0.35);
  --hud-accent: #FACC15;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--dark);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.025em; line-height: 1.12; font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
a { color: inherit; }
[hidden] { display: none !important; }
.ic { width: 1.25em; height: 1.25em; flex: none; display: block; }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  padding-right: 0.06em;        /* o itálico/peso 800 não corta a última letra */
}

/* foco de teclado/controle: anel bem visível nos dois temas (o HUD usa branco) */
:is(button, a, [tabindex]):focus { outline: none; }
:is(button, a, [tabindex]):focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.75); }
html.night :is(button, a, [tabindex]):focus-visible { box-shadow: 0 0 0 6px rgba(11, 13, 18, 0.8); }
:is(.hud, .touch, .topbar) :is(button, a):focus-visible { outline-color: #fff; box-shadow: 0 0 0 6px rgba(0, 113, 227, 0.75); }

/* -------------------------------------------------------------- 2. palco */
/* (inset 0 num elemento fixo acompanha a área VISÍVEL do navegador do celular: quando as barras
   do Safari/Chrome aparecem ou somem, o palco muda de altura junto — é o mesmo que 100dvh) */
.app {
  position: fixed; inset: 0;
  overflow: hidden;
  touch-action: none;           /* nada de zoom/rolagem acidental sobre o jogo */
  user-select: none; -webkit-user-select: none;
}
#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  outline: none;
  background: #8ccbf3;
}
/* leve escurecida na base da tela: assenta o HUD e dá profundidade à pista */
.vignette {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
  background: linear-gradient(rgba(7, 30, 50, 0), rgba(7, 30, 50, 0.3));
  pointer-events: none;
}
/* transição entre telas: um véu que fecha e abre (js/ui/screens.js) */
.wipe {
  position: absolute; inset: 0; z-index: 60;
  background: var(--dark);
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s ease;
}
.wipe.on { opacity: 1; }

/* -------------------------------------------------------- 3. componentes */
/* cartão de vidro (o "cartão branco arredondado" que o dono gostou no jogo do Codex) */
.card {
  width: min(760px, 100%);
  padding: 26px 32px 22px;
  border-radius: var(--r-card);
  background: var(--card);
  border: 1px solid var(--card-line);
  box-shadow: var(--shadow-card);
  color: var(--text);
}
/* vidro fosco barato: o desfoque vem de um canvas pequeno ampliado (js/ui/glass.js) */
.card.has-glass { position: relative; background: none; overflow: hidden; isolation: isolate; }
.card > .glass { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
.card-small { width: min(420px, 100%); text-align: center; padding: 30px 28px 24px; }
.card-small h2 { font-size: 30px; margin: 6px 0 8px; }
.card-small p { color: var(--text-2); font-size: 15px; line-height: 1.5; }

.eyebrow {
  display: block;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--blue-text);
}
.fine { color: var(--text-2); font-size: 12px; line-height: 1.4; }

/* botões (pílulas, como .btn do site) */
.btn-primary, .btn-soft, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border-radius: 980px; white-space: nowrap; text-decoration: none;
  font-weight: 600; letter-spacing: -0.01em;
  transition: transform 0.22s var(--ease), background 0.2s ease, box-shadow 0.22s ease;
}
.btn-primary {
  width: 100%; min-height: 54px; padding: 14px 30px;
  background: var(--blue); color: var(--on-blue);
  font-size: 17px; font-weight: 700;
  box-shadow: 0 10px 26px var(--blue-ring);
}
.btn-primary:hover { background: var(--blue-hov); transform: scale(1.015); }
.btn-primary:active { transform: scale(0.985); }
.btn-soft {
  min-height: 46px; padding: 11px 20px;
  background: var(--blue-soft); color: var(--blue-text);
  font-size: 15px;
}
.btn-soft:hover { background: var(--blue-ring); }
.btn-soft:active { transform: scale(0.98); }
.btn-ghost { min-height: 44px; padding: 10px 18px; color: var(--blue-text); font-size: 15px; }
.btn-ghost:hover { background: var(--blue-soft); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: rgba(214, 48, 49, 0.1); }

/* pílula escura sobre a pista (barra do menu) e botão redondo do HUD */
.pill-btn, .hud-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; min-width: 44px; padding: 0 16px 0 13px;
  border-radius: 980px;
  background: var(--hud-glass); color: #fff; text-decoration: none;
  border: 1px solid var(--hud-line);
  box-shadow: var(--hud-shadow);
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  pointer-events: auto;
  transition: background 0.18s ease, transform 0.18s var(--ease);
}
.pill-btn:hover, .hud-btn:hover { background: var(--hud-glass-strong); }
.pill-btn:active, .hud-btn:active { transform: scale(0.95); }
.pill-btn .ic { width: 18px; height: 18px; }
.pill-icon, .hud-btn { width: 44px; padding: 0; }
.hud-btn .ic { width: 20px; height: 20px; }
/* botão de som: mostra o alto-falante certo */
[data-mute] .ic-off, [data-mute][aria-pressed="true"] .ic-on { display: none; }
[data-mute][aria-pressed="true"] .ic-off { display: block; }
[data-mute][aria-pressed="true"] { color: #ffb4a8; }

/* botão redondo claro (fechar diálogo) */
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--track); color: var(--text-2);
  transition: background 0.18s ease;
}
.icon-btn:hover { background: var(--line); color: var(--text); }
.icon-btn .ic { width: 18px; height: 18px; }

/* vidro escuro do HUD: translúcido, sem desfoque (barato) e com contraste garantido */
.glass-dark {
  background: var(--hud-glass); color: #fff;
  border: 1px solid var(--hud-line);
  box-shadow: var(--hud-shadow);
}

/* peça selecionável (piloto, circuito) */
.option {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  border-radius: var(--r-tile);
  background: var(--tile);
  border: 1px solid var(--line);
  text-align: left;
  transition: transform 0.22s var(--ease), box-shadow 0.22s ease, border-color 0.18s ease, background 0.18s ease;
}
.option:hover { transform: translateY(-2px); box-shadow: var(--shadow-tile); background: var(--tile-hov); }
.option[aria-checked="true"] {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring), 0 10px 24px var(--blue-soft);
}
.option .tick {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--blue); color: var(--on-blue); box-shadow: 0 0 0 2px var(--tile-hov);
  transform: scale(0); transition: transform 0.25s var(--pop);
}
.option .tick .ic { width: 13px; height: 13px; }
.option[aria-checked="true"] .tick { transform: scale(1); }
.option b { display: block; font-size: 16px; font-weight: 700; letter-spacing: -0.015em; }
.option small { display: block; margin-top: 2px; color: var(--text-2); font-size: 12.5px; font-weight: 500; line-height: 1.3; }

/* seletor segmentado (modo, adversários, abas) */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px;
  padding: 3px; border-radius: var(--r-ctl);
  background: var(--track);
}
.option.seg-option {
  justify-content: center; text-align: center;
  min-height: 44px; padding: 6px 6px; gap: 6px;
  border-radius: 11px; border-color: transparent; background: transparent;
  color: var(--text-2);
}
.option.seg-option:hover { transform: none; box-shadow: none; background: rgba(255, 255, 255, 0.5); }
html.night .option.seg-option:hover { background: rgba(255, 255, 255, 0.07); }
.option.seg-option b { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.option.seg-option .ic { width: 17px; height: 17px; }
.option.seg-option:is([aria-checked="true"], [aria-selected="true"]) {
  background: var(--tile-hov); color: var(--blue-text); border-color: transparent;
  box-shadow: 0 2px 8px rgba(8, 20, 40, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
html.night .option.seg-option:is([aria-checked="true"], [aria-selected="true"]) { background: rgba(255, 255, 255, 0.14); }

/* interruptores (aceleração automática, assistente, som…) */
.switches { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch {
  display: flex; align-items: center; gap: 11px;
  min-height: 52px; padding: 8px 14px 8px 12px;
  border-radius: var(--r-ctl);
  background: var(--tile); border: 1px solid var(--line);
  text-align: left;
  transition: background 0.18s ease;
}
.switch:hover { background: var(--tile-hov); }
.switch-track {
  flex: none; position: relative; width: 46px; height: 28px; border-radius: 980px;
  background: rgba(120, 120, 128, 0.32); transition: background 0.22s ease;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28); transition: transform 0.26s var(--pop);
}
.switch[aria-checked="true"] .switch-track { background: var(--blue); }
html:not(.night) .switch[aria-checked="true"] .switch-track { background: #34c759; }   /* verde do "ligado", como no iOS */
.switch[aria-checked="true"] .switch-thumb { transform: translateX(18px); }
.switch-text { min-width: 0; }
.switch-text b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.switch-text small { display: block; color: var(--text-2); font-size: 12px; font-weight: 500; line-height: 1.3; }
.switches-compact { grid-template-columns: 1fr; }

kbd {
  display: inline-block; min-width: 26px; padding: 3px 7px; margin: 0 2px;
  border-radius: 8px; background: var(--tile-hov); border: 1px solid var(--line);
  box-shadow: 0 1.5px 0 var(--line);
  font: 600 12px var(--font); color: var(--text); text-align: center;
}

/* olho da marca (CSS puro) */
.brand-eye {
  display: inline-block; position: relative;
  width: 1.24em; height: 0.74em; margin-right: 0.28em;
  background: #fff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.075em var(--blue);
  vertical-align: 0.02em;
}
.brand-eye::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 0.5em; height: 0.5em; margin: -0.25em 0 0 -0.25em;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff 0 12%, #0b2540 13% 34%, var(--blue) 35%);
}

/* ------------------------------------------------------- 4. sobreposições */
.overlay, .loading {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(18px + var(--safe-t)) calc(18px + var(--safe-r)) calc(18px + var(--safe-b)) calc(18px + var(--safe-l));
  background: rgba(11, 13, 18, 0.36);
  animation: fade-in 0.25s ease both;
}
.overlay { touch-action: pan-y; }
.overlay > .card { animation: card-in 0.42s var(--ease) both; }
.loading { background: linear-gradient(180deg, #2f9bea, #8ccbf3 60%, #b9dba0); z-index: 50; }
html.night .loading { background: linear-gradient(180deg, #0B0D12, #15181F); }
.loading-card {
  display: grid; justify-items: center; gap: 6px;
  min-width: 250px; padding: 28px 36px 26px; border-radius: var(--r-card);
  background: var(--card); border: 1px solid var(--card-line);
  box-shadow: var(--shadow-card);
  font-size: 14px; color: var(--text-2);
}
.loading-card strong { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; color: var(--text); }
.loading-card .brand-eye { font-size: 32px; margin: 0 0 4px; }
.loading-bar { width: 100%; height: 5px; margin-top: 10px; border-radius: 980px; background: var(--track); overflow: hidden; }
.loading-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--grad); transition: width 0.3s ease; }
.noscript { position: absolute; inset: auto 0 20px; text-align: center; color: #fff; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(0.975); } to { opacity: 1; transform: none; } }

/* Aparelho fraco (degraus de socorro da qualidade, js/main.js põe a classe): o que fica por cima
   do canvas é recomposto a cada quadro — sem vinheta, sem degradês e sem sombras, tudo liso. */
html.low-gfx .vignette { display: none; }
html.low-gfx :is(.glass-dark, .pill-btn, .hud-btn, .toast, .lights) { background: #1b1e26; box-shadow: none; }
html.low-gfx :is(.steer-pad, .touch button) { background: rgba(255, 255, 255, 0.24); box-shadow: none; text-shadow: none; }
html.low-gfx .touch .touch-drift { background: rgba(0, 113, 227, 0.72); }
html.low-gfx .touch .touch-gas { background: rgba(36, 160, 70, 0.7); }
html.low-gfx .steer-knob { box-shadow: none; }
html.low-gfx .menu { background: none; }

/* "reduzir movimento": do sistema (media query) ou da opção do menu (classe no <html>) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: 0.001s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important;
}
