:root {
  --pink: #ff4f9a;
  --pink-d: #d6307a;
  --yellow: #ffc629;
  --yellow-d: #e09a00;
  --cyan: #2ed3ff;
  --cyan-d: #0a9fd0;
  --green: #4be37a;
  --green-d: #1fb04f;
  --purple: #7a3dff;
  --ink: #2b1745;
  --cream: #fff8ef;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #9fe0ff;
  font-family: 'Fredoka', 'Trebuchet MS', sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; }
input { font-family: inherit; }

/* ---------- telas ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
#pause, #end { background: rgba(43, 23, 69, 0.45); backdrop-filter: blur(4px); }

.card {
  background: var(--cream);
  border: 5px solid var(--ink);
  border-radius: 32px;
  box-shadow: 0 10px 0 var(--ink), 0 24px 50px rgba(43, 23, 69, 0.35);
  padding: 26px 26px 22px;
  width: 100%;
  animation: pop-in 0.45s cubic-bezier(.2, 1.6, .4, 1);
}
.small-card { max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.end-card { max-width: 520px; text-align: center; }

@keyframes pop-in {
  from { transform: scale(0.6) rotate(-3deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

/* =====================================================================
   menu v3: a interface vai em volta do seu carrinho. O 3D (arena + carrinho no pedestal) fica
   atrás e main.js enquadra o carrinho onde o #garage-spot está. PC: logo no canto, perfil +
   ajustes + som no topo direito, carrinho à esquerda do centro, modo + JOGAR no canto de baixo
   à direita, barra de comandos no canto de baixo à esquerda. Telas médias e celular deitado:
   no fim do arquivo. Celular em pé não tem menu: só o aviso #rotate.
   ===================================================================== */
#menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px 28px;
  align-items: start;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(30px, env(safe-area-inset-right, 0px))
    max(30px, env(safe-area-inset-bottom, 0px)) max(28px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  transition: opacity .25s;
}
/* saindo para a partida: a interface some enquanto o carrinho desce do pedestal (main.js launch) */
#menu.leaving { opacity: 0; pointer-events: none; }

/* logo: public/img/logo.png (recorte de "Logo 3D Parque Maluco Vibrante.png"), fundo transparente */
.m-brand { grid-column: 1; grid-row: 1; justify-self: start; position: relative; z-index: 1; min-width: 0; }
.logo { line-height: 0; margin: 0 -6px; }
.logo img {
  display: block;
  width: clamp(190px, 21vw, 290px);
  height: auto;
  max-height: 24vh;
  object-fit: contain;
  object-position: left top;
  pointer-events: none;
  animation: logo-float 3.2s ease-in-out infinite;
}
@keyframes logo-float {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-6px) rotate(1deg) scale(1.02); }
}
@media (prefers-reduced-motion: reduce) {
  .logo img { animation: none; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-7px) rotate(-4deg); }
}

/* ---------- topo direito: perfil compacto, ajustes e som ---------- */
/* nas duas colunas: alinhado à direita sem alargar a coluna dos modos (o carrinho fica no meio) */
.m-top { grid-column: 1 / 3; grid-row: 1; justify-self: end; display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.round-btn {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cream);
  display: grid;
  place-items: center;
  transition: transform .1s, box-shadow .1s;
}
.round-btn .ico { width: 28px; height: 28px; }
#btn-settings .ico { --fill: #a46bff; }
#btn-sound .ico { --fill: var(--purple); }
.round-btn:hover { transform: translateY(-2px); }
.round-btn:active { transform: translateY(4px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), 0 2px 0 var(--ink); }

.profile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 18px 0 6px;
  background: var(--cream);
  border-radius: 999px;
}
.lvl-badge {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: conic-gradient(var(--pink), var(--yellow), var(--cyan), var(--green), var(--pink));
  border: 3px solid var(--ink);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  transform: rotate(-6deg);
}
.profile .xp { width: 180px; display: flex; flex-direction: column; gap: 5px; }
.profile .xp-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; font-weight: 700; }
#xp-left { font-size: 12px; font-weight: 600; color: #6b4aa8; }
.profile .xp-bar { position: relative; height: 14px; margin: 0; }
/* XP da última partida: faixa amarela que a barra verde alcança (main.js showXpGain) */
.profile .xp-bar > #xp-gain { position: absolute; left: 0; top: 0; background: var(--yellow); border-radius: 0; }
.profile .xp-bar > #xp-fill { position: relative; }
.best { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding-left: 12px; border-left: 3px solid #e5d9ff; font-size: 16px; white-space: nowrap; }
.best .ico { width: 20px; height: 20px; }
.xp-pop {
  position: absolute;
  z-index: 2;
  left: 64px;
  bottom: -22px;
  padding: 2px 12px 3px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  transform: rotate(7deg);
  animation: pop-in 0.45s cubic-bezier(.2, 1.6, .4, 1);
  pointer-events: none;
}

/* ---------- garagem: nome em cima, carrinho (3D) no meio, cor embaixo ---------- */
.m-garage {
  grid-column: 1;
  grid-row: 1 / 4;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 88px 0 56px;
}
#garage-spot { flex: 1 1 auto; width: min(620px, 100%); min-height: 120px; max-height: 500px; }

/* mesma etiqueta que os outros veem em cima do seu carrinho; o lápis abre a edição, o dado sorteia */
.name-tag {
  --car: var(--purple);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  background: rgba(43, 23, 69, 0.9);
  border: 4px solid var(--car);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--ink);
}
.name-tag::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: -12px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  background: var(--car);
  border: solid var(--ink);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.tag-lvl {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: conic-gradient(var(--pink), var(--yellow), var(--cyan), var(--green), var(--pink));
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
}
#name {
  width: 8em;
  min-width: 4.5em;
  max-width: 8.5em;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  background: transparent;
  border: 3px solid transparent;
  border-radius: 999px;
  padding: 1px 10px;
  text-align: center;
  text-overflow: ellipsis;
  outline: none;
}
/* etiqueta do tamanho do nome onde o navegador sabe medir o campo (Chrome); nos outros, 8em */
@supports (field-sizing: content) {
  #name { width: auto; field-sizing: content; }
}
#name::placeholder { color: rgba(255, 255, 255, 0.6); }
.name-tag:focus-within #name { background: #fff; color: var(--ink); border-color: var(--ink); box-shadow: 0 0 0 4px rgba(255, 79, 154, 0.45); }
.name-tag:focus-within #name::placeholder { color: #9b87c2; }
.tag-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--yellow);
  display: grid;
  place-items: center;
  font-size: 18px;
  --fill: #fff;
}
.tag-btn.dice { background: var(--cyan); }
.tag-btn.dice:active { transform: rotate(-20deg) scale(0.92); }
#btn-name .i-ok, .name-tag:focus-within #btn-name .i-edit { display: none; }
.name-tag:focus-within #btn-name { background: var(--green); }
.name-tag:focus-within #btn-name .i-ok { display: block; }

