/* ==========================================================================
   AoE2 Replay Visualizer — themed to match the main site (apps/website).
   Tokens mirror base.css: LIGHT is the default (:root); DARK is opt-in via
   [data-theme="dark"] on <html> (synced from the parent site's theme toggle
   via localStorage in index.html). The map playfield stays dark (it's the
   "screen"); all surrounding chrome uses the parchment / gold design system.
   ========================================================================== */

/* ---------- LIGHT MODE (default) ---------- */
:root {
    /* Backgrounds / surfaces — warm parchment */
    --bg-deep:          #efe9dc;
    --bg:               #f6f1e7;
    --bg-warm:          #ece4d4;
    --bg-hover:         #e1d7c4;
    --surface-elevated: #fbf7ee;

    /* Borders */
    --border:           #c9bda3;
    --border-light:     #b7a986;

    /* Text */
    --text:             #241d10;
    --text-muted:       #5f5235;
    --text-dim:         #6f6346;

    /* Gold accent */
    --gold:             #7a5c0c;
    --gold-light:       #a07e1f;
    --gold-dark:        #6b4f0e;
    --gold-tint:        rgba(138, 106, 18, 0.10);
    --gold-cta:         #a37d15;
    --text-on-gold:     #1a1408;

    /* Tamed strength scale */
    --strong:           #2f6b34;
    --weak:             #9a5a17;
    --poor:             #9e2b22;
    --strong-tint:      rgba(47, 107, 52, 0.14);
    --weak-tint:        rgba(154, 90, 23, 0.14);
    --poor-tint:        rgba(158, 43, 34, 0.14);

    /* Team identity / age accents */
    --team1:            #a23226;
    --team2:            #1c6796;

    /* Game map playfield (intentionally dark in both themes) */
    --map-bg:           #0d1b0d;
    /* Translucent panel that floats over the dark map */
    --map-hud:          rgba(251, 247, 238, 0.92);

    /* Typography */
    --font-display:     "Cinzel", Georgia, serif;
    --font-body:        "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono:        "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

    /* Shadows */
    --shadow-sm:        0 2px 8px rgba(0, 0, 0, 0.10);
    --shadow-card:      0 2px 10px rgba(0, 0, 0, 0.12);
}

/* ---------- DARK MODE (opt-in, synced from parent) ---------- */
[data-theme="dark"] {
    --bg-deep:          #120d07;
    --bg:               #1e1610;
    --bg-warm:          #2a1f14;
    --bg-hover:         #342618;
    --surface-elevated: #251c12;

    --border:           #3d2e1e;
    --border-light:     #5a4228;

    --text:             #ece1cd;
    --text-muted:       #b3a484;
    --text-dim:         #8c7c5e;

    --gold:             #cdac50;
    --gold-light:       #ddbd66;
    --gold-dark:        #8b6914;
    --gold-tint:        rgba(205, 172, 80, 0.14);
    --gold-cta:         #cdac50;
    --text-on-gold:     #1a1408;

    --strong:           #6fb15e;
    --weak:             #cf9a4a;
    --poor:             #cf6a5e;
    --strong-tint:      rgba(111, 177, 94, 0.16);
    --weak-tint:        rgba(207, 154, 74, 0.16);
    --poor-tint:        rgba(207, 106, 94, 0.16);

    --team1:            #cf5a4b;
    --team2:            #4a9fd4;

    --map-bg:           #0d1b0d;
    --map-hud:          rgba(37, 28, 18, 0.92);

    --shadow-sm:        0 2px 8px rgba(0, 0, 0, 0.22);
    --shadow-card:      0 2px 10px rgba(0, 0, 0, 0.28);
}

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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* dvh excludes the mobile address bar so the bottom controls stay on-screen */
    padding: 10px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-warm);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

header h1 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.01em;
}

