/* Stylesheet for the top-down city racing game.
   Layout: HUD on top, canvas stage with leaderboard side panel.
   Designed dark, retro-arcade adjacent. Mobile-friendly down to ~320px. */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #0e1116;
    color: #e8eef5;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow: hidden;
}

a {
    color: #ffd166;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 4px 10px 4px;
    background: linear-gradient(180deg, rgba(10, 13, 18, 0.18), rgba(10, 13, 18, 0.06) 80%, rgba(10, 13, 18, 0));
    z-index: 5;
    pointer-events: none;
}

.hud-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    pointer-events: auto;
}

.hud-top {
    margin-bottom: 2px;
}

.hud-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    font-size: 22px;
    filter: drop-shadow(0 0 6px rgba(255, 210, 80, 0.4));
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    pointer-events: auto;
    color: inherit;
    line-height: 1;
}
.brand-mark:hover { transform: scale(1.08); }

.liga-link {
    color: #8a93a3;
    pointer-events: auto;
}
.liga-link:hover { color: #ffd166; }

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.02em;
}

.brand-title-paren {
    color: #ffd166;
    font-weight: 600;
    margin-left: 1px;
}

.brand-byline {
    font-size: 11px;
    color: #8a93a3;
}

.audio-toggle {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(20, 26, 36, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #c8d2e0;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.audio-toggle:hover {
    background: rgba(40, 52, 68, 0.85);
}

.audio-toggle.is-on {
    background: rgba(109, 213, 179, 0.16);
    border-color: rgba(109, 213, 179, 0.45);
    color: #b9f0d8;
}

.audio-icon {
    font-size: 14px;
    line-height: 1;
}

@media (max-width: 540px) {
    .audio-label { display: none; }
    .audio-toggle { padding: 6px 8px; }
}

.hud-lap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.1;
}

.lap-label {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 10px;
    color: #8a93a3;
}

.lap-value {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: 0.02em;
}

.lap-sep {
    color: #4a5260;
    margin: 0 2px;
}

.hud-mid {
    align-items: stretch;
    gap: 12px;
    flex-wrap: wrap;
}

.metric-banner {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 10px;
    row-gap: 0;
    align-items: baseline;
    background: rgba(20, 26, 36, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 6px;
    min-width: 0;
    flex: 1 1 220px;
}

.metric-kicker {
    grid-column: 1;
    grid-row: 1;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 9px;
    color: #8a93a3;
}

.metric-name {
    grid-column: 1;
    grid-row: 2;
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.15;
}

.metric-direction {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    font-size: 10px;
    color: #ffd166;
}

.share-pill {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: center;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #c8d2e0;
    padding: 2px 7px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.18s, border-color 0.18s;
}
.share-pill:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
}