.color-row { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; background: var(--cream); }
.color-row .lbl { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; margin: 0 2px 0 6px; }
.arrow-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: #eee4ff;
  display: grid;
  place-items: center;
}
.arrow-btn .ico { width: 16px; height: 16px; }
.arrow-btn:active { transform: scale(0.9); }
#swatches { display: flex; align-items: center; gap: 7px; }
.swatch {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  display: grid;
  place-items: center;
  transition: transform .15s;
}
/* a bolinha é pequena, o toque não: área de 44 px em volta */
.swatch::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; }
.swatch:hover { transform: scale(1.15); }
/* a escolhida cresce com anel e visto, com margem para não encostar nas vizinhas */
.swatch.sel { width: 42px; height: 42px; margin: 0 3px; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.swatch .ico { width: 20px; height: 20px; }
.swatch:not(.sel) .ico { display: none; }

/* ---------- modo + JOGAR (canto de baixo à direita) ---------- */
.m-modes {
  grid-column: 2;
  grid-row: 2 / 4;
  align-self: end;
  position: relative;
  z-index: 1;
  width: 404px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modes-head { display: flex; align-items: center; justify-content: space-between; }
.modes-title { padding: 4px 14px; background: rgba(43, 23, 69, 0.86); color: #fff; border-radius: 999px; font-size: 13px; font-weight: 700; letter-spacing: 2px; }
.modes-keys { display: flex; gap: 4px; padding: 4px 8px; background: rgba(43, 23, 69, 0.86); border-radius: 999px; }
#modes { display: flex; flex-direction: column; gap: 12px; }
.mode {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: 84px;
  padding: 0 16px 0 12px;
  background: var(--cream);
  border-radius: 22px;
  color: var(--ink);
  text-align: left;
  transition: transform .15s, background-color .15s;
}
.mode[data-mode='solo'] { --mc: var(--pink); }
.mode[data-mode='quick'] { --mc: var(--cyan); }
.mode[data-mode='friends'] { --mc: var(--yellow); }
.mode:hover { transform: translateY(-2px); }
.mode .disc {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: var(--mc);
  display: grid;
  place-items: center;
}
.mode .disc .ico { width: 30px; height: 30px; --fill: var(--cream); }
.mode[data-mode='quick'] .disc .ico { --fill: var(--yellow); }
.m-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mt { font-size: 22px; font-weight: 700; line-height: 1.1; }
.mt-short { display: none; }
.ms { font-size: 14px; font-weight: 500; line-height: 1.2; color: #6b4aa8; }
.chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
}
.chip .ico { width: 12px; height: 12px; --fill: var(--cyan); stroke-width: 3; }
.m-check {
  position: absolute;
  right: -10px;
  top: -12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  display: none;
  place-items: center;
}
.m-check .ico { width: 20px; height: 20px; }
/* escolhido: cheio da cor do modo, inclinado, com visto (o JOGAR pega a mesma cor) */
.mode.sel { background: var(--mc); transform: rotate(-1deg); }
.mode.sel .disc { background: var(--cream); }
.mode.sel .disc .ico { --fill: var(--mc); }
.mode.sel .mt { font-size: 24px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.mode.sel .ms { color: var(--ink); font-weight: 600; }
.mode.sel .m-check { display: grid; }
.mode-sub { display: none; }
/* Sala com amigos aberta: os outros modos encolhem para caber o código */
@media (min-height: 501px) {
  #menu.mode-friends .mode:not(.sel) { height: 60px; gap: 12px; padding-left: 9px; border-radius: 20px; }
  #menu.mode-friends .mode:not(.sel) .disc { width: 42px; height: 42px; border-width: 3px; }
  #menu.mode-friends .mode:not(.sel) .disc .ico { width: 24px; height: 24px; }
  #menu.mode-friends .mode:not(.sel) .ms { display: none; }
  #menu.mode-friends .mode:not(.sel) .mt { font-size: 19px; }
}

/* gaveta amarela embaixo do card "Sala com amigos": código em 4 casas ou o ingresso do convite */
.friends {
  margin-top: -26px;
  padding: 26px 12px 12px;
  background: var(--yellow);
  border: 4px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06), 0 6px 0 var(--ink);
  transform: rotate(-1deg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.code-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; background: var(--cream); border: 3px solid var(--ink); border-radius: 16px; }
.code-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.code-head label { font-size: 15px; font-weight: 700; }
.code-hint { font-size: 12px; font-weight: 600; color: #6b4aa8; }
.code-row { display: flex; align-items: center; gap: 8px; }
.slot {
  flex: none;
  width: 54px;
  height: 60px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 30px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  caret-color: var(--pink);
  outline: none;
}
.slot:focus { background: #fff3c4; }
#btn-join { flex: 1; width: auto; height: 54px; padding: 0 10px; border-radius: 16px; font-size: 18px; box-shadow: 0 4px 0 var(--ink); }
#btn-join .ico { width: 18px; height: 18px; stroke-width: 3.6; --fill: none; }
#friends.has-invite .code-box { display: none; }

/* convite (?sala=ABCD na URL) ou "voltar pra sala": ingresso no lugar do código. Os picotes são
   furos de máscara; o anel do ::before/::after desenha o contorno deles, e a sombra dura vem do
   drop-shadow no embrulho (dentro da máscara ela seria cortada). */
.ticket-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; filter: drop-shadow(0 5px 0 var(--ink)); animation: pop-in 0.45s cubic-bezier(.2, 1.6, .4, 1); }
.ticket {
  --notch: 52px;
  position: relative;
  align-self: stretch;
  padding: 0 18px 12px;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5);
  -webkit-mask:
    radial-gradient(circle at 0 var(--notch), #0000 13px, #000 13.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% var(--notch), #0000 13px, #000 13.5px) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle at 0 var(--notch), #0000 13px, #000 13.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% var(--notch), #0000 13px, #000 13.5px) right / 51% 100% no-repeat;
}
.ticket::before, .ticket::after {
  content: '';
  position: absolute;
  top: calc(var(--notch) - 21px);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid var(--ink);
}
.ticket::before { left: -21px; }
.ticket::after { right: -21px; }
.ticket.back { background: #c9f2ff; }
.ticket-top {
  height: calc(var(--notch) - 4px);
  margin: 0 4px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 3px dashed var(--ink);
  font-size: 18px;
  font-weight: 700;
}
.ticket-top .ico { width: 26px; height: 26px; --fill: var(--pink); }
.ticket.back .ticket-top .ico { stroke-width: 3; --fill: none; }
.ticket-code { display: flex; align-items: baseline; justify-content: center; gap: 12px; margin: 8px 0 0; }
.ticket-code .lbl { font-size: 13px; font-weight: 700; letter-spacing: 2px; }
#invite-code {
  font-size: 44px;
  line-height: 1;
  letter-spacing: 9px;
  color: var(--pink);
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
}
.pill-link {
  padding: 5px 14px;
  background: rgba(43, 23, 69, 0.85);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  filter: none;
}

#status { padding: 7px 12px; text-align: center; font-size: 14px; font-weight: 600; color: var(--pink-d); background: #fff; border: 3px solid var(--ink); border-radius: 14px; }
#status:empty { display: none; }

/* JOGAR: o maior botão da tela; pega a cor do modo escolhido (main.js renderModes) */
.m-play { position: relative; margin-top: 10px; --pc: var(--pink); }
#menu.mode-quick .m-play { --pc: var(--cyan); }
#menu.mode-friends .m-play { --pc: var(--yellow); }
#menu.mode-friends.invited .m-play { --pc: var(--green); }
#btn-play {
  position: relative;
  height: 100px;
  gap: 14px;
  padding: 0 18px;
  background: var(--pc);
  border-width: 5px;
  border-radius: 999px;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.4), 0 8px 0 var(--ink);
  font-size: 48px;
  letter-spacing: 1px;
  white-space: nowrap;
  -webkit-text-stroke: 2.5px var(--ink);
  text-shadow: 0 4px 0 var(--ink);
  animation: pulse 1.8s ease-in-out infinite;
  transition: background-color .2s, transform .1s, box-shadow .1s, filter .15s;
}
#btn-play.mid { font-size: 40px; }
#btn-play.long { font-size: 32px; letter-spacing: 0; }
#btn-play:hover { box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.4), 0 11px 0 var(--ink); }
#btn-play:active { box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.08), 0 2px 0 var(--ink); }
.play-ico {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--cream);
  border: 4px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 26px;
  --fill: var(--pc);
  text-shadow: none;
}
.play-tag {
  position: absolute;
  z-index: 2;
  left: -10px;
  top: -20px;
  padding: 1px 11px 2px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transform: rotate(-5deg);
  pointer-events: none;
}
.play-tag:empty { display: none; }
/* tecla que também joga: Enter; com controle, o botão dele (main.js renderPlayKey) */
.play-key { position: absolute; z-index: 2; right: -6px; top: -13px; transform: rotate(5deg); pointer-events: none; }
.pad-glyph {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--cream);
  box-shadow: 0 2px 0 var(--ink);
  color: #8ec5ff;
  font-size: 16px;
  font-weight: 700;
}

/* teclas desenhadas (menu, ajustes, barra de comandos) */
.play-key kbd, .m-modes kbd, .cmd-bar kbd, .set-esc kbd, .keys kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 7px;
  box-shadow: 0 2px 0 var(--ink);
}
.play-key kbd { font-size: 13px; padding: 1px 8px; }