#match-info {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Map Container - Takes all available space (playfield stays dark) */
.map-container {
    position: relative;
    background-color: var(--map-bg);
    border: 2px solid var(--border-light);
    border-radius: 10px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

#map-canvas {
    cursor: grab;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none; /* let JS handle finger pan/pinch instead of the browser scrolling */
}

#map-canvas:active {
    cursor: grabbing;
}

.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: var(--map-hud);
    border: 1px solid var(--border-light);
    padding: 8px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.zoom-controls button {
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border: 1px solid var(--border-light);
    background: var(--surface-elevated);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.zoom-controls button:hover {
    background: var(--bg-hover);
}

#zoom-level {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Controls Panel - Fixed at bottom */
.controls-panel {
    background: var(--bg-warm);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 15px;
    margin-top: 10px;
    flex-shrink: 0;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.playback-controls button {
    padding: 6px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--border-light);
    background: var(--surface-elevated);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.playback-controls button:hover {
    background: var(--bg-hover);
    border-color: var(--gold-light);
}

#btn-play {
    background: var(--strong);
    border-color: var(--strong);
    color: #fff;
    min-width: 70px;
    font-weight: 600;
}

#btn-play:hover {
    background: var(--strong);
    filter: brightness(1.08);
}

#btn-play.playing {
    background: var(--poor);
    border-color: var(--poor);
}

#btn-play.playing:hover {
    background: var(--poor);
    filter: brightness(1.08);
}

.time-display {
    margin-left: 15px;
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--gold);
}

.speed-controls {
    margin-left: auto;
    display: flex;
    gap: 5px;
}

.speed-btn {
    padding: 5px 10px !important;
    font-size: 0.8rem !important;
    background: var(--surface-elevated) !important;
    color: var(--text) !important;
    border: 1px solid var(--border-light) !important;
}

.speed-btn.active {
    background: var(--gold-cta) !important;
    border-color: var(--gold-cta) !important;
    color: var(--text-on-gold) !important;
    font-weight: 600;
}

.timeline-container {
    width: 100%;
}

#timeline {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-hover);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

#timeline::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--gold-cta);
    border-radius: 50%;
    cursor: pointer;
}

#timeline::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--gold-cta);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Info Panel - Overlay on map */
.info-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10;
    max-width: 250px;
}

.player-legend {
    background: var(--map-hud);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

.player-legend h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 8px;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.8rem;
    color: var(--text);
}

.player-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.player-item label {
    cursor: pointer;
    flex: 1;
}

.player-item input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--gold-cta);
}

.team-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.team-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Player Tracker - Production rates panel */
.player-tracker-container {
    background: var(--map-hud);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    max-height: 350px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.player-tracker-container h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 8px;
}

.player-tracker {
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text);
}