.commentary {
    flex: 2 1 280px;
    background: rgba(20, 26, 36, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #c8d2e0;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#track {
    display: block;
    width: 100%;
    height: 100%;
}

.leaderboard {
    position: absolute;
    top: 96px;
    right: 12px;
    width: 270px;
    max-height: calc(100% - 120px);
    overflow: hidden;
    background: rgba(20, 26, 36, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(2px);
    box-shadow: none;
    z-index: 4;
    display: flex;
    flex-direction: column;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.leaderboard-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    /* Reset native button styling so the header looks the same as before */
    background: transparent;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    color: inherit;
    font: inherit;
    width: 100%;
    cursor: pointer;
    text-align: left;
    pointer-events: auto;
}

.leaderboard-caret {
    margin-left: auto;
    font-size: 12px;
    color: #8a93a3;
    transition: transform 0.2s ease;
    /* Caret is mostly an affordance for mobile collapse — hidden on wider
       layouts where the panel always shows the full list. */
    display: none;
}

/* Rotate caret when collapsed (▾ → ▸ visually). */
.leaderboard.is-collapsed .leaderboard-caret {
    transform: rotate(-90deg);
}

.leaderboard-header span:first-child {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 11px;
    color: #c8d2e0;
}

.leaderboard-hint {
    font-size: 10px;
    color: #ffd166;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    overflow-y: auto;
}

.leaderboard-list li {
    display: grid;
    grid-template-columns: 44px 20px auto auto;
    align-items: center;
    column-gap: 0;
    padding: 3px 8px;
    font-size: 12px;
    transition: background 0.2s ease, transform 0.25s ease;
}

.leaderboard-list li > .emblem {
    margin-left: 2px;
}

.leaderboard-list li > .city {
    margin-left: 4px;
}

.leaderboard-list li > .delta {
    margin-left: 6px;
}

.leaderboard-list li.is-leader {
    background: linear-gradient(90deg, rgba(255, 209, 102, 0.08), transparent);
}

/* Brief flash on the climber (green) and the passed car (red) when they
   swap positions. The animation fades back to transparent on its own. */
.leaderboard-list li.is-climbing {
    animation: poredakClimb 1500ms ease-out;
}

.leaderboard-list li.is-dropping {
    animation: poredakDrop 1500ms ease-out;
}

@keyframes poredakClimb {
    0%   { background: rgba(76, 222, 168, 0.55); }
    60%  { background: rgba(76, 222, 168, 0.30); }
    100% { background: transparent; }
}

@keyframes poredakDrop {
    0%   { background: rgba(255, 99, 99, 0.55); }
    60%  { background: rgba(255, 99, 99, 0.30); }
    100% { background: transparent; }
}

.leaderboard-list li .rank {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: #8a93a3;
    text-align: left;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: baseline;
    white-space: nowrap;
}

.leaderboard-list li.is-leader .rank {
    color: #ffd166;
}

.leaderboard-list .from-rank {
    font-size: 10px;
    font-weight: 500;
    color: #8a93a3;
    /* Reserved width — always present so adding/removing the bracket never
       shifts row width. Empty cell still occupies the same space. */
    display: inline-block;
    min-width: 22px;
    margin-left: 0;
    text-align: left;
}

.leaderboard-list li .emblem {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    object-fit: contain;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-list li .city {
    color: #e8eef5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-list li .delta {
    font-size: 11px;
    color: #8a93a3;
    font-variant-numeric: tabular-nums;
    text-align: right;
    justify-self: end;
    transition: color 0.5s ease;
}

/* Gap-trend tinting: green = catching the car above, red = falling behind.
   Two shades per side based on how fast the gap is changing. */
.leaderboard-list li .delta.gap-shrink       { color: #6dd5b3; }
.leaderboard-list li .delta.gap-shrink-strong { color: #2bd49b; font-weight: 600; }
.leaderboard-list li .delta.gap-grow         { color: #e08585; }
.leaderboard-list li .delta.gap-grow-strong  { color: #ff6363; font-weight: 600; }

.lap-card {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.35s ease;
    padding: 0 16px;
}

.lap-card.is-visible {
    opacity: 1;
}

.lap-card-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(10, 13, 18, 0.62), rgba(10, 13, 18, 0.25) 60%, transparent 80%);
}

.lap-card-content {
    position: relative;
    width: min(520px, 100%);
    background: rgba(15, 19, 26, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 22px 26px;
    text-align: center;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}

.lap-card-kicker {
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 11px;
    color: #ffd166;
    margin-bottom: 8px;
}

.lap-card-title {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 800;
    font-size: 30px;
    line-height: 1.1;
    margin-bottom: 8px;
}

.lap-card-desc {
    font-size: 14px;
    color: #c8d2e0;
    margin-bottom: 14px;
    line-height: 1.4;
}

.lap-card-meta {
    margin-bottom: 14px;
}

/* Live transcript of the spoken intro — typed out at the audio's pace so
   sound-off players can read along. Hidden until the first character lands. */
.lap-card-spoken {
    font-size: 13px;
    line-height: 1.4;
    color: #c8d2e0;
    margin-bottom: 14px;
    min-height: 1.4em;
    white-space: pre-wrap;
}
.lap-card-spoken:empty { margin-bottom: 0; min-height: 0; }
.lap-card-spoken::after {
    content: '▏';
    color: #ffd166;
    margin-left: 1px;
    animation: caret-blink 1s steps(2) infinite;
}
.lap-card-spoken:empty::after,
.lap-card-spoken.is-done::after { content: ''; }
@keyframes caret-blink {
    50% { opacity: 0; }
}

.lap-card-direction {
    display: inline-block;
    background: rgba(255, 209, 102, 0.14);
    color: #ffd166;
    border: 1px solid rgba(255, 209, 102, 0.32);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.lap-card-countdown {
    margin-top: 6px;
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 800;
    font-size: 56px;
    color: #ffd166;
    text-shadow: 0 0 24px rgba(255, 209, 102, 0.42);
    line-height: 1;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lap-card-countdown.is-go {
    color: #6dd5b3;
    text-shadow: 0 0 24px rgba(109, 213, 179, 0.45);
    letter-spacing: 0.04em;
}

.lap-card-countdown.is-pulse {
    animation: countdownPulse 0.6s ease-out;
}

@keyframes countdownPulse {
    0% { transform: scale(1.7); opacity: 0; }
    35% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.results-podium {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    text-align: left;
}

.results-podium li {
    display: grid;
    grid-template-columns: 28px 24px 1fr auto;
    gap: 10px;
    padding: 6px 10px;
    align-items: center;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 4px;
}

.results-podium li.podium-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.18), transparent);
    color: #ffe487;
}
.results-podium li.podium-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.13), transparent);
}
.results-podium li.podium-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.16), transparent);
}