/* ---------- barra de comandos (canto de baixo à esquerda): troca pelo último aparelho ---------- */
.cmd-bar {
  grid-column: 1;
  grid-row: 3;
  align-self: end;
  justify-self: start;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(43, 23, 69, 0.86);
  color: #fff;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.cmd-bar:empty { display: none; }
.cmd-bar .sep { width: 4px; height: 4px; margin: 0 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); }
.glyph {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.glyph.g-a { background: #1d9e4f; }
.glyph.g-b { background: #d63a3a; }
.glyph.g-y { background: #b38600; }
.glyph.g-x { background: #3a63e0; }
.dpad { width: 22px; height: 22px; flex: none; }
.dpad path:first-child { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.dpad path + path { stroke: var(--yellow); stroke-width: 2.6; stroke-linecap: round; }

/* ---------- navegação por teclado / controle ----------
   body.kbd-nav liga ao usar setas, Tab ou o controle (some ao mexer o mouse): anel amarelo e
   uma seta que pula do lado do que está em foco */
body.kbd-nav :is(#menu, #settings, #pause, #end, #pad-panel) [data-nav]:focus { outline: 5px solid var(--yellow); outline-offset: 4px; }
body.kbd-nav .slot:focus { outline-offset: 2px; }
body.kbd-nav :is(.mode, #btn-play):focus::before {
  content: '';
  position: absolute;
  left: -46px;
  top: 50%;
  width: 28px;
  height: 30px;
  margin-top: -15px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 28'%3E%3Cpath d='M3 3 23 14 3 25Z' fill='%23ffc629' stroke='%232b1745' stroke-width='3.5' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: nudge 0.7s ease-in-out infinite;
}
body.kbd-nav .mode.sel:focus::before { left: -44px; }
@keyframes nudge {
  50% { transform: translateX(-6px); }
}
body.calm .mode:focus::before, body.calm #btn-play:focus::before { animation: none; }
#menu .btn:focus-visible, #menu .round-btn:focus-visible, #menu .mode:focus-visible { outline: none; }
body.kbd-nav #menu .round-btn:focus, body.kbd-nav #menu .tag-btn:focus { outline: 4px solid var(--yellow); outline-offset: 3px; }

/* ---------- ajustes: tela empilhada por cima do menu ou da pausa ---------- */
#settings { z-index: 22; justify-content: flex-end; background: rgba(43, 23, 69, 0.42); backdrop-filter: blur(3px); }
.settings-card {
  max-width: 600px;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 18px 22px 22px;
  animation: slide-in 0.3s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes slide-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.set-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
#btn-set-back { width: 50px; height: 50px; background: var(--yellow); }
#btn-set-back .ico { width: 24px; height: 24px; }
.set-title {
  flex: 1;
  font-size: 38px;
  line-height: 1;
  letter-spacing: 1px;
  color: #fff;
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--ink);
}
.set-esc { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #6b4aa8; }
.set-sec { margin: 6px 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 2px; color: #6b4aa8; }
.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 12px 6px 14px;
  background: #fff;
  border: 3px solid #e5d9ff;
  border-radius: 16px;
}
body.kbd-nav .set-row:focus-within { background: #fff3c4; border-color: var(--ink); }
.set-row .lbl { flex: 1; font-size: 17px; font-weight: 700; }
.set-row input[type='range'] {
  flex: none;
  width: 210px;
  height: 24px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.set-row input[type='range']::-webkit-slider-runnable-track { height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: linear-gradient(90deg, #a46bff var(--v, 50%), #eee4ff var(--v, 50%)); }
.set-row input[type='range']::-moz-range-track { height: 8px; border: 3px solid var(--ink); border-radius: 999px; background: #eee4ff; }
.set-row input[type='range']::-moz-range-progress { height: 8px; border-radius: 999px; background: #a46bff; }
.set-row input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -8px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink); box-shadow: 0 2px 0 var(--ink); }
.set-row input[type='range']::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink); }
.set-row .val { width: 44px; text-align: right; font-size: 14px; font-weight: 700; }
.segs { flex: none; display: flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; outline-offset: 3px; }
.segs button { height: 34px; padding: 0 12px; font-size: 14px; font-weight: 700; color: var(--ink); background: var(--cream); }
.segs button + button { border-left: 3px solid var(--ink); }
.segs button.on { background: #a46bff; color: #fff; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; }
.keys-row { flex-wrap: wrap; row-gap: 6px; padding-top: 10px; padding-bottom: 10px; }
.keys-row .lbl { flex: none; width: 100%; }
.keys { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.keys kbd:not(:first-child) { margin-left: 6px; }
#btn-pad { width: auto; height: 40px; padding: 0 14px; font-size: 15px; border-radius: 14px; box-shadow: 0 4px 0 var(--ink); }
.wheel-only { display: none; }
body.wheel .wheel-only { display: flex; }

.online-title { font-weight: 700; margin-bottom: 8px; }
.online-row { display: flex; gap: 8px; }
.online-row + .online-row { margin-top: 10px; }
.online-row .btn { font-size: 16px; padding: 10px; }

/* ---------- barra de XP (perfil do menu e fim de rodada) ---------- */
.xp-top { display: flex; justify-content: space-between; font-weight: 600; font-size: 15px; }
.xp-bar {
  height: 16px;
  border: 3px solid var(--ink);
  border-radius: 99px;
  background: #eee4ff;
  overflow: hidden;
  margin: 4px 0;
}
.xp-bar > div {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--green), var(--green) 10px, #7cf29d 10px, #7cf29d 20px);
  border-radius: 99px;
  transition: width .6s ease;
}

/* ---------- botões ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  padding: 12px 16px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--ink);
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
  transition: transform .1s, box-shadow .1s, filter .15s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-2px) scale(1.02); box-shadow: 0 8px 0 var(--ink); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { font-size: 24px; padding: 14px; }
/* foco de teclado bem visível (Tab) */
.btn:focus-visible, .round-btn:focus-visible, .tag-btn:focus-visible, .swatch:focus-visible, .pill-link:focus-visible {
  outline: 4px solid var(--cyan);
  outline-offset: 3px;
}
.btn.pink { background: var(--pink); }
.btn.cyan { background: var(--cyan); }
.btn.yellow { background: var(--yellow); }
.btn.green { background: var(--green); }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
.note { font-weight: 500; }
.big-title { font-size: 34px; font-weight: 700; color: var(--pink); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }

#menu.mode-friends.mode-code .m-play { --pc: var(--green); }
#fade { position: fixed; inset: 0; z-index: 19; background: #fff; opacity: 0; pointer-events: none; }
#fade.on { animation: fade-out 0.5s ease-out; }
body.calm #fade.on { animation-duration: 0.3s; }
@keyframes fade-out {
  from { opacity: 0.85; }
  to { opacity: 0; }
}

/* ---------- loading ---------- */
#loading { background: linear-gradient(#6fd0ff, #ffd6f0); flex-direction: column; gap: 10px; z-index: 50; }
.loader-car { font-size: 64px; animation: bounce 0.6s ease-in-out infinite; }
.loader-txt { font-size: 22px; font-weight: 700; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }

/* peça de brinquedo: contorno grosso, brilho no topo e extrusão dura */
.plate {
  border: 4px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), 0 6px 0 var(--ink);
}
/* ícone de brinquedo (símbolos em index.html): cor chapada em --fill + contorno grosso */
.ico {
  display: block;
  width: 1em;
  height: 1em;
  overflow: visible;
  fill: var(--fill, var(--yellow));
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
}

#speedlines {
  position: absolute;
  inset: -10%;
  opacity: 0;
  background:
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, 0.55) 0deg 1.2deg, transparent 1.2deg 9deg);
  -webkit-mask-image: radial-gradient(circle at center, transparent 32%, #000 70%);
  mask-image: radial-gradient(circle at center, transparent 32%, #000 70%);
  transition: opacity .2s;
}
/* só gira quando aparece (main.js põe .on): tela cheia girando invisível ainda custa no celular */
#speedlines.on { animation: spin-lines 0.3s linear infinite; }
@keyframes spin-lines { to { transform: rotate(9deg); } }

#flash { position: absolute; inset: 0; opacity: 0; }
#flash.hit { animation: flash-hit .35s ease-out; background: radial-gradient(circle, transparent 40%, rgba(255, 214, 63, 0.7)); }
#flash.ouch { animation: flash-hit .35s ease-out; background: radial-gradient(circle, transparent 40%, rgba(255, 79, 154, 0.6)); }
@keyframes flash-hit { from { opacity: 1; } to { opacity: 0; } }

/* carro chegando por fora da tela: disco branco com a seta na cor dele, num anel em volta do
   centro. O JS posiciona a div (transform) e gira a seta (propriedade rotate); o pulsar usa a
   propriedade scale para não brigar com nenhum dos dois. */
#threats { position: absolute; inset: 0; overflow: hidden; }
.threat {
  position: absolute; left: 0; top: 0; width: 50px; height: 50px; margin: -25px 0 0 -25px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--cream); border: 4px solid var(--ink); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.6);
  will-change: transform, opacity;
}
.threat .ico { width: 30px; height: 30px; transform-origin: 50% 50%; stroke-width: 2.6; animation: threat-pulse .45s ease-in-out infinite alternate; }
@keyframes threat-pulse { to { scale: 1.15; } }

/* modo calmo (pausa → "Tremor e flash"): sem flash, sem linhas, sem pulsar */
body.calm #flash, body.calm #speedlines { display: none; }
body.calm .threat .ico { animation: none; }
@media (max-width: 620px), (max-height: 500px) {
  .threat { width: 38px; height: 38px; margin: -19px 0 0 -19px; border-width: 3px; }
  .threat .ico { width: 23px; height: 23px; }
}

/* placa do piloto: medalha com a posição, pontos na placa roxa e quanto falta pro líder */
#pilot { position: absolute; top: 22px; left: 22px; transform: rotate(-2deg); transform-origin: 0 0; }
.pilot-row { display: flex; align-items: center; }
#rank {
  position: relative;
  z-index: 2;
  flex: none;
  width: 86px;
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--cream);
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  transform: rotate(-6deg);
}
#rank small { font-size: .55em; align-self: flex-start; margin-top: 17%; }
#rank.r1 { background: var(--yellow); }
#rank.r2 { background: #e3e6f3; }
#rank.r3 { background: #ff9a52; }
#rank .crown { position: absolute; left: 26%; top: -27%; font-size: .78em; transform: rotate(-8deg); display: none; }
#rank.r1 .crown { display: block; }
#score-box {
  margin-left: -24px;
  min-width: 150px;
  padding: 7px 20px 11px 36px;
  background: var(--purple);
  border-radius: 22px;
}
.lbl { font-size: 13px; font-weight: 700; letter-spacing: 2px; }
#score-box .lbl { color: #e6d8ff; font-size: 12px; }
#gap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -4px 0 0 74px;
  padding: 2px 12px 2px 8px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transform: rotate(1.5deg);
}
#gap .ico { font-size: 20px; }
#gap.lead { background: var(--green); font-weight: 700; padding-left: 12px; }
#gap.lead .ico { display: none; }
#gap:has(#gap-txt:empty) { display: none; }
#score {
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
  transform-origin: 0 60%;
}
#score.bump { animation: score-bump .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes score-bump {
  0% { transform: scale(1); color: var(--yellow); }
  40% { transform: scale(1.22) rotate(-3deg); color: var(--yellow); }
  100% { transform: scale(1); }
}

/* combo: adesivo rosa ao lado do painel (onde o olho já está), com selo a cada sequência.
   Balança pela propriedade rotate; translate fica livre para o layout em pé. */
#combo { position: absolute; right: calc(100% + 26px); bottom: 34px; rotate: -4deg; animation: combo-wob 1.6s ease-in-out infinite; }
@keyframes combo-wob {
  0%, 100% { rotate: -4deg; }
  50% { rotate: -1.5deg; }
}
#combo-tag {
  position: absolute;
  left: 22px;
  top: -27px;
  z-index: 2;
  padding: 1px 12px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transform: rotate(6deg);
}
#combo-tag:empty { display: none; }
#combo-tag.cyan { background: var(--cyan); }
#combo-tag.rainbow, #combo.lvl10 .combo-plate { background: linear-gradient(90deg, var(--pink), var(--yellow), var(--green), var(--cyan), #a46bff); }
#combo-tag.rainbow { color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.combo-plate { display: grid; gap: 5px; padding: 7px 16px 10px; background: var(--pink); border-radius: 22px; }
.combo-top { display: flex; align-items: center; gap: 8px; }
.combo-top .lbl { color: #fff; font-size: 12px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.combo-ico { font-size: 30px; display: none; }
#combo[class*='lvl'] .combo-ico { display: block; }
#combo-num { font-size: 46px; line-height: 1; color: var(--yellow); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
#combo.lvl5 #combo-num { font-size: 50px; }
#combo.lvl7 #combo-num { font-size: 54px; }
#combo.lvl10 #combo-num { font-size: 58px; color: #fff; }
.combo-track { height: 12px; background: #ffd0ea; border: 3px solid var(--ink); border-radius: 9px; overflow: hidden; }
#combo.lvl10 .combo-track { background: var(--cream); }
#combo-bar { height: 100%; background: var(--yellow); }

/* cronômetro: sem inclinação, é lido de relance; a barra embaixo é o que falta da rodada */
#clock { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 9px; }
#time-track { width: 150px; height: 12px; background: #eee4ff; border: 3px solid var(--ink); border-radius: 99px; box-shadow: 0 3px 0 var(--ink); overflow: hidden; }
#time-fill { height: 100%; width: 100%; background: var(--pink); }
#round-tag {
  position: absolute;
  right: calc(100% - 16px);
  top: 6px;
  z-index: 1;
  padding: 2px 10px;
  background: var(--purple);
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 3px 0 var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
  transform: rotate(-7deg);
}
#hurry-tag {
  padding: 2px 14px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  transform: rotate(-3deg);
}
#clock:not(.hurry) #hurry-tag { display: none; }
#clock.hurry ~ #room-tag { visibility: hidden; }
#timer {
  position: relative;
  min-width: 152px;
  padding: 0 28px 5px;
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  background: var(--yellow);
  border-radius: 999px;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.55), inset 0 -5px 0 var(--yellow-d), 0 6px 0 var(--ink);
  color: #fff;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
}
#timer.hurry {
  background: var(--pink);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), inset 0 -5px 0 var(--pink-d), 0 6px 0 var(--ink);
  animation: hurry .5s ease-in-out infinite;
}
@keyframes hurry {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

#room-tag {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  background: var(--cyan);
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--ink);
  padding: 2px 14px 3px;
  font-weight: 700;
  color: #fff;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
