:root {
    --violet-dark: #1a052e;
    --violet: #5b21b6;
    --violet-mid: #7c3aed;
    --violet-light: #a78bfa;
    --gold: #fbbf24;
    --gold-glow: rgba(251, 191, 36, 0.45);
    --silver: #e5e7eb;
    --bronze: #f59e0b;
    --text: #faf5ff;
    --text-muted: rgba(250, 245, 255, 0.7);
    --contest-accent: #fbbf24;
    --contest-accent-glow: rgba(251, 191, 36, 0.35);
    --training-accent: #34d399;
    --training-accent-glow: rgba(52, 211, 153, 0.35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body.display {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    background: #0f031a;
    color: var(--text);
    font-family: "Segoe UI", "DejaVu Sans", "Liberation Sans", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding:
        max(1.2vh, env(safe-area-inset-top, 0px))
        max(3.5vw, env(safe-area-inset-right, 0px))
        max(1.5vh, env(safe-area-inset-bottom, 0px))
        max(3.5vw, env(safe-area-inset-left, 0px));
    gap: 0.9vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 12%, rgba(124, 58, 237, 0.55) 0%, transparent 38%),
        radial-gradient(circle at 82% 88%, rgba(91, 33, 182, 0.5) 0%, transparent 35%),
        linear-gradient(165deg, var(--violet-dark) 0%, #2d0a4e 50%, #120224 100%);
}

body.display.mode-contest {
    border-top: 5px solid var(--contest-accent);
    --display-qr-size: 168px;
    --display-qr-label-size: 0.92rem;
}

body.display.mode-training {
    border-top: 5px solid var(--training-accent);
    --display-qr-size: 108px;
    --display-qr-label-size: 0.62rem;
}

.display-tv-only {
    display: block;
}

.display-mobile-only {
    display: none;
}

.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

.highscore-banner {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 50;
    padding: max(1rem, env(safe-area-inset-top, 0px)) 4vw max(1rem, env(safe-area-inset-bottom, 0px));
    background: transparent;
}

.highscore-banner.is-visible {
    background: rgba(6, 1, 14, 0.86);
}

.highscore-banner-popup {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: min(92vw, 42rem);
    max-width: 100%;
    padding: clamp(1.5rem, 3vh, 2.5rem) clamp(1.75rem, 4vw, 3.25rem);
    text-align: center;
    border-radius: 1.35rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, transparent 40%),
        linear-gradient(180deg, rgba(28, 8, 48, 0.98) 0%, rgba(10, 2, 22, 0.98) 100%);
    border: 2px solid rgba(251, 191, 36, 0.75);
    box-shadow:
        0 0 0 1px rgba(251, 191, 36, 0.2),
        0 0 48px rgba(251, 191, 36, 0.3),
        0 0 100px rgba(91, 33, 182, 0.35),
        0 24px 60px rgba(0, 0, 0, 0.7);
    transform: scale(0.7);
    opacity: 0;
}

.highscore-banner.is-visible .highscore-banner-popup {
    animation: highscoreBannerPopup 5s ease forwards;
}

.highscore-banner-text {
    margin: 0;
    width: 100%;
    font-size: clamp(1.75rem, min(8vh, 5.5vw), 4.5rem);
    font-weight: 900;
    line-height: 1.05;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fde68a;
    text-shadow:
        0 0 28px rgba(251, 191, 36, 0.75),
        0 2px 0 rgba(120, 53, 15, 0.85),
        0 4px 16px rgba(0, 0, 0, 0.85);
}

.highscore-banner-name {
    margin: 0;
    width: 100%;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    font-size: clamp(1.2rem, min(4.5vh, 3vw), 2.5rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    color: #ffffff;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.highscore-banner-quote {
    margin: 0;
    width: 100%;
    font-size: clamp(0.95rem, min(2.8vh, 2vw), 1.5rem);
    font-weight: 700;
    font-style: italic;
    line-height: 1.25;
    letter-spacing: 0.04em;
    color: rgba(253, 230, 138, 0.92);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.highscore-banner.is-improved .highscore-banner-quote {
    color: #6ee7b7;
}

.highscore-banner.is-first .highscore-banner-quote {
    color: #d9f99d;
}

.highscore-banner.is-first .highscore-banner-text {
    color: #d9f99d;
    text-shadow:
        0 0 28px rgba(163, 230, 53, 0.65),
        0 2px 0 rgba(54, 83, 20, 0.85),
        0 4px 16px rgba(0, 0, 0, 0.85);
}

.highscore-banner.is-improved .highscore-banner-text {
    color: #6ee7b7;
    text-shadow:
        0 0 28px rgba(52, 211, 153, 0.65),
        0 2px 0 rgba(6, 78, 59, 0.85),
        0 4px 16px rgba(0, 0, 0, 0.85);
}

.highscore-banner.is-improved .highscore-banner-popup {
    border-color: rgba(52, 211, 153, 0.75);
    box-shadow:
        0 0 0 1px rgba(52, 211, 153, 0.2),
        0 0 48px rgba(52, 211, 153, 0.28),
        0 0 100px rgba(91, 33, 182, 0.35),
        0 24px 60px rgba(0, 0, 0, 0.7);
}

.highscore-banner.is-first .highscore-banner-popup {
    border-color: rgba(163, 230, 53, 0.75);
    box-shadow:
        0 0 0 1px rgba(163, 230, 53, 0.2),
        0 0 48px rgba(163, 230, 53, 0.24),
        0 0 100px rgba(91, 33, 182, 0.35),
        0 24px 60px rgba(0, 0, 0, 0.7);
}

@keyframes highscoreBannerPopup {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }

    10% {
        transform: scale(1.05);
        opacity: 1;
    }

    18% {
        transform: scale(1);
        opacity: 1;
    }

    82% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.98);
        opacity: 0;
    }
}