.podium-pos {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 800;
    font-size: 18px;
    text-align: center;
}

.podium-emblem {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    object-fit: contain;
}

.podium-value {
    font-variant-numeric: tabular-nums;
    color: #c8d2e0;
}

/* Expand button + full-poredak table on the results card. */
.results-expand {
    pointer-events: auto;
    margin-top: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #c8d2e0;
    padding: 5px 12px;
    border-radius: 999px;
    cursor: pointer;
    font: 600 11px 'Bricolage Grotesque', sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.results-expand:hover { background: rgba(255, 255, 255, 0.08); }
.results-expand-caret { font-size: 11px; transition: transform 0.2s ease; }
.results-expand[aria-expanded="true"] .results-expand-caret { transform: rotate(180deg); }
.results-expand[aria-expanded="true"] .results-expand-label::after { content: ' (zatvori)'; opacity: 0.6; }

.results-full {
    margin-top: 12px;
    text-align: left;
    /* The whole lap-card uses `pointer-events: none` so race clicks pass
       through to the canvas. The expanded poredak needs to capture pointer
       events so the user can scroll it and select / copy text out of it. */
    pointer-events: auto;
    user-select: text;
}

.results-full * {
    user-select: text;
}

.results-full-head,
.results-full-list li {
    display: grid;
    grid-template-columns: 24px 1fr auto auto auto;
    column-gap: 10px;
    align-items: center;
    padding: 4px 8px;
    font-variant-numeric: tabular-nums;
}

.results-full-head {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #6f7886;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 6px;
}

.results-full-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 36vh;
    overflow-y: auto;
}

.results-full-list li {
    font-size: 12px;
    color: #e8eef5;
    border-radius: 4px;
}
.results-full-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }

