/* Split layout for the race-finish overlay (photo on left, content on right). */

#overlay .finish-split {
    display: flex;
    flex-direction: row;
    gap: 24px;
    align-items: stretch;
    width: min(1100px, 92vw);
    max-height: 88vh;
    padding: 16px;
    box-sizing: border-box;
}

.finish-photo-pane {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
    position: relative;
    aspect-ratio: 3 / 2;
}

.finish-photo-pane.is-empty::before {
    content: 'No finish photo';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(226, 232, 240, 0.4);
    font-family: 'Rajdhani', Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

#finish-photo-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.finish-photo-pane .finish-photo-stamp {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    background: rgba(220, 38, 38, 0.85);
    color: #fff;
    font-family: 'Rajdhani', Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-radius: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.finish-content-pane {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    overflow-y: auto;
    padding: 0 8px;
}

.finish-content-pane > #end-title { margin: 0 0 8px 0; }

/* Result overlay action row — allow multiple buttons (download/share/menu) to
   wrap on narrow viewports while staying centered under the leaderboard. */
.finish-content-pane .action-buttons {
    flex-wrap: wrap;
    justify-content: center;
}

/* Minimize button on the modal */
.finish-minimize-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    font-family: 'Rajdhani', Arial, sans-serif;
    transition: background 150ms ease-out, transform 120ms ease-out;
}
.finish-minimize-btn:hover { background: rgba(30, 41, 59, 0.95); transform: translateY(-1px); }
.finish-minimize-btn:active { transform: translateY(0); }

/* Floating thumbnail when minimized */
#finish-thumb {
    position: fixed;
    right: 14px;
    bottom: 14px;
    width: 144px;
    height: 96px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
    transition: transform 160ms ease-out, border-color 160ms ease-out;
}
#finish-thumb:hover { transform: translateY(-2px) scale(1.03); border-color: rgba(255, 255, 255, 0.5); }
#finish-thumb.hidden { display: none; }

#finish-thumb-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#finish-thumb-rank {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 8px;
    background: rgba(220, 38, 38, 0.92);
    color: #fff;
    font-family: 'Rajdhani', Arial, sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    border-radius: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

#finish-thumb-restore-hint {
    position: absolute;
    bottom: 4px;
    right: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Rajdhani', Arial, sans-serif;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

/* When minimized, hide the full overlay and let the game show through */
body.finish-minimized #overlay { display: none; }
body.finish-minimized::before { display: none !important; }

/* Mobile: stack vertically */
@media (max-width: 900px) {
    #overlay .finish-split {
        flex-direction: column;
        gap: 12px;
        max-height: 92vh;
        overflow-y: auto;
    }
    .finish-photo-pane { aspect-ratio: 16 / 10; }
    #finish-thumb { width: 120px; height: 80px; }
}
