body {
    font-family: Arial, sans-serif;
    margin: 0;
    background: #f4f1ea;
    text-align: center;
    color: #333;
}

#replay-controls {
    margin: 20px auto;
    max-width: 900px;
    padding: 0 16px;
}

#replay-form {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#log-id {
    padding: 8px 12px;
    font-size: 16px;
    width: 120px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    padding: 8px 16px;
    font-size: 15px;
    background: #3e302b;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

button:hover {
    background: #251c19;
}

.secondary-btn {
    background: #605149;
    color: #fff;
}

.secondary-btn:hover {
    background: #423630;
}

.secondary-btn:disabled {
    background: #c5bfb6;
    color: #777;
    cursor: not-allowed;
}

.music-btn {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.95);
    color: #444;
    border: 1px solid #dcd7ce;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.music-btn:hover {
    background: #fff;
    color: #111;
    border-color: #bbb;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.music-btn.playing {
    background: #237b38;
    color: #fff;
    border-color: #1c632d;
    box-shadow: 0 2px 8px rgba(35, 123, 56, 0.3);
}

.music-btn.playing:hover {
    background: #1e6d31;
    border-color: #175225;
    color: #fff;
}

#replay-status {
    min-height: 20px;
    margin-top: 10px;
    font-weight: 500;
}

#status {
    margin: 10px;
    font-weight: bold;
    color: #777;
}

#progress {
    height: 20px;
    width: 300px;
}

.spinner {
    height: 30px;
    width: 30px;
    margin: 10px auto;
    animation: rotation 0.8s linear infinite;
    border-left: 5px solid #ebebeb;
    border-right: 5px solid #ebebeb;
    border-bottom: 5px solid #ebebeb;
    border-top: 5px solid #787878;
    border-radius: 100%;
}

@keyframes rotation {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Layout Container: Canvas + Scoreboard */
.visualizer-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
    margin: 20px auto;
    max-width: 1200px;
    padding: 0 16px;
}

.canvas-column {
    width: 800px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#video-controls {
    display: none;
    background: #fff;
    border-radius: 8px;
    padding: 12px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e2ddd3;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

#video-controls.visible {
    display: flex;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.time-label {
    font-size: 13px;
    font-weight: bold;
    color: #555;
    min-width: 38px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#tick-scrubber {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #e6e2d8;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

#tick-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3e302b;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: transform 0.1s, background 0.2s;
}

#tick-scrubber::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #ef4123;
}

#tick-scrubber::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: #3e302b;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: transform 0.1s, background 0.2s;
}

#tick-scrubber::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: #ef4123;
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ctrl-btn {
    background: #ede9e0;
    color: #333;
    border: 1px solid #dcd7ce;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 34px;
    transition: all 0.15s ease;
}

.ctrl-btn:hover {
    background: #e0dbd0;
    color: #000;
}

.ctrl-btn-main {
    background: #3e302b;
    color: #fff;
    border-color: #3e302b;
    padding: 6px 18px;
    font-size: 13px;
    min-width: 68px;
}

.ctrl-btn-main:hover {
    background: #251c19;
    color: #fff;
}

.speed-btn {
    background: #ede9e0;
    color: #555;
    border: 1px solid #dcd7ce;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    height: 28px;
    transition: all 0.15s ease;
}

.speed-btn:hover {
    background: #e0dbd0;
    color: #111;
}

.speed-btn.active {
    background: #3e302b;
    color: #fff;
    border-color: #3e302b;
}

.emscripten_border {
    display: inline-block;
    border: 2px solid #3e302b;
    border-radius: 6px;
    overflow: hidden;
    background-color: #000;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

canvas.emscripten {
    display: block;
    border: 0;
    background-color: #000;
}

/* Scoreboard Panel */
#scoreboard-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: left;
}

#player-cards {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hud-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e2ddd3;
}

.hud-title {
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin-bottom: 8px;
}

.tick-display {
    font-size: 24px;
    font-weight: bold;
    color: #222;
    margin-bottom: 8px;
}

.progress-bar-bg {
    height: 8px;
    background: #e6e2d8;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #3e302b;
    transition: width 0.1s linear;
}

/* Player Cards */
.player-card {
    background: #fff;
    border-radius: 8px;
    padding: 14px 16px;
    border-left: 6px solid #ccc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.p1-card { border-left-color: #ef4123; }
.p2-card { border-left-color: #9d4620; }
.p3-card { border-left-color: #ffef4d; }
.p4-card { border-left-color: #659753; }

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-name {
    font-weight: bold;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
}

.p1-badge { background: #ef4123; }
.p2-badge { background: #9d4620; }
.p3-badge { background: #d4c200; color: #111; }
.p4-badge { background: #659753; }

.player-stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #555;
}

.score-text {
    font-weight: bold;
    color: #222;
}

.territory-bar-bg {
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.territory-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 0.15s ease-out;
}

.p1-fill { background: #ef4123; }
.p2-fill { background: #9d4620; }
.p3-fill { background: #ffef4d; }
.p4-fill { background: #659753; }

.winner-tag {
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    background: #eab308;
    color: #000;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.bot-label {
    font-weight: 700;
    color: #111;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-substats {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #777;
}

.match-meta-banner {
    background: #fff;
    border: 1px solid #e0dbce;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #444;
    display: none;
}

.match-meta-banner.active {
    display: block;
}

.match-meta-title {
    font-weight: bold;
    font-size: 13px;
    color: #222;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#replay-select {
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    max-width: 320px;
    background: #fff;
    color: #333;
}

#output {
    width: 800px;
    max-width: 90%;
    height: 100px;
    margin: 20px auto;
    display: block;
    background-color: #1e1e1e;
    color: #eee;
    font-family: monospace;
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #444;
}
