/* Autorama — overlays alegres, arredondados, botões grandes.
   Tudo em rem: o rem escala com a janela (1024px até 4K), então o layout inteiro encolhe/cresce junto. */

:root {
  --ink: #1d2b4f;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: #fffdf5;
  --yellow: #ffd23f;
  --orange: #ff9f1c;
  --green: #2ecc71;
  --green-d: #1c9a52;
  --blue: #2f8cff;
  --blue-d: #1b64c9;
  --red: #ff5252;
  --red-d: #cc2f2f;
  --gray: #6c7a96;
  --gray-d: #4a5670;
}

* { box-sizing: border-box; }

html {
  /* 16px a 1280x720; escala com a menor dimensão relativa */
  font-size: clamp(10px, min(1.25vw, 2.22vh), 72px);
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8bd46e;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-weight: 800;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body[data-phase="racing"],
body[data-phase="countdown"] { cursor: none; }

#game,
#game3d {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#ui {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: auto;
}
.screen.center { align-items: center; justify-content: center; }
.screen.dim { background: rgba(15, 30, 70, 0.55); }
#screen-pause.dim { background: rgba(15, 30, 70, 0.12); } /* o render já escurece a pista na pausa */

/* ---------- Botões ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 5rem;
  padding: 0.6rem 2rem;
  border: 0;
  border-radius: 1.6rem;
  font: inherit;
  font-weight: 900;
  font-size: 1.8rem;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 0.12rem 0 rgba(0, 0, 0, 0.25);
  background: var(--c, var(--blue));
  box-shadow: 0 0.5rem 0 var(--cd, var(--blue-d)), 0 0.9rem 1.4rem rgba(0, 0, 0, 0.25);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.15s, scale 0.15s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-0.1rem); }
.btn:active { transform: translateY(0.35rem); filter: brightness(0.96); }
.btn:focus-visible { outline: 0.35rem solid #fff; outline-offset: 0.2rem; }

.btn-green  { --c: var(--green);  --cd: var(--green-d); }
.btn-blue   { --c: var(--blue);   --cd: var(--blue-d); }
.btn-red    { --c: var(--red);    --cd: var(--red-d); }
.btn-orange { --c: #ffb020;       --cd: #c98400; }
.btn-gray   { --c: var(--gray);   --cd: var(--gray-d); }

.btn-small { min-height: 4.5rem; font-size: 1.4rem; padding: 0.4rem 1.4rem; border-radius: 1.3rem; }
.btn-big   { min-height: 6.5rem; font-size: 2.2rem; padding: 0.6rem 2.4rem; border-radius: 2rem; }
.btn-huge  { min-height: 8rem; font-size: 3.6rem; padding: 0.6rem 5rem; border-radius: 2.6rem; }

/* Botões de escolha: brancos quando desligados, amarelos com anel e visto quando ligados */
.choice {
  --c: #ffffff;
  --cd: #c5cde0;
  color: var(--ink);
  text-shadow: none;
  border: 0.3rem solid #e4e9f4;
}
.choice.selected {
  --c: var(--yellow);
  --cd: #d49400;
  border-color: var(--orange);
  scale: 1.04;
  box-shadow:
    0 0.5rem 0 var(--cd),
    0 0 0 0.35rem rgba(255, 159, 28, 0.6),
    0 0.9rem 1.4rem rgba(0, 0, 0, 0.25);
}
.choice.selected::after {
  content: "✔";
  position: absolute;
  top: -0.8rem;
  right: -0.8rem;
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 1.2rem;
  text-shadow: none;
  box-shadow: 0 0.2rem 0 var(--green-d);
}

/* Selo de botão do controle */
.pad-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.9em;
  height: 1.9em;
  padding: 0 0.3em;
  border-radius: 50%;
  background: #555;
  color: #fff;
  font-size: 0.6em;
  font-weight: 900;
  text-shadow: none;
  box-shadow: inset 0 -0.15em 0 rgba(0, 0, 0, 0.25);
}
.pad-badge.big { font-size: 0.75em; }
.pad-badge.cross    { background: #3d7bff; }
.pad-badge.circle   { background: #ff4d4d; }
.pad-badge.square   { background: #ff6fd8; }
.pad-badge.triangle { background: #27c28a; }
.pad-badge.opt      { border-radius: 0.7em; font-size: 0.5em; letter-spacing: 0.05em; background: #3a4560; }
.modes-row > .pad-badge.big { font-size: 2.2rem; flex: none; }

/* ---------- 1. Abertura ---------- */

#screen-intro {
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.3), rgba(25, 55, 120, 0.6));
}
.intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.6rem;
  text-align: center;
  animation: pop 0.35s ease-out;
}
.logo {
  margin: 0;
  font-size: 8rem;
  line-height: 1.05;
  color: #fff;
  text-shadow: 0 0.4rem 0 #e53935, 0 0.9rem 1.8rem rgba(0, 0, 0, 0.4);
}
.intro-hint {
  margin: 0;
  font-size: 1.3rem;
  color: #fff;
  text-shadow: 0 0.1rem 0.4rem rgba(0, 0, 0, 0.7);
}

/* ---------- 2. Menu ---------- */

#screen-menu {
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 2rem 0.8rem;
  gap: 0.8rem;
  overflow-x: hidden;
  overflow-y: auto;
  transition: opacity 0.2s;
}
/* com o painel dos pais aberto, o menu fica apagado ao fundo */
body.settings-open #screen-menu { opacity: 0.4; pointer-events: none; }