.results-full-list .rf-pos { color: #8a93a3; font-weight: 700; text-align: right; }
.results-full-list .rf-city {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.results-full-list .rf-city-emblem {
    width: 16px; height: 16px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    object-fit: contain;
}
.results-full-list .rf-stat { color: #c8d2e0; font-size: 11px; }
.results-full-list .rf-change { font-weight: 600; min-width: 38px; text-align: right; }
.results-full-list .rf-improv {
    color: #8a93a3;
    font-size: 11px;
    min-width: 56px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Coloured shades for both Δ pos. and Promjena columns — green = good
   direction (gained position / stat moved the better way), red = bad. */
.results-full-list .rf-change.up,        .results-full-list .rf-improv.up        { color: #6dd5b3; }
.results-full-list .rf-change.up-strong, .results-full-list .rf-improv.up-strong { color: #2bd49b; font-weight: 600; }
.results-full-list .rf-change.dn,        .results-full-list .rf-improv.dn        { color: #e08585; }
.results-full-list .rf-change.dn-strong, .results-full-list .rf-improv.dn-strong { color: #ff6363; font-weight: 600; }
.results-full-list .rf-change.flat,      .results-full-list .rf-improv.flat      { color: #5a626f; }

.lap-card-mover {
    margin-top: 12px;
    font-size: 13px;
    color: #c8d2e0;
}

.lap-card-mover strong {
    color: #6dd5b3;
}

.lap-card-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
}

.lap-card-section-title {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 10px;
    color: #8a93a3;
    margin-bottom: 8px;
}

.championship-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.championship-list li {
    display: grid;
    grid-template-columns: 22px 22px 1fr 36px;
    gap: 8px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 5px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.03);
}

.championship-list li.is-leader {
    background: linear-gradient(90deg, rgba(255, 209, 102, 0.18), transparent);
    color: #ffe487;
}

.championship-list .ch-rank {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 700;
    color: #8a93a3;
    text-align: right;
}

.championship-list li.is-leader .ch-rank {
    color: #ffd166;
}

.championship-list .ch-emblem {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    object-fit: contain;
}

.championship-list .ch-points {
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: #c8d2e0;
    font-weight: 700;
}

.championship-list .ch-delta {
    font-size: 10px;
    margin-left: 4px;
    color: #6dd5b3;
}

.lap-card--results.is-finale .lap-card-content {
    border-color: rgba(255, 209, 102, 0.45);
    box-shadow: 0 22px 60px rgba(255, 209, 102, 0.18), 0 22px 60px rgba(0, 0, 0, 0.55);
}

/* Action row at the bottom of the results card: replay + next-race buttons. */
.results-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
    justify-content: center;
}

.results-btn {
    pointer-events: auto;
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #f4f6fb;
    padding: 10px 18px;
    border-radius: 999px;
    font: 600 13px 'Bricolage Grotesque', sans-serif;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.results-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.32);
}

.results-btn:active {
    transform: translateY(1px);
}

.results-btn--primary {
    background: linear-gradient(135deg, #ffd166 0%, #ff9f1c 100%);
    color: #1a1300;
    border-color: transparent;
}

.results-btn--primary:hover {
    background: linear-gradient(135deg, #ffdc8a 0%, #ffb347 100%);
}

.btn-countdown {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    padding: 2px 8px;
    min-width: 22px;
    text-align: center;
}

.btn-countdown:empty {
    display: none;
}

@media (max-width: 540px) {
    .lap-card-title {
        font-size: 22px;
    }
    .lap-card-countdown {
        font-size: 44px;
        min-height: 44px;
    }
    .lap-card-content {
        padding: 16px 18px;
    }
    .results-podium li {
        font-size: 12px;
        grid-template-columns: 24px 22px 1fr auto;
    }
}

.loader {
    position: fixed;
    inset: 0;
    background: rgba(10, 13, 18, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 10;
    transition: opacity 0.4s ease;
}

.loader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: #ffd166;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-weight: 700;
    font-size: 16px;
}

.loader-detail {
    font-size: 12px;
    color: #8a93a3;
    text-align: center;
    max-width: 320px;
}

.error {
    position: fixed;
    inset: 50% 16px auto 16px;
    transform: translateY(-50%);
    background: #2a1414;
    border: 1px solid #ff6b6b;
    color: #ffd6d6;
    padding: 16px 18px;
    border-radius: 10px;
    z-index: 11;
    max-width: 480px;
    margin: 0 auto;
}

.error strong {
    display: block;
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-size: 16px;
    margin-bottom: 6px;
}

.error p {
    margin: 0;
    font-size: 13px;
}

@media (max-width: 720px) {
    .leaderboard {
        width: 220px;
    }
    .metric-name {
        font-size: 14px;
    }
}

@media (max-width: 540px) {
    .hud { padding: 3px 6px 3px; }
    .hud-row { gap: 8px; }
    .hud-top { margin-bottom: 1px; }
    .brand-mark { font-size: 18px; }
    .brand-title { font-size: 15px; }
    .brand-byline { display: none; }
    .lap-label { font-size: 9px; letter-spacing: 0.14em; }
    .lap-value { font-size: 16px; }
    .metric-banner {
        padding: 3px 7px;
        flex-basis: 160px;
        column-gap: 6px;
    }
    .metric-name { font-size: 13px; }
    .metric-direction { font-size: 9px; }
    .commentary { font-size: 11px; padding: 3px 8px; }

    .leaderboard {
        position: absolute;
        top: auto;
        bottom: 6px;
        right: 6px;
        left: 6px;
        width: auto;
        max-height: 56vh;
        /* Float over the track instead of pushing it up; very translucent so
           the track shows through. */
        background: rgba(14, 18, 26, 0.42);
        border: 1px solid rgba(255, 255, 255, 0.06);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }
    .leaderboard-caret { display: inline-block; }
    /* Collapsed mobile state: keep the header + first 3 rows visible. */
    .leaderboard.is-collapsed .leaderboard-list li:nth-child(n+4) {
        display: none;
    }
    .leaderboard-list li {
        grid-template-columns: 36px 18px auto auto;
        font-size: 11px;
        padding: 2px 8px;
    }
    .leaderboard-list li > .city { margin-left: 3px; }
    .leaderboard-list li > .delta { margin-left: 4px; font-size: 10px; }
    .leaderboard-list li .rank { font-size: 12px; }
    .leaderboard-list .from-rank { min-width: 18px; font-size: 9px; }
    .leaderboard-list li .emblem { width: 16px; height: 16px; }
    .leaderboard-header { padding: 6px 8px; }

    .lap-card-content { padding: 14px 14px; }
    .lap-card-title { font-size: 18px; }
    .lap-card-desc { font-size: 12px; }
    .lap-card-countdown { font-size: 40px; }
    .results-actions { gap: 6px; margin-top: 12px; }
    .results-btn { padding: 8px 12px; font-size: 11px; }

    /* When the user expands "Cijeli poredak" on mobile, blow the results
       card up to full screen and let the whole content area scroll
       vertically (instead of an inner-scroll on the list, which is
       awkward on touch with a bounded outer card). */
    .lap-card--results:has(#btn-expand-poredak[aria-expanded="true"]) {
        align-items: stretch;
        padding: 0;
    }
    .lap-card--results:has(#btn-expand-poredak[aria-expanded="true"]) .lap-card-content {
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        overflow-y: auto;
        border-radius: 0;
        border: 0;
        padding: 16px 14px 24px;
        -webkit-overflow-scrolling: touch;
    }
    .lap-card--results:has(#btn-expand-poredak[aria-expanded="true"]) .results-full-list {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 380px) {
    .brand-mark { font-size: 16px; }
    .brand-title { font-size: 13px; }
    .lap-value { font-size: 14px; }
    .lap-label { font-size: 8px; }
    .metric-name { font-size: 12px; }
}

/* About modal — opens when the chequered flag in the HUD is clicked. */
.about-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 10, 14, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
/* `display: flex` above overrides the [hidden] UA rule, so the modal stays
   visible. Restore the toggle by explicitly hiding when the attribute is set. */
.about-overlay[hidden] { display: none; }
.about-card {
    pointer-events: auto;
    background: #161a23;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 22px 22px 18px;
    max-width: 420px;
    width: 100%;
    color: #e8eef5;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}
.about-card p { margin: 8px 0; }
.about-title {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-size: 20px;
    margin: 0 0 12px;
    color: #ffd166;
}
.about-card a { color: #ffd166; }
.about-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: transparent;
    border: 0;
    color: #8a93a3;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.about-close:hover { color: #fff; }

/* Briefly-shown "Kopirano!" toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(20, 26, 36, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e8eef5;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12px;
    z-index: 60;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}
.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.results-btn--ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.18);
}