#room-tag .ico { font-size: 1.15em; stroke-width: 3; }
#room-tag.slow { background: var(--yellow); }
#room-tag.warn { background: var(--pink); animation: hurry-tag .6s ease-in-out infinite; }
@keyframes hurry-tag {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

/* ---------- lobby da sala online ---------- */
#lobby {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: min(400px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  overflow-y: auto;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 8px 0 var(--ink), 0 18px 40px rgba(43, 23, 69, 0.3);
  padding: 14px 16px 12px;
  pointer-events: auto;
  animation: pop-in 0.45s cubic-bezier(.2, 1.6, .4, 1);
}
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lobby-lbl { font-size: 13px; font-weight: 700; letter-spacing: 3px; opacity: .7; }
#lobby-code {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 4px;
  line-height: 1;
  color: var(--pink);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--ink);
}
#btn-lobby-invite { width: auto; font-size: 16px; padding: 8px 14px; }
.lobby-sub { margin: 12px 0 6px; font-weight: 600; font-size: 15px; }
#lobby-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#lobby-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 8px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  font-weight: 600;
  font-size: 14px;
}
#lobby-list .dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
#lobby-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lobby-list .crown { flex: none; margin-left: auto; }
#lobby-list li.free { background: transparent; border-style: dashed; opacity: .55; font-weight: 500; }
#lobby-list li.free .dot { background: transparent; border-style: dashed; }
#lobby-msg { margin: 12px 0 10px; text-align: center; font-weight: 700; color: var(--purple); min-height: 22px; }
#btn-start:disabled { filter: grayscale(.8); opacity: .55; cursor: not-allowed; transform: none; box-shadow: 0 6px 0 var(--ink); }
.lobby-hint { margin-top: 10px; text-align: center; font-size: 13px; font-weight: 500; opacity: .7; }

/* no lobby a tela fica limpa: sem placar, relógio, posição e pontos (ainda não valem) */
body.in-lobby #pilot,
body.in-lobby #clock,
body.in-lobby #room-tag,
body.in-lobby #side,
body.in-lobby #minimap { display: none; }
@media (max-width: 620px), (max-height: 500px) {
  body.in-lobby #dash { display: none; }
  #lobby { top: 12px; max-height: calc(100% - 24px); padding: 10px 12px; }
  #lobby-code { font-size: 28px; }
  .lobby-hint { display: none; }
}

#side { position: absolute; top: 18px; right: 20px; display: flex; flex-direction: column; gap: 16px; align-items: flex-end; }

/* placar compacto: top 3 e, se você estiver fora, "···" + a sua linha */
#board-box { width: 252px; background: var(--cream); border-radius: 20px; overflow: hidden; }
#board-more { padding: 0 0 7px; text-align: center; font-size: 13px; font-weight: 600; color: #6b4aa8; }
#board-more:empty { display: none; }
#board .sep { justify-content: center; padding: 0; line-height: .5; font-weight: 700; letter-spacing: 3px; color: #6b4aa8; }
.board-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 4px;
  background: var(--purple);
  border-bottom: 4px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
}
.board-head .ico { font-size: 18px; transform: rotate(-12deg); }
#board { display: grid; gap: 1px; padding: 6px 7px 7px; }
#board .row { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 15px; padding: 2px 6px; border-radius: 12px; }
#board .row.me { background: var(--yellow); box-shadow: inset 0 0 0 2.5px var(--ink); font-weight: 700; }
#board .pos { flex: none; width: 22px; height: 22px; display: grid; place-items: center; font-size: 13px; font-weight: 700; border-radius: 50%; }
#board .pos.top { border: 2.5px solid var(--ink); font-size: 12px; }
#board .p1 { background: var(--yellow); }
#board .p2 { background: #d3dbec; }
#board .p3 { background: #ff9d5c; }
#board .row.me .p1 { background: #fff; }
#board .dot { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--ink); }
#board .bot { flex: none; font-size: 17px; --fill: #d9ccff; stroke-width: 2.2; }
#board .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board .sc { font-weight: 700; }