@keyframes highscoreBannerMobile {
    0% {
        transform: translateY(-120%);
        opacity: 0;
    }

    12% {
        transform: translateY(0);
        opacity: 1;
    }

    82% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-12%);
        opacity: 0;
    }
}

/* TV, Desktop & Querformat – zentrierter Highscore wie am Beamer */
@media (min-width: 901px), (orientation: landscape) {
    .confetti-canvas {
        z-index: 45;
    }
}

.display-stats-tv {
    position: absolute;
    top: max(1.2vh, env(safe-area-inset-top, 0px));
    left: max(3.5vw, env(safe-area-inset-left, 0px));
    z-index: 3;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: rgba(26, 5, 46, 0.72);
    border: 1px solid rgba(167, 139, 250, 0.35);
    font-size: clamp(0.72rem, 1.6vh, 0.95rem);
    letter-spacing: 0.04em;
    backdrop-filter: blur(8px);
}

.display-stats-tv-count {
    font-weight: 800;
    color: var(--violet-light);
}

.display-qr-wrap {
    position: absolute;
    top: max(1.2vh, env(safe-area-inset-top, 0px));
    right: max(3.5vw, env(safe-area-inset-right, 0px));
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem;
    border-radius: 1vh;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.display-qr {
    display: block;
    width: var(--display-qr-size, 108px) !important;
    height: var(--display-qr-size, 108px) !important;
}

.display-qr-label {
    font-size: var(--display-qr-label-size, 0.62rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1a052e;
    text-align: center;
    line-height: 1.25;
    max-width: calc(var(--display-qr-size, 108px) + 1rem);
}

body.display.mode-contest .display-qr-wrap {
    padding: 0.75rem 0.85rem;
    gap: 0.55rem;
}

.display-mode-banner {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    align-self: center;
    z-index: 1;
}

.display-mode-banner-contest {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.24), rgba(91, 33, 182, 0.2));
    border: 1px solid rgba(251, 191, 36, 0.45);
    box-shadow: 0 0 24px var(--contest-accent-glow);
}

.display-mode-banner-training {
    background: linear-gradient(90deg, rgba(52, 211, 153, 0.2), rgba(91, 33, 182, 0.2));
    border: 1px solid rgba(52, 211, 153, 0.45);
    box-shadow: 0 0 24px var(--training-accent-glow);
}