.menu-top {
  flex: none;
  width: 100%;
  max-width: 76rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.pad-status { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; min-width: 0; flex: 1 1 auto; }
.pill {
  max-width: 46rem;
  padding: 0.6rem 1.3rem;
  border: 0.25rem solid #ffb300;
  border-radius: 2rem;
  background: rgba(255, 249, 225, 0.95);
  color: #7a4b00;
  font-size: 1.2rem;
  line-height: 1.2;
}
.pill.ok { border-color: var(--green); background: #eaffef; color: #116b34; }
.menu-top-right { flex: 0 0 auto; display: flex; justify-content: flex-end; min-width: 0; }

.menu-panel {
  flex: none;
  margin: auto 0;
  width: 100%;
  max-width: 76rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.6rem 1.4rem;
  border: 0.3rem solid rgba(255, 255, 255, 0.9);
  border-radius: 2.4rem;
  background: var(--panel);
  -webkit-backdrop-filter: blur(0.6rem);
  backdrop-filter: blur(0.6rem);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.25);
  animation: pop 0.25s ease-out;
}

.track-row { width: 100%; display: flex; align-items: center; gap: 1rem; }
.arrow {
  flex: none;
  width: 5rem;
  height: 5rem;
  min-height: 5rem;
  padding: 0;
  border-radius: 50%;
  font-size: 2rem;
}
.cards {
  flex: 1;
  display: grid;
  /* uma linha só: os cartões encolhem para caber, seja quantas pistas houver */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 12.5rem);
  justify-content: center;
  gap: 1.1rem;
  padding: 0.8rem 0.6rem;
}
.card {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.6rem 0.6rem 0.7rem;
  border: 0.35rem solid transparent;
  border-radius: 1.6rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  opacity: 0.88;
  box-shadow: 0 0.4rem 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, opacity 0.15s;
}
.card:hover { opacity: 1; transform: translateY(-0.15rem); }
.card.selected {
  border-color: var(--orange);
  background: #fff8d6;
  opacity: 1;
  transform: scale(1.07);
  box-shadow: 0 0 0 0.35rem rgba(255, 210, 63, 0.95), 0 1rem 2rem rgba(0, 0, 0, 0.3);
}
.card-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 1rem;
  background: #9bd978;
}
.card-name { font-size: 1.3rem; line-height: 1.1; text-align: center; }
.card-stars { font-size: 1.5rem; letter-spacing: 0.08em; line-height: 1; color: #ffb300; }
.card-stars .off { color: #cdd5e2; }
.card-record { min-height: 1.3rem; font-size: 1.05rem; line-height: 1.2; color: #8a5a00; white-space: nowrap; }

.modes-row { width: 100%; display: flex; align-items: center; justify-content: center; gap: 1rem; }

/* fileira de carros: o jogador 1 tem anel vermelho e selo "1"; o jogador 2, anel azul e selo "2" */
.car-row { width: 100%; display: flex; align-items: center; justify-content: center; gap: 1rem; }
.car-row > .pad-badge.big { font-size: 2.2rem; flex: none; background: #3d7bff; }
.car-cards {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 9.5rem);
  justify-content: center;
  gap: 0.9rem;
  padding: 0.6rem 0.6rem 0.2rem;
}
.car-card {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.3rem 0.4rem 0.4rem;
  border: 0.3rem solid transparent;
  border-radius: 1.2rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  opacity: 0.85;
  box-shadow: 0 0.3rem 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, opacity 0.15s;
}
.car-card:hover { opacity: 1; transform: translateY(-0.15rem); }
.car-canvas { display: block; width: 100%; aspect-ratio: 16 / 10; }
.car-name { font-size: 1.05rem; line-height: 1.1; text-align: center; white-space: nowrap; }
.car-card.sel1, .car-card.sel2 { opacity: 1; transform: scale(1.06); }
.car-card.sel1 { border-color: #e53935; box-shadow: 0 0 0 0.25rem rgba(229, 57, 53, 0.45), 0 0.8rem 1.4rem rgba(0, 0, 0, 0.25); }
.car-card.sel2 { border-color: #1e88e5; box-shadow: 0 0 0 0.25rem rgba(30, 136, 229, 0.45), 0 0.8rem 1.4rem rgba(0, 0, 0, 0.25); }
.car-card.sel1.sel2 { border-color: #e53935 #1e88e5 #1e88e5 #e53935; }
.car-badge {
  position: absolute;
  top: -0.7rem;
  display: none;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 0.2rem solid #fff;
  border-radius: 50%;
  font-size: 1.1rem;
  color: #fff;
}
.car-badge.p1 { left: -0.6rem; background: #e53935; }
.car-badge.p2 { right: -0.6rem; background: #1e88e5; }
.car-card.sel1 .car-badge.p1, .car-card.sel2 .car-badge.p2 { display: grid; }
.modes {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 20rem));
  justify-content: center;
  gap: 1.3rem;
  padding: 0.5rem;
}
.mode {
  min-height: 6.4rem;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 1.5rem;
  text-align: center;
}
.mode-icon { font-size: 2.5rem; line-height: 1; }

.btn-play {
  width: 100%;
  max-width: 40rem;
  min-height: 6.8rem;
  padding: 0.4rem 2rem;
  border-radius: 2.4rem;
  font-size: 3.2rem;
  animation: pulse 1.4s ease-in-out infinite;
}

.menu-hint {
  flex: none;
  padding: 0.4rem 1.2rem;
  border-radius: 1rem;
  background: rgba(20, 40, 90, 0.5);
  color: #fff;
  font-size: 1rem;
  text-align: center;
  text-shadow: 0 0.1rem 0.3rem rgba(0, 0, 0, 0.6);
}
.menu-hint-2 { margin-left: 1rem; opacity: 0.9; }

/* ---------- 3. Painel de ajustes ---------- */

#panel-settings {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: min(36rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 0 1.6rem 3rem;
  overflow-x: hidden;
  overflow-y: auto;
  border-left: 0.4rem solid var(--yellow);
  background: rgba(255, 253, 245, 0.95);
  -webkit-backdrop-filter: blur(0.8rem);
  backdrop-filter: blur(0.8rem);
  box-shadow: -0.6rem 0 2rem rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  font-size: 1rem;
  animation: slide-in 0.2s ease-out;
}
.panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 -1.6rem;
  padding: 1rem 1.6rem 0.8rem;
  background: rgba(255, 253, 245, 0.98);
  border-bottom: 0.2rem solid rgba(0, 0, 0, 0.08);
}
.panel-head h2 { margin: 0; font-size: 1.7rem; }

.group {
  padding: 1rem 1.2rem 1.2rem;
  border-radius: 1.6rem;
  background: #fff;
  box-shadow: 0 0.2rem 0 rgba(0, 0, 0, 0.1);
}
.group h3 { margin: 0 0 0.8rem; font-size: 1.5rem; }

.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.level-grid + .switch-row { margin-top: 0.6rem; }
.inline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; margin: 0.3rem 0 0.9rem; }
.inline-row .setting-help { flex: 1; min-width: 12rem; margin: 0; }
.level { min-height: 4.5rem; font-size: 1.4rem; padding: 0.4rem 0.8rem; border-radius: 1.3rem; }

.setting { margin-bottom: 0.9rem; }
.setting-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.setting-label { font-size: 1.25rem; }
.setting-head output { font-size: 1.4rem; color: #d86b00; min-width: 4.5rem; text-align: right; }
.setting-help { margin-top: 0.1rem; font-size: 0.95rem; font-weight: 700; color: #5d6b8c; line-height: 1.25; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2.8rem;
  margin: 0.2rem 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 0.9rem;
  border-radius: 0.5rem;
  background: linear-gradient(to right, var(--orange) var(--p), #d5dcea var(--p));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 2.4rem;
  height: 2.4rem;
  margin-top: -0.75rem;
  border: 0.3rem solid #fff;
  border-radius: 50%;
  background: #ff7a00;
  box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-track {
  height: 0.9rem;
  border-radius: 0.5rem;
  background: linear-gradient(to right, var(--orange) var(--p), #d5dcea var(--p));
}
input[type="range"]::-moz-range-thumb {
  width: 1.8rem;
  height: 1.8rem;
  border: 0.3rem solid #fff;
  border-radius: 50%;
  background: #ff7a00;
  box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.4);
}
input[type="range"]:focus-visible { outline: 0.25rem solid var(--blue); outline-offset: 0.1rem; border-radius: 0.6rem; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.7rem; margin: 0.5rem 0 1rem; }
.seg-btn { min-height: 4.5rem; font-size: 1.5rem; padding: 0.4rem 0.4rem; border-radius: 1.2rem; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4.5rem;
  cursor: pointer;
}
.switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch {
  flex: none;
  position: relative;
  width: 5rem;
  height: 2.8rem;
  border-radius: 1.4rem;
  background: #c3cbdb;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0.15rem 0.4rem rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}
.switch-row input:checked + .switch { background: var(--green); }
.switch-row input:checked + .switch::after { transform: translateX(2.2rem); }
.switch-row input:focus-visible + .switch { outline: 0.25rem solid var(--blue); outline-offset: 0.15rem; }
.switch-text { font-size: 1.15rem; line-height: 1.2; }
#btn-clear-records { margin-top: 0.8rem; }

/* Testador de gatilho */
.tester { margin-top: 0.4rem; padding: 0.9rem 1rem 1rem; border-radius: 1.3rem; background: #eef3ff; }
.tester-title { margin-bottom: 0.5rem; font-size: 1.15rem; color: var(--blue-d); }
.tester-row { margin-bottom: 0.8rem; }
.tester-name { display: flex; align-items: center; gap: 0.5rem; font-size: 1.1rem; margin-bottom: 0.2rem; }
.tester-name small { font-size: 0.85rem; font-weight: 700; color: #5d6b8c; }
.dot { flex: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--c, #999); }
.meter-row { display: flex; align-items: center; gap: 0.7rem; margin: 0.2rem 0; }
.meter-label { flex: none; width: 3.6rem; font-size: 0.95rem; color: #5d6b8c; }
.meter { flex: 1; height: 1.4rem; overflow: hidden; border-radius: 1rem; background: #d5dcea; }
.meter > i { display: block; width: 0; height: 100%; border-radius: 1rem; }
.meter.raw > i { background: linear-gradient(90deg, #ffd23f, #ff7a00); }
.meter.use > i { background: linear-gradient(90deg, #5be37d, #1c9a52); }
.meter-row output { flex: none; width: 3.6rem; font-size: 1rem; text-align: right; }

/* ---------- 4/5. Pausa e fim de corrida ---------- */

.dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
  min-width: min(34rem, 92vw);
  max-width: 92vw;
  padding: 2.2rem 3rem 3rem;
  border: 0.45rem solid #fff;
  border-radius: 2.6rem;
  background: var(--panel-solid);
  box-shadow: 0 1.4rem 4rem rgba(0, 0, 0, 0.45);
  animation: pop 0.25s ease-out;
}
.dialog h2 { margin: 0; font-size: 3.6rem; text-align: center; }
.btn-col { display: flex; flex-direction: column; gap: 1.2rem; width: 100%; }
.btn-col .btn { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.4rem; }

.results { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.8rem; padding: 0.6rem; }
.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 14rem;
  max-width: 22rem;
  padding: 0.8rem 1.6rem 1.2rem;
  border: 0.45rem solid var(--car-color, #999);
  border-radius: 2rem;
  background: #fff;
  text-align: center;
}
.result.win {
  background: #fff8d6;
  transform: scale(1.08);
  box-shadow: 0 0 0 0.4rem var(--yellow), 0 1rem 2rem rgba(0, 0, 0, 0.25);
}
.result .trophy { height: 4.4rem; font-size: 3.6rem; line-height: 1.2; }
.result .rcar {
  display: grid;
  place-items: center;
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  background: var(--car-color, #999);
  font-size: 2.4rem;
}
.result .rname { font-size: 1.6rem; color: var(--car-color, var(--ink)); }
.result .rstars { font-size: 2.2rem; line-height: 1.25; word-break: break-all; }
.result .rstars.none { color: #b4bdd0; }
.result .rbest { min-height: 1.6rem; font-size: 1.4rem; color: #4a5368; }
.result .rrecord {
  padding: 0.2rem 1rem;
  border-radius: 1rem;
  background: var(--yellow);
  font-size: 1.4rem;
  color: #5a3a00;
}

/* ---------- Animações ---------- */

@keyframes pop {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.04; }
}
@keyframes slide-in {
  from { transform: translateX(3rem); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Janelas bem estreitas: empilha o topo do menu */
@media (max-width: 900px) {
  .menu-top { flex-wrap: wrap; justify-content: center; }
  .pad-status { align-items: center; }
  .menu-top-right { flex: 0 0 auto; }
}

/* ---------- Tema neon: cidade praiana ao pôr do sol (body.theme-neon) ---------- */

body.theme-neon { --panel: rgba(24, 12, 46, 0.72); --ink: #ffffff; background: #2a1440; }
body.theme-neon #screen-intro { background: linear-gradient(180deg, rgba(40, 10, 70, 0.05), rgba(40, 10, 70, 0.55)); }
body.theme-neon .logo {
  font-style: italic;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffe082 0%, #ff8a3d 38%, #ff3d8b 70%, #a63dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 1.2rem rgba(255, 60, 160, 0.75)) drop-shadow(0 0.4rem 0 rgba(40, 0, 60, 0.85));
}
body.theme-neon .intro-hint,
body.theme-neon .menu-hint { color: #ffd6f0; }
body.theme-neon .menu-hint { background: rgba(30, 8, 50, 0.6); }
body.theme-neon .btn-green { --c: linear-gradient(180deg, #ff6aa8, #ff2f7d); --cd: #a3105a; }
body.theme-neon .btn-green { box-shadow: 0 0.5rem 0 var(--cd), 0 0 1.6rem rgba(255, 61, 139, 0.75); }
body.theme-neon .btn-orange { --c: linear-gradient(180deg, #ffb35a, #ff7a2f); --cd: #b8480f; }
body.theme-neon .btn-blue { --c: linear-gradient(180deg, #4fd8ff, #2f8cff); --cd: #1b4fa8; }
body.theme-neon .menu-panel {
  border-color: #ff4fb0;
  box-shadow: 0 0 1.6rem rgba(255, 79, 176, 0.65), inset 0 0 1.2rem rgba(80, 220, 255, 0.25);
}
body.theme-neon .pill { background: rgba(24, 12, 46, 0.78); color: #ffffff; border-color: rgba(255, 255, 255, 0.35); }
body.theme-neon .pill.ok { background: rgba(10, 60, 45, 0.8); color: #8dffc0; border-color: #5dff9c; }
body.theme-neon .card { background: rgba(255, 255, 255, 0.08); color: #ffffff; border-color: rgba(120, 230, 255, 0.35); }
body.theme-neon .card.selected {
  background: rgba(255, 79, 176, 0.2);
  border-color: #4ff0ff;
  box-shadow: 0 0 0 0.3rem rgba(79, 240, 255, 0.55), 0 0 1.6rem rgba(79, 240, 255, 0.8);
}
body.theme-neon .card-canvas { background: #2a1d45; }
body.theme-neon .card-stars .off { color: rgba(255, 255, 255, 0.25); }
body.theme-neon .card-record { color: #ffd27a; }
body.theme-neon .choice { --c: rgba(255, 255, 255, 0.1); --cd: rgba(0, 0, 0, 0.35); color: #ffffff; border-color: rgba(120, 230, 255, 0.35); }
body.theme-neon .choice.selected {
  --c: linear-gradient(180deg, #ff6aa8, #ff2f7d);
  --cd: #a3105a;
  border-color: #ffd23f;
  box-shadow: 0 0.5rem 0 var(--cd), 0 0 1.4rem rgba(255, 61, 139, 0.8);
}
body.theme-neon .screen.dim { background: rgba(30, 6, 50, 0.55); }
body.theme-neon .dialog {
  background: rgba(28, 12, 52, 0.92);
  color: #ffffff;
  border-color: #ff4fb0;
  box-shadow: 0 0 2rem rgba(255, 79, 176, 0.6);
}
body.theme-neon .result { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
body.theme-neon .result.win { background: rgba(255, 210, 63, 0.18); }
body.theme-neon .result .rbest { color: #ffd6f0; }
body.theme-neon .car-card { background: rgba(255, 255, 255, 0.08); color: #ffffff; border-color: rgba(120, 230, 255, 0.25); }
body.theme-neon .car-card.sel1 { border-color: #ff4f6a; box-shadow: 0 0 0 0.25rem rgba(255, 79, 106, 0.5), 0 0 1.4rem rgba(255, 79, 106, 0.8); }
body.theme-neon .car-card.sel2 { border-color: #4fb4ff; box-shadow: 0 0 0 0.25rem rgba(79, 180, 255, 0.5), 0 0 1.4rem rgba(79, 180, 255, 0.8); }
body.theme-neon .car-card.sel1.sel2 { border-color: #ff4f6a #4fb4ff #4fb4ff #ff4f6a; }

/* painel dos pais no neon: o --ink fica branco, então o fundo do painel também escurece */
body.theme-neon #panel-settings {
  border-left-color: #ff4fb0;
  background: rgba(24, 12, 46, 0.95);
  box-shadow: -0.6rem 0 2rem rgba(0, 0, 0, 0.5), -0.2rem 0 1.4rem rgba(255, 79, 176, 0.45);
}
body.theme-neon .panel-head { background: rgba(24, 12, 46, 0.98); border-bottom-color: rgba(255, 255, 255, 0.12); }
body.theme-neon .group { background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 0.15rem rgba(120, 230, 255, 0.18); }
body.theme-neon .setting-help,
body.theme-neon .tester-name small,
body.theme-neon .meter-label { color: #cbbcec; }
body.theme-neon .setting-head output { color: #ffb35a; }
body.theme-neon .tester { background: rgba(79, 240, 255, 0.08); }
body.theme-neon .tester-title { color: #7fe6ff; }
body.theme-neon .meter,
body.theme-neon .switch { background: rgba(255, 255, 255, 0.2); }
body.theme-neon input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(to right, var(--orange) var(--p), rgba(255, 255, 255, 0.2) var(--p));
}
body.theme-neon input[type="range"]::-moz-range-track {
  background: linear-gradient(to right, var(--orange) var(--p), rgba(255, 255, 255, 0.2) var(--p));
}

/* ---------- Minijogos, cores, álbum e pilotos ---------- */

/* cinco modos numa linha (três de corrida e dois minijogos) */
.modes { grid-template-columns: repeat(5, minmax(0, 14rem)); gap: 1rem; }
.mode { min-height: 5.6rem; }
.mode { font-size: 1.35rem; }
.mode.game:not(.selected) { border-color: #d6c8ff; } /* minijogo: borda lilás */

/* cores do carro: bolinhas; o jogador 1 tem anel vermelho e selo "1", o jogador 2 anel azul e selo "2" */
.color-row { width: 100%; display: flex; align-items: center; justify-content: center; gap: 1rem; }
.color-row > .pad-badge.big { font-size: 2.2rem; flex: none; }
.color-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.9rem; padding: 0.4rem; }
.color-chip {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 3.6rem;
  height: 3.6rem;
  padding: 0;
  border: 0.3rem solid #fff;
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  box-shadow: 0 0.25rem 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.15s, box-shadow 0.15s;
}
.color-chip:hover { transform: translateY(-0.15rem); }
.color-chip.sel1, .color-chip.sel2 { transform: scale(1.15); }
.color-chip.sel1 { box-shadow: 0 0 0 0.3rem #e53935; }
.color-chip.sel2 { box-shadow: 0 0 0 0.3rem #1e88e5; }
.color-chip.sel1.sel2 { box-shadow: 0 0 0 0.3rem #e53935, 0 0 0 0.6rem #1e88e5; }
.color-chip .car-badge { top: -0.8rem; width: 1.6rem; height: 1.6rem; font-size: 0.9rem; }
.color-chip.sel1 .car-badge.p1, .color-chip.sel2 .car-badge.p2 { display: grid; }

/* fechado no álbum: apagado, com cadeado e as estrelas que faltam */
.card.locked, .car-card.locked { opacity: 0.55; }
.card.locked .card-canvas, .car-card.locked .car-canvas { filter: grayscale(1) brightness(0.45); }
.color-chip.locked { filter: grayscale(0.85) brightness(0.7); opacity: 0.6; }
.card, .car-card { position: relative; }
.lock-tag {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  background: rgba(20, 24, 40, 0.85);
  color: #ffd23f;
  font-size: 1.1rem;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}
.color-chip .lock-tag { top: 50%; padding: 0; background: none; font-size: 1.4rem; }
.nope { animation: nope 0.35s ease-in-out; }
@keyframes nope {
  0%, 100% { translate: 0 0; }
  20% { translate: -0.5rem 0; }
  40% { translate: 0.5rem 0; }
  60% { translate: -0.35rem 0; }
  80% { translate: 0.35rem 0; }
}

/* botão do álbum no menu */
.menu-top-right { gap: 0.8rem; }
.btn-album { position: relative; }
.album-total { margin-left: 0.3rem; }
.album-new {
  position: absolute;
  top: -0.7rem;
  right: -0.7rem;
  display: grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border: 0.2rem solid #fff;
  border-radius: 1rem;
  background: var(--red);
  color: #fff;
  font-size: 1rem;
  animation: pulse 1.4s ease-in-out infinite;
}
.album-new.hidden { display: none; }
.pad-badge.touch { border-radius: 0.35em; min-width: 2.6em; background: #607d8b; }

/* tela do álbum */
#screen-album { z-index: 6; overflow-y: auto; }
.album-dialog > * { flex: none; } /* com a rolagem, o flex não pode espremer a barra */
.album-dialog { width: min(78rem, 94vw); max-height: 94vh; gap: 1rem; padding: 1.6rem 2.2rem 2rem; overflow-y: auto; }
.album-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.album-head h2 { font-size: 3rem; }
.album-stars { font-size: 3rem; font-weight: 900; color: #ffb300; text-shadow: 0 0.2rem 0 rgba(0, 0, 0, 0.15); }
.album-progress { width: 100%; height: 1.6rem; overflow: hidden; border-radius: 1rem; background: #d5dcea; }
.album-progress > i { display: block; width: 0; height: 100%; border-radius: 1rem; background: linear-gradient(90deg, #ffd23f, #ff9f1c); transition: width 0.4s; }
.album-next { font-size: 1.4rem; font-weight: 900; }
.album-grid { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 1rem; }
.sticker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.5rem 0.7rem;
  border: 0.3rem solid #ffd23f;
  border-radius: 1.2rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 0.3rem 0 rgba(0, 0, 0, 0.12);
  font-weight: 900;
}
.sticker.locked { border-style: dashed; border-color: #b4bdd0; background: #eef1f7; }
.sticker-canvas { display: block; width: 100%; aspect-ratio: 16 / 10; }
.sticker-swatch { width: 5.4rem; height: 5.4rem; margin: 0.2rem 0; border: 0.3rem solid #fff; border-radius: 50%; background: var(--c); box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.3); }
.sticker.locked .sticker-canvas, .sticker.locked .sticker-swatch { filter: grayscale(1) brightness(0.3); opacity: 0.55; }
.sticker-name { font-size: 1.1rem; line-height: 1.1; text-align: center; }
.sticker.locked .sticker-name { opacity: 0.5; }
.sticker-need { font-size: 1.2rem; color: #8a5a00; }
.sticker-new {
  position: absolute;
  top: -0.7rem;
  right: -0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 0.8rem;
  background: var(--red);
  color: #fff;
  font-size: 0.95rem;
  transform: rotate(8deg);
}

/* figurinhas novas no fim da corrida */
.finish-stickers { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.finish-stickers.hidden { display: none; }
.finish-stickers-title { font-size: 2rem; font-weight: 900; color: #ff9f1c; }
.finish-stickers-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.finish-stickers-row .sticker { width: 10rem; animation: pop 0.4s ease-out; }

/* pilotos no painel dos pais */
.pilot-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.3rem 0 0.6rem; }
.pilot-label { flex: none; width: 6.4rem; font-weight: 900; }
.pilot-num { flex: none; font-weight: 900; }
.text-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.8rem;
  border: 0.2rem solid #c9d1e0;
  border-radius: 0.8rem;
  background: #fff;
  color: #1d2b4f;
  font: inherit;
  font-size: 1.2rem;
}
.text-input.num { flex: none; width: 4.6rem; text-align: center; }
.text-input:focus { outline: none; border-color: var(--orange); }

body.theme-neon .sticker { background: rgba(255, 255, 255, 0.1); color: #fff; }
body.theme-neon .sticker.locked { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.25); }
body.theme-neon .sticker-need { color: #ffd23f; }
body.theme-neon .album-progress { background: rgba(255, 255, 255, 0.2); }
/* fim com figurinhas novas: tudo precisa caber numa tela de 720 de altura */
#screen-finish .dialog > * { flex: none; }
#screen-finish .dialog { gap: 1rem; max-height: 96vh; overflow-y: auto; padding-top: 1.6rem; padding-bottom: 2rem; }
.finish-stickers-row .sticker { width: 8rem; padding: 0.4rem 0.4rem 0.5rem; }
.finish-stickers-row .sticker-swatch { width: 3.6rem; height: 3.6rem; }
.finish-stickers-title { font-size: 1.7rem; }
/* figurinhas novas ao lado do resultado (embaixo, os botões sairiam da tela) */
.finish-body { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1.6rem; }
.finish-stickers-row { max-width: 28rem; }

/* aviso quando o jogo é aberto direto do arquivo (file://) */
#file-warning {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 28, 0.85); padding: 16px;
}
#file-warning .dialog { max-width: 560px; text-align: center; }
#file-warning p { line-height: 1.5; }

/* fim de corrida no 3D: resultado numa faixa embaixo, sem escurecer, para ver a câmera de chegada
   girando em volta do carro (o "venceu!" fica numa faixa no alto, desenhada no canvas) */
#screen-finish.over3d { align-items: flex-end; background: transparent; padding-bottom: 1.2rem; pointer-events: none; }
#screen-finish.over3d .dialog {
  pointer-events: auto;
  flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0.8rem 1.6rem; max-height: 48vh; padding: 0.9rem 1.6rem; border-radius: 2rem;
  min-width: 0; box-shadow: 0 0.8rem 2.4rem rgba(0, 0, 0, 0.35);
}
#screen-finish.over3d .dialog h2 { display: none; }
#screen-finish.over3d .finish-body { gap: 1rem; }
#screen-finish.over3d .results { gap: 1rem; padding: 0; }
#screen-finish.over3d .result { flex-direction: row; gap: 0.8rem; min-width: 0; max-width: none; padding: 0.4rem 1.2rem; }
#screen-finish.over3d .result.win { transform: none; }
#screen-finish.over3d .btn-row { gap: 0.8rem; }

/* ---------- Editor de pista (peças Carrera GO!!!) ---------- */

.card-build { justify-content: center; border: 0.35rem dashed #b9c4d8; background: #f4f7fc; }
.card-build-icon {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 16 / 10; border-radius: 1rem;
  background: #dfe7f3; font-size: 4rem;
}
#screen-editor { z-index: 6; }
.editor-dialog {
  width: min(118rem, 97vw); height: 96vh; max-width: 97vw;
  gap: 0.9rem; padding: 1.2rem 1.6rem 1.4rem;
}
.editor-dialog > * { flex: none; }
.editor-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.editor-head h2 { font-size: 2.6rem; }
.editor-status {
  padding: 0.5rem 1.2rem; border-radius: 1rem;
  background: #ffe9e9; color: #a32020; font-size: 1.4rem; font-weight: 900; text-align: right;
}
.editor-status.ok { background: #dcf7e6; color: #17733d; }
.editor-stage {
  flex: 1 1 auto; min-height: 0; width: 100%;
  border-radius: 1.4rem; background: #9bd978;
  box-shadow: inset 0 0 0 0.3rem rgba(0, 0, 0, 0.06);
}
.editor-canvas { display: block; width: 100%; height: 100%; cursor: pointer; touch-action: none; }
.editor-palette { width: 100%; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 0.6rem; }
.editor-piece {
  position: relative; appearance: none; -webkit-appearance: none;
  padding: 0.3rem; border: 0.25rem solid #d5dcea; border-radius: 1rem;
  background: #fff; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 0.3rem 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.1s, border-color 0.1s;
}
.editor-piece:hover { border-color: var(--orange); transform: translateY(-0.15rem); }
.editor-piece:active { transform: translateY(0.2rem); }
.editor-piece.empty { opacity: 0.55; }
.editor-piece-canvas { display: block; width: 100%; aspect-ratio: 4 / 3; }
.editor-left {
  position: absolute; top: -0.6rem; right: -0.5rem;
  min-width: 2.2rem; padding: 0 0.4rem; border-radius: 1rem;
  background: var(--blue); color: #fff; font-size: 1.1rem; font-weight: 900; line-height: 2.2rem; text-align: center;
}
.editor-left:empty { display: none; }
.editor-piece.empty .editor-left { background: var(--red); }
.editor-tools { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; }
.editor-tools .btn:disabled { filter: grayscale(1); opacity: 0.45; cursor: default; transform: none; }
.editor-spacer { flex: 1; }
.editor-box { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.2rem; font-size: 1.2rem; font-weight: 900; }
.editor-box-help { width: 100%; }
.editor-box-item { display: flex; align-items: center; gap: 0.5rem; }
.editor-head h2 { white-space: nowrap; }
.editor-head .editor-status { flex: 1; }
.editor-head-btns { display: flex; gap: 0.8rem; }
.editor-head-btns .btn:disabled { filter: grayscale(1); opacity: 0.45; cursor: default; transform: none; }

/* ---------- Autorama de verdade (câmera conta as voltas) ---------- */

#screen-real { z-index: 6; }
.real-dialog { width: min(124rem, 97vw); height: 96vh; max-width: 97vw; gap: 0.9rem; padding: 1.2rem 1.6rem 1.4rem; }
.real-dialog > * { flex: none; }
.real-head { width: 100%; display: flex; align-items: center; gap: 1.2rem; }
.real-head h2 { font-size: 2.6rem; white-space: nowrap; }
.real-status { flex: 1; padding: 0.5rem 1.2rem; border-radius: 1rem; background: #e6efff; color: #1b4a9a; font-size: 1.3rem; font-weight: 900; }
.real-status.bad { background: #ffe9e9; color: #a32020; }
.real-body { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; gap: 1.2rem; }
.real-left { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.real-stage { position: relative; flex: 1 1 auto; min-height: 0; border-radius: 1.4rem; overflow: hidden; background: #111; }
.real-video, .real-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.real-video { object-fit: contain; }
.real-overlay { cursor: crosshair; touch-action: none; }
.real-setup { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; }
.real-laps { display: flex; align-items: center; gap: 0.5rem; }
.real-laps .btn { min-width: 4.5rem; padding: 0.4rem 0.8rem; }
.real-laps-n { min-width: 7rem; text-align: center; font-size: 1.5rem; font-weight: 900; }
.real-sens { display: flex; align-items: center; gap: 0.6rem; font-size: 1.3rem; font-weight: 900; }
.real-sens input { width: 12rem; }
.real-cam { font: inherit; font-size: 1.2rem; padding: 0.5rem; border-radius: 0.8rem; max-width: 18rem; }
.real-right { flex: 0 0 34rem; display: flex; flex-direction: column; gap: 0.9rem; }
.real-lights { display: flex; justify-content: center; gap: 1rem; padding: 0.5rem; border-radius: 1.4rem; background: #1d2433; }
.real-lights i { width: 2.8rem; height: 2.8rem; border-radius: 50%; background: #3a2226; box-shadow: inset 0 0 0 0.3rem rgba(0, 0, 0, 0.35); }
.real-lights i.on { background: #ff3b3b; box-shadow: 0 0 1.4rem #ff3b3b; }
.real-lights i.go { background: #2ecc71; box-shadow: 0 0 1.4rem #2ecc71; }
.real-card {
  display: flex; flex-direction: column; gap: 0.35rem; padding: 0.6rem 0.9rem; color: var(--ink);
  border: 0.4rem solid var(--c); border-radius: 1.4rem; background: #fff;
  transition: background 0.15s, transform 0.15s;
}
.real-card.flash { background: #fff4c2; transform: scale(1.02); }
.real-card.win { background: #fff1a8; }
.real-card-top { display: flex; align-items: center; gap: 0.8rem; }
.real-car { width: 6.4rem; height: 3.6rem; flex: none; }
.real-card-mid { flex: 1; min-width: 0; }
.real-name { font-size: 1.4rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.real-lapcount { font-size: 2.6rem; font-weight: 900; line-height: 1.05; color: var(--ink); }
.real-times { font-size: 1.15rem; font-weight: 900; color: #5a6680; }
.real-meter { position: relative; height: 0.9rem; border-radius: 0.5rem; background: #e3e8f2; overflow: hidden; }
.real-meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); }
.real-meter b { position: absolute; top: 0; bottom: 0; width: 0.25rem; background: #1d2433; }
.real-undo { flex: none; min-height: 3.2rem; padding: 0.3rem 0.8rem; font-size: 1.1rem; }
.real-undo:disabled, .real-setup .btn:disabled { filter: grayscale(1); opacity: 0.4; cursor: default; transform: none; }
.real-record { font-size: 1.3rem; font-weight: 900; color: #8a5a00; text-align: center; }
.real-go { margin-top: auto; width: 100%; font-size: 2rem; }
.racing .real-setup { display: none; }
body.theme-neon .real-card { background: rgba(255, 255, 255, 0.08); }
body.theme-neon .real-card.flash { background: rgba(255, 210, 63, 0.3); }
body.theme-neon .real-card.win { background: rgba(255, 210, 63, 0.22); }
body.theme-neon .real-times { color: #cbbcec; }
body.theme-neon .real-meter { background: rgba(255, 255, 255, 0.15); }
body.theme-neon .real-meter b { background: #ffffff; }
body.theme-neon .real-record { color: #ffd27a; }

/* tela mais alta que larga (celular em pé): tudo numa coluna, com rolagem */
@media (max-aspect-ratio: 1/1) {
  .real-dialog, .editor-dialog { height: auto; max-height: 97vh; overflow-y: auto; padding: 1rem; }
  .real-head, .editor-head { flex-wrap: wrap; gap: 0.6rem; }
  .real-head h2, .editor-head h2 { flex: 1; font-size: 2.2rem; }
  .real-head .real-status, .editor-head .editor-status { order: 3; flex: 1 1 100%; text-align: left; }
  .real-body { flex-direction: column; }
  .real-stage { flex: none; width: 100%; aspect-ratio: var(--ar, 4 / 3); max-height: 40vh; }
  .racing .real-stage { max-height: 24vh; }
  .real-go { position: sticky; bottom: 0; z-index: 1; }
  .real-right { flex: none; width: 100%; }
  .real-go { margin-top: 0.4rem; }
  .editor-stage { flex: none; aspect-ratio: 1; max-height: 55vh; }
  .editor-palette { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
