/* Friends Cars – dunkles Glas-Design über 3D-Szenen und gerenderten Bildern */
/* Schriften (SIL Open Font License, Lizenztexte in /fonts): Exo 2 für Titel, Tacho und Einblendungen, Outfit für Text */
@font-face { font-family: "Exo 2"; src: url("/fonts/exo-2-latin-wght-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Exo 2"; src: url("/fonts/exo-2-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Outfit"; src: url("/fonts/outfit-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
:root {
  --bg: #0b0d24;
  --bg2: #171a45;
  --glass: rgba(16, 19, 48, .62);
  --glass-strong: rgba(14, 16, 42, .82);
  --edge: rgba(255, 255, 255, .14);
  --edge-strong: rgba(255, 255, 255, .3);
  --text: #f4f5ff;
  --muted: #a5abd6;
  --accent: #ff4d3d;
  --sun: #ffd23f;
  --cyan: #54e6e0;
  --grad: linear-gradient(135deg, #ffd23f 0%, #ff8a2a 45%, #ff4d3d 100%);
  --radius: 22px;
  --shadow: 0 24px 60px rgba(0, 0, 0, .5), 0 2px 0 rgba(255, 255, 255, .06) inset;
  --display: "Exo 2", ui-rounded, "Segoe UI", system-ui, sans-serif;
  font-family: "Outfit", ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); overflow: hidden; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
/* Alles, was nach Rennsport aussehen soll, bekommt die Display-Schrift */
.logo, .btn.big, .code, .charinfo strong, .tracks strong, .pos, .speedo .num, #countdown, #banner, #technique,
.standings .pts, .standings .rank, .podium i, .awards strong, .t-drift, .kicker, h2, .field > span, .pill, .seg button, .results li::before {
  font-family: var(--display);
}

/* ---------- Bildschirme ---------- */
.screen {
  position: fixed; inset: 0; display: none;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(11, 13, 36, .55) 0%, rgba(11, 13, 36, .86) 62%, var(--bg) 100%),
    url("/assets/img/menu-bg.jpg") center / cover no-repeat,
    radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg));
}
.screen.active { display: flex; animation: screen-in .35s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: scale(1.015); } }

/* ---------- Glasflächen ---------- */
.card {
  position: relative; width: min(100%, 440px); margin: auto;
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 30px 24px 22px; box-shadow: var(--shadow); overflow: hidden;
}
.card.wide { width: min(100%, 860px); }
.flagband { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--grad); }

.logo {
  margin: 0 0 4px; font-size: clamp(46px, 9vw, 92px); line-height: .86;
  font-weight: 900; font-style: italic; letter-spacing: -.035em; text-transform: uppercase;
  transform: skewY(-3deg); color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, .55);
}
.logo span {
  display: block; margin-left: .5em; padding-right: .12em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .35));
}
.logo.small { font-size: 36px; margin-bottom: 18px; }

/* ---------- Hauptmenü ---------- */
.home { margin: auto; width: min(100%, 1120px); display: grid; grid-template-columns: 1.15fr minmax(330px, 440px); gap: 36px; align-items: center; }
.hero { min-width: 0; }
.tagline { margin: 22px 0 6px; color: var(--muted); font-weight: 600; font-size: 17px; }
.stage { position: relative; height: clamp(210px, 40vh, 380px); }
.stage::before {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: 4%; height: 34%;
  background: radial-gradient(closest-side, rgba(255, 138, 42, .38), transparent);
  pointer-events: none; filter: blur(6px);
}
#preview { position: relative; width: 100%; height: 100%; display: block; }
.arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--edge-strong);
  background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: 28px; line-height: 1; font-weight: 900; cursor: pointer; padding: 0 0 4px;
  transition: transform .12s, background .12s;
}
.arrow.l { left: 0; } .arrow.r { right: 0; }
.arrow:hover { background: rgba(255, 255, 255, .16); }
.arrow:active { transform: translateY(-50%) scale(.92); }