/* quem bateu em quem: a mais nova em cima, some em 3 s (main.js feed) */
#feed { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; }
#feed .item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 13px 3px 4px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  animation: feed-in .35s cubic-bezier(.2, 1.6, .4, 1);
  transition: opacity .4s;
}
#feed .item:nth-child(2) { opacity: .88; }
#feed .item:nth-child(3), #feed .item.faded { opacity: .66; }
#feed .item.out { opacity: 0; }
@keyframes feed-in { from { transform: translateX(30px) scale(.8); opacity: 0; } }
#feed .tag { padding: 0 8px; background: var(--yellow); border: 2.5px solid var(--ink); border-radius: 99px; font-size: 12px; letter-spacing: 1px; }
#feed .tag.pink { background: var(--pink); color: #fff; }
#feed .tag.cyan { background: var(--cyan); }
#feed .dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--ink); }
#feed .to { font-size: 16px; stroke-width: 3.2; }
#feed .st { font-size: 20px; margin-left: 3px; }
#feed .pts { color: var(--yellow); font-size: 18px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 2px 0 var(--ink); }

/* minimapa: a arena vista de cima (desenhada em drawMinimap), menor, no canto de baixo */
#minimap { position: absolute; left: 20px; bottom: 24px; box-sizing: content-box; width: 204px; height: 145px; border-radius: 20px; background: var(--purple); }

/* painel: pancada-ômetro (velocidade) em cima do turbo, no centro de baixo */
#dash { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; }
#gauge { display: block; width: 240px; height: 144px; overflow: visible; }
#gauge text { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; }
#g-top { fill: #6b4aa8; }
#gauge.mega #g-top { fill: var(--pink); }

/* turbo: raio da marca + barra */
#boost { display: flex; align-items: center; width: 296px; }
#boost .bolt {
  position: relative;
  z-index: 1;
  flex: none;
  width: 48px;
  height: 48px;
  margin-right: -16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--purple);
  font-size: 30px;
  stroke-width: 2;
  transform: rotate(-8deg);
}
#boost .bar { position: relative; flex: 1; height: 30px; padding-left: 16px; border-radius: 99px; background: #eee4ff; overflow: hidden; }
#boost-fill {
  height: 100%;
  width: 100%;
  background: var(--cyan);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), inset 0 -4px 0 var(--cyan-d);
  border-radius: 0 99px 99px 0;
}
#boost .lbl {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-left: 14px;
  color: #fff;
  font-size: 16px;
  letter-spacing: 4px;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
}
#boost.full #boost-fill {
  background: linear-gradient(90deg, var(--yellow), #fff27a, var(--yellow));
  background-size: 200% 100%;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), inset 0 -4px 0 var(--yellow-d);
  animation: shimmer 1s linear infinite;
}
#boost.full .bolt { animation: bolt-ready .7s ease-in-out infinite; }
/* turbo ligado: barra laranja esvaziando e o raio aceso */
#boost.on #boost-fill { background: linear-gradient(90deg, var(--yellow), #ff8a34); box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), inset 0 -4px 0 #e06a10; animation: none; }
#boost.on .bolt { background: var(--yellow); --fill: #fff; animation: bolt-ready .35s ease-in-out infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes bolt-ready {
  0%, 100% { transform: rotate(-8deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.14); }
}

/* só a pausa (câmera e som moram dentro dela) */
#hud-btns { position: absolute; bottom: 26px; right: 20px; display: flex; align-items: center; gap: 10px; }
#hud-btns kbd {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 0 9px 1px;
}
#btn-pause, #btn-cam {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 30px;
  --fill: var(--purple);
  border-radius: 18px;
  background: var(--cream);
  box-shadow: inset 0 3px 0 #fff, 0 5px 0 var(--ink);
  transform: rotate(-3deg);
  transition: transform .1s, box-shadow .1s;
}
#btn-pause:hover, #btn-cam:hover { transform: translateY(-2px); box-shadow: inset 0 3px 0 #fff, 0 7px 0 var(--ink); }
#btn-pause:active, #btn-cam:active { transform: translateY(4px); box-shadow: inset 0 3px 0 #fff, 0 1px 0 var(--ink); }

/* dicas de teclado: aparecem nos primeiros segundos da partida (main.js showHelp) */
#help {
  position: absolute;
  bottom: 196px;
  left: 20px;
  opacity: 0;
  transition: opacity .6s;
  max-width: 360px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
}
#help.show { opacity: 1; }
#help span { display: flex; align-items: center; gap: 4px; }
#help kbd {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  -webkit-text-stroke: 0;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 7px;
  box-shadow: 0 2px 0 var(--ink);
  padding: 0 6px 1px;
}

