/* ===== ARENA ROUND STYLES ===== */

/* Special Arena Button Styling (Results Screen) */
.arena-special-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    font-size: 1.25rem;
    padding: 1rem 2.5rem;
    margin: 2rem 0;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
    border: 2px solid #fbbf24;
    animation: arenaButtonPulse 2s ease-in-out infinite;
    font-weight: 700;
    color: white;
}

@keyframes arenaButtonPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 4px 30px rgba(245, 158, 11, 0.8);
        transform: scale(1.02);
    }
}

.arena-special-btn:hover:not(:disabled) {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 30px rgba(245, 158, 11, 0.6);
    background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
}

.arena-special-btn:active:not(:disabled) {
    transform: scale(1.02);
}

/* Fighting Style Selection (Upload Screen) */
.fighting-style-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.fighting-style-option {
    cursor: pointer;
}

.fighting-style-option input[type="radio"] {
    display: none;
}

.style-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fighting-style-option input[type="radio"]:checked + .style-card {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.style-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.style-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.melee-icon { filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.6)); }
.range-icon { filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.6)); }
.hybrid-icon { filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6)); }

.style-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.style-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Tournament Stats Summary (Results Screen) */
.stats-summary-container {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.stats-summary-container h3 {
    text-align: center;
    color: var(--primary-light);
    margin-bottom: 0.5rem;
}

.stats-table {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.stats-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    align-items: center;
    transition: all 0.2s ease;
}

.stats-row:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.stats-participant {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stats-participant img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-secondary);
}

.stats-participant-info {
    flex: 1;
}

.stats-participant-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.stats-participant-style {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.stats-value {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
}

.health-stat {
    color: var(--secondary);
}

.attack-stat {
    color: var(--danger);
}

/* Arena Screen Layout */
.arena-container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.arena-header {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.arena-header .title {
    margin: 0;
    font-size: 1.5rem;
}

.arena-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.arena-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.arena-main {
    flex: 1;
    display: flex;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
    justify-content: center;
    align-items: flex-start;
    max-width: 100%;
}

#arena-canvas {
    flex-shrink: 0;
    background: linear-gradient(135deg, #1a1f3a 0%, #0f172a 100%);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: crosshair;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    max-width: 900px;
    width: 100%;
    height: auto;
}

.arena-sidebar {
    width: 280px;
    max-width: 280px;
    min-width: 280px;
    max-height: 600px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

.arena-sidebar::-webkit-scrollbar {
    width: 8px;
}

.arena-sidebar::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.arena-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.arena-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.arena-sidebar h3 {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.arena-participants-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.arena-participant-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

.arena-participant-card.alive {
    border-color: var(--secondary);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.arena-participant-card.alive:hover {
    transform: translateX(4px);
    border-color: var(--primary-light);
}

.arena-participant-card.dead {
    opacity: 0.35;
    filter: grayscale(1);
    position: relative;
}

.arena-participant-card.dead::after {
    content: '💀';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0.6;
    pointer-events: none;
}

.arena-participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.arena-participant-details {
    flex: 1;
    min-width: 0;
}

.arena-participant-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.arena-participant-health-bar {
    width: 100%;
    height: 8px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.25rem;
    border: 1px solid rgba(71, 85, 105, 0.4);
}

.arena-participant-health-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease, background 0.3s ease;
    position: relative;
}

.arena-participant-health-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
    border-radius: 4px 4px 0 0;
}

.arena-participant-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-weight: 600;
}

.arena-participant-style-icon {
    font-size: 1.25rem;
}

/* Victory Overlay */
.arena-victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.arena-victory-overlay.hidden {
    display: none;
}

.victory-content {
    text-align: center;
    max-width: 500px;
    background: var(--bg-secondary);
    border: 3px solid var(--warning);
    border-radius: 16px;
    padding: 3rem 2rem;
    box-shadow: 0 20px 60px rgba(245, 158, 11, 0.4);
    animation: victorySlideIn 0.5s ease;
}

@keyframes victorySlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.victory-content h2 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--warning), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
    animation: victoryPulse 2s ease infinite;
}

@keyframes victoryPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.victory-winner {
    margin-bottom: 2rem;
}

.victory-winner img {
    width: 150px;
    height: 150px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid var(--warning);
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

.victory-winner h3 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.victory-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.victory-content .primary-btn,
.victory-content .secondary-btn {
    margin: 0.5rem;
    min-width: 180px;
}

.victory-content .primary-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.victory-content .primary-btn:hover {
    background: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);
    transform: scale(1.05);
}

.stat-item {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: block;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .arena-sidebar {
        width: 220px;
        min-width: 220px;
        max-width: 220px;
    }
}

