/*
 * Leinwand der Live-Auslosung.
 * Querformat: Die Bühne füllt das ganze Fenster (16:9, 16:10 und 4:3), Maße relativ zur Bühne in cqw/cqh
 * (1 cqw = 1 % der Breite, 1 cqh = 1 % der Höhe) → passt sich jedem Beamer an, ohne Ränder.
 * Hochformat (Handy): normaler Seitenfluss, Gruppen untereinander.
 */
:root {
    --court: #0E2F6B;        /* Hallenboden-Blau, Grundfläche */
    --court-deep: #0A2454;   /* Vignette, Kartenrücken */
    --panel: #15407F;        /* Gruppenkarten */
    --line: #FFFFFF;         /* Spielfeldlinien, Text */
    --muted: #A8BEE6;        /* Nebentext auf Blau */
    --pot1: #FFD23F;         /* Topf 1: Hallenlinien-Gelb */
    --pot2: #46D9FF;         /* Topf 2: Eis-Cyan */
    --pot3: #FF8A5B;
    --pot4: #B9F27C;
    --seed: #FFFFFF;
    --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
    --text: 'Barlow', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.screen {
    background: var(--court-deep);
    color: var(--line);
    font-family: var(--text);
    display: grid;
    place-items: center;
    overflow: hidden;
}
[hidden] { display: none !important; }

.stage {
    container-type: size;
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background:
        radial-gradient(ellipse at 50% 40%, var(--court-glow, #13408A) 0%, var(--court) 55%, var(--court-deep) 100%);
    display: grid;
    grid-template-rows: 9cqh 1fr auto;
    overflow: hidden;
}
/* Mittellinie und Mittelkreis des Hallenfelds, ganz leise im Hintergrund */
.stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 52%, transparent 17cqh, rgba(255, 255, 255, .06) 17cqh, rgba(255, 255, 255, .06) calc(17cqh + 3px), transparent calc(17cqh + 3px)),
        linear-gradient(90deg, transparent calc(50% - 1.5px), rgba(255, 255, 255, .06) calc(50% - 1.5px), rgba(255, 255, 255, .06) calc(50% + 1.5px), transparent calc(50% + 1.5px));
    pointer-events: none;
}

/* ---------- Kopfzeile ---------- */
.bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1.4cqw;
    padding: 0 2.4cqw;
    border-bottom: 3px solid rgba(255, 255, 255, .85);
}
.bar-logo { height: 6.6cqh; width: auto; background: #FFFFFF; padding: .3cqh .4cqw; border-radius: .4cqw; }
.bar-title {
    margin: 0;
    font: 900 3.1cqw/1 var(--display);
    letter-spacing: .01em;
}
.bar-sub {
    margin: 0;
    font: 500 1.35cqw/1 var(--text);
    color: var(--muted);
    padding-left: 1.4cqw;
    border-left: 2px solid rgba(255, 255, 255, .35);
}
.bar-pots { margin-left: auto; display: flex; gap: 1.6cqw; }
.pot-chip {
    display: flex;
    align-items: baseline;
    gap: .6cqw;
    font: 600 1.25cqw/1 var(--text);
    color: var(--muted);
}
.pot-chip b {
    font: 900 2.2cqw/1 var(--display);
    color: var(--pot-ink, var(--pot-color, var(--line)));
}

/* ---------- Übersicht: 8 Gruppen ---------- */
.views { position: relative; min-height: 0; }
.overview, .present, .focus { position: absolute; inset: 0; }
.groups {
    height: 100%;
    display: grid;
    grid-template-columns: repeat(var(--cols, 4), 1fr);
    grid-auto-rows: 1fr;
    gap: 1.2cqw;
    padding: 1.6cqw 2.4cqw;
}
.group {
    position: relative;
    display: grid;
    grid-template-rows: auto 1fr;
    background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--panel) 55%, transparent));
    border: 2px solid rgba(255, 255, 255, .22);
    border-radius: .5cqw;
    padding: .9cqw 1.1cqw 1cqw;
    min-height: 0;
}
.group-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: .9cqw;
    padding-bottom: .6cqw;
    border-bottom: 2px solid rgba(255, 255, 255, .5);
}
.group-letter {
    font: 900 4.4cqw/0.8 var(--display);
}
.group-name {
    font: 600 1.15cqw/1.15 var(--text);
    color: var(--muted);
}
.group-sponsor { height: 3.2cqw; max-width: 7cqw; object-fit: contain; }
.slots { display: grid; grid-auto-rows: 1fr; gap: .35cqw; padding-top: .6cqw; min-height: 0; }
.slot {
    display: grid;
    grid-template-columns: 1.8cqw 2.4cqw 1fr;
    align-items: center;
    gap: .7cqw;
    padding-left: .5cqw;
    border-left: .35cqw solid var(--pot-color, var(--seed));
    min-height: 0;
}
.slot-pos { font: 800 1.4cqw/1 var(--display); color: var(--muted); }
.slot-crest { width: 2.4cqw; height: 2.4cqw; object-fit: contain; }
.slot-crest-empty {
    width: 1.5cqw; height: 1.5cqw; margin-left: .45cqw;
    border-radius: 50%;
    border: 2px dashed var(--pot-color, var(--muted));
    opacity: .7;
}
.slot-team {
    font: 800 1.55cqw/1.05 var(--display);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.slot-open { font: 500 1.05cqw/1 var(--text); color: var(--muted); opacity: .8; }
.slot-open b { font-weight: 700; color: var(--line); margin-right: .5em; }
.slot.just-placed { animation: placed-glow 2.4s ease-out 1; }
@keyframes placed-glow {
    0% { background: color-mix(in srgb, var(--pot-color, #fff) 55%, transparent); }
    100% { background: transparent; }
}

/* ---------- Vorstellung eines Teams (der große Moment) ---------- */
.present {
    display: grid;
    place-items: center;
}
.present-ball {
    position: absolute;
    width: 30cqh;
    height: 30cqh;
    border-radius: 50%;
    background:
        radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .95) 0 7%, rgba(255, 255, 255, 0) 30%),
        radial-gradient(circle at 50% 50%, var(--pot-color, #fff) 0 58%, color-mix(in srgb, var(--pot-color, #fff) 60%, #000) 100%);
    box-shadow: 0 2.4cqh 6cqh rgba(0, 0, 0, .35);
}
.present-card {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 1.2cqh;
    max-width: 80cqw;
}
.present-crest { height: 34cqh; width: auto; max-width: 40cqw; object-fit: contain; }
.present-kicker {
    margin: 0;
    font: 700 1.6cqw/1 var(--text);
    color: var(--pot-ink, var(--pot-color, var(--line)));
}
.present-name {
    margin: 0;
    font: 900 7.4cqw/0.92 var(--display);
    letter-spacing: .005em;
    text-wrap: balance;
}
.present-info { margin: 0; font: 500 1.7cqw/1.3 var(--text); color: var(--muted); max-width: 60ch; }
.present-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: .6cqw; margin-top: 1cqh; }
.free-slot {
    font: 800 1.5cqw/1 var(--display);
    padding: .45cqw .7cqw;
    border: 2px solid var(--pot-color, #fff);
    border-radius: .3cqw;
    color: var(--pot-ink, var(--pot-color, #fff));
}

/* Ablauf: Kugel rollt herein, öffnet sich, Wappen und Name erscheinen */
.present.reveal .present-ball { animation: ball-in 1.1s cubic-bezier(.2, .8, .2, 1) both, ball-open .5s ease-in 1.5s both; }
.present.reveal .present-card > * { animation: card-in .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: 1.7s; }
.present.reveal .present-card > .present-name { animation-delay: 1.85s; }
.present.reveal .present-card > .present-info,
.present.reveal .present-card > .present-slots { animation-delay: 2.05s; }
@keyframes ball-in {
    from { transform: translateX(-70cqw) rotate(-540deg); }
    to { transform: translateX(0) rotate(0); }
}
@keyframes ball-open {
    to { transform: scale(2.6); opacity: 0; }
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(3cqh) scale(.92); }
    to { opacity: 1; transform: none; }
}
.present.static .present-ball { display: none; }
.present-title { display: grid; justify-items: center; gap: 1.2cqh; }
.present-squad { margin: 0; font: 600 1.6cqw/1.2 var(--text); color: var(--muted); }
.present-squad:empty { display: none; }
.club-colors { display: flex; gap: .5cqw; }
.club-colors span { width: 3.2cqw; height: 1cqw; border-radius: .2cqw; box-shadow: 0 0 0 2px rgba(255, 255, 255, .8); background: var(--club-color); }

/* Setcard: Team mit gepflegter Vereinsseite (nach dem Vorbild der bisherigen Vorstellungsfolien) */
.present.has-profile .present-card {
    width: 92cqw;
    max-width: none;
    height: 100%;
    padding: 3cqh 0 3cqh;
    grid-template-columns: 15cqw 1fr 34cqw;
    grid-template-rows: auto minmax(0, 1fr) auto;
    box-sizing: border-box;
    grid-template-areas:
        "crest title facts"
        "photo photo facts"
        "slots slots facts";
    justify-items: start;
    align-items: start;
    text-align: left;
    gap: 2.4cqh 2cqw;
}
.present.has-profile .present-crest { grid-area: crest; height: 22cqh; max-width: 15cqw; }
.present.has-profile .present-title { grid-area: title; justify-items: start; align-self: center; gap: .8cqh; }
.present.has-profile .present-name { font-size: 5.6cqw; }
.present.has-profile .present-info { font-size: 1.6cqw; }
.present.has-profile .present-photo {
    grid-area: photo;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
    border-radius: .6cqw;
    border: 3px solid rgba(255, 255, 255, .85);
    /* Das Foto bringt keine eigene Höhe ins Raster ein: Es füllt nur den Platz, der nach Name und Infos übrig bleibt */
    contain: size;
    justify-self: stretch;
}
.present.has-profile .present-slots { grid-area: slots; justify-content: flex-start; margin: 0; }
.present-facts {
    grid-area: facts;
    align-self: stretch;
    background: rgba(255, 255, 255, .96);
    color: #13213F;
    border-radius: .6cqw;
    padding: 2.4cqh 1.8cqw;
    font: 500 1.25cqw/1.35 var(--text);
    overflow: hidden;
    contain: size;   /* langer Infotext verlängert nicht die Leinwand, sondern wird unten abgeschnitten */
    justify-self: stretch;   /* ohne eigene Größe muss der Kasten die Spalte ausfüllen */
}
.present-facts h3 { margin: 1.6cqh 0 .4cqh; font: 800 1.3cqw/1.1 var(--text); color: var(--court); }
.present-facts h3:first-child { margin-top: 0; }
.present-facts p { margin: 0 0 .4cqh; }
.present-facts ul { margin: 0; padding: 0; list-style: none; }
.present-facts li { margin: 0 0 .7cqh; }
.present-facts .fact-lead { font: 800 1.7cqw/1.15 var(--display); color: #13213F; }

/* ---------- Gruppe im Fokus (Team landet auf seinem Platz) ---------- */
.focus { display: grid; place-items: center; }
.focus-card {
    width: 62cqw;
    background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--panel) 70%, transparent));
    border: 3px solid rgba(255, 255, 255, .5);
    border-radius: .8cqw;
    padding: 2cqw 2.6cqw 2.4cqw;
    animation: focus-in .6s cubic-bezier(.2, .8, .2, 1) both;
}
.focus-card .group-head { grid-template-columns: auto 1fr auto; gap: 2cqw; padding-bottom: 1.4cqw; border-bottom-width: 3px; }
.focus-card .group-letter { font-size: 11cqw; }
.focus-card .group-name { font: 800 3cqw/1.05 var(--display); color: var(--line); }
.focus-card .group-sponsor { height: 9cqh; max-width: 16cqw; }
.focus-card .slots { gap: 1cqh; padding-top: 1.6cqh; }
.focus-card .slot { grid-template-columns: 3cqw 5cqw 1fr; gap: 1.4cqw; padding: .6cqh 0 .6cqh 1cqw; border-left-width: .5cqw; }
.focus-card .slot-pos { font-size: 2.6cqw; }
.focus-card .slot-crest { width: 5cqw; height: 5cqw; }
.focus-card .slot-crest-empty { width: 3cqw; height: 3cqw; margin-left: 1cqw; }
.focus-card .slot-team { font-size: 3.4cqw; }
.focus-card .slot-open { font-size: 1.8cqw; }
.focus-card .slot.landing { animation: landing 1.6s cubic-bezier(.2, .8, .2, 1) .35s both; }
.focus-card .slot.landing .slot-crest { animation: crest-drop .8s cubic-bezier(.3, 1.4, .5, 1) .45s both; }
/* Spiele neben der Gruppenkarte: Karte wird schmaler, Liste rechts daneben */
.focus.with-matches { grid-template-columns: 50cqw 38cqw; justify-content: center; justify-items: stretch; gap: 3cqw; }
.focus.with-matches .focus-card { width: 100%; }
.focus.with-matches .focus-card .slot-team { font-size: 2.9cqw; }
.focus-matches {
    align-self: center;
    animation: focus-in .6s cubic-bezier(.2, .8, .2, 1) .15s both;
}
.m-title { margin: 0 0 1cqh; font: 900 3.4cqw/1 var(--display); }
.m-day { margin: 2cqh 0 .8cqh; font: 700 1.5cqw/1 var(--text); color: var(--muted); }
.m-row {
    display: grid;
    grid-template-columns: 6.4cqw 1fr auto 1fr;
    align-items: baseline;
    gap: 1cqw;
    padding: 1.3cqh 1cqw;
    border-top: 1px solid rgba(255, 255, 255, .18);
}
.m-time { font: 800 2.1cqw/1 var(--display); color: var(--muted); }
.m-team, .m-open { font: 800 2.1cqw/1.1 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-open { color: var(--muted); font-weight: 600; }
.m-vs { font: 800 2.1cqw/1 var(--display); color: var(--muted); }
.m-row.hit { background: rgba(255, 255, 255, .14); border-radius: .3cqw; }
.m-row.hit .m-time { color: var(--line); }
@keyframes focus-in {
    from { opacity: 0; transform: scale(.9); }
    to { opacity: 1; transform: none; }
}
@keyframes landing {
    0% { background: color-mix(in srgb, var(--pot-color, #fff) 80%, transparent); transform: translateX(4cqw); opacity: 0; }
    30% { transform: none; opacity: 1; }
    100% { background: color-mix(in srgb, var(--pot-color, #fff) 14%, transparent); }
}
@keyframes crest-drop {
    from { transform: translateY(-8cqh) scale(1.6); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* ---------- Sponsoren ---------- */
.sponsors {
    position: relative;
    height: 10cqh;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    overflow: hidden;
}
.sponsor-track {
    display: flex;
    align-items: center;
    gap: 6cqw;
    padding-left: 3cqw;
    white-space: nowrap;
    animation: ticker var(--ticker-duration, 40s) linear infinite;
}
.sponsor-track img + img { margin-left: 0; }
.sponsor-track img { height: 6.4cqh; width: auto; max-width: 16cqw; object-fit: contain; }
/* Die Liste ist doppelt im Band: Nach der Hälfte sieht es exakt aus wie am Anfang → nahtlose Schleife */
@keyframes ticker {
    to { transform: translateX(calc(-50% - 1.5cqw)); }
}

/* ---------- Status und Bedienung ---------- */
.connection {
    position: absolute;
    left: 50%;
    bottom: 12cqh;
    transform: translateX(-50%);
    margin: 0;
    padding: .6cqw 1.2cqw;
    border-radius: .4cqw;
    background: #B3261E;
    font: 600 1.1cqw/1 var(--text);
}
.fullscreen {
    position: absolute;
    right: 1cqw;
    bottom: 1cqw;
    font: 600 .9cqw/1 var(--text);
    padding: .5cqw .8cqw;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: .3cqw;
    background: color-mix(in srgb, var(--court-deep) 80%, transparent);
    color: var(--line);
    cursor: pointer;
}
.fullscreen:focus-visible { outline: 3px solid var(--pot1); outline-offset: 2px; }
:fullscreen .fullscreen, .idle .fullscreen { display: none; }
.idle { cursor: none; }
.noscript { color: #fff; font: 600 18px/1.4 var(--text); padding: 24px; }

/* ---------- Hochformat (Handy): normaler Seitenfluss ---------- */
@media (orientation: portrait), (max-width: 720px) {
    body.screen { display: block; overflow: auto; }
    .stage {
        container-type: inline-size;
        width: 100%;
        height: auto;
        min-height: 100vh;
        grid-template-rows: auto 1fr auto;
    }
    .bar { flex-wrap: wrap; padding: 3cqw 4cqw; gap: 2cqw 3cqw; }
    .bar-logo { height: 10cqw; }
    .bar-title { font-size: 8cqw; }
    .bar-sub { font-size: 3.6cqw; border: 0; padding: 0; width: 100%; order: 3; }
    .bar-pots { margin-left: 0; order: 4; gap: 5cqw; }
    .pot-chip { font-size: 3.4cqw; gap: 1.5cqw; }
    .pot-chip b { font-size: 6cqw; }
    .overview, .present, .focus { position: static; }
    .groups { --cols: 2 !important; gap: 3cqw; padding: 4cqw; height: auto; }
    .group { padding: 2.4cqw; border-radius: 1.6cqw; }
    .group-letter { font-size: 11cqw; }
    .group-name { font-size: 3cqw; }
    .group-sponsor { height: 7cqw; max-width: 14cqw; }
    .slots { gap: 1.2cqw; padding-top: 1.6cqw; }
    .slot { grid-template-columns: 4cqw 6cqw 1fr; gap: 1.6cqw; border-left-width: 1cqw; padding: .6cqw 0 .6cqw 1.4cqw; }
    .slot-pos { font-size: 3.6cqw; }
    .slot-crest { width: 6cqw; height: 6cqw; }
    .slot-crest-empty { width: 4cqw; height: 4cqw; margin-left: 1cqw; }
    .slot-team { font-size: 4.2cqw; }
    .slot-open { font-size: 3cqw; }
    .present, .focus { padding: 8cqw 4cqw; min-height: 70vh; }
    .present-ball { width: 40cqw; height: 40cqw; }
    .present-crest { height: 40cqw; max-width: 70cqw; }
    .present-kicker { font-size: 4.4cqw; }
    .present-name { font-size: 14cqw; }
    .present-info { font-size: 4.2cqw; }
    .free-slot { font-size: 4cqw; padding: 1.2cqw 1.8cqw; }
    .present.has-profile .present-card { display: flex; flex-direction: column; width: 100%; height: auto; }
    .present.has-profile .present-crest { height: 30cqw; max-width: 50cqw; }
    .present.has-profile .present-name { font-size: 11cqw; }
    .present.has-profile .present-photo { height: auto; }
    .present-facts { font-size: 3.8cqw; padding: 4cqw; border-radius: 2cqw; width: 100%; }
    .present-facts h3 { font-size: 4cqw; }
    .present-facts .fact-lead { font-size: 5cqw; }
    .focus-card { width: 100%; padding: 4cqw; border-radius: 2cqw; }
    .focus.with-matches { display: block; }
    .focus.with-matches .focus-card .slot-team { font-size: 7cqw; }
    .focus-matches { margin-top: 6cqw; }
    .m-title { font-size: 7cqw; }
    .m-day { font-size: 3.6cqw; margin-top: 4cqw; }
    .m-row { grid-template-columns: 12cqw 1fr auto 1fr; gap: 2cqw; padding: 2cqw; }
    .m-time, .m-team, .m-open, .m-vs { font-size: 4.4cqw; }
    .focus-card .group-letter { font-size: 22cqw; }
    .focus-card .group-name { font-size: 6.4cqw; }
    .focus-card .group-sponsor { height: 14cqw; max-width: 28cqw; }
    .focus-card .slot { grid-template-columns: 6cqw 10cqw 1fr; }
    .focus-card .slot-pos { font-size: 6cqw; }
    .focus-card .slot-crest { width: 10cqw; height: 10cqw; }
    .focus-card .slot-team { font-size: 7cqw; }
    .focus-card .slot-open { font-size: 4cqw; }
    .sponsors { height: 18cqw; }
    .sponsor-track img { height: 11cqw; max-width: 34cqw; }
    .connection { position: fixed; bottom: 22cqw; font-size: 3.6cqw; padding: 2cqw 3cqw; }
    .fullscreen { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; }
    .present .present-ball { display: none; }
    .sponsor-track { animation: none; padding-left: 4cqw; flex-wrap: wrap; }
}

/* ---------- Regie: Gruppe vor der Ziehung, nächster Platz ---------- */
.focus-card .slot.next-slot { animation: next-slot 1.6s ease-in-out infinite; }
@keyframes next-slot {
    0%, 100% { background: color-mix(in srgb, var(--pot-color, #fff) 10%, transparent); }
    50% { background: color-mix(in srgb, var(--pot-color, #fff) 38%, transparent); }
}

/* ---------- Übergänge (Stinger) ---------- */
.stinger { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
.stinger-panel, .stinger-accent { position: absolute; top: -10%; bottom: -10%; left: -25%; right: -25%; transform: translateX(130%) skewX(-14deg); }
.stinger-panel { background: var(--court-deep); }
.stinger-accent { background: var(--pot1); }
.stinger-content { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2.5cqh; opacity: 0; }
.stinger-logo { background: #FFFFFF; border-radius: 1.2cqw; padding: 2.5cqh 2.5cqw; box-shadow: 0 2cqh 6cqh rgba(0, 0, 0, .35); }
.stinger-logo img { display: block; height: 32cqh; max-width: 50cqw; object-fit: contain; }
.stinger-caption { margin: 0; font: 900 4.4cqw/1 var(--display); color: #FFFFFF; }
.stinger-caption:empty { display: none; }
/* Sponsor-Variante: weiße Fläche (Sponsorlogos sind für Weiß gestaltet), Akzent in der Turnierfarbe */
.stinger.sponsor .stinger-panel { background: #FFFFFF; }
.stinger.sponsor .stinger-accent { background: var(--court); }
.stinger.sponsor .stinger-logo { background: none; box-shadow: none; padding: 0; }
.stinger.sponsor .stinger-logo img { height: 40cqh; max-width: 60cqw; }
.stinger.sponsor .stinger-caption { color: var(--court); }
.stinger.run .stinger-accent { animation: sting-sweep 1.3s cubic-bezier(.75, 0, .25, 1) both; }
.stinger.run .stinger-panel { animation: sting-sweep 1.3s cubic-bezier(.75, 0, .25, 1) .12s both; }
.stinger.run .stinger-content { animation: sting-content 1.3s ease both; }
@keyframes sting-sweep {
    0% { transform: translateX(130%) skewX(-14deg); }
    36%, 60% { transform: translateX(0) skewX(-14deg); }
    100% { transform: translateX(-135%) skewX(-14deg); }
}
@keyframes sting-content {
    0%, 26% { opacity: 0; transform: scale(.82); }
    40%, 58% { opacity: 1; transform: none; }
    72%, 100% { opacity: 0; transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) { .stinger { display: none !important; } }