.display-mode-badge {
    font-weight: 800;
    letter-spacing: 0.14em;
    font-size: clamp(0.75rem, 1.8vh, 1rem);
}

.display-mode-banner-contest .display-mode-badge {
    color: var(--contest-accent);
}

.display-mode-banner-training .display-mode-badge {
    color: var(--training-accent);
}

.display-event-name {
    font-size: clamp(0.75rem, 1.7vh, 0.95rem);
    color: var(--text-muted);
}

.display-event-note {
    font-size: clamp(0.68rem, 1.4vh, 0.85rem);
    color: var(--text-muted);
    opacity: 0.85;
}

.display-event-note::before {
    content: '· ';
}

.display-stats-mobile {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    margin-top: 0.25rem;
}

.stat-item {
    text-align: center;
    padding: 0.75rem 0.5rem;
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

.stat-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--violet-light);
}

@keyframes flashPulse {
    0% { box-shadow: 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); }
    35% { box-shadow: 0 0 40px var(--gold-glow); transform: scale(1.015); }
    100% { box-shadow: 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); }
}

.last-entry.flash-new,
.rank-1.flash-new {
    animation: flashPulse 2s ease;
}

.glow {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(60px);
}

.glow-top {
    top: -8vh;
    left: 10vh;
    width: 40vh;
    height: 40vh;
    background: rgba(124, 58, 237, 0.35);
}

.glow-bottom {
    bottom: -10vh;
    right: 8vh;
    width: 35vh;
    height: 35vh;
    background: rgba(167, 139, 250, 0.22);
}

.display-header {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5vh;
    position: relative;
    z-index: 1;
}

.display-logo {
    width: 11vh;
    height: 11vh;
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(167, 139, 250, 0.65));
}