.charinfo { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.charinfo .portrait { width: 84px; height: 84px; border-radius: 24px; flex: none; object-fit: cover; border: 2px solid var(--edge-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.charinfo strong { display: block; font-size: 34px; font-weight: 900; font-style: italic; text-transform: uppercase; line-height: 1; }
.charinfo span { color: var(--sun); font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.stats { display: grid; grid-template-columns: auto 120px; gap: 6px 10px; margin: 0; align-items: center; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stats dt { margin: 0; }
.stats dd { margin: 0; height: 8px; border-radius: 8px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.stats dd i { display: block; height: 100%; border-radius: 8px; background: var(--grad); transition: width .3s cubic-bezier(.2, 1.2, .4, 1); }

@media (max-width: 880px) {
  .home { grid-template-columns: 1fr; gap: 18px; }
  .hero { text-align: center; }
  .logo { display: inline-block; }
  .tagline { margin-top: 14px; font-size: 15px; }
  .stage { height: 210px; }
  .charinfo { justify-content: center; text-align: left; }
  .setup { width: 100%; }
}

.field { display: block; margin-bottom: 18px; }
.field > span, h2 { display: block; font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
h2 span { color: var(--sun); }
input {
  width: 100%; font: inherit; font-weight: 800; font-size: 18px; color: var(--text);
  background: rgba(255, 255, 255, .07); border: 1px solid var(--edge); border-radius: 14px; padding: 13px 15px;
  transition: border-color .15s, background .15s;
}
input::placeholder { color: rgba(165, 171, 214, .6); }
input:focus { outline: none; border-color: var(--sun); background: rgba(255, 255, 255, .11); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }

/* Fahrer-Auswahl mit Porträts */
.chars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.chars button {
  position: relative; display: grid; justify-items: center; gap: 0;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--edge); border-radius: 16px;
  padding: 0 0 6px; cursor: pointer; overflow: hidden; font-size: 11px; font-weight: 800; letter-spacing: .02em;
  transition: transform .15s cubic-bezier(.2, 1.4, .4, 1), border-color .15s, box-shadow .15s;
}
.chars img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; margin-bottom: 5px; }
.chars button:hover { transform: translateY(-2px); border-color: var(--edge-strong); }
.chars button[aria-checked="true"] { border-color: var(--sun); box-shadow: 0 0 0 2px var(--sun), 0 10px 26px rgba(255, 138, 42, .35); transform: translateY(-3px); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25);
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, .25), inset 0 5px 8px rgba(255, 255, 255, .3);
  cursor: pointer; padding: 0; transition: transform .15s cubic-bezier(.2, 1.4, .4, 1);
}
.swatches button[aria-checked="true"] { border-color: #fff; transform: scale(1.18); box-shadow: 0 0 0 3px rgba(255, 255, 255, .25), inset 0 -6px 10px rgba(0, 0, 0, .25); }

/* ---------- Knöpfe ---------- */
.btn {
  font-weight: 900; font-size: 16px; border: 1px solid var(--edge); border-radius: 14px; padding: 12px 16px;
  background: rgba(255, 255, 255, .1); cursor: pointer; transition: transform .1s, background .15s, box-shadow .15s;
}
.btn:hover { background: rgba(255, 255, 255, .17); }
.btn:active { transform: scale(.97); }
.btn.big {
  width: 100%; font-size: 20px; padding: 16px; text-transform: uppercase; font-style: italic; letter-spacing: .03em;
  color: #1a0d07; border: 0; background: var(--grad);
  box-shadow: 0 10px 30px rgba(255, 77, 61, .42), inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -4px 0 rgba(0, 0, 0, .18);
}
.btn.big:hover { filter: brightness(1.07); }
.btn.big:active { transform: translateY(2px) scale(.99); }
.btn.big:disabled { filter: grayscale(1) brightness(.7); cursor: default; }
.btn.ghost { background: transparent; border-color: var(--edge-strong); }
.btn.small { font-size: 14px; padding: 10px 13px; white-space: nowrap; }
.btn.tiny { font-size: 17px; padding: 0; width: 42px; height: 42px; border-radius: 13px; background: var(--glass-strong); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.btn.link { background: none; border: 0; color: var(--muted); font-weight: 800; font-size: 14px; padding: 8px; }
.btn.link:hover { color: #fff; background: none; }
.btn.wide-btn { display: block; width: 100%; margin-top: 10px; }
.linkrow { display: flex; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.card > .btn.link { display: block; margin: 8px auto 0; }
.joinrow { display: flex; gap: 8px; margin-top: 14px; }
.joinrow input { text-transform: uppercase; letter-spacing: .3em; text-align: center; }

/* ---------- Lobby ---------- */
.lobbyhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 12px; margin-bottom: 4px; }
.lobbyhead .invite { order: 3; flex: 1 0 100%; }
.headbtns { display: flex; gap: 6px; align-items: center; }
.btn.icon { padding: 9px 11px; font-size: 16px; line-height: 1; }
.btn.icon.on { background: rgba(255, 255, 255, .18); }
/* Hinweisfenster: installieren oder Vollbild */
.appcard { width: min(100%, 460px); margin: auto; text-align: center; }
.applead { margin: 0 0 16px; font-weight: 600; line-height: 1.45; color: #dfe2ff; }
.approtate { display: flex; align-items: center; justify-content: center; gap: 10px; margin: -6px 0 16px; font-weight: 700; font-size: 14px; color: var(--sun); }
.approtate b { color: #fff; }
.phone { flex: none; width: 15px; height: 26px; border: 2px solid currentColor; border-radius: 5px; animation: turn 2.6s ease-in-out infinite; }
.phone.big { display: block; width: 34px; height: 60px; border-width: 4px; border-radius: 10px; margin: 6px auto 18px; color: var(--sun); }
@keyframes turn { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }
/* Dreh-Hinweis im Rennen: nur hochkant auf Touch-Geräten */
#rotate { display: none; z-index: 9; text-align: center; }
#rotate .card { margin: auto; width: min(100%, 360px); }
@media (orientation: portrait) and (pointer: coarse) {
  body:not(.portrait-ok) #screen-game.active #rotate { display: flex; }
}
.appbtns { display: flex; gap: 10px; }
.appbtns .btn { flex: 1; margin: 0; font-size: 17px; padding: 14px 8px; white-space: nowrap; }
.appbtns .btn.ghost { color: #fff; background: rgba(255, 255, 255, .08); box-shadow: none; }
.appguide { text-align: left; margin-top: 4px; }
.appguide h2 { margin: 0 0 10px; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 8px; font-size: 15px; font-weight: 600; line-height: 1.4; color: #dfe2ff; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 14px; color: #14173a; background: var(--grad); }
.steps b { color: #fff; }
.lobbyhead small { font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.code { font-size: 50px; font-weight: 900; font-style: italic; letter-spacing: .12em; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.invite { display: flex; gap: 8px; }
.invite input { font-size: 14px; min-width: 0; font-weight: 700; padding: 10px 13px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; font-weight: 600; }
.hint.center { text-align: center; }
.card.wide > h2 { margin-top: 22px; }

/* Streckenkarten mit Titelbild und Streckenverlauf */
.tracks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tracks button {
  position: relative; text-align: left; padding: 0; overflow: hidden;
  border: 1px solid var(--edge); border-radius: 18px; background: #101330; cursor: pointer; aspect-ratio: 16 / 10;
  transition: transform .18s cubic-bezier(.2, 1.4, .4, 1), box-shadow .18s, border-color .18s;
}
.tracks button:disabled { cursor: default; }
.tracks .cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.tracks button::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(11, 13, 36, 0) 30%, rgba(11, 13, 36, .92) 100%); }
.tracks canvas { position: absolute; right: 8px; top: 8px; z-index: 2; width: 34%; aspect-ratio: 16 / 10; border-radius: 10px; border: 1px solid var(--edge); }
.tracks .meta { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 10px 12px; }
.tracks strong { display: block; font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 17px; text-shadow: 0 2px 8px rgba(0, 0, 0, .7); }
.tracks small { display: none; }
.tracks em { font-style: normal; font-size: 11px; font-weight: 800; color: var(--sun); letter-spacing: .05em; }
.tracks button:not(:disabled):hover { transform: translateY(-3px); border-color: var(--edge-strong); }
.tracks button:not(:disabled):hover .cover { transform: scale(1.06); }
.tracks button[aria-checked="true"] { border-color: var(--sun); box-shadow: 0 0 0 2px var(--sun), 0 14px 34px rgba(255, 138, 42, .35); transform: translateY(-3px); }
.tracks button[aria-checked="true"]::after {
  content: "✓"; position: absolute; top: 8px; left: 8px; z-index: 3; width: 26px; height: 26px; border-radius: 50%;
  background: var(--grad); color: #1a0d07; font-weight: 900; display: grid; place-items: center;
}
@media (max-width: 620px) {
  .tracks { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tracks strong { font-size: 13px; }
  .tracks canvas { display: none; }
}

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin: 22px 0; }
@media (max-width: 620px) { .cols { grid-template-columns: 1fr; gap: 14px; } }
.seg { display: flex; gap: 6px; margin-bottom: 16px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, .28); }
.seg button { flex: 1; padding: 9px 0; border-radius: 11px; border: 0; background: transparent; font-weight: 900; font-size: 14px; cursor: pointer; color: var(--muted); transition: background .15s, color .15s; }
.seg button:disabled { cursor: default; }
.seg button[aria-checked="true"] { background: rgba(255, 255, 255, .92); color: #14173a; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.players li { display: flex; align-items: center; gap: 11px; background: rgba(255, 255, 255, .06); border: 1px solid var(--edge); border-radius: 14px; padding: 6px 12px 6px 6px; font-weight: 800; }
.face { width: 40px; height: 40px; border-radius: 13px; flex: none; object-fit: cover; display: block; border: 2px solid var(--ring, rgba(255, 255, 255, .4)); }
.players em { margin-left: auto; font-style: normal; font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--sun); }
.players li.empty { border-style: dashed; color: var(--muted); font-weight: 600; background: transparent; justify-content: center; padding: 12px; }

/* ---------- Wertung / Siegerehrung ---------- */
.kicker { display: block; font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.standings { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.standings li {
  display: grid; grid-template-columns: 2em 40px 1fr auto auto; align-items: center; gap: 11px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--edge); border-radius: 14px; padding: 5px 14px 5px 10px; font-weight: 800;
  animation: rise .35s both;
}
.standings li.mine { border-color: var(--sun); background: rgba(255, 210, 63, .1); }
.standings .rank { font-style: italic; font-weight: 900; color: var(--sun); }
.standings .gain { font-size: 13px; color: #6ef0a0; font-variant-numeric: tabular-nums; }
.standings .pts { font-size: 22px; font-style: italic; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 10px; height: 230px; margin: 4px 0 18px; }
.podium div { position: relative; display: grid; justify-items: center; align-content: start; gap: 2px; border-radius: 18px 18px 0 0; font-weight: 900; padding-top: 12px; animation: grow .6s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: bottom; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35); }
.podium img { width: 72px; height: 72px; border-radius: 22px; object-fit: cover; margin-top: -84px; border: 3px solid #fff; box-shadow: 0 10px 24px rgba(0, 0, 0, .5); }
.podium span { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; color: #1a0d07; }
.podium i { font-style: italic; font-size: 34px; color: rgba(26, 13, 7, .75); }
.podium .p1 { height: 150px; background: linear-gradient(#ffe27a, #f0a81a); order: 2; }
.podium .p2 { height: 114px; background: linear-gradient(#dfe5ee, #9aa5b6); order: 1; animation-delay: .15s; }
.podium .p3 { height: 88px; background: linear-gradient(#f0b08a, #b96a3f); order: 3; animation-delay: .3s; }
@keyframes grow { from { transform: scaleY(0); } }
.awards { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.awards li { background: rgba(0, 0, 0, .3); border: 1px solid var(--edge); border-radius: 14px; padding: 10px 13px; font-size: 13px; font-weight: 700; line-height: 1.35; }
.awards strong { display: block; color: var(--sun); font-style: italic; font-weight: 900; text-transform: uppercase; font-size: 14px; }
.awards em { font-style: normal; color: var(--muted); }
@media (max-width: 540px) { .awards { grid-template-columns: 1fr; } }
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
#screen-standings .card { z-index: 4; }

/* ---------- Hilfe ---------- */
.keys { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 9px; font-size: 14px; font-weight: 600; line-height: 1.45; color: #dfe2ff; }
.keys b { color: #fff; }
kbd { display: inline-block; min-width: 26px; text-align: center; background: rgba(255, 255, 255, .12); border: 1px solid var(--edge-strong); border-bottom-width: 3px; border-radius: 8px; padding: 1px 7px; font: inherit; font-weight: 900; font-size: 12px; margin-right: 3px; }

/* ---------- Rennen: HUD ---------- */
#screen-game { padding: 0; overflow: hidden; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; animation: none; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#speedfx {
  position: absolute; inset: -20%; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: repeating-conic-gradient(from 0deg at 50% 46%, rgba(255, 255, 255, .5) 0 .6deg, transparent .6deg 7deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent 52%, #000 100%);
  mask-image: radial-gradient(closest-side, transparent 52%, #000 100%);
  animation: speedspin .5s steps(4) infinite;
}
#speedfx.on { opacity: .55; }
@keyframes speedspin { to { transform: rotate(7deg); } }
/* dunkle Ränder oben und unten, damit die Anzeigen auf jeder Strecke lesbar bleiben */
#screen-game::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(8, 9, 26, .5) 0, transparent 18%, transparent 80%, rgba(8, 9, 26, .42) 100%); }
.hud { position: absolute; z-index: 2; color: #fff; pointer-events: none; }
.hud.tl { left: max(14px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); display: grid; gap: 7px; justify-items: start; }
.hud.tr { right: max(14px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); display: grid; justify-items: end; gap: 8px; }
.hud.tr .btn { pointer-events: auto; }
.hudbtns { display: flex; gap: 7px; pointer-events: auto; }

/* Platzierung als schräge Plakette */
.pos {
  display: flex; align-items: baseline; gap: 2px; padding: 2px 16px 4px 12px; border-radius: 16px 6px 16px 6px;
  background: var(--grad); color: #1a0d07; font-weight: 900; font-style: italic; line-height: 1; transform: skewX(-8deg);
  box-shadow: 0 8px 24px rgba(255, 77, 61, .45), inset 0 2px 0 rgba(255, 255, 255, .5);
}
.pos span { font-size: 58px; letter-spacing: -.04em; }
.pos small { font-size: 20px; opacity: .7; }
.pill { background: var(--glass-strong); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--edge); border-radius: 999px; padding: 5px 13px; font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.mono { font-variant-numeric: tabular-nums; }
#hud-best { color: var(--cyan); }
#hud-bolts { color: var(--sun); }
#hud-bolts.full { background: var(--grad); color: #1a0d07; border-color: transparent; }
#minimap { width: 132px; height: 132px; border-radius: 20px; background: rgba(11, 13, 36, .5); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--edge); }

/* Tacho: Bogen füllt sich mit dem Tempo, im Boost leuchtet er türkis */
.hud.br { right: max(16px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
.speedo { position: relative; width: 132px; height: 132px; }
.speedo svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(135deg); }
.speedo circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.speedo .track { stroke: rgba(11, 13, 36, .6); stroke-dasharray: 245 400; }
.speedo .fill { stroke: url(#speedo-grad); stroke-dasharray: 0 400; transition: stroke-dasharray .12s linear; filter: drop-shadow(0 0 6px rgba(255, 138, 42, .7)); }
.speedo.boost .fill { stroke: var(--cyan); filter: drop-shadow(0 0 10px var(--cyan)); }
.speedo .num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-weight: 900; font-style: italic; font-variant-numeric: tabular-nums; line-height: .9; text-shadow: 0 2px 10px rgba(0, 0, 0, .7); }
.speedo .num span { font-size: 40px; }
.speedo .num small { font-size: 11px; letter-spacing: .12em; opacity: .75; font-style: normal; }

/* Item-Plätze: Bild als Hintergrund, Anzahl als kleine Marke */
.hud.item {
  left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%);
  width: 84px; height: 84px; border-radius: 24px; border: 2px solid var(--edge-strong);
  background: var(--glass-strong) center / cover no-repeat; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: 15px; font-weight: 900; padding: 0; white-space: nowrap;
  display: grid; align-items: end; justify-items: end; pointer-events: auto; cursor: pointer; overflow: hidden;
  transition: transform .15s cubic-bezier(.2, 1.6, .4, 1), box-shadow .15s, border-color .15s;
}
.hud.item b, .t-item b, .hud.item2 b { background: var(--glass-strong); border-radius: 8px 0 0 0; padding: 1px 7px; font-size: 14px; }
.hud.item b:empty, .t-item b:empty, .hud.item2 b:empty { display: none; }
.hud.item.ready { border-color: var(--sun); box-shadow: 0 0 0 4px rgba(255, 210, 63, .28), 0 10px 30px rgba(255, 138, 42, .4); transform: translateX(-50%) scale(1.04); }
.hud.item.holding { border-color: var(--cyan); box-shadow: 0 0 0 6px rgba(84, 230, 224, .4); }
.hud.item2 {
  left: calc(50% + 54px); top: max(58px, calc(env(safe-area-inset-top) + 48px));
  width: 44px; height: 44px; border-radius: 14px; display: grid; align-items: end; justify-items: end; overflow: hidden;
  border: 2px solid var(--edge-strong); background: var(--glass-strong) center / cover no-repeat; font-weight: 900;
}

#technique {
  left: 50%; top: max(108px, calc(env(safe-area-inset-top) + 98px)); transform: translateX(-50%) skewX(-8deg);
  white-space: nowrap; color: var(--technique-color, #fff); font-style: italic; font-size: 15px; letter-spacing: .04em; text-transform: uppercase;
  border-color: var(--technique-color, var(--edge)); box-shadow: 0 0 24px -6px var(--technique-color, transparent);
  animation: pop .3s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: translateX(-50%) skewX(-8deg) scale(.6); opacity: 0; } }

#countdown, #banner { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; pointer-events: none; font-weight: 900; font-style: italic; }
#countdown {
  font-size: min(36vw, 260px);
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 10px 0 rgba(0, 0, 0, .35)) drop-shadow(0 0 40px rgba(255, 138, 42, .5));
}
#banner { font-size: min(11vw, 76px); text-transform: uppercase; color: #fff; text-shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 0 40px rgba(255, 138, 42, .8); opacity: 0; transition: opacity .25s; padding-bottom: 20vh; }
#banner.show { opacity: 1; }
#flash { position: absolute; inset: 0; z-index: 3; pointer-events: none; background: #fff; opacity: 0; }
#flash.go { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .95; } 12% { opacity: .15; } 22% { opacity: .8; } 100% { opacity: 0; } }

/* ---------- Touch-Steuerung ---------- */
.touch { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#steerzone {
  position: absolute; left: 0; bottom: 0; width: 52%; height: 68%; pointer-events: auto; touch-action: none;
  display: flex; align-items: flex-end; justify-content: center; padding: 0 0 max(40px, env(safe-area-inset-bottom));
}
#steerhint {
  margin: 0; text-align: center; font-weight: 800; font-size: 13px; line-height: 1.35;
  background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px dashed var(--edge-strong); border-radius: 18px; padding: 11px 16px; pointer-events: none; transition: opacity .3s;
}
#steerhint.gone { opacity: 0; }
.stick {
  position: absolute; width: 156px; height: 156px; margin: -78px 0 0 -78px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .06), rgba(16, 19, 48, .5));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 2px solid var(--edge-strong); box-shadow: 0 0 30px rgba(84, 230, 224, .25), inset 0 0 24px rgba(0, 0, 0, .35);
  pointer-events: none; display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
  color: rgba(255, 255, 255, .7); font-size: 16px;
}
.knob {
  position: absolute; left: 50%; top: 50%; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #c9d4ff 60%, #8f9ad6);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .5), 0 0 0 4px rgba(84, 230, 224, .35);
}
.tbtns {
  position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(78px, calc(env(safe-area-inset-bottom) + 64px));
  display: grid; grid-template-columns: auto auto; gap: 12px; align-items: end; justify-items: end;
}
.tbtns button {
  pointer-events: auto; touch-action: none; border-radius: 50%; border: 2px solid var(--edge-strong);
  background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-weight: 900; text-transform: uppercase; letter-spacing: .06em; width: 68px; height: 68px; font-size: 10px; padding: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .4), inset 0 2px 0 rgba(255, 255, 255, .18); transition: transform .08s;
}
.tbtns .t-item { grid-column: 2; width: 78px; height: 78px; background: var(--glass) center / cover no-repeat; overflow: hidden; display: grid; align-items: end; justify-items: end; border-radius: 26px; }
.tbtns .t-item:not(.ready) { opacity: .55; }
.tbtns .t-item.ready { border-color: var(--sun); box-shadow: 0 0 0 4px rgba(255, 210, 63, .28), 0 8px 20px rgba(0, 0, 0, .4); }
.tbtns .t-drift {
  width: 112px; height: 112px; font-size: 19px; font-style: italic; color: #1a0d07; border: 0;
  background: var(--grad); grid-column: 2; grid-row: 2 / span 2;
  box-shadow: 0 12px 30px rgba(255, 77, 61, .5), inset 0 3px 0 rgba(255, 255, 255, .5), inset 0 -6px 0 rgba(0, 0, 0, .18);
}
.tbtns .t-s { grid-column: 1; }
.tbtns button.on { transform: scale(.92); filter: brightness(1.25); }

/* ---------- Overlays ---------- */
.overlay { position: absolute; inset: 0; display: flex; padding: 16px; background: rgba(6, 7, 20, .6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-y: auto; z-index: 5; animation: screen-in .25s ease-out; }
.overlay.top { position: fixed; z-index: 20; }
.results { list-style: none; counter-reset: r; margin: 0 0 18px; padding: 0; display: grid; gap: 6px; }
.results li { counter-increment: r; display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .06); border: 1px solid var(--edge); border-radius: 14px; padding: 9px 13px; font-weight: 800; }
.results li::before { content: counter(r) "."; font-style: italic; font-weight: 900; width: 1.6em; color: var(--sun); }
.results li.mine { border-color: var(--sun); background: rgba(255, 210, 63, .1); }
.results i { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.results b { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--glass-strong); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--sun); color: #fff; font-weight: 800; padding: 11px 20px; border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5); z-index: 30; max-width: calc(100vw - 32px); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .screen.active, .overlay, .standings li, .podium div, #technique, #speedfx { animation: none; }
  .btn, .stats dd i, #banner, .tracks button, .tracks .cover { transition: none; }
  #confetti { display: none; }
}

/* ---------- Handy: alles Wichtige ohne Scrollen ---------- */
@media (max-width: 620px) {
  .screen { padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
  .card { padding: 18px 14px 14px; overflow: visible; border-radius: 20px; }
  .flagband { border-radius: 20px 20px 0 0; }
  .home { gap: 10px; }
  .logo { font-size: 38px; }
  .logo.small { font-size: 28px; margin-bottom: 12px; }
  .tagline { display: none; }
  .stage { height: clamp(120px, 22vh, 190px); }
  .arrow { width: 40px; height: 40px; font-size: 24px; }
  .charinfo { gap: 12px; flex-wrap: nowrap; justify-content: flex-start; }
  .charinfo .portrait { width: 56px; height: 56px; border-radius: 16px; }
  .charinfo strong { font-size: 24px; }
  .charinfo span { font-size: 11px; }
  .stats { grid-template-columns: auto 1fr; flex: 1; min-width: 90px; gap: 4px 8px; font-size: 10px; }
  .field { margin-bottom: 12px; }
  input { padding: 11px 13px; font-size: 16px; }

  /* Fahrer und Farben als Wischleisten */
  .chars, .swatches { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px; margin: 0 -14px; padding: 4px 14px 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .chars::-webkit-scrollbar, .swatches::-webkit-scrollbar, .tracks::-webkit-scrollbar, .players::-webkit-scrollbar { display: none; }
  .chars button { flex: 0 0 72px; scroll-snap-align: center; }
  .swatches button { flex: none; width: 34px; height: 34px; }

  /* Hauptknopf bleibt am unteren Rand sichtbar */
  #btn-primary, #btn-start, #btn-enter, #btn-st-next { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 6; }
  .btn.big { font-size: 18px; padding: 14px; }
  .joinrow { margin-top: 10px; }
  .linkrow { margin-top: 4px; }

  /* Lobby */
  .lobbyhead { margin-bottom: 0; gap: 8px 10px; }
  .appbtns { flex-direction: column; }
  .code { font-size: 38px; }
  .invite input { font-size: 12px; padding: 9px 10px; }
  #invite-hint { display: none; }
  .card.wide > h2 { margin-top: 14px; }
  .tracks { display: flex; overflow-x: auto; gap: 10px; margin: 0 -14px; padding: 4px 14px 8px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .tracks button { flex: 0 0 64%; scroll-snap-align: center; }
  .tracks strong { font-size: 15px; }
  .tracks canvas { display: block; width: 40%; }
  .cols { margin: 14px 0 10px; gap: 10px; }
  .players { display: flex; overflow-x: auto; gap: 8px; margin: 0 -14px; padding: 0 14px 4px; scrollbar-width: none; }
  .players li { flex: none; padding: 5px 12px 5px 5px; font-size: 14px; }
  .players li.empty { padding: 8px 14px; font-size: 13px; }
  .players em { margin-left: 4px; }
  .face { width: 34px; height: 34px; border-radius: 11px; }
  /* Einstellungen zweispaltig: Überschrift links, Auswahl rechts */
  #screen-lobby .cols > section:last-child { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 12px; }
  #screen-lobby .cols > section:last-child h2 { margin: 0; }
  #screen-lobby .seg { margin: 0; }
  .seg button { padding: 8px 0; font-size: 13px; }
  #lobby-status:empty { display: none; }

  /* Wertung */
  .podium { height: 190px; }
  .podium img { width: 58px; height: 58px; margin-top: -68px; }
}
/* niedrige Querformat-Bildschirme (Handy quer): Menü zweispaltig und flach */
@media (max-height: 520px) and (orientation: landscape) {
  .home { grid-template-columns: 1fr 1.1fr; gap: 14px; align-items: start; }
  .logo { font-size: 30px; }
  .tagline { display: none; }
  .stage { height: 110px; }
  .card { padding: 14px; }
  .field { margin-bottom: 8px; }
  .chars { display: flex; overflow-x: auto; gap: 8px; scrollbar-width: none; }
  .chars button { flex: 0 0 64px; }
  .tracks { display: flex; overflow-x: auto; gap: 10px; scrollbar-width: none; }
  .tracks button { flex: 0 0 34%; }
  .tracks::-webkit-scrollbar, .chars::-webkit-scrollbar { display: none; }

  /* Lobby quer am Handy: Code, Einladung und Knöpfe in einer Zeile */
  .screen { padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  #screen-lobby .card { padding: 14px 14px 10px; overflow: visible; }
  .lobbyhead { flex-wrap: nowrap; align-items: center; margin-bottom: 0; }
  .lobbyhead .invite { order: 0; flex: 1 1 auto; min-width: 0; }
  .lobbycode { display: flex; align-items: baseline; gap: 8px; }
  .code { font-size: 30px; }
  .invite input { font-size: 12px; padding: 8px 10px; }
  .btn.small { font-size: 13px; padding: 8px 11px; }
  #invite-hint { display: none; }
  .card.wide > h2 { margin-top: 10px; margin-bottom: 6px; }
  #screen-lobby .tracks { margin: 0 -14px; padding: 2px 14px 4px; scroll-snap-type: x proximity; }
  #screen-lobby .tracks button { flex: 0 0 23%; scroll-snap-align: center; border-radius: 14px; }
  .tracks strong { font-size: 13px; }
  .tracks .meta { padding: 6px 8px; }
  .cols { grid-template-columns: 1fr 1.25fr; margin: 10px 0 8px; gap: 14px; }
  .players { gap: 5px; }
  .players li { padding: 4px 10px 4px 4px; font-size: 14px; }
  .players li.empty { padding: 7px; font-size: 13px; }
  .face { width: 30px; height: 30px; border-radius: 10px; }
  #screen-lobby .cols > section:last-child { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 10px; }
  #screen-lobby .cols > section:last-child h2, #screen-lobby .cols h2 { margin: 0 0 4px; }
  #screen-lobby .cols > section:last-child h2 { margin: 0; }
  #screen-lobby .seg { margin: 0; }
  .seg button { padding: 6px 0; font-size: 13px; }
  #btn-primary, #btn-start, #btn-enter, #btn-st-next { position: sticky; bottom: max(6px, env(safe-area-inset-bottom)); z-index: 6; }
  .btn.big { font-size: 17px; padding: 11px; }
  #lobby-status:empty { display: none; }

  /* Pause, Zieleinlauf, Wertung und Hilfe quer */
  #pause .card, #results .card { width: min(100%, 660px); padding: 12px 16px 8px; margin: auto; }
  #pause .card { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #pause .card > h2, #pause .card > .hint, #btn-resume, #btn-leave-pause { grid-column: 1 / -1; margin: 0; }
  #pause .btn.wide-btn { margin: 0; padding: 9px; font-size: 14px; }
  #pause .logo.small, #results .logo.small, #screen-standings .logo.small, #help .logo.small { font-size: 22px; margin-bottom: 4px; }
  #pause .hint { display: none; }
  .results { grid-template-columns: 1fr 1fr; gap: 5px 8px; margin-bottom: 10px; }
  .results li { padding: 6px 11px; font-size: 14px; }
  .standings { grid-template-columns: 1fr 1fr; gap: 5px 8px; margin-bottom: 10px; }
  .podium { height: 140px; margin: 54px 0 10px; }
  .podium img { width: 48px; height: 48px; border-radius: 15px; margin-top: -58px; }
  .awards { gap: 6px; margin-bottom: 10px; }
  #help .card { padding: 12px 16px; }
  .keys { font-size: 12.5px; gap: 6px; margin-bottom: 10px; }
  .approtate { margin: -4px 0 10px; font-size: 13px; }

  /* Hinweisfenster quer: Text links, Anleitung kompakt */
  .overlay { padding: 8px; }
  .appcard { width: min(100%, 620px); padding: 12px 16px 6px; }
  .appcard .logo.small { font-size: 22px; margin-bottom: 6px; }
  .applead { font-size: 13px; margin-bottom: 10px; }
  .appbtns .btn { padding: 10px 8px; font-size: 16px; }
  .steps { grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; }
  .steps li { grid-template-columns: 24px 1fr; gap: 8px; }
  .steps li::before { width: 24px; height: 24px; font-size: 12px; }
  .appguide .hint { font-size: 12px; margin-top: 6px; }
}

/* Wischleisten dürfen das Raster nicht in die Breite drücken */
.home > *, .card { min-width: 0; }
@media (max-width: 880px) { .home { grid-template-columns: minmax(0, 1fr); } }

/* Startseite quer am Handy: Kart links, Einstellungen rechts – ohne Scrollen */
@media (max-height: 520px) and (orientation: landscape) {
  .home { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 14px; align-items: center; }
  .hero { text-align: center; }
  .logo { font-size: 26px; margin-bottom: 0; }
  .stage { height: clamp(96px, 34vh, 150px); }
  .arrow { width: 36px; height: 36px; font-size: 22px; }
  .charinfo { gap: 10px; flex-wrap: nowrap; justify-content: center; }
  .charinfo .portrait { width: 46px; height: 46px; border-radius: 14px; }
  .charinfo strong { font-size: 20px; }
  .charinfo span { font-size: 10px; }
  .stats { font-size: 9px; gap: 3px 6px; }
  .setup { padding: 14px 14px 8px; }
  .setup .field { margin-bottom: 7px; }
  .setup input { padding: 8px 12px; font-size: 16px; }
  .chars, .swatches { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 7px; margin: 0 -14px; padding: 2px 14px 4px; scrollbar-width: none; }
  .chars::-webkit-scrollbar, .swatches::-webkit-scrollbar { display: none; }
  .chars button { flex: 0 0 56px; }
  .swatches button { flex: none; width: 30px; height: 30px; }
  .joinrow { margin-top: 8px; }
  .linkrow { margin-top: 2px; }
  .linkrow .btn.link { padding: 4px 8px; font-size: 13px; }
  #pause .card { text-align: center; }
  #pause .logo.small { margin-bottom: 6px; }
}

/* iPhone/iPad: kein Zoom beim Antippen von Feldern, kein Doppeltipp-Zoom, keine Textauswahl auf Knöpfen */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { touch-action: manipulation; }
.ios input { font-size: 16px !important; }
.btn, .seg button, .tracks button, .chars button, .swatches button, #touch, .hud { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#screen-game { -webkit-touch-callout: none; }
.screen { height: 100%; height: 100dvh; }

/* Nichts darf breiter sein als der Bildschirm (iPhone mit großer Schrift: Lobby ließ sich seitlich verschieben) */
html, body { overflow-x: hidden; max-width: 100%; }
.screen { overflow-x: hidden; overscroll-behavior-x: none; }
.card { max-width: 100%; }
.cols > section, .seg, .seg button, .lobbyhead > *, .invite > * { min-width: 0; }
.seg button { overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; line-height: 1.15; }
@media (max-width: 620px) {
  #screen-lobby .cols > section:last-child { grid-template-columns: auto minmax(0, 1fr); }
  #screen-lobby .cols { grid-template-columns: minmax(0, 1fr); }
  .invite .btn.small { flex: none; }
  .invite input { flex: 1 1 0; }
}
@media (max-width: 360px) {
  .seg button { font-size: 11px; padding: 8px 1px; letter-spacing: 0; }
  .code { font-size: 32px; }
  .btn.small { font-size: 13px; padding: 9px 10px; }
}

/* Startbild beim Öffnen und Ladeanzeige in der Kart-Vorschau */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg)); transition: opacity .45s ease, visibility .45s; }
.splash.done { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-in { display: grid; justify-items: center; gap: 18px; padding: 24px; }
.splash .logo { font-size: clamp(40px, 11vw, 72px); margin: 0; animation: splash-pop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.splash-track { position: relative; width: min(64vw, 280px); height: 46px; border-bottom: 4px dashed rgba(255, 255, 255, .28); overflow: hidden; }
.splash-track .tyre { position: absolute; left: 0; bottom: 2px; animation: splash-roll 1.5s linear infinite; }
.splash-text { font-weight: 800; font-size: 14px; letter-spacing: .06em; color: var(--muted); }
.tyre { display: inline-block; width: 34px; height: 34px; border-radius: 50%; border: 8px solid #17181d; background: conic-gradient(#fff 0 12%, var(--sun) 12% 20%, #fff 20% 32%, var(--sun) 32% 40%, #fff 40% 52%, var(--sun) 52% 60%, #fff 60% 72%, var(--sun) 72% 80%, #fff 80% 92%, var(--sun) 92%); box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); animation: tyre-spin .7s linear infinite; }
@keyframes tyre-spin { to { transform: rotate(360deg); } }
@keyframes splash-roll { from { left: -40px; transform: rotate(0); } to { left: 100%; transform: rotate(1080deg); } }
@keyframes splash-pop { from { opacity: 0; transform: scale(.8) translateY(10px); } }
.stageloader { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; font-weight: 800; font-size: 13px; color: var(--muted); pointer-events: none; transition: opacity .3s; }
.stageloader.done { opacity: 0; }
#preview { transition: opacity .35s; }
.stage.loading #preview { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .tyre, .splash-track .tyre, .splash .logo { animation: none; } }

/* QR-Code zum Beitreten */
.qrcard { width: min(100%, 420px); margin: auto; text-align: center; }
.qrbox { background: #fff; border-radius: 18px; padding: 14px; margin: 0 auto 12px; width: min(100%, 300px); box-shadow: 0 12px 34px rgba(0, 0, 0, .45); }
.qrbox canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qrcode-line { margin: 0 0 4px; font-weight: 800; color: var(--muted); display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.qrcode-line .code { font-size: 34px; }
.invite { flex-wrap: wrap; }
.invite input { flex: 1 1 140px; }
@media (max-height: 520px) and (orientation: landscape) {
  .invite { flex-wrap: nowrap; }
  .qrcard { width: min(100%, 560px); display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: center; padding: 12px 16px; text-align: left; }
  .qrcard .logo.small { grid-column: 2; font-size: 22px; margin: 0; }
  .qrbox { grid-row: 1 / span 4; width: min(52vh, 230px); margin: 0; padding: 10px; }
  .qrcode-line { justify-content: flex-start; }
  .qrcard .hint.center { text-align: left; }
  .qrcard .btn.big { grid-column: 2; }
}

/* Startknopf der Lobby samt Hinweis bleiben als Block am unteren Rand sichtbar */
.lobbygo { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 6; display: grid; gap: 6px; }
.lobbygo .btn.big { margin: 0; }
.lobbygo .hint { margin: 0; }
#btn-start, #btn-enter { position: static !important; }

/* ================= Handy im Querformat: alles auf einen Blick, ohne Scrollen ================= */
@media (max-height: 520px) and (orientation: landscape) {
  /* ---------- Lobby: links Strecken und Fahrer, rechts Einstellungen und Start ---------- */
  #screen-lobby { align-items: stretch; overflow: hidden; }
  #screen-lobby .card.wide {
    width: 100%; max-width: none; height: 100%; margin: 0; padding: 9px 12px 8px; overflow: hidden;
    display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "head head" "tracks set" "players set" "players go"; gap: 6px 14px;
  }
  #screen-lobby .lobbyhead { grid-area: head; margin: 0; }
  #screen-lobby .card.wide > h2, #invite-hint, #screen-lobby .card.wide > .btn.link { display: none; }
  #track-cards {
    grid-area: tracks; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr);
    gap: 5px; margin: 0 !important; padding: 0 !important; overflow: hidden; min-height: 0; scroll-snap-type: none;
  }
  #track-cards button { flex: none !important; aspect-ratio: auto; min-height: 0; border-radius: 11px; }
  #track-cards canvas { display: none !important; }
  #track-cards .meta { padding: 3px 7px; }
  #track-cards .meta > :not(strong) { display: none; }
  #track-cards strong { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #screen-lobby .cols { display: contents; }
  #screen-lobby .cols > section:first-child { grid-area: players; min-width: 0; min-height: 0; }
  #screen-lobby .cols > section:last-child { grid-area: set; align-self: center; min-width: 0; gap: 7px 10px; }
  #screen-lobby .cols h2 { font-size: 10px; margin: 0 0 3px; }
  #screen-lobby .cols > section:last-child h2 { margin: 0; }
  /* Fahrer als schmale Namensschilder */
  #screen-lobby .players { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; overflow: hidden; max-height: 58px; }
  #screen-lobby .players li { flex: none; padding: 2px 8px 2px 2px; font-size: 12px; border-radius: 10px; gap: 5px; }
  #screen-lobby .players li.empty { padding: 3px 9px; font-size: 11px; }
  #screen-lobby .players .face { width: 22px; height: 22px; border-radius: 7px; border-width: 1.5px; }
  #screen-lobby .players em { font-size: 8px; margin-left: 1px; }
  #screen-lobby .seg { padding: 3px; border-radius: 11px; }
  #screen-lobby .seg button { padding: 6px 0; font-size: 12px; border-radius: 9px; white-space: nowrap; hyphens: none; -webkit-hyphens: none; overflow-wrap: normal; letter-spacing: 0; }
  #seg-mode button { font-size: 11px; }
  .lobbygo { grid-area: go; position: static; align-self: end; gap: 3px; }
  .lobbygo .btn.big { font-size: 16px; padding: 10px; }
  .lobbygo .hint { font-size: 11px; line-height: 1.25; }

  /* ---------- Wertung und Siegerehrung: links Titel, Podest, Auszeichnungen – rechts die Tabelle ---------- */
  #screen-standings { align-items: stretch; overflow: hidden; }
  #screen-standings .card.wide {
    width: 100%; max-width: none; height: 100%; margin: 0; padding: 10px 14px 8px; overflow: hidden;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto auto auto; gap: 4px 16px;
  }
  #screen-standings .card.wide > * { min-width: 0; }
  #screen-standings .card.wide > .kicker { grid-column: 1; grid-row: 1; margin: 0; }
  #screen-standings .card.wide > .logo.small { grid-column: 1; grid-row: 2; margin: 0; font-size: 22px; }
  #screen-standings .card.wide > .podium { grid-column: 1; grid-row: 3; height: min(100%, 124px); min-height: 70px; margin: 46px 0 0; align-self: end; gap: 8px; }
  #screen-standings .card.wide > .awards { grid-column: 1; grid-row: 4; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0; font-size: 11px; }
  #screen-standings .card.wide > #btn-st-next { grid-column: 1; grid-row: 5; position: static; margin: 0; font-size: 16px; padding: 10px; }
  #screen-standings .card.wide > #st-wait { grid-column: 1; grid-row: 6; margin: 0; font-size: 11px; }
  #screen-standings .card.wide > #st-wait:empty { display: none; }
  #screen-standings .card.wide > #btn-leave-st { grid-column: 1; grid-row: 7; margin: 0 auto; padding: 2px 8px; font-size: 12px; }
  /* die Tabelle füllt die rechte Hälfte über die ganze Höhe */
  #screen-standings .card.wide > .standings { grid-column: 2; grid-row: 1 / -1; grid-template-columns: 1fr; gap: 4px; margin: 0; align-content: center; overflow: hidden; }
  #screen-standings .standings li { padding: 3px 11px 3px 7px; gap: 8px; font-size: 13px; border-radius: 11px; grid-template-columns: 1.6em 26px 1fr auto auto; }
  #screen-standings .standings .face { width: 26px; height: 26px; border-radius: 8px; }
  #screen-standings .standings .pts { font-size: 17px; }
  #screen-standings .podium img { width: 40px; height: 40px; border-radius: 12px; margin-top: -46px; border-width: 2px; }
  #screen-standings .podium div { padding-top: 8px; font-size: 12px; border-radius: 12px 12px 0 0; }
  #screen-standings .awards li { padding: 4px 8px; }

  /* ---------- Rennen: Karte neben den Platz, Tacho klein nach oben – rechts unten nur noch die Knöpfe ---------- */
  .hud.tl { left: max(10px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); grid-template-columns: 72px 82px auto; gap: 4px 8px; align-items: start; }
  .hud.tl .pos { grid-column: 1; grid-row: 1 / span 4; align-self: start; }
  .hud.tl .pill { grid-column: 3; font-size: 11px; padding: 3px 8px; }
  .pos span { font-size: 40px; }
  .pos small { font-size: 15px; }
  #minimap { position: fixed; left: calc(max(10px, env(safe-area-inset-left)) + 80px); top: max(8px, env(safe-area-inset-top)); width: 82px; height: 82px; border-radius: 14px; }
  .hud.tr { right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); }
  .hud.br { bottom: auto; top: max(6px, env(safe-area-inset-top)); right: calc(max(10px, env(safe-area-inset-right)) + 132px); }
  .speedo { width: 62px; height: 62px; }
  .speedo circle { stroke-width: 12; }
  .speedo .num span { font-size: 20px; }
  .speedo .num small { font-size: 7px; letter-spacing: .08em; }
  .hud.item { width: 60px; height: 60px; border-radius: 18px; top: max(8px, env(safe-area-inset-top)); }
  .hud.item2 { left: calc(50% + 38px); top: max(42px, calc(env(safe-area-inset-top) + 36px)); width: 34px; height: 34px; border-radius: 11px; }
  #technique { top: max(76px, calc(env(safe-area-inset-top) + 70px)); font-size: 13px; }
  .tbtns { bottom: max(12px, env(safe-area-inset-bottom)); right: max(12px, env(safe-area-inset-right)); gap: 9px; }
  .tbtns button { width: 60px; height: 60px; }
  .tbtns .t-item { width: 68px; height: 68px; border-radius: 22px; }
  .tbtns .t-drift { width: 102px; height: 102px; font-size: 17px; }
  #steerzone { height: 60%; }
}

/* Siegerehrung quer: Säulen als Anteil der Feldhöhe (sonst ragen sie über die Auszeichnungen), Titel einzeilig */
@media (max-height: 520px) and (orientation: landscape) {
  #screen-standings .podium .p1 { height: 100%; }
  #screen-standings .podium .p2 { height: 77%; }
  #screen-standings .podium .p3 { height: 60%; }
  #screen-standings .podium i { font-size: 22px; line-height: 1; }
  #screen-standings .podium span { font-size: 11px; }
  #screen-standings .card.wide > .logo.small { font-size: 20px; line-height: 1.1; white-space: nowrap; }
  #screen-standings .card.wide > .logo.small span { display: inline; margin-left: .22em; }
  #screen-standings .awards li { padding: 3px 8px; font-size: 10.5px; line-height: 1.25; border-radius: 10px; }
  #screen-standings .awards strong { font-size: 11px; }
  #screen-standings .card.wide > .podium { margin-top: 44px; min-height: 64px; }
}

/* Sehr flache Bildschirme (Handy quer mit eingeblendeten Browserleisten): Siegerehrung noch etwas dichter */
@media (max-height: 360px) and (orientation: landscape) {
  #screen-standings .card.wide > .kicker { display: none; }
  #screen-standings .podium img { width: 32px; height: 32px; border-radius: 10px; margin-top: -37px; }
  #screen-standings .card.wide > .podium { margin-top: 36px; min-height: 58px; }
  #screen-standings .podium div { padding-top: 6px; }
}

/* Lobby quer, Feinschliff: Kopfzeile ohne Link-Feld (Kopieren, Teilen und QR-Code genügen), Einstellungen mit der
   Beschriftung ÜBER dem Schalter, damit die Schalter die ganze Spaltenbreite haben und nichts ineinanderläuft */
@media (max-height: 520px) and (orientation: landscape) {
  #screen-lobby #invite-link { display: none; }
  #screen-lobby .lobbyhead { justify-content: flex-start; gap: 8px; }
  #screen-lobby .lobbyhead .invite { flex: 0 0 auto; flex-wrap: nowrap; gap: 6px; }
  #screen-lobby .lobbyhead .headbtns { margin-left: auto; }
  #screen-lobby .cols > section:last-child { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; align-self: center; }
  #screen-lobby .cols > section:last-child h2 { font-size: 9px; margin: 3px 0 0; letter-spacing: .1em; }
  #screen-lobby .cols > section:last-child h2:first-child { margin-top: 0; }
  #screen-lobby .seg button, #seg-mode button { font-size: 12px; padding: 5px 0; }
}

/* Startseite quer: passt ohne Scrollen. „Lobby erstellen“ und das Beitreten per Code stehen in einer Zeile,
   Fahrerbilder und Farbfelder sind etwas kleiner. */
@media (max-height: 520px) and (orientation: landscape) {
  #screen-home { overflow: hidden; align-items: center; }
  .home { align-items: center; gap: 12px; }
  .hero .logo { font-size: 24px; }
  .stage { height: clamp(84px, 32vh, 140px); }
  .charinfo .portrait { width: 40px; height: 40px; border-radius: 12px; }
  .charinfo strong { font-size: 18px; }
  .setup { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 6px 8px; padding: 12px 12px 6px; align-content: center; }
  .setup > .field, .setup > .linkrow { grid-column: 1 / -1; margin: 0; }
  .setup .field > span { font-size: 9px; margin: 0 0 3px; }
  .setup input { padding: 6px 11px; }
  .setup .chars { margin: 0 -12px; padding: 2px 12px 3px; gap: 6px; }
  .setup .chars button { flex: 0 0 50px; font-size: 10px; border-radius: 11px; padding: 0 0 4px; }
  .setup .chars img { margin-bottom: 2px; }
  .setup .swatches { margin: 0 -12px; padding: 3px 12px; gap: 8px; }
  .setup .swatches button { width: 25px; height: 25px; }
  .setup #btn-primary { grid-column: 1; position: static; margin: 0; font-size: 15px; padding: 9px 6px; }
  .setup .joinrow { grid-column: 2; margin: 0; gap: 5px; }
  .setup .joinrow input { min-width: 0; padding: 6px 4px; letter-spacing: .14em; }
  .setup .joinrow .btn { padding: 8px 9px; font-size: 13px; white-space: nowrap; }
  .setup .linkrow .btn.link { padding: 1px 8px; font-size: 12px; }
}

/* Rennen quer, Feinschliff: Karte UNTER der Platzanzeige (macht die Mitte freier), Tacho ein Stück weiter links */
@media (max-height: 520px) and (orientation: landscape) {
  .hud.tl { grid-template-columns: 72px auto; gap: 4px 8px; }
  .hud.tl .pos { grid-column: 1; grid-row: 1 / span 2; }
  .hud.tl .pill { grid-column: 2; }
  #minimap { left: max(10px, env(safe-area-inset-left)); top: calc(max(8px, env(safe-area-inset-top)) + 56px); width: 76px; height: 76px; border-radius: 13px; }
  .hud.br { right: calc(max(10px, env(safe-area-inset-right)) + 172px); }
}
