/* Resultados Mario Kart — visual
   Céu noturno índigo, placas de cronometragem inclinadas, metais de pódio e uma cor por jogador.
   Tipografia: Saira variável (largura 50–125%, peso 100–900, itálico), licença OFL. */

@font-face {
  font-family: "Saira";
  src: url("../fonts/saira-latin-standard-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 50% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Saira";
  src: url("../fonts/saira-latin-standard-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 50% 125%;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #1c1a4a;
  --night-2: #151339;
  --panel: #27246a;
  --panel-2: #34318a;
  --line: rgba(214, 208, 255, 0.16);
  --ink: #f6f4ff;
  --muted: #b3afe0;
  --faint: #8a86c4;
  --gold: #ffc83d;
  --silver: #cbd5e8;
  --bronze: #e8965c;
  --go: #3ddc84;
  --stop: #ff5468;
  --focus: #6fc3ff;
  --road: linear-gradient(100deg, #ff5468 0 16.66%, #ff9f1c 0 33.33%, #ffd84d 0 50%,
                          #3ddc84 0 66.66%, #3ab0ff 0 83.33%, #9b7bff 0 100%);
  --r-m: 12px;
  --r-l: 20px;
  --font: "Saira", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Uma cor por jogador (atribuída na ordem de entrada) */
.c0 { --pc: #ff6b7a; }
.c1 { --pc: #ffb224; }
.c2 { --pc: #ffe45c; }
.c3 { --pc: #4fe08a; }
.c4 { --pc: #44ccff; }
.c5 { --pc: #8ea4ff; }
.c6 { --pc: #c194ff; }
.c7 { --pc: #ff8ad2; }
.c8 { --pc: #33e8ca; }
.c9 { --pc: #cdf26a; }
.c10 { --pc: #ffa488; }
.c11 { --pc: #e4e6ff; }

/* ------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--night);
  color: var(--ink);
  font: 450 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.hint { color: var(--muted); font-size: 0.9375rem; }
.empty-note { color: var(--muted); padding: 28px 8px; text-align: center; }
.form-error { color: #ff97a3; font-weight: 600; font-size: 0.9375rem; }
.form-error:empty { display: none; }
.pc-text { color: var(--pc); font-weight: 650; }

/* ------------------------------------------------------------ campos e botões */

input, select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-m);
  background: var(--night-2);
  color: var(--ink);
  font: 500 1rem var(--font);
}
input::placeholder { color: var(--faint); }
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(111, 195, 255, 0.3);
}
select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B3AFE0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--panel-2);
  color: var(--ink);
  font: 650 1rem/1.1 var(--font);
  font-stretch: 92%;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--gold); color: var(--night); font-weight: 800; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: transparent; color: #ff8593; box-shadow: inset 0 0 0 1.5px rgba(255, 84, 104, 0.55); }
.btn.danger-fill { background: var(--stop); color: #fff; }
.btn.big { min-height: 56px; font-size: 1.125rem; }
.btn.grow { flex: 1; }
.btn.stacked { flex-direction: column; gap: 1px; padding: 6px 14px; }
.btn .kicker { font-size: 0.75rem; font-weight: 600; opacity: 0.72; }
.btn.icon-only { width: 52px; padding: 0; flex: none; }
.btn svg, .icon-btn svg, .link-btn svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.btn svg .fill { fill: currentColor; stroke: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: var(--r-m);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.small { width: 44px; height: auto; background: transparent; color: var(--faint); border-radius: 0; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 600 0.9375rem var(--font);
  text-decoration: underline;
  text-decoration-color: rgba(246, 244, 255, 0.35);
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn svg { width: 18px; height: 18px; }
.link-btn.with-icon { text-decoration: none; color: var(--muted); }
.danger-text { color: #ff8593; }

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }

.tag {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--night);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: 0.1em;
  white-space: nowrap;
}
.tag.muted { background: var(--panel-2); color: var(--muted); }
.tag.you-tag { background: var(--pc, var(--ink)); }
.tag.today { background: rgba(61, 220, 132, 0.18); color: var(--go); }
.tag.open-tag { background: var(--go); }

.origin {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.65;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--night-2);
}
.segmented button {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 700 0.9375rem var(--font);
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--night); }

.road { height: 10px; background: var(--road); }

/* ------------------------------------------------------------ página inicial */

.home {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(32px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
}
.wordmark { display: grid; }
.wm-top {
  font-style: italic;
  font-weight: 380;
  font-stretch: 125%;
  font-size: 1.375rem;
  color: var(--muted);
}
.wm-main {
  margin-left: -0.03em;
  font-style: italic;
  font-weight: 900;
  font-stretch: 50%;
  font-size: clamp(5.25rem, 28vw, 9.5rem);
  line-height: 0.8;
  letter-spacing: -0.01em;
}
.hero .road {
  height: 14px;
  margin: 18px 0 18px;
  clip-path: polygon(16px 0, 100% 0, calc(100% - 16px) 100%, 0 100%);
}
.lede { max-width: 32ch; font-size: 1.1875rem; line-height: 1.45; }

.home-section { margin-top: 36px; }
.home-section h2 {
  font-style: italic;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 1.75rem;
  line-height: 1.1;
}
.home-section .hint { margin-top: 4px; }
.home-section .inline-form { margin-top: 12px; }
.home-section .form-error { margin-top: 8px; }
.create { padding: 22px 18px; border-radius: var(--r-l); background: var(--panel); }
.create input { background: var(--night); }
.stack { display: grid; gap: 14px; margin-top: 16px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.9375rem; }
.code-input {
  font-style: italic;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 1.375rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.room-list { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.room-list li { display: flex; overflow: hidden; border-radius: 10px; background: var(--panel); }
.room-list a {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 56px;
  padding: 0 4px 0 16px;
  text-decoration: none;
}
.rl-name { flex: 1; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.rl-code { font-style: italic; font-weight: 800; font-stretch: 72%; letter-spacing: 0.06em; color: var(--muted); }
.foot { margin-top: 56px; color: var(--faint); font-size: 0.8125rem; }

/* ------------------------------------------------------------ sala: topo e abas */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: rgba(28, 26, 74, 0.94);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
}
.top-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px 4px 8px;
}
.back { display: grid; place-items: center; width: 36px; height: 44px; color: var(--muted); }
.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.room-title { min-width: 0; }
#room-name {
  overflow: hidden;
  font-style: italic;
  font-weight: 800;
  font-stretch: 72%;
  font-size: 1.4375rem;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.room-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}
.me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--ink); font-weight: 650; text-overflow: ellipsis; }
.me-name .dot { width: 9px; height: 9px; }
.live { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.on::before { background: var(--go); box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.22); }
.live.off { color: #ff97a3; }
.live.off::before { background: var(--stop); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.code-btn {
  display: grid;
  justify-items: start;
  min-height: 44px;
  padding: 4px 12px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--panel);
  color: var(--ink);
  line-height: 1.05;
  cursor: pointer;
}
.code-label { font-size: 0.6875rem; font-weight: 600; color: var(--muted); }
.code { font-style: italic; font-weight: 800; font-stretch: 75%; font-size: 1.125rem; letter-spacing: 0.06em; }

.tabs { display: flex; max-width: 640px; margin: 0 auto; padding: 0 12px; }
.tab {
  position: relative;
  flex: 1;
  min-height: 46px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 1rem var(--font);
  font-stretch: 88%;
  cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -1px;
  height: 4px;
  border-radius: 3px 3px 0 0;
  background: var(--gold);
  transform: skewX(-24deg);
}

.layout { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h3 { font-style: italic; font-weight: 800; font-stretch: 78%; font-size: 1.25rem; }
.side-title { display: none; }
.count { color: var(--muted); font-size: 0.875rem; font-weight: 600; }

/* ------------------------------------------------------------ entrar na sala */

.join {
  max-width: 608px;
  margin: 16px auto 0;
  padding: 20px 16px;
  border-radius: var(--r-l);
  background: var(--panel);
  box-shadow: inset 0 0 0 2px var(--gold);
}
.join h2 { font-style: italic; font-weight: 850; font-stretch: 65%; font-size: 2.25rem; line-height: 1; }
.join .hint { margin-top: 6px; }
.join .inline-form { margin-top: 4px; }
.join input { background: var(--night); }
.join .form-error { margin-top: 8px; }
.join .link-btn { margin-top: 8px; color: var(--muted); }
@media (max-width: 640px) { .join { margin: 12px 16px 0; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chips:empty { display: none; }
.chip.player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--night);
  color: var(--ink);
  font: 650 1rem var(--font);
  box-shadow: inset 0 0 0 1.5px var(--line);
  cursor: pointer;
}
.dot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--pc, var(--faint)); }

/* ------------------------------------------------------------ corrida atual */

.race-card { padding: 18px 16px 16px; overflow: hidden; border-radius: var(--r-l); background: var(--panel); }
.race-no { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 0.9375rem; }
.track-name {
  margin: 4px 0 8px;
  font-style: italic;
  font-weight: 850;
  font-stretch: 60%;
  font-size: clamp(2.6rem, 12.5vw, 3.6rem);
  line-height: 0.9;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.track-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-size: 0.9375rem; }
.race-card .road { margin: 16px -16px 18px; transform-origin: left center; }
.race-card .road.sweep { animation: sweep 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes sweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.race-card.closed .road { filter: saturate(0.25) brightness(0.75); }
.race-card.empty p:last-child { color: var(--muted); max-width: 40ch; }

.entry-label { margin-bottom: 10px; font-weight: 700; font-size: 1.0625rem; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pos {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 74px;
  padding: 8px 4px 6px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--night);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line);
  cursor: pointer;
  touch-action: manipulation;
}
.pos .n { font-style: italic; font-weight: 850; font-stretch: 56%; font-size: 2.5rem; line-height: 0.82; }
.pos .n small, .my-result .big small { font-size: 0.48em; vertical-align: top; margin-left: 1px; }
.pos .s {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pos.p1 .n { color: var(--gold); }
.pos.p2 .n { color: var(--silver); }
.pos.p3 .n { color: var(--bronze); }
@media (hover: hover) { .pos:not(.taken):not(.mine):hover { box-shadow: inset 0 0 0 2px var(--ink); } }
.pos.mine { background: var(--ink); box-shadow: none; }
.pos.mine.p1 { background: var(--gold); }
.pos.mine.p2 { background: var(--silver); }
.pos.mine.p3 { background: var(--bronze); }
.pos.mine .n, .pos.mine .s { color: var(--night); }
.pos.taken { background: transparent; box-shadow: inset 0 0 0 1px rgba(214, 208, 255, 0.08); cursor: not-allowed; }
.pos.taken .n { opacity: 0.3; }
.pos.taken .s { color: var(--pc); }
.pos.busy { animation: busy 0.6s ease-in-out infinite alternate; }
@keyframes busy { to { opacity: 0.45; } }

.my-result { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.my-result .big {
  flex: none;
  padding-right: 2px;
  font-style: italic;
  font-weight: 900;
  font-stretch: 52%;
  font-size: 5.25rem;
  line-height: 0.76;
}
.big.m1 { color: var(--gold); }
.big.m2 { color: var(--silver); }
.big.m3 { color: var(--bronze); }
.big.pop { animation: pop 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes pop { from { transform: scale(0.55); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.my-result p { font-weight: 600; font-size: 1.0625rem; line-height: 1.35; }
.my-result p .hint { display: block; margin-top: 2px; font-weight: 500; }
.entry > .link-btn { margin-top: 6px; color: var(--muted); }
.spectator-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
  margin-top: 14px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.reminder {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: var(--r-l);
  background: #2f2a5e;
  box-shadow: inset 0 0 0 2px var(--gold);
}
.reminder p { margin-bottom: 12px; }
.reminder .link-btn { margin-top: 6px; color: var(--muted); }

.admin-bar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  gap: 8px;
  margin: 4px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--night) 72%, rgba(28, 26, 74, 0));
}

.arrivals { margin-top: 18px; }

/* ------------------------------------------------------------ torre de cronometragem (chegada e ranking) */

.tower { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tower li {
  display: grid;
  grid-template-columns: 56px 10px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 48px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
}
.plate {
  display: flex;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  padding-right: 9px;
  background: var(--panel-2);
  clip-path: polygon(0 0, 100% 0, calc(100% - 11px) 100%, 0 100%);
  font-style: italic;
  font-weight: 850;
  font-stretch: 58%;
  font-size: 1.625rem;
  line-height: 1;
}
.plate.m1 { background: var(--gold); color: var(--night); }
.plate.m2 { background: var(--silver); color: var(--night); }
.plate.m3 { background: var(--bronze); color: var(--night); }
.stripe { align-self: stretch; width: 6px; margin-left: -3px; background: var(--pc, var(--faint)); transform: skewX(-14deg); }
.who { min-width: 0; padding: 6px 10px; }
.nm { display: block; overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.who small { display: block; color: var(--muted); font-size: 0.8125rem; line-height: 1.3; }
.tower .pts {
  padding: 0 14px 0 6px;
  font-style: italic;
  font-weight: 800;
  font-stretch: 68%;
  font-size: 1.375rem;
  white-space: nowrap;
}
.tower .pts small { margin-left: 3px; color: var(--muted); font-style: normal; font-weight: 600; font-size: 0.68em; font-stretch: 100%; }
.tower li.waiting { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.tower li.waiting .plate { background: transparent; color: var(--faint); }
.tower li.waiting .nm { color: var(--muted); }
.tower li.waiting .pts { color: var(--faint); font-style: normal; font-weight: 600; font-size: 0.875rem; font-stretch: 100%; }
.ranking li { min-height: 60px; }
.ranking .pts { font-size: 1.75rem; }
.scope-note { margin-bottom: 8px; }

/* ------------------------------------------------------------ histórico */

.day { margin-bottom: 26px; }
.day-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0 2px;
  font-style: italic;
  font-weight: 800;
  font-stretch: 78%;
  font-size: 1.375rem;
}
.day-title .hint { font-style: normal; font-weight: 500; font-stretch: 100%; font-size: 0.875rem; }
.h-race { padding: 14px 0; border-bottom: 1px solid var(--line); }
.h-race header { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.h-no {
  color: var(--faint);
  font-style: italic;
  font-weight: 850;
  font-stretch: 58%;
  font-size: 1.875rem;
  line-height: 0.9;
  text-align: right;
}
.h-title h4 { font-weight: 700; font-size: 1.0625rem; line-height: 1.25; }
.h-title p { margin-top: 2px; color: var(--muted); font-size: 0.8125rem; }
.h-side { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: 0.875rem; }
.h-results, .h-race > .hint, .h-race > .link-btn { margin-left: 52px; }
.h-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding: 0; list-style: none; }
.h-results li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 11px 3px 3px;
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.875rem;
}
.hp {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 24px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--panel-2);
  font-style: italic;
  font-weight: 800;
  font-stretch: 72%;
}
.hp.m1 { background: var(--gold); color: var(--night); }
.hp.m2 { background: var(--silver); color: var(--night); }
.hp.m3 { background: var(--bronze); color: var(--night); }
.hn { color: var(--pc); font-weight: 650; }
.hpts { color: var(--muted); font-size: 0.8125rem; }
.h-race > .hint { margin-top: 8px; font-size: 0.875rem; }
.h-race > .link-btn { margin-top: 4px; }

.track-stats { margin: 12px 0 0; padding: 0; list-style: none; }
.track-stats li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 2px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.ts-n {
  grid-row: span 2;
  color: var(--gold);
  font-style: italic;
  font-weight: 850;
  font-stretch: 58%;
  font-size: 1.875rem;
  line-height: 0.95;
  text-align: right;
}
.ts-main b { font-weight: 700; }
.ts-main small { display: block; color: var(--muted); font-size: 0.8125rem; }
.ts-win { color: var(--muted); font-size: 0.875rem; }

/* ------------------------------------------------------------ diálogos */

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: var(--r-l);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(5, 4, 25, 0.6);
}
dialog::backdrop { background: rgba(9, 8, 30, 0.74); }
.dlg-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px 18px;
  background: var(--panel);
}
.dlg-head h2 { font-style: italic; font-weight: 800; font-stretch: 72%; font-size: 1.5rem; line-height: 1.1; }
.dlg-head .icon-btn { background: var(--panel-2); }
.dlg-body { padding: 4px 18px 22px; }

dialog.full { width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none; margin: 0; border-radius: 0; overflow: hidden; }
dialog.full[open] { display: flex; flex-direction: column; }
@media (min-width: 760px) {
  dialog.full { width: min(1000px, 94vw); height: min(900px, 92dvh); margin: auto; border-radius: var(--r-l); }
}

dialog.ask { width: min(440px, calc(100vw - 24px)); }
.ask .dlg-body { padding: 22px 20px 18px; }
.ask-title { margin-bottom: 10px; font-style: italic; font-weight: 800; font-stretch: 72%; font-size: 1.625rem; line-height: 1.1; }
.ask-body p { margin-bottom: 8px; color: var(--muted); }
.ask-body b { color: var(--ink); }
.ask-input { margin: 6px 0 4px; }
/* No HTML o botão principal vem primeiro (Enter confirma); na tela ele fica à direita */
.ask-actions { display: flex; flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 16px; }
.ask-body .drawn-name { margin: 2px 0 4px; font-style: italic; font-weight: 850; font-stretch: 58%; font-size: 3rem; line-height: 0.92; color: var(--ink); }
.ask-actions:has([data-role="alt"]:not([hidden])) { flex-direction: column; align-items: stretch; }
.drawn { margin-bottom: 8px; }

/* escolha de pista */
.picker-tools { display: grid; gap: 10px; padding: 0 18px 12px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: var(--r-m);
  background: var(--night);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.search:focus-within { box-shadow: inset 0 0 0 2px var(--focus); }
.search svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { min-height: 46px; padding: 0; border: 0; background: transparent; }
.search input:focus-visible { box-shadow: none; }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: none;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--night);
  color: var(--muted);
  font: 700 0.9375rem var(--font);
  box-shadow: inset 0 0 0 1.5px var(--line);
  cursor: pointer;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--night); box-shadow: none; }
.picker-list { flex: 1; overflow-y: auto; padding-top: 6px; overscroll-behavior: contain; }
.cups { display: grid; gap: 24px; }
@media (min-width: 760px) { .cups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 28px; } }
.cup-block h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-style: italic; font-weight: 800; font-stretch: 80%; font-size: 1.1875rem; }
.cup-emoji { font-style: normal; font-size: 1.125rem; }
.cup-tracks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.track-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--night);
  color: var(--ink);
  font: inherit;
  text-align: left;
  box-shadow: inset 0 0 0 1.5px var(--line);
  cursor: pointer;
}
.t-name { font-weight: 700; font-stretch: 90%; line-height: 1.15; }
.t-meta { display: flex; align-items: center; gap: 6px; min-height: 18px; color: var(--muted); font-size: 0.75rem; }
.times { font-weight: 700; }
.track-btn.current { box-shadow: inset 0 0 0 2px var(--gold); }
@media (hover: hover) { .track-btn:hover { box-shadow: inset 0 0 0 2px var(--ink); } }

/* convite */
.share { display: grid; justify-items: center; gap: 14px; text-align: center; }
.qr { width: 220px; height: 220px; border-radius: 14px; background: #fff; }
.share-code-line { color: var(--muted); }
.share-code { display: block; color: var(--ink); font-style: italic; font-weight: 850; font-stretch: 70%; font-size: 2.75rem; letter-spacing: 0.08em; line-height: 1; }
.copy-row { display: flex; gap: 8px; width: 100%; }
.copy-row input { flex: 1; min-width: 0; font-size: 0.9375rem; }
.share > .btn.primary { width: 100%; }
.admin-link { display: grid; gap: 8px; justify-items: start; width: 100%; padding-top: 16px; border-top: 1px solid var(--line); text-align: left; }

/* ajustes */
.settings section { padding: 16px 0; border-top: 1px solid var(--line); }
.settings > section:first-child { padding-top: 4px; border-top: 0; }
.settings h3 { margin-bottom: 4px; font-size: 1.0625rem; font-weight: 700; }
.settings .hint { margin-bottom: 10px; }
.settings input { background: var(--night); }
.points-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.pt { display: grid; gap: 2px; color: var(--muted); font-size: 0.8125rem; font-weight: 600; text-align: center; }
.pt input { min-height: 44px; padding: 0 4px; font-weight: 700; text-align: center; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.players-admin { margin: 0; padding: 0; list-style: none; }
.players-admin li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.pa-name { font-weight: 650; }
.pa-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 0 16px; }
.players-admin li.inactive .pa-name { color: var(--muted); }
.danger-zone h3 { color: #ff8593; }

/* correção de corrida */
.edit-rows { display: grid; gap: 4px; margin: 12px 0 10px; }
.edit-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 156px; align-items: center; gap: 10px; }
.er-name { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.edit-row select { min-height: 46px; background-color: var(--night); }
.edit-row select.dup { border-color: var(--stop); box-shadow: 0 0 0 3px rgba(255, 84, 104, 0.3); }
#edit-form .form-error { margin-bottom: 10px; }
#edit-form .btn.primary { width: 100%; }
.edit-more { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* aviso rápido (usa a camada popover, por cima dos diálogos) */
.toast {
  position: fixed;
  inset: auto auto calc(20px + env(safe-area-inset-bottom)) 50%;
  z-index: 100;
  display: none;
  width: max-content;
  max-width: min(92vw, 480px);
  margin: 0;
  padding: 12px 16px;
  overflow: visible;
  border: 0;
  border-radius: var(--r-m);
  background: var(--ink);
  color: var(--night);
  font: 650 0.9375rem/1.35 var(--font);
  box-shadow: 0 14px 34px rgba(5, 4, 25, 0.5);
  transform: translateX(-50%);
}
.toast.show { display: block; animation: toast-in 0.2s ease-out; }
.toast[data-kind="error"] { background: var(--stop); color: #fff; }
.with-bar .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* sala inexistente ou excluída */
.gone { display: grid; justify-items: center; gap: 14px; max-width: 520px; margin: 56px auto; padding: 0 20px; text-align: center; }
.gone h2 { font-style: italic; font-weight: 850; font-stretch: 62%; font-size: 2.5rem; line-height: 1; }
.gone p { color: var(--muted); }
.is-gone .tabs, .is-gone .layout, .is-gone .join, .is-gone .code-btn,
.is-gone [data-act="settings"], .is-gone .room-meta { display: none !important; }
.loading .layout, .loading .tabs { visibility: hidden; }

/* ------------------------------------------------------------ telas largas: corrida + ranking lado a lado (bom para TV) */

@media (min-width: 1000px) {
  .top-row, .tabs { max-width: 1160px; }
  .tabs { justify-content: flex-start; gap: 8px; }
  .tab { flex: none; padding: 0 22px; }
  .tab[data-tab="ranking"] { display: none; }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    align-items: start;
    gap: 36px;
    max-width: 1160px;
    padding-top: 24px;
  }
  #tab-race, #tab-history { grid-column: 1; grid-row: 1; }
  #tab-ranking { grid-column: 2; grid-row: 1; position: sticky; top: 120px; }
  .side-title { display: block; font-style: italic; font-weight: 850; font-stretch: 62%; font-size: 2.25rem; line-height: 1; }
  .join { max-width: 1128px; }
  .admin-bar { margin: 4px 0 0; padding-left: 0; padding-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
