/* --- race tracks --- */

.race-tracks {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 20px;
    width: 100%;
    max-width: 1100px;
}

.track-row {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 12px;
}

.track-row.hidden {
    display: none;
}

.track-stats {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px 32px;
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.canvas-frame {
    position: relative;
    min-width: 0;
    max-width: 100%;
    line-height: 0;
}

.canvas-wrapper canvas {
    display: block;
    width: auto;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    margin: 0;
}

.canvas-wrapper.hidden {
    display: none;
}

.canvas-label {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    background: rgba(16, 20, 42, 0.85);
    color: var(--teal);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.4;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--panel-border);
    pointer-events: none;
    display: none;
}

.race-banner {
    margin: 0;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--amber);
    min-height: 1.2em;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.race-banner.visible {
    opacity: 1;
}

#race-toggle-btn.active {
    border-color: var(--amber);
    color: var(--amber);
}

.winner-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 6;
    background: rgba(16, 20, 42, 0.9);
    color: var(--amber);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.4;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--amber);
    pointer-events: none;
    display: none;
}

.winner-badge.visible {
    display: block;
}

/* --- race mode layout --- */

#app.racing main {
    padding-right: 16px;
}

#app.racing .race-tracks {
    max-width: none;
    width: 100%;
    gap: 12px;
}

#app.racing .track-row {
    flex-direction: row;
    align-items: stretch;
    gap: 16px;
}

#app.racing .track-stats {
    flex-direction: column;
    justify-content: center;
    flex-wrap: nowrap;
    width: 220px;
    flex-shrink: 0;
    gap: 12px;
}

#app.racing .stat {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

#app.racing .stat-value {
    white-space: normal;
}

#app.racing .canvas-wrapper {
    justify-content: flex-end;
}

#app.racing .canvas-label {
    display: block;
}
