body {
    margin: 0;
    padding: 0;
}

.replay-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem 2rem;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: 1.5rem;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #2d5016;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
}

.replay-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.battle-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.robot-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0.75rem 1.75rem;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 12px;
    min-width: 200px;
    transition: all 0.3s ease;
}

.robot-card:hover {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    transform: translateY(-2px);
}

.robot-card.robot1-card {
    border-left: 4px solid #3b82f6;
}

.robot-card.robot2-card {
    border-right: 4px solid #ef4444;
}

.robot-card.leading {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.robot-card.robot2-card.leading {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.robot-name-display {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.robot-stats {
    display: none;
}

.rounds-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    flex-shrink: 0;
}

.score-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    background: white;
    color: #2d5016;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    flex-grow: 1;
    text-align: center;
}

.robot1-card .score-display {
    border-color: #bfdbfe;
    color: #3b82f6;
}

.robot2-card .score-display {
    border-color: #fecaca;
    color: #ef4444;
}

.robot-card.leading .score-display {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    font-size: 1.1rem;
}

.robot-card.robot2-card.leading .score-display {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.vs-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.vs-text {
    font-size: 0.875rem;
    color: #9ca3af;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.battle-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.battle-content {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-start;
}

.battle-main {
    flex: 0 1 auto;
}

.battle-sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.score-table-container {
    width: 100%;
    max-width: 1400px;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.score-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.score-table thead th {
    background: #f9fafb;
    padding: 0.875rem 1rem;
    text-align: center;
    font-weight: 700;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-table thead th:first-child {
    text-align: left;
}

.score-table tbody td {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    color: #1f2937;
}

.score-table tbody td.robot-name {
    text-align: left;
    font-weight: 700;
    color: #1f2937;
}

.score-table tbody td.score-total {
    font-size: 1.125rem;
    color: #2d5016;
    font-weight: 800;
}

.score-table tbody tr:hover {
    background: #f9fafb;
}

.score-table tbody tr.robot1-row {
    border-left: 4px solid #3b82f6;
}

.score-table tbody tr.robot2-row {
    border-left: 4px solid #ef4444;
}

.canvas-container {
    position: relative;
    background: #1a1a2e;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    width: fit-content;
}

#battleCanvas {
    display: block;
    margin: 0;
    padding: 0;
    vertical-align: top;
}

#battleCanvas canvas {
    display: block;
    margin: 0;
    padding: 0;
}

.battle-stats {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.robot-stat {
    background: rgba(0, 0, 0, 0.7);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    color: white;
    min-width: 200px;
}

.robot-stat.robot1 {
    border-left: 4px solid #3b82f6;
}

.robot-stat.robot2 {
    border-left: 4px solid #ef4444;
}

.robot-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.robot-health {
    font-size: 0.85rem;
    color: #d1d5db;
}

.robot-energy {
    font-size: 0.85rem;
    color: #d1d5db;
}

.controls-container {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.control-btn {
    background: #2d5016;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.control-btn:hover {
    background: #1f3a0f;
}

.control-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.round-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.round-info {
    font-size: 0.95rem;
    color: #1f2937;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.speed-btn {
    background: #e5e7eb;
    color: #374151;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.speed-btn:hover {
    background: #d1d5db;
}

.speed-btn.active {
    background: #2d5016;
    color: white;
}

.timeline-container {
    flex: 1;
}

.turn-slider {
    width: 100%;
    height: 18px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    cursor: pointer;
    margin: 0;
    padding: 0;
}

.turn-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2d5016;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    margin-top: -5px;
}

.turn-slider::-webkit-slider-thumb:hover {
    background: #1f3a0f;
    transform: scale(1.1);
}

.turn-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2d5016;
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.2s;
}

.turn-slider::-moz-range-thumb:hover {
    background: #1f3a0f;
    transform: scale(1.1);
}

.turn-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right,
        #2d5016 0%,
        #2d5016 var(--slider-progress, 0%),
        #e5e7eb var(--slider-progress, 0%),
        #e5e7eb 100%);
}

.turn-slider::-moz-range-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e5e7eb;
}