.titles h1 {
    font-size: clamp(2rem, 3.6vh, 3.2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(167, 139, 250, 0.75);
    line-height: 1.05;
}

.subline {
    margin-top: 0.3vh;
    font-size: clamp(0.85rem, 1.8vh, 1.2rem);
    color: var(--text-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.last-entry {
    flex: 0 0 auto;
    text-align: center;
    padding: 1vh 2vh;
    border: 2px solid rgba(167, 139, 250, 0.55);
    border-radius: 1.4vh;
    background: rgba(91, 33, 182, 0.32);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 0 40px rgba(124, 58, 237, 0.15);
    position: relative;
    z-index: 1;
}

.last-entry.empty-state {
    padding: 1.4vh 2vh;
}

.last-entry .label {
    font-size: clamp(0.75rem, 1.6vh, 1rem);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
}

.last-entry .last-name {
    font-size: clamp(1.4rem, 3.2vh, 2.4rem);
    font-weight: 700;
    margin-top: 0.2vh;
    line-height: 1.1;
}

.last-platz {
    display: block;
    margin-top: 0.4vh;
    font-size: clamp(0.75rem, 1.8vh, 1.1rem);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.last-entry .last-time {
    font-size: clamp(2rem, 5vh, 3.5rem);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 40px var(--gold-glow);
    line-height: 1;
    margin-top: 0.2vh;
}

.top-list {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.top-list h2 {
    flex: 0 0 auto;
    text-align: center;
    font-size: clamp(0.9rem, 2vh, 1.3rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 0.6vh;
    color: var(--violet-light);
}

.top-list-title-mobile {
    display: none;
}

/* TV/Desktop: genau 10 Plätze */
.top-list ol .rank:nth-child(n+11) {
    display: none;
}

.top-list ol {
    list-style: none;
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-rows: repeat(10, 1fr);
    gap: 0.45vh;
    overflow: hidden;
}

.rank {
    display: grid;
    grid-template-columns: 8vh 1fr auto;
    align-items: center;
    gap: 1.2vh;
    min-height: 0;
    padding: 0 2vh;
    border-radius: 1vh;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(167, 139, 250, 0.12);
    overflow: hidden;
}

.rank .place {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: clamp(1rem, 2.8vh, 1.8rem);
    width: clamp(2rem, 5vh, 3.2rem);
    height: clamp(2rem, 5vh, 3.2rem);
    margin: 0 auto;
    border-radius: 50%;
    line-height: 1;
}

.rank-1 .place {
    background: var(--gold);
    color: #1a052e;
    box-shadow: 0 0 16px var(--gold-glow);
}

.rank-2 .place {
    background: var(--silver);
    color: #1a052e;
}

.rank-3 .place {
    background: var(--bronze);
    color: #1a052e;
}

.rank:not(.rank-1):not(.rank-2):not(.rank-3):not(.rank-empty) .place {
    width: auto;
    height: auto;
    border-radius: 0;
    background: transparent;
    color: var(--violet-light);
    font-size: clamp(1.1rem, 3.2vh, 2rem);
}

.rank-empty .place {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border: 1px dashed rgba(167, 139, 250, 0.25);
}

.rank .name {
    font-size: clamp(1.2rem, 3.6vh, 2.2rem);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank .time {
    font-size: clamp(1.2rem, 3.6vh, 2.2rem);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    color: var(--violet-light);
    white-space: nowrap;
}

.rank-1 .name,
.rank-1 .time {
    font-size: clamp(1.35rem, 4vh, 2.5rem);
}

.rank-2 .name,
.rank-2 .time {
    font-size: clamp(1.3rem, 3.85vh, 2.35rem);
}

.rank-3 .name,
.rank-3 .time {
    font-size: clamp(1.25rem, 3.7vh, 2.25rem);
}

.rank-1 {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.28), rgba(255, 255, 255, 0.08));
    border: 2px solid var(--gold);
    box-shadow: 0 0 24px var(--gold-glow);
}

.rank-1 .time {
    color: var(--gold);
}

.rank-2 {
    background: linear-gradient(90deg, rgba(229, 231, 235, 0.2), rgba(255, 255, 255, 0.06));
    border: 2px solid var(--silver);
}

.rank-2 .time {
    color: var(--silver);
}

.rank-3 {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.22), rgba(255, 255, 255, 0.06));
    border: 2px solid var(--bronze);
}

.rank-3 .time {
    color: var(--bronze);
}

.rank-empty {
    opacity: 0.38;
    border-style: dashed;
    background: rgba(255, 255, 255, 0.02);
}

.rank-empty .name,
.rank-empty .time {
    color: var(--text-muted);
}

@media (min-width: 901px) {
    .display-header {
        margin-top: 5vh;
    }

    .top-list,
    .last-entry,
    .display-header,
    .display-mode-banner {
        position: relative;
        z-index: 1;
    }
}

.instagram-follow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.95rem 1rem;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    box-shadow: 0 8px 28px rgba(131, 58, 180, 0.5);
    transition: transform 0.15s ease;
}

.instagram-follow:active {
    transform: scale(0.98);
}

.instagram-icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.instagram-handle {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0.92;
    letter-spacing: 0.02em;
}

.mobile-footer {
    display: none;
}

/* Tablet & Mobile – scrollbar, kein Fest-Viewport */
@media (max-width: 900px), (max-width: 1024px) and (hover: none) and (pointer: coarse) {
    html {
        height: 100%;
        overflow: hidden;
    }

    html,
    body.display {
        overflow: hidden;
        height: 100%;
        min-height: 100dvh;
        width: 100%;
    }

    .screen {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        gap: 0.85rem;
        padding:
            calc(4.85rem + env(safe-area-inset-top, 0px))
            max(4vw, env(safe-area-inset-right, 0px))
            max(1.25rem, env(safe-area-inset-bottom, 0px))
            max(4vw, env(safe-area-inset-left, 0px));
    }

    .display-header,
    .display-mode-banner,
    .last-entry,
    .top-list,
    .display-stats-mobile {
        flex-shrink: 0;
    }

    .display-tv-only {
        display: none !important;
    }

    .display-mobile-only {
        display: block;
    }

    .display-stats-mobile.display-mobile-only {
        display: grid;
    }

    .mobile-footer.display-mobile-only {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        z-index: 30;
        margin-top: 0;
        padding:
            max(0.45rem, env(safe-area-inset-top, 0px))
            max(4vw, env(safe-area-inset-right, 0px))
            0.55rem
            max(4vw, env(safe-area-inset-left, 0px));
        background: rgba(15, 3, 26, 0.98);
        border-top: none;
        border-bottom: 1px solid rgba(167, 139, 250, 0.22);
        box-shadow: 0 10px 36px rgba(0, 0, 0, 0.42);
    }

    .mobile-footer .instagram-follow {
        display: flex;
        padding: 0.7rem 0.85rem;
        font-size: 0.92rem;
        border-radius: 12px;
    }

    .mobile-footer .instagram-icon {
        width: 1.35rem;
        height: 1.35rem;
    }

    .mobile-footer .instagram-handle {
        font-size: 0.72rem;
        margin-top: -0.1rem;
    }

    .confetti-canvas {
        z-index: 35;
    }

    .instagram-follow {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .instagram-handle {
        flex-basis: 100%;
        text-align: center;
        margin-top: -0.15rem;
    }

    .display-header {
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 0.85rem;
        margin-top: 0;
        padding-right: 0;
    }

    .display-logo {
        width: 56px;
        height: 56px;
        flex-shrink: 0;
    }

    .titles {
        min-width: 0;
        flex: 1;
    }

    .titles h1 {
        font-size: clamp(1rem, 4.5vw, 1.45rem);
        letter-spacing: 0.04em;
        line-height: 1.15;
    }

    .subline {
        font-size: clamp(0.68rem, 2.8vw, 0.85rem);
        letter-spacing: 0.06em;
        margin-top: 0.2rem;
    }

    .display-mode-banner {
        flex-direction: column;
        align-items: center;
        border-radius: 12px;
        width: 100%;
        align-self: stretch;
        padding: 0.65rem 0.85rem;
        gap: 0.3rem;
    }

    .display-event-name,
    .display-event-note {
        text-align: center;
    }

    .last-entry {
        padding: 1rem;
        border-radius: 14px;
    }

    .last-entry .last-name {
        font-size: clamp(1.15rem, 4.5vw, 1.6rem);
    }

    .last-entry .last-time {
        font-size: clamp(1.6rem, 7vw, 2.2rem);
    }

    .top-list {
        flex: none;
        min-height: auto;
        overflow: visible;
    }

    .top-list-title-tv {
        display: none;
    }

    .top-list-title-mobile {
        display: block;
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }

    .top-list ol {
        flex: none;
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        overflow: visible;
        min-height: auto;
        grid-template-rows: none;
    }

    .top-list ol .rank:nth-child(n+11) {
        display: grid;
    }

    .top-list ol .rank-empty {
        display: none;
    }

    .rank {
        flex-shrink: 0;
        min-height: 3.5rem;
        padding: 0.75rem 0.85rem;
        border-radius: 12px;
        grid-template-columns: 2.25rem minmax(0, 1fr) auto;
        gap: 0.65rem;
    }

    .rank .name {
        font-size: clamp(0.95rem, 4.2vw, 1.12rem);
    }

    .rank .time {
        font-size: clamp(0.9rem, 3.8vw, 1.08rem);
    }

    .rank-1 .name,
    .rank-1 .time {
        font-size: clamp(1rem, 4.5vw, 1.18rem);
    }

    .rank-2 .name,
    .rank-2 .time,
    .rank-3 .name,
    .rank-3 .time {
        font-size: clamp(0.98rem, 4.2vw, 1.12rem);
    }

    .rank .place {
        width: 2rem;
        height: 2rem;
        font-size: 0.85rem;
    }

    .rank:not(.rank-1):not(.rank-2):not(.rank-3):not(.rank-empty) .place {
        width: auto;
        height: auto;
        font-size: clamp(0.9rem, 3.8vw, 1rem);
    }

    .display-stats-mobile {
        margin-top: 0.5rem;
        gap: 0.55rem;
    }

    .stat-item {
        padding: 0.85rem 0.45rem;
        border-radius: 12px;
    }

    .stat-label {
        font-size: 0.62rem;
    }

    .stat-value {
        font-size: clamp(0.92rem, 4vw, 1.05rem);
    }
}

/* Smartphones Hochformat – Feintuning */
@media (max-width: 600px) {
    .last-entry .label {
        font-size: 0.68rem;
        letter-spacing: 0.1em;
    }

    .last-platz {
        font-size: 0.72rem;
    }

    .top-list h2 {
        font-size: 0.78rem;
        letter-spacing: 0.12em;
    }
}

/* Smartphones Querformat – kompakter */
@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
    .display-header {
        flex-direction: row;
        text-align: left;
        gap: 0.6rem;
    }

    .display-logo {
        width: 44px;
        height: 44px;
    }

    .titles h1 {
        font-size: 1rem;
    }

    .subline {
        font-size: 0.65rem;
    }

    .last-entry {
        padding: 0.45rem 0.75rem;
    }

    .last-entry .last-name {
        font-size: 1rem;
    }

    .last-entry .last-time {
        font-size: 1.35rem;
    }

    .rank {
        min-height: 2.75rem;
    }

    .rank .name,
    .rank .time {
        font-size: 0.82rem;
    }
}

/* Highscore: kompakter Toast nur Mobile Hochformat */
@media (max-width: 900px) and (orientation: portrait) {
    .highscore-banner {
        align-items: flex-start;
        justify-content: center;
        padding:
            max(0.85rem, env(safe-area-inset-top, 0px))
            max(4vw, env(safe-area-inset-right, 0px))
            0
            max(4vw, env(safe-area-inset-left, 0px));
    }

    .highscore-banner.is-visible {
        background: rgba(6, 1, 14, 0.9);
    }

    .highscore-banner-popup {
        width: min(92vw, 22rem);
        padding: 1.1rem 1.25rem 1.15rem;
        border-radius: 1rem;
        transform: translateY(-120%);
        opacity: 0;
    }

    .highscore-banner-text {
        font-size: clamp(1.25rem, 5.8vw, 1.75rem);
        letter-spacing: 0.05em;
    }

    .highscore-banner-name {
        font-size: clamp(0.95rem, 4.2vw, 1.2rem);
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .highscore-banner-quote {
        font-size: clamp(0.85rem, 3.6vw, 1.05rem);
    }

    .highscore-banner.is-visible .highscore-banner-popup {
        animation: highscoreBannerMobile 5s ease forwards;
    }
}

.display-main-content {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9vh;
    overflow: hidden;
}

.display-main-content[hidden] {
    display: none !important;
}

.challenge-overlay {
    position: relative;
    z-index: 4;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.2vh;
    padding: 2vh 4vw;
}

.challenge-overlay[hidden] {
    display: none !important;
}

.challenge-overlay-kicker {
    font-size: clamp(0.85rem, 2vh, 1.1rem);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--training-accent);
    font-weight: 700;
}

.challenge-overlay-name {
    font-size: clamp(2rem, 7vh, 4.5rem);
    font-weight: 800;
    line-height: 1.05;
    max-width: 18ch;
    text-wrap: balance;
    text-shadow: 0 0 50px var(--training-accent-glow);
}

.challenge-overlay-countdown {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5vh;
    margin-top: 1vh;
}

.challenge-overlay-prefix {
    font-size: clamp(1rem, 2.8vh, 1.6rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.challenge-overlay-timer {
    font-size: clamp(3.5rem, 14vh, 8rem);
    font-weight: 800;
    line-height: 1;
    color: var(--gold);
    text-shadow: 0 0 50px var(--gold-glow);
    font-variant-numeric: tabular-nums;
}

.screen.challenge-mode-active .display-stats-tv,
.screen.challenge-mode-active .display-qr-wrap,
.screen.challenge-mode-active .mobile-footer {
    opacity: 0;
    pointer-events: none;
}