#popups { position: absolute; inset: 0; overflow: hidden; }
.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  animation: popup 1.5s cubic-bezier(.2, 1.5, .4, 1) forwards;
  white-space: nowrap;
}
.p-main { font-size: 56px; font-weight: 700; color: var(--yellow); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
.p-sub { font-size: 30px; font-weight: 700; color: #fff; -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; margin-top: -4px; }
.p-combo { font-size: 24px; font-weight: 700; color: var(--pink); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.popup.mega .p-main { font-size: 76px; color: var(--pink); }
.popup.gold .p-main { color: #ffe066; }
.popup.rainbow .p-main, .popup.streak .p-main {
  background: linear-gradient(90deg, var(--pink), var(--yellow), var(--green), var(--cyan), #a46bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0;
  text-shadow: none;
  filter: drop-shadow(0 3px 0 var(--ink)) drop-shadow(0 -2px 0 var(--ink)) drop-shadow(2px 0 0 var(--ink)) drop-shadow(-2px 0 0 var(--ink));
}
.popup.streak .p-main { font-size: 46px; }
.popup.ouch .p-main { font-size: 40px; color: #fff; }
/* --tilt: inclinação sorteada em popup() — cada um para torto de um jeito */
@keyframes popup {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-10deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1) rotate(var(--tilt, 0deg)); }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -140%) scale(0.9) rotate(var(--tilt, 0deg)); opacity: 0; }
}

/* ---------- fim de rodada ---------- */
#podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 18px 0 10px; min-height: 190px; }
.pod { width: 130px; display: flex; flex-direction: column; align-items: center; animation: rise .6s cubic-bezier(.2, 1.4, .4, 1) backwards; }
.pod-2 { animation-delay: .15s; }
.pod-3 { animation-delay: .3s; }
.pod-name { font-weight: 700; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-score { font-weight: 700; font-size: 22px; color: var(--pink); }
.pod-block { width: 100%; border: 4px solid var(--ink); border-radius: 16px 16px 6px 6px; display: grid; place-items: start center; padding-top: 6px; font-size: 34px; box-shadow: 0 5px 0 var(--ink); }
.pod-1 .pod-block { height: 110px; }
.pod-2 .pod-block { height: 80px; }
.pod-3 .pod-block { height: 56px; }
.pod.me .pod-name { color: var(--purple); }
@keyframes rise { from { transform: translateY(80px); opacity: 0; } }
#end-me { font-size: 20px; font-weight: 700; margin: 6px 0 12px; }
.xp-gain { background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 14px; text-align: left; }
#end-xp { color: var(--green-d); font-size: 18px; }
#end-levelup { text-align: center; font-weight: 700; font-size: 20px; color: var(--purple); animation: pop-in .5s cubic-bezier(.2, 1.6, .4, 1); }
.end-next { margin: 14px 0 12px; font-weight: 600; font-size: 17px; }
.end-next b { font-size: 22px; color: var(--pink); }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 220px; /* acima do painel (pancada-ômetro + turbo) */
  transform: translate(-50%, 30px);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 99px;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 60;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- toque ---------- */
#touch { position: fixed; inset: auto 0 0 0; height: 0; z-index: 15; }
#touch .pad { position: absolute; bottom: 70px; display: flex; gap: 12px; align-items: flex-end; }
#touch .left { left: 16px; }
#touch .right { right: 16px; }
#touch .col { display: flex; flex-direction: column; gap: 10px; }
#touch button {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  font-size: 38px;
  --fill: #fff;
  background: rgba(122, 61, 255, 0.78);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), 0 5px 0 var(--ink);
  touch-action: none;
}
#touch button.on { transform: translateY(4px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), 0 1px 0 var(--ink); background: var(--pink); }
#touch button.boost { width: 84px; height: 84px; border-radius: 50%; font-size: 50px; background: rgba(255, 198, 41, 0.92); }
.a-left { transform: rotate(-90deg); }
.a-right { transform: rotate(90deg); }
.a-down { transform: rotate(180deg); }

/* ---------- HUD em tela pequena (celular, janela estreita ou baixa): tudo menor ---------- */
@media (max-width: 760px), (max-height: 560px) {
  #help { display: none; }
  #pilot { top: 12px; left: 12px; }
  #rank { width: 58px; height: 58px; font-size: 30px; border-width: 3px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--ink); }
  #score-box { margin-left: -16px; min-width: 96px; padding: 4px 13px 7px 23px; border-radius: 16px; border-width: 3px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--ink); }
  #score-box .lbl { font-size: 9px; letter-spacing: 1.5px; }
  #score { font-size: 32px; -webkit-text-stroke-width: 4px; text-shadow: 0 3px 0 var(--ink); }
  #gap { margin: -3px 0 0 48px; padding: 1px 9px 1px 5px; font-size: 11.5px; gap: 4px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  #gap .ico { font-size: 15px; }
  #clock { top: 9px; gap: 6px; }
  #timer { min-width: 104px; padding: 0 18px 3px; font-size: 28px; -webkit-text-stroke-width: 4px; border-width: 3px; }
  #time-track { width: 104px; height: 9px; border-width: 2.5px; box-shadow: 0 2px 0 var(--ink); }
  #round-tag { display: none; }
  #hurry-tag { font-size: 11px; padding: 0 9px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  #room-tag { top: 76px; font-size: 12px; }
  #side { top: 10px; right: 12px; gap: 7px; }
  #board-box { width: 184px; border-radius: 14px; border-width: 3px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--ink); }
  .board-head { display: none; }
  #board { padding: 4px 4px 2px; }
  #board .row { font-size: 12.5px; gap: 5px; padding: 2px 6px; }
  #board .pos { width: 18px; height: 18px; font-size: 10px; }
  #board .pos.top { border-width: 2px; }
  #board .dot { width: 11px; height: 11px; border-width: 2px; }
  #board .bot { display: none; }
  #board-more { font-size: 10px; padding-bottom: 4px; }
  #feed { gap: 7px; }
  #feed .item { gap: 5px; padding: 2px 9px 2px 3px; font-size: 12px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  #feed .item:nth-child(n + 3) { display: none; }
  #feed .tag { padding: 0 6px; font-size: 10px; border-width: 2px; letter-spacing: .5px; }
  #feed .dot { width: 11px; height: 11px; border-width: 2px; }
  #feed .to { font-size: 13px; }
  #feed .st { font-size: 15px; }
  #feed .pts { font-size: 14px; -webkit-text-stroke-width: 2.4px; }
  #minimap { left: 12px; bottom: 12px; width: 126px; height: 90px; border-radius: 14px; border-width: 3px; }
  #dash { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); gap: 1px; }
  #gauge { width: 156px; height: 94px; }
  #boost { width: 180px; }
  #boost .bolt { width: 32px; height: 32px; margin-right: -12px; border-width: 3px; font-size: 20px; }
  #boost .bar { height: 20px; padding-left: 10px; border-width: 3px; }
  #boost .lbl { display: none; }
  #combo { right: calc(100% + 14px); bottom: 26px; }
  #combo-tag { left: 16px; top: -20px; padding: 0 8px; font-size: 11px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  .combo-plate { gap: 4px; padding: 5px 11px 7px; border-radius: 16px; border-width: 3px; }
  .combo-top { gap: 5px; }
  .combo-top .lbl { font-size: 9px; letter-spacing: 1.5px; }
  .combo-ico { font-size: 20px; }
  #combo-num { font-size: 30px; -webkit-text-stroke-width: 4px; text-shadow: 0 3px 0 var(--ink); }
  #combo.lvl5 #combo-num { font-size: 33px; }
  #combo.lvl7 #combo-num { font-size: 36px; }
  #combo.lvl10 #combo-num { font-size: 38px; }
  .combo-track { height: 8px; border-width: 2px; }
  #hud-btns { right: 12px; bottom: 12px; }
  #hud-btns kbd { display: none; }
  #btn-pause, #btn-cam { width: 42px; height: 42px; border-radius: 14px; border-width: 3px; font-size: 22px; }
  .p-main { font-size: 40px; }
  .p-sub { font-size: 22px; }
  .pod { width: 96px; }
}

/* ---------- toque: os cantos de baixo são dos botões ---------- */
@media (pointer: coarse) {
  #minimap { top: 150px; left: 22px; bottom: auto; }
  #hud-btns { top: 20px; right: 20px; bottom: auto; }
  #hud-btns kbd { display: none; }
  #board-box { margin-right: 66px; }
}
@media (pointer: coarse) and (max-width: 760px), (pointer: coarse) and (max-height: 560px) {
  #minimap { top: 108px; left: 12px; }
  #hud-btns { top: 12px; right: 12px; }
  #board-box { margin-right: 50px; }
}

/* retrato estreito: a fileira de cima não cabe em uma linha só */
@media (max-width: 620px) {
  #clock { left: auto; right: 62px; transform: none; align-items: flex-end; }
  #side { top: 118px; }
  #board-box { margin-right: 0; }
  #feed { display: none; }
  #minimap { top: 118px; left: 12px; bottom: auto; }
  #hud-btns { top: 12px; right: 12px; bottom: auto; }
  #dash { bottom: calc(236px + env(safe-area-inset-bottom, 0px)); }
  #combo { right: auto; left: 50%; bottom: calc(100% + 26px); translate: -50% 0; }
  #room-tag { top: 74px; left: auto; right: 12px; transform: rotate(2deg); }
}

/* ---------- volante / controle ---------- */
.btn.purple { background: #a46bff; }
#pad-panel { z-index: 40; background: rgba(43, 23, 69, 0.5); backdrop-filter: blur(4px); overflow-y: auto; align-items: flex-start; }
.pad-card { max-width: 480px; margin: auto; display: flex; flex-direction: column; gap: 12px; }
.pad-card .big-title { text-align: center; }
.pad-name { text-align: center; font-weight: 600; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px; }
.meters { display: grid; gap: 7px; }
.meter { display: grid; grid-template-columns: 95px 1fr; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.meter .track { position: relative; height: 18px; border: 3px solid var(--ink); border-radius: 99px; background: #eee4ff; overflow: hidden; }
.meter .track > div { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--green); }
.meter .track.center::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.meter .track.center > div { background: var(--cyan); }
#pad-brake { background: var(--pink) !important; }
.lamp { width: 34px; height: 26px; border: 3px solid var(--ink); border-radius: 10px; display: grid; place-items: center; background: #eee; opacity: .5; }
.lamp.on { background: var(--yellow); opacity: 1; }
.sens { display: block; font-weight: 600; font-size: 14px; }
.sens span { display: flex; justify-content: space-between; }
.sens input { width: 100%; accent-color: var(--pink); }
#pad-steps { display: flex; gap: 6px; margin-top: 8px; }
#pad-steps span { flex: 1; text-align: center; font-size: 13px; font-weight: 700; border: 3px solid var(--ink); border-radius: 12px; padding: 4px; background: #fff; }
#pad-steps span.now { background: var(--yellow); animation: pulse 0.8s ease-in-out infinite; }
#pad-steps span.done { background: var(--green); color: #fff; }
.calib-msg { min-height: 24px; text-align: center; font-weight: 700; color: var(--purple); margin: 8px 0; }
.pad-help { font-size: 13px; padding-left: 18px; display: grid; gap: 4px; }
.ffb-box { border: 3px dashed var(--ink); border-radius: 20px; padding: 12px; background: #fff4e0; display: grid; gap: 8px; }
.ffb-box small { font-weight: 500; opacity: .7; }
#ffb-opts { display: grid; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--pink); }

/* =====================================================================
   celular: toque, áreas seguras, deitado x em pé, telas que rolam
   ===================================================================== */
button, input { -webkit-tap-highlight-color: transparent; }
body { -webkit-touch-callout: none; }

/* área de toque maior que o desenho do botão (o dedo erra por pouco) */
#touch button { position: relative; }
#touch button::before { content: ''; position: absolute; inset: -14px; } /* ~10 px além da borda de 4 px */

/* toque puro: atalhos de teclado e o painel do volante só atrapalham */
@media (hover: none) and (pointer: coarse) {
  .m-gear, .play-key { display: none; }
}

/* notch e barra de gestos (viewport-fit=cover no index.html) */
#hud {
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
}
#touch .left { left: calc(16px + env(safe-area-inset-left, 0px)); }
#touch .right { right: calc(16px + env(safe-area-inset-right, 0px)); }
#touch .pad { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
.screen {
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

/* pausa e fim de rodada rolam se não couberem (antes o título e o botão sumiam) */
#pause, #end { overflow-y: auto; align-items: flex-start; }
.small-card, .end-card { margin: auto; }

/* aviso para girar o celular (só aparece no jogo, em pé, em tela de toque) */
#rotate {
  position: fixed;
  inset: 0;
  z-index: 25; /* acima do menu e da pausa: em pé nada disso é usado */
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(43, 23, 69, 0.55);
  backdrop-filter: blur(3px);
}
.rotate-card {
  max-width: 320px;
  display: grid;
  gap: 10px;
  text-align: center;
  background: var(--cream);
  border: 5px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 22px 20px 18px;
  animation: pop-in 0.45s cubic-bezier(.2, 1.6, .4, 1);
}
.rotate-phone { font-size: 64px; line-height: 1; animation: tilt-phone 1.8s ease-in-out infinite; }
@keyframes tilt-phone {
  0%, 25% { transform: rotate(0); }
  55%, 100% { transform: rotate(-90deg); }
}
.rotate-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--pink);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--ink);
}
.rotate-sub { font-weight: 500; }
.rotate-invite { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 10px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 14px; font-weight: 600; }
.rotate-invite .ico { width: 22px; height: 22px; --fill: var(--pink); }
.rotate-invite b { letter-spacing: 3px; }
#btn-rotate { margin-top: 4px; }

/* ---------- celular deitado: HUD nos cantos de cima, controles embaixo ---------- */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  #touch .pad { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  /* placa + minimapa à esquerda, placar + feed à direita, pausa no canto (regras de toque
     acima); o painel fica entre os dois grupos de botões */
  #toast { top: 96px; bottom: auto; }
}