.turn-slider::-moz-range-progress {
    height: 8px;
    border-radius: 4px;
    background: #2d5016;
}

.timeline-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.stats-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.stats-card.robot1 {
    border-top: 4px solid #3b82f6;
}

.stats-card.robot2 {
    border-top: 4px solid #ef4444;
}

.stats-card h3 {
    font-size: 1.15rem;
    margin: 0 0 1.25rem 0;
    color: #111827;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.875rem;
    line-height: 1.4;
    gap: 0.75rem;
}

.stat-row:last-child {
    margin-bottom: 0;
}

.stat-row.energy-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.stat-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.stat-value {
    font-size: 1rem;
    color: #111827;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-bar {
    height: 12px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease, background 0.3s ease;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.stat-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.1) 100%);
    border-radius: 6px;
}

.stat-bar-fill.energy {
    background: linear-gradient(90deg, #059669 0%, #10b981 100%);
}

.stat-bar-fill.energy.low {
    background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%);
}

.stat-bar-fill.energy.critical {
    background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
    animation: pulse-critical 1.5s ease-in-out infinite;
}

@keyframes pulse-critical {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.score-row-main {
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 1rem;
    margin-bottom: 1rem !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-value-main {
    font-size: 1.5rem;
    color: #2d5016;
    font-weight: 800;
}

.score-breakdown {
    background: #f9fafb;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.score-breakdown-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-row-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 0.8rem;
}

.stat-label-mini {
    color: #6b7280;
    font-size: 0.8rem;
}

.stat-value-mini {
    color: #1f2937;
    font-weight: 600;
    font-size: 0.8rem;
}

.rounds-won {
    background: #f9fafb;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.rounds-won-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.rounds-won-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.round-badge {
    background: white;
    border-radius: 6px;
    padding: 0.5rem;
    text-align: center;
    border: 2px solid transparent;
}

.round-badge.first {
    border-color: #fbbf24;
}

.round-badge.second {
    border-color: #d1d5db;
}

.round-badge.third {
    border-color: #cd7f32;
}

.badge-number {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1f2937;
}

.badge-label {
    font-size: 0.7rem;
    color: #6b7280;
    font-weight: 600;
    margin-top: 0.125rem;
}

.winner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.winner-card {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    text-align: center;
    max-width: 600px;
    animation: slideUp 0.4s ease-out;
    border: 1px solid #e5e7eb;
}

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

.winner-card h2 {
    font-size: 2rem;
    margin: 0 0 2rem 0;
    color: #1f2937;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.winner-name {
    font-size: 2.5rem;
    font-weight: 800;
    color: #2d5016;
    margin-bottom: 1rem;
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.winner-score {
    font-size: 1.5rem;
    color: #6b7280;
    margin-bottom: 2rem;
}

.winner-stats {
    font-size: 1.25rem;
    color: #6b7280;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.winner-card {
    position: relative;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.final-scores {
    margin: 2.5rem 0 2rem 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.score-entry {
    padding: 1.5rem;
    border-radius: 12px;
    background: #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    gap: 1.5rem;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.score-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.score-entry.winner {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #fcd34d;
    box-shadow: 0 10px 30px rgba(251, 191, 36, 0.2);
    font-weight: 600;
}

.score-entry > div:first-child {
    flex: 1;
}

.score-entry > div:last-child {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.score-entry .robot-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #1f2937;
}

.score-entry .score {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #2d5016 0%, #4a7c2c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-entry.winner .score {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-entry .rounds-info {
    font-size: 0.95rem;
    color: #6b7280;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.score-entry.winner .rounds-info {
    color: #b45309;
    font-weight: 600;
}

.winner-card .control-btn {
    margin-top: 1rem;
    margin-left: auto;
    margin-right: auto;
    display: block;
    padding: 0.75rem 2rem;
    font-size: 1rem;
}