.tracker-header {
    display: grid;
    grid-template-columns: 1fr 70px 70px;
    gap: 8px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* "Mil/min" header: neutral unit sprite + label, right-aligned to match the
   numeric column below it. The sprite sits in a FIXED 16x16 box with
   object-fit: contain so an off-shape figure is letterboxed inside the box
   (never cropped, never overflowing). 16px < the 70px column and < the row's
   text line, so it cannot bleed into the Vill/min column or the rows. */
.tracker-mil-head {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.tracker-mil-icon {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    object-fit: contain;
    padding: 1px;
    box-sizing: border-box;
}

.tracker-row {
    display: grid;
    grid-template-columns: 1fr 70px 70px;
    gap: 8px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
}

.tracker-row:hover {
    background: var(--gold-tint);
}

.tracker-player {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracker-rate {
    text-align: right;
}

.rate-top {
    color: var(--strong);
}

.rate-top-1 {
    color: var(--strong);
    font-weight: bold;
}

.rate-bottom {
    color: var(--poor);
}

.rate-bottom-1 {
    color: var(--poor);
    font-weight: bold;
}

/* Technology Tracker Panel - Right side */
.tech-panel {
    position: absolute;
    top: 10px;
    right: 50px;
    background: var(--map-hud);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.tech-panel h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 8px;
}

.tech-tracker {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: var(--text);
}

.tech-team-section {
    min-width: 200px;
}

.tech-team-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.tech-player-row {
    margin-bottom: 8px;
}

.tech-player-name {
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.tech-player-age {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-muted);
}

.tech-player-age.feudal {
    background: var(--strong-tint);
    color: var(--strong);
}

.tech-player-age.castle {
    background: var(--gold-tint);
    color: var(--gold);
}

.tech-player-age.imperial {
    background: var(--weak-tint);
    color: var(--weak);
}

.tech-list {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding-left: 4px;
    min-height: 75px; /* Space for 5 tech items */
}

.tech-item {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
    line-height: 1.3;
}

.tech-name {
    color: var(--text);
}

.tech-time {
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Player age badge in legend */
.player-age-badge {
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 2px;
    background: var(--bg-hover);
    color: var(--text-muted);
    margin-left: 4px;
}

.player-age-badge.dark {
    background: var(--bg-hover);
    color: var(--text-dim);
}

.player-age-badge.feudal {
    background: var(--strong-tint);
    color: var(--strong);
}

.player-age-badge.castle {
    background: var(--gold-tint);
    color: var(--gold);
}

.player-age-badge.imperial {
    background: var(--weak-tint);
    color: var(--weak);
}

/* Story Captions */
.captions-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
    max-width: 80%;
}

.caption {
    background: var(--map-hud);
    border: 1px solid var(--border-light);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    text-align: center;
    box-shadow: var(--shadow-card);
    animation: captionFadeIn 0.3s ease-out;
    max-width: 600px;
}

.caption.fading {
    animation: captionFadeOut 0.5s ease-out forwards;
}

.caption .player-name {
    font-weight: 600;
    color: var(--gold);
}

@keyframes captionFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes captionFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Loading overlay (old) */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: var(--gold);
    z-index: 1000;
}

/* Browse / secondary buttons */
.browse-btn,
.upload-btn {
    background: var(--surface-elevated);
    color: var(--text);
    padding: 6px 14px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
}

.browse-btn:hover,
.upload-btn:hover {
    background: var(--bg-hover);
    border-color: var(--gold-light);
}

.browse-btn:disabled {
    background: var(--bg-warm);
    color: var(--text-dim);
    border-color: var(--border);
    cursor: not-allowed;
}

/* Share-clip modal */
.clip-panel {
    max-width: 720px;
}

.clip-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0 0 14px;
}

.clip-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.clip-controls label {
    color: var(--text);
    font-size: 0.9rem;
}

.clip-controls select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.9rem;
    min-width: 160px;
}

.clip-status {
    color: var(--gold);
    font-size: 0.9rem;
    padding: 10px 0;
}

.clip-status.hidden,
.clip-result.hidden {
    display: none;
}

.clip-result video {
    width: 100%;
    border-radius: 8px;
    background: #000;
    display: block;
    margin-bottom: 14px;
}

.clip-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.clip-links label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.clip-copy-row {
    display: flex;
    gap: 8px;
}

.clip-copy-row input {
    flex: 1;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

/* Modal Panel */
.modal-panel {
    background: var(--surface-elevated);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--gold);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text);
}

.back-btn {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 8px;
}

.back-btn:hover {
    color: var(--gold-light);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Match List */
.match-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition:
        background 0.2s,
        transform 0.1s;
    border: 1px solid var(--border);
}

.match-item:hover {
    background: var(--bg-hover);
    border-color: var(--gold-light);
}

.match-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.match-map {
    font-weight: 600;
    color: var(--text);
}

.match-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.match-item-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-teams {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
}

.match-team {
    display: flex;
    align-items: center;
    gap: 4px;
}

.match-team.winner {
    color: var(--strong);
    font-weight: 600;
}

.match-team.loser {
    color: var(--text-dim);
}

