/* Alle Maße beziehen sich auf die 1600 x 900 große Bühne, die als Ganzes skaliert wird. */
* { box-sizing: border-box; }

:root {
  --gold: #ffc928;
  --rot: #e63946;
  --dunkel: #10151f;
  --tafel: rgba(16, 21, 31, 0.9);
  --text: #f4f6fa;
  --blass: #a9b3c4;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0d13;
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  user-select: none;
}

#buehne {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1600px;
  height: 900px;
  transform-origin: center;
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: #3f9b4b;
}

#spielfeld { position: absolute; inset: 0; width: 1600px; height: 900px; display: block; }

h1, h2, p { margin: 0; }
h2 { font-size: 26px; font-weight: 800; letter-spacing: 0.02em; }
.klein { font-size: 18px; color: var(--blass); text-transform: uppercase; letter-spacing: 0.08em; }
.gross { font-size: 36px; font-weight: 800; line-height: 1.1; }
.zahl { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.zahl small { font-size: 20px; font-weight: 600; color: var(--blass); }
.riesig { font-size: 68px; }

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.35em;
  border: 2px solid currentColor;
  border-radius: 6px;
  font: inherit;
  font-size: 0.8em;
  text-align: center;
  opacity: 0.85;
}

.gesicht { border-radius: 50%; display: block; }