/* ---------- celular em pé ---------- */
@media (pointer: coarse) and (orientation: portrait) {
  /* aviso embaixo do placar: em baixo estão os botões, o painel e o combo */
  #toast { top: 222px; bottom: auto; }
}

/* ---------- menu em tela média (notebook pequeno, tablet, janela estreita): o carrinho desce
   para baixo do logo e a coluna de modos afina ---------- */
@media (max-width: 1320px) {
  .m-garage { grid-row: 2 / 4; padding: 0 0 56px; }
}
@media (max-width: 1000px) {
  .m-modes { width: 340px; }
  .mode { height: 74px; gap: 12px; }
  .mode .disc { width: 48px; height: 48px; }
  .mode .disc .ico { width: 26px; height: 26px; }
  .mt { font-size: 19px; }
  .mode.sel .mt { font-size: 21px; }
  .ms { font-size: 13px; }
  .slot { width: 46px; height: 54px; font-size: 26px; }
  #btn-join { height: 50px; font-size: 16px; }
  #btn-play { height: 84px; font-size: 40px; }
  #btn-play.mid { font-size: 33px; }
  #btn-play.long { font-size: 27px; }
  .play-ico { width: 46px; height: 46px; }
  .profile .xp { width: 130px; }
  #xp-left { display: none; }
  .cmd-bar { flex-wrap: wrap; white-space: normal; max-width: 100%; }
}

/* ---------- menu no celular deitado: carrinho à esquerda, modo + JOGAR num painel à direita
   (no polegar). Em pé não tem menu: o aviso #rotate cobre tudo. ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  #menu {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 392px);
    gap: 8px 14px;
    padding: 8px max(12px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  }
  .logo img { width: 124px; max-height: none; }
  .m-top { gap: 8px; }
  .profile { height: 44px; gap: 7px; padding: 0 10px 0 4px; border-width: 3px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--ink); }
  .lvl-badge { width: 32px; height: 32px; font-size: 15px; -webkit-text-stroke: 1.5px var(--ink); }
  .profile .xp { width: 104px; gap: 3px; }
  .profile .xp-top { font-size: 12px; }
  #xp-left { display: none; }
  .profile .xp-bar { height: 10px; border-width: 2.5px; }
  .best { height: 24px; padding-left: 7px; font-size: 13px; border-left-width: 2px; }
  .best .ico { width: 15px; height: 15px; }
  .xp-pop { left: 40px; bottom: -18px; font-size: 13px; }
  .round-btn { width: 44px; height: 44px; border-width: 3px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--ink); }
  .round-btn .ico { width: 22px; height: 22px; }

  .m-garage { grid-row: 1 / 4; padding: 72px 0 0; gap: 6px; }
  #garage-spot { min-height: 60px; }
  .name-tag { gap: 6px; padding: 3px; border-width: 3px; }
  .tag-lvl { width: 28px; height: 28px; font-size: 13px; }
  #name { max-width: 7.5em; font-size: 18px; }
  .tag-btn { width: 30px; height: 30px; font-size: 14px; }
  .color-row { gap: 6px; padding: 4px 10px; border-width: 3px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--ink); }
  .color-row .lbl, .arrow-btn { display: none; }
  #swatches { gap: 8px; }
  .swatch { width: 28px; height: 28px; }
  .swatch.sel { width: 34px; height: 34px; margin: 0 2px; }
  .swatch .ico { width: 16px; height: 16px; }

  /* painel creme com tudo da partida */
  .m-modes {
    width: auto;
    gap: 8px;
    padding: 10px 12px 12px;
    background: var(--cream);
    border: 4px solid var(--ink);
    border-radius: 22px;
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), 0 5px 0 var(--ink);
  }
  .modes-head { display: none; }
  /* modo em 3 botões lado a lado */
  #modes { flex-direction: row; gap: 0; border: 4px solid var(--ink); border-radius: 18px; overflow: hidden; box-shadow: 0 4px 0 var(--ink); }
  .mode {
    flex: 1;
    min-width: 0;
    height: 54px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
  }
  .mode:hover, .mode.sel { transform: none; }
  .mode + .mode { border-left: 4px solid var(--ink); }
  .mode .disc, .mode.sel .disc { width: auto; height: auto; border: 0; background: none; }
  .mode .disc .ico { width: 22px; height: 22px; --fill: var(--mc); }
  .mode.sel .disc .ico { --fill: var(--cream); }
  .mode .m-txt { flex: none; align-items: center; }
  .mode .ms, .mode .chip, .mode .m-check, .mode.sel .m-check, .mt-long { display: none; }
  .mt-short { display: inline; }
  .mt { font-size: 13px; }
  .mode.sel .mt { font-size: 15px; -webkit-text-stroke: 1.5px var(--ink); }
  .mode-sub { display: block; margin-top: -2px; text-align: center; font-size: 12px; font-weight: 600; color: #6b4aa8; }
  body.kbd-nav :is(.mode, #btn-play):focus::before { display: none; }

  .friends { margin: 0; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; transform: none; }
  .code-box { gap: 4px; padding: 6px 8px 8px; border-width: 3px; }
  .code-head label { font-size: 13px; }
  .code-hint { font-size: 11px; }
  .code-row { gap: 6px; }
  .slot { width: 40px; height: 44px; font-size: 22px; border-radius: 10px; }
  #btn-join { height: 44px; font-size: 15px; border-radius: 14px; }
  .ticket-wrap { gap: 6px; }
  .ticket { --notch: 40px; padding: 0 14px 8px; }
  .ticket-top { font-size: 14px; }
  .ticket-top .ico { width: 20px; height: 20px; }
  .ticket-code { margin-top: 4px; }
  #invite-code { font-size: 28px; letter-spacing: 6px; }
  .pill-link { padding: 3px 12px; font-size: 12px; }

  .m-play { margin-top: 4px; }
  #btn-play { height: 64px; gap: 10px; font-size: 32px; -webkit-text-stroke: 2px var(--ink); text-shadow: 0 3px 0 var(--ink); box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.4), 0 5px 0 var(--ink); }
  #btn-play.mid { font-size: 27px; }
  #btn-play.long { font-size: 22px; }
  .play-ico { width: 38px; height: 38px; border-width: 3px; font-size: 18px; }
  .play-tag { left: auto; right: 16px; top: -12px; padding: 0 8px 1px; font-size: 11px; transform: rotate(4deg); }
  .play-key { display: none; }
  .cmd-bar { display: none; }
}

/* toque: sem teclado, sem barra de comandos */
@media (pointer: coarse) {
  .cmd-bar, .modes-keys, .play-key, .code-hint { display: none; }
}
/* celular em pé não tem menu (só se joga deitado): fica o aviso #rotate (main.js) */
@media (pointer: coarse) and (orientation: portrait) {
  #menu { visibility: hidden; }
}

/* ---------- pausa e fim de rodada em tela baixa ---------- */
@media (max-height: 500px) {
  .small-card { gap: 8px; padding: 16px 20px; }
  /* pausa online tem 5 botões: em 1 coluna passava da tela do celular deitado. Título, textos e
     Continuar na linha toda; o resto em 2 colunas */
  .small-card { display: grid; grid-template-columns: 1fr 1fr; max-width: 560px; }
  .small-card > :not(.btn), .small-card > .btn.big { grid-column: 1 / -1; }
  .small-card .btn { padding: 9px 8px; font-size: 15px; }
  .small-card .btn.big { padding: 10px; font-size: 20px; }
  .small-card .big-title, .end-card .big-title { font-size: 24px; text-shadow: 0 3px 0 var(--ink); }
  .end-card { max-width: 560px; padding: 14px 18px; }
  #podium { min-height: 0; margin: 6px 0 2px; }
  .pod-name { font-size: 13px; }
  .pod-score { font-size: 17px; }
  .pod-block { font-size: 22px; padding-top: 2px; border-width: 3px; }
  .pod-1 .pod-block { height: 62px; }
  .pod-2 .pod-block { height: 46px; }
  .pod-3 .pod-block { height: 32px; }
  #end-me { font-size: 16px; margin: 4px 0 8px; }
  .xp-gain { padding: 6px 12px; }
  #end-levelup { font-size: 16px; }
  .end-next { margin: 8px 0; font-size: 15px; }
  .end-card .btn { padding: 8px; font-size: 16px; }
}

/* Android estreito (360 px): pontos e relógio não se encostam */
@media (max-width: 380px) {
  #score-box { min-width: 80px; padding-right: 10px; }
  #timer { min-width: 86px; padding: 0 12px 3px; font-size: 24px; }
  #time-track { width: 86px; }
}

/* ---------- velocímetro pequeno + nitro (pedido do testador no celular, 2026-10-27) ---------- */
/* pílula do velocímetro embaixo do relógio: só no celular deitado (no PC fica o pancada-ômetro).
   Marcas: 16% = começa a pontuar (4 u/s), 56% = MEGA (14 u/s), de 0 a 90 km/h */
#speedo {
  display: none;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px 0 7px;
  background: var(--cream);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 2px 0 var(--ink);
}
#speedo .trk { position: relative; width: 52px; height: 8px; border-radius: 99px; background: #eee4ff; border: 2px solid var(--ink); overflow: hidden; }
#speedo-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: #b9a6e0; border-radius: 99px; }
#speedo .mk { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .55; }
#speedo .mk.hit { left: 16%; }
#speedo .mk.mega { left: 56%; }
#speedo-num { min-width: 20px; font-size: 16px; font-weight: 700; line-height: 1; text-align: right; }
#speedo small { font-size: 10px; font-weight: 600; letter-spacing: .5px; color: #6b4aa8; }
#speedo .tag { display: none; padding: 0 6px; font-size: 10px; font-weight: 700; letter-spacing: 1px; background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); border-radius: 99px; }
#speedo.hit #speedo-fill { background: var(--cyan); }
#speedo.mega { background: var(--pink); color: #fff; }
#speedo.mega small { color: #fff; }
#speedo.mega #speedo-fill { background: var(--yellow); }
#speedo.mega .tag { display: block; }