@media (max-width: 1024px) {
    .arena-main {
        flex-direction: column;
        align-items: center;
    }

    .arena-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        max-height: 200px;
    }

    .arena-participants-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stats-value {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .stat-label {
        text-align: left;
        margin: 0;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .fighting-style-options {
        grid-template-columns: 1fr;
    }

    .arena-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .arena-controls {
        width: 100%;
        justify-content: space-between;
    }

    .victory-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .arena-sidebar {
        display: block; /* Keep visible on mobile */
        max-height: 150px;
    }

    .arena-participant-card {
        padding: 0.5rem;
    }

    .arena-participant-avatar {
        width: 32px;
        height: 32px;
    }

    .victory-content {
        padding: 2rem 1rem;
        margin: 1rem;
    }

    .victory-content h2 {
        font-size: 2rem;
    }

    .victory-winner img {
        width: 120px;
        height: 120px;
    }
}

/* Mobile Arena Canvas Scaling (Feature 1) */
@media (max-width: 768px) {
    #arena-canvas {
        /* Scale canvas to fit mobile viewport while maintaining aspect ratio */
        width: calc(100vw - 2rem) !important;
        height: auto !important;
        max-width: 100%;
        transform-origin: top left;
    }

    #replay-canvas {
        /* Also scale replay canvas for mobile */
        width: 100% !important;
        height: auto !important;
    }

    .arena-main {
        padding: 0.5rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 375px) {
    #arena-canvas {
        width: calc(100vw - 1rem) !important;
    }
}

/* Canvas Particle Effects (Visual Polish) */
@keyframes particleFloat {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateY(-100px) scale(0);
        opacity: 0;
    }
}

/* Damage Number Animations (rendered on canvas) */
@keyframes damageNumber {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-50px);
        opacity: 0;
    }
}

/* Arena Setup Overlay */
.arena-setup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.arena-setup-overlay.hidden {
    display: none;
}

.setup-content {
    background: var(--bg-secondary);
    border: 3px solid var(--primary);
    border-radius: 12px;
    padding: 2rem;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
}

.setup-content h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--primary-light);
}

/* Setup Stats */
.setup-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.setup-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    min-width: 120px;
}

.stat-icon {
    font-size: 2rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Preview Canvas */
#setup-preview-canvas {
    display: block;
    margin: 0 auto 1.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: #1a1a2e;
    max-width: 100%;
    height: auto;
}

/* Legend */
.setup-legend {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid;
}

.melee-border { border-color: #dc2626; }
.range-border { border-color: #3b82f6; }
.hybrid-border { border-color: #8b5cf6; }

/* Instructions */
.setup-instructions {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Action Buttons */
.setup-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* CRITICAL: Host-only button visibility overrides */
.host-only {
    display: none;
}

.host-only.visible {
    display: block !important;
}

button.host-only.visible {
    display: inline-block !important;
}

.arena-battle-btn {
    font-size: 1.5rem !important;
    padding: 1.25rem 3rem !important;
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%) !important;
    border: 3px solid #fca5a5 !important;
    box-shadow: 0 0 30px rgba(220, 38, 38, 0.6) !important;
    animation: battleButtonPulse 2s ease-in-out infinite;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: white !important;
}

@keyframes battleButtonPulse {
    0%, 100% {
        box-shadow: 0 0 30px rgba(220, 38, 38, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 50px rgba(220, 38, 38, 0.9);
        transform: scale(1.05);
    }
}

.arena-battle-btn:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 0 60px rgba(220, 38, 38, 1) !important;
}

/* Replay Overlay */
.arena-replay-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.arena-replay-overlay.hidden {
    display: none;
}

.replay-content {
    width: 100%;
    max-width: 1000px;
    background: var(--bg-secondary);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.4);
}

.replay-content h2 {
    font-size: 2rem;
    color: var(--primary-light);
    margin-bottom: 1.5rem;
    text-align: center;
}

#replay-canvas {
    width: 100%;
    height: auto;
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    display: block;
    background: linear-gradient(135deg, #1a1f3a 0%, #0f172a 100%);
}

.replay-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.replay-slider {
    flex: 1;
    min-width: 200px;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-secondary);
    outline: none;
    -webkit-appearance: none;
}

.replay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
}

.replay-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
    border: none;
}

.replay-speed {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.replay-speed:hover {
    border-color: var(--primary);
}

.replay-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

@media (max-width: 768px) {
    .replay-content {
        padding: 1rem;
    }

    .replay-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .replay-slider {
        min-width: 100%;
    }

    .setup-content {
        margin: 1rem;
        padding: 1.5rem;
    }

    #setup-preview-canvas {
        max-width: 100%;
        height: auto;
    }

    .setup-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .setup-legend {
        flex-direction: column;
        gap: 0.75rem;
    }

    .setup-actions {
        flex-direction: column;
    }

    .arena-battle-btn {
        font-size: 1.25rem !important;
        padding: 1rem 2rem !important;
    }
}
