.track-viewer-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.track-viewer-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}

.track-viewer-view { min-width: 0; }
.track-viewer-lists { min-width: 0; }

/* Wide screens (16:9 / ultrawide): pin the preview on the left and let the
   track lists scroll on the right, so importing needs far less scrolling. */
@media (min-width: 1000px) {
    .track-viewer-container { max-width: 1500px; }
    .track-viewer-layout { grid-template-columns: minmax(360px, 480px) 1fr; }
    .track-viewer-view { position: sticky; top: 16px; }
}

.track-section { margin-bottom: 8px; }
.track-section h2 {
    color: #fff;
    font-size: 1.15rem;
    margin: 4px 0 6px;
}

.track-viewer-header {
    text-align: center;
    margin-bottom: 20px;
}

.track-viewer-header h1 {
    color: #fff;
}

.track-viewer-header p {
    color: #aaa;
}

.track-selector {
    margin-bottom: 20px;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 8px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.track-selector label {
    color: #fff;
}

.track-selector select,
.track-selector input[type="file"] {
    padding: 8px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #333;
    color: #fff;
}

.track-selector select {
    min-width: 200px;
}

.track-selector span {
    color: #888;
}

#track-canvas {
    display: block;
    margin: 0 auto;
    border: 3px solid #444;
    background: #000;
    image-rendering: pixelated;
    max-width: 100%;
    height: auto;
}

.track-viewer-hint {
    text-align: center;
    color: #888;
    font-size: 0.9em;
    margin-top: 10px;
}

.tropical-scenery { border-color: #2e7d32 !important; }
.desert-scenery { border-color: #d4a017 !important; }
.alpine-scenery { border-color: #5c6bc0 !important; }
.city-scenery { border-color: #78909c !important; }
.country-scenery { border-color: #8d6e63 !important; }

.track-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.track-list-item {
    padding: 12px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    color: #ccc;
}

.track-list-item:hover {
    background: #3a3a3a;
    border-color: #666;
}

.track-list-item.selected {
    background: #2e7d32;
    border-color: #4caf50;
    color: #fff;
}

/* The last track previewed (from the portal/archive importer): keep it obvious
   so the matching Import button is easy to find. */
.track-list-item.viewed {
    background: #3d3520;
    border-color: #ffd54f;
    box-shadow: 0 0 0 2px #ffd54f;
    color: #fff;
}

.archive-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
    grid-column: 1 / -1;
}

.archive-page-info {
    color: #aaa;
    font-size: 0.9em;
}

.archive-page-input {
    width: 64px;
    padding: 4px 6px;
    background: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    text-align: center;
}

/* Fixed-height scroll area so switching archive pages never reflows the page. */
#archiveList {
    height: 60vh;
    overflow-y: auto;
    align-content: start;
}

.archive-pager {
    margin-top: 10px;
}

/* All-time high scores under the map in the track viewer. */
.track-highscores {
    margin-top: 12px;
    text-align: left;
    color: #ccc;
}
.track-highscores h4 {
    color: #fff;
    margin-bottom: 4px;
}
.track-highscores ol {
    margin: 0;
    padding-left: 1.4rem;
}
.track-highscores li {
    margin: 2px 0;
}
.track-highscores .hs-time {
    font-family: monospace;
    color: #ffd54f;
}

/* Metadata badges in the track library list */
.track-list-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.track-list-item .track-name {
    font-weight: 600;
    line-height: 1.2;
    word-break: break-all;
}
.track-list-item .track-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #9a9a9a;
    white-space: nowrap;
}
.surface-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #777;
    display: inline-block;
    flex: 0 0 auto;
}
.surface-dot.surface-paved { background: #cfcfcf; }
.surface-dot.surface-dirt { background: #9c6438; }
.surface-dot.surface-ice { background: #9cfcfc; }
.surface-dot.surface-mixed { background: #fc9c00; }
.surface-dot.surface-unknown { background: #555; }