/* nitro: anel em volta do botão do raio (toque) e adesivo do quanto ganhou (toque e PC).
   --n = quanto tem (main.js); cheio brilha e pulsa, usando fica laranja */
#touch button.boost .nitro-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  pointer-events: none;
  background: conic-gradient(var(--nc, var(--yellow)) 0 var(--n, 100%), rgba(43, 23, 69, .55) var(--n, 100%) 100%);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px));
          mask: radial-gradient(closest-side, transparent calc(100% - 9px), #000 calc(100% - 8px));
}
#touch button.boost .nitro-ring-out { position: absolute; inset: -14px; border-radius: 50%; border: 3px solid var(--ink); pointer-events: none; }
#touch button.boost.low { background: rgba(214, 200, 168, .92); }
#touch button.boost.low .ico { opacity: .55; }
#touch button.boost.full { box-shadow: 0 0 0 4px #fff, 0 0 26px 8px rgba(255, 198, 41, .9), 0 5px 0 var(--ink); animation: nitro-pulse .7s ease-in-out infinite; }
#touch button.boost.full .nitro-ring, #touch button.boost.burn .nitro-ring { --nc: #ff8a34; }
@keyframes nitro-pulse { 50% { scale: 1.06; } }
.nitro-tag {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 18px);
  translate: -50% 0;
  rotate: -6deg;
  padding: 1px 10px 2px;
  white-space: nowrap;
  pointer-events: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink);
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 99px;
  box-shadow: 0 3px 0 var(--ink);
}
.nitro-tag:empty { display: none; }
.nitro-tag.full { rotate: 0deg; color: #fff; background: var(--pink); }
.nitro-tag.gain { animation: nitro-gain .8s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes nitro-gain {
  from { scale: .4; opacity: 0; }
  30% { scale: 1.15; opacity: 1; }
  to { scale: 1; }
}
#boost { position: relative; }
#boost .nitro-tag { left: auto; right: -6px; bottom: calc(100% + 4px); translate: none; }
body.calm #touch button.boost.full, body.calm .nitro-tag.gain { animation: none; }
@media (prefers-reduced-motion: reduce) {
  #touch button.boost.full, .nitro-tag.gain { animation: none; }
}

/* ---------- celular deitado: meio livre, cards menores, só os controles grandes ---------- */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  /* sem pancada-ômetro nem barra de turbo no meio de baixo (tampavam o carrinho): a velocidade vai
     pra pílula embaixo do relógio e o turbo pro anel do botão. O painel vira estático para o combo
     se posicionar pela HUD */
  #dash { position: static; transform: none; }
  #gauge, #boost { display: none; }
  #speedo { display: flex; }
  #combo { left: 10px; right: auto; bottom: 116px; scale: .85; transform-origin: left bottom; }
  /* palavras de batida um pouco mais baixas: o meio de cima tem o velocímetro */
  .popup { margin-top: 40px; }

  /* cards menores (posição, pontos, placar, feed, minimapa, relógio, pausa) */
  #pilot { top: 8px; left: 10px; }
  #rank { width: 40px; height: 40px; font-size: 20px; border-width: 3px; box-shadow: 0 3px 0 var(--ink); }
  #score-box { margin-left: -12px; min-width: 60px; padding: 1px 10px 3px 17px; border-radius: 12px; border-width: 3px; box-shadow: 0 3px 0 var(--ink); }
  #score-box .lbl { display: none; }
  #score { font-size: 22px; -webkit-text-stroke-width: 3px; text-shadow: 0 2px 0 var(--ink); }
  #gap { margin: -1px 0 0 30px; padding: 0 7px 0 4px; font-size: 11px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
  #gap .ico { font-size: 12px; }
  #clock { top: 6px; gap: 4px; }
  #timer { min-width: 80px; padding: 0 12px 2px; font-size: 22px; -webkit-text-stroke-width: 3px; border-width: 3px; }
  #time-track { width: 80px; height: 7px; border-width: 2px; }
  #side { top: 8px; right: 10px; gap: 5px; }
  #board-box { width: 148px; margin-right: 44px; border-radius: 12px; border-width: 2.5px; background: rgba(255, 248, 239, .9); box-shadow: 0 3px 0 var(--ink); }
  #board { padding: 3px 3px 2px; }
  #board .row { gap: 4px; padding: 1px 5px; font-size: 11px; }
  #board .pos { width: 15px; height: 15px; font-size: 9px; }
  #board .dot { width: 9px; height: 9px; }
  #board-more { display: none; }
  #feed .item:nth-child(n + 2) { display: none; }
  #feed .item { padding: 1px 7px 1px 3px; font-size: 11px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
  #feed .tag { font-size: 9px; }
  #minimap { top: 70px; left: 10px; width: 96px; height: 68px; border-width: 2.5px; border-radius: 11px; }
  #hud-btns { top: 8px; right: 10px; }
  #btn-pause, #btn-cam { width: 36px; height: 36px; font-size: 18px; border-radius: 12px; border-width: 3px; }

  /* controles maiores */
  #touch .pad { gap: 14px; }
  #touch button { width: 84px; height: 84px; border-radius: 26px; font-size: 44px; }
  #touch .col button { width: 80px; height: 80px; }
  #touch button.boost { width: 92px; height: 92px; border-radius: 50%; font-size: 54px; }
}

/* ---------- botão de câmera (só no toque; no PC é a tecla C) ---------- */
#btn-cam { display: none; position: relative; }
#cam-tag {
  position: absolute;
  right: -7px;
  bottom: -7px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 99px;
}
@media (pointer: coarse) {
  #btn-cam { display: grid; }
  /* pausa no canto, câmera à esquerda dela; o placar abre espaço para as duas (embaixo da pausa a
     câmera batia no feed quando o placar encolhe para 3 linhas) */
  #hud-btns { flex-direction: row-reverse; gap: 9px; }
  #board-box { margin-right: 132px; }
}
@media (pointer: coarse) and (max-width: 760px), (pointer: coarse) and (max-height: 560px) {
  #board-box { margin-right: 98px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  #board-box { margin-right: 89px; }
}