/* ---------- Anzeigen während des Rennens ---------- */
.tafel {
  position: absolute;
  top: 20px;
  bottom: 20px;
  width: 400px;
  padding: 24px;
  border-radius: 20px;
  background: var(--tafel);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#hud-links { left: 20px; }
#hud-rechts { right: 20px; }
#buehne.menue .tafel { display: none; }

#hud-fahrer { display: grid; gap: 10px; }
.fahrerkarte {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 8px 12px 8px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border-left: 8px solid var(--farbe);
}
.fahrerkarte .gesicht { border: 4px solid var(--farbe); }
.fahrerkarte .name { font-size: 25px; font-weight: 800; line-height: 1.15; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fahrerkarte .unter { font-size: 16px; color: var(--blass); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fahrerkarte .mitte { min-width: 0; }
.fahrerkarte .rechts { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fahrerkarte.fertig .rechts { color: var(--gold); }
.joker-marke {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  line-height: 1.4em;
  border-radius: 50%;
  border: 2px dashed var(--gold);
  color: var(--gold);
  text-align: center;
  font-size: 0.8em;
  font-weight: 900;
  font-style: italic;
}
.joker-marke.erledigt { background: var(--gold); border-style: solid; color: var(--dunkel); }
#hud-solo { display: none; flex-direction: column; gap: 14px; }
#hud-links.solo #hud-solo { display: flex; }
#hud-links.solo .fahrerkarte .rechts .runde { display: none; }
#hud-solo img { width: 100%; height: 190px; object-fit: cover; border-radius: 12px; display: block; background: #2a3242; }
.hud-werte { display: flex; justify-content: space-between; }
.regel { line-height: 1.4; }

.rundenzeiten { list-style: none; margin: 0; padding: 0; font-size: 24px; font-variant-numeric: tabular-nums; }
.rundenzeiten li { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.rundenzeiten li.beste { color: var(--gold); font-weight: 800; }

.bestenliste { list-style: none; margin: 0; padding: 0; font-size: 22px; flex: 1; overflow: hidden; }
.bestenliste li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.bestenliste .platz { color: var(--blass); font-weight: 700; }
.bestenliste .wer { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }
.bestenliste .wer small { font-weight: 400; color: var(--blass); font-size: 17px; }
.bestenliste .zeit { font-variant-numeric: tabular-nums; font-weight: 800; }
.bestenliste li:first-child .zeit { color: var(--gold); }
.bestenliste li.neu { background: rgba(255, 201, 40, 0.18); border-radius: 6px; }
.bestenliste .leer { display: block; color: var(--blass); border: 0; }

.tasten { font-size: 19px; color: var(--blass); display: grid; gap: 8px; }

#meldung {
  position: absolute;
  left: 50%;
  top: 60px;
  transform: translateX(-50%);
  padding: 10px 26px;
  border-radius: 999px;
  background: rgba(16, 21, 31, 0.92);
  border: 3px solid var(--gold);
  font-size: 30px;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#meldung.sichtbar { opacity: 1; }

#countdown {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 300px;
  font-weight: 900;
  font-style: italic;
  color: #fff;
  text-shadow: 0 8px 0 rgba(0, 0, 0, 0.45), 0 0 60px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
#countdown.sichtbar { display: flex; }

/* ---------- Start- und Zielbildschirm ---------- */
.schirm { position: absolute; inset: 0; display: none; }
.schirm.sichtbar { display: flex; }

#start {
  flex-direction: column;
  gap: 22px;
  padding: 34px 48px 40px;
  background: linear-gradient(160deg, rgba(16, 21, 31, 0.97), rgba(22, 32, 52, 0.95));
}
#start header { display: flex; align-items: center; gap: 44px; }
#start h1 {
  font-size: 96px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}
#start h1 span { color: var(--gold); margin-left: 0.12em; }
#start-gruss { font-size: 28px; line-height: 1.35; color: var(--text); max-width: 760px; }

.start-spalten { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 430px; gap: 40px; }
.auswahl { display: flex; flex-direction: column; gap: 14px; min-height: 0; --akzent: var(--gold); }
.modus { display: flex; gap: 34px; flex-wrap: wrap; }
.schalter { display: flex; align-items: center; gap: 8px; font-size: 20px; color: var(--blass); }
.schalter > span { margin-right: 4px; }
.schalter button { padding: 6px 16px; font-size: 21px; min-width: 52px; }
.schalter button.an { background: var(--text); border-color: var(--text); color: var(--dunkel); }
.reiter { display: flex; gap: 12px; }
.reiter button { border-color: var(--farbe); color: var(--farbe); }
.reiter button.an { background: var(--farbe); color: var(--dunkel); }
.reiter:empty, .versteckt { display: none !important; }
.nr {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  line-height: 1.5em;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--dunkel);
  text-align: center;
}
.karten { display: flex; flex-wrap: wrap; gap: 16px; overflow-y: auto; padding: 6px; min-height: 0; }

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  padding: 10px 20px;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: rgba(255, 255, 255, 0.16); }
button:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
button.haupt { background: var(--gold); border-color: var(--gold); color: var(--dunkel); font-size: 30px; padding: 14px 34px; }
button.haupt:hover { background: #ffd85c; }
button.warnung { background: var(--rot); border-color: var(--rot); }

.karte { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 12px; font-size: 22px; }
.karte.gewaehlt { border-color: var(--akzent); background: color-mix(in srgb, var(--akzent) 22%, transparent); box-shadow: 0 0 0 3px var(--akzent); }
.karte .marken { position: absolute; top: -8px; right: -8px; display: flex; gap: 4px; }
.marke {
  width: 30px;
  height: 30px;
  line-height: 30px;
  border-radius: 50%;
  color: var(--dunkel);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 0 0 3px var(--dunkel);
}
.karte img { width: 200px; height: 120px; object-fit: cover; border-radius: 8px; display: block; background: #2a3242; }
.karte .fehlt {
  width: 200px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 8px;
  background: #2a3242;
  color: var(--blass);
  font-size: 17px;
  font-weight: 400;
}

.start-zeile { display: flex; align-items: flex-end; gap: 22px; margin-top: auto; }
.start-zeile button.haupt { margin-left: auto; }
.start-zeile label { display: flex; flex-direction: column; gap: 6px; font-size: 18px; color: var(--blass); }
input[type="text"] {
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  width: 250px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  user-select: text;
}
input[type="text"]:focus { outline: none; border-color: var(--gold); }

.seite {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 22px 24px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.28);
}
.seite-unten { display: grid; gap: 14px; }
.seite-unten .klein { text-transform: none; letter-spacing: 0; line-height: 1.35; }
.knopfreihe { display: flex; gap: 14px; flex-wrap: wrap; }
.seite .knopfreihe button { font-size: 18px; padding: 8px 14px; }

/* Der Zieleinlauf liegt über der linken Anzeige, damit die "50" sichtbar bleibt. */
#ziel { inset: 20px auto 20px 20px; width: 400px; }
.ziel-karte {
  flex: 1;
  padding: 28px 24px;
  border-radius: 20px;
  background: rgb(16, 21, 31);
  border: 4px solid var(--gold);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}
.ziel-karte > :empty { display: none; }
.ziel-karte h1 { font-size: 50px; font-weight: 900; font-style: italic; }
#ziel-zeit { color: var(--gold); }
#ziel-rangliste { flex: 0 0 auto; text-align: left; }
#ziel-rangliste .wer small { color: var(--rot); font-weight: 700; }
#ziel-platz { font-size: 23px; font-weight: 700; line-height: 1.3; }
#ziel-gruss { font-size: 23px; line-height: 1.35; margin-top: 6px; }
.ziel-karte .knopfreihe { flex-direction: column; margin-top: auto; }