.match-vs {
    color: var(--text-dim);
    font-size: 0.75rem;
}

.match-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.match-id {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    user-select: all;
}

.match-id:hover {
    background: var(--gold-tint);
    color: var(--gold);
}

.match-result-indicator {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.match-result-indicator.win {
    background: var(--strong-tint);
    color: var(--strong);
}

.match-result-indicator.loss {
    background: var(--poor-tint);
    color: var(--poor);
}

/* Match Detail Panel */
.match-detail-panel {
    max-width: 700px;
}

.match-detail-header {
    text-align: center;
    margin-bottom: 20px;
}

.match-detail-header h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 4px;
}

.match-detail-header .match-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.match-teams-detail {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.team-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
}

.team-header {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.team-header.winner {
    color: var(--strong);
    font-weight: 600;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.player-civ-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: var(--bg-hover);
    object-fit: cover;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: 500;
    color: var(--text);
}

.player-name.target {
    color: var(--gold);
}

.player-civ {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.player-rating {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Primary Button (gold CTA, matches the site) */
.primary-btn {
    background: var(--gold-cta);
    color: var(--text-on-gold);
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, filter 0.2s;
}

.primary-btn:hover {
    filter: brightness(1.06);
}

.primary-btn:disabled {
    background: var(--bg-warm);
    color: var(--text-dim);
    cursor: not-allowed;
    filter: none;
}

/* Player Search (find-a-player step) */
.player-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.player-search-bar input[type="text"] {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.95rem;
}

.player-search-bar input[type="text"]:focus {
    outline: none;
    border-color: var(--gold);
}

.player-search-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 24px 12px;
}

.player-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-result {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition:
        background 0.2s,
        transform 0.1s;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.player-result:hover {
    background: var(--bg-hover);
    border-color: var(--gold-light);
}

.player-result-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.player-result-clan {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.player-result-name {
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-result-verified {
    color: var(--strong);
    font-size: 0.85rem;
}

.player-result-country {
    color: var(--text-muted);
    font-size: 0.75rem;
    background: var(--bg-hover);
    padding: 1px 6px;
    border-radius: 4px;
}

.player-result-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.selected-player-header {
    margin-bottom: 14px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.selected-player-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.selected-player-name {
    color: var(--text);
    font-weight: 600;
    font-size: 1.05rem;
}

#back-to-player-search {
    margin-bottom: 12px;
}

/* Upload Fallback */
.upload-fallback {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.upload-fallback input[type="file"] {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-muted);
}

.loading-spinner.large {
    font-size: 1.2rem;
}

.loading-spinner::before {
    content: "";
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    margin-right: 12px;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.large::before {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

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

.loading-panel {
    text-align: center;
    color: var(--gold);
}

.loading-panel p {
    margin-top: 16px;
    font-size: 1rem;
    color: var(--text);
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* ---- Mobile / narrow screens ---- */
/* The playback row (transport buttons + time + speed buttons) is a no-wrap
   flexbox; on a phone it overflows off the right edge, hiding Play and the
   speed buttons. Let it wrap and center so every control stays on-screen. */
@media (max-width: 768px) {
    /* Let the page scroll on phones instead of clipping the bottom controls. */
    html,
    body {
        overflow: auto;
    }

    .container {
        height: auto;
        min-height: 100dvh;
    }

    /* Give the map a fixed share of the screen so the controls flow below it
       and are always reachable by scrolling. */
    .map-container {
        flex: none;
        height: 60vh;
    }

    .controls-panel {
        padding: 10px;
    }

    .playback-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }

    .time-display {
        margin-left: 0;
        width: 100%;
        text-align: center;
        order: -1; /* show the clock above the buttons */
    }

    .speed-controls {
        margin-left: 0; /* don't push speed buttons off the right edge */
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .playback-controls button {
        padding: 8px 12px; /* a bit larger tap targets */
    }
}
