/* ========================================
   MULTIPLAYER ARENA STYLES
   ======================================== */

/* Multiplayer Main Container */
#multiplayer-container {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.95);
    z-index: 9998;
    display: none;
    overflow-y: auto;
}

#multiplayer-container.active {
    display: flex;
    flex-direction: column;
}

/* Header */
.mp-header {
    padding: 20px;
    background: linear-gradient(135deg, #1a1d29 0%, #0f1117 100%);
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mp-header h1 {
    margin: 0;
    font-size: 24px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 12px;
}

.mp-header h1::before {
    content: '⚔️';
    font-size: 28px;
}

.mp-close-btn {
    padding: 8px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
}

.mp-close-btn:hover {
    background: var(--hover);
    color: var(--ink);
}

/* Navigation Tabs */
.mp-nav {
    display: flex;
    gap: 4px;
    padding: 16px 20px 0;
    background: var(--panel);
}

.mp-nav-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mp-nav-tab:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.03);
}

.mp-nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Content Area */
.mp-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.mp-section {
    display: none;
}

.mp-section.active {
    display: block;
}

/* ========================================
   MATCHMAKING QUEUE
   ======================================== */

.queue-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.queue-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.queue-mode-card {
    padding: 24px;
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.queue-mode-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.queue-mode-card.selected {
    border-color: var(--primary);
    background: rgba(194, 58, 85, 0.1);
}

.queue-mode-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.queue-mode-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 8px;
}

.queue-mode-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.queue-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.queue-btn {
    padding: 16px 48px;
    background: linear-gradient(135deg, var(--primary) 0%, #b8385a 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(194, 58, 85, 0.3);
}

.queue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(194, 58, 85, 0.5);
}

.queue-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.queue-status {
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    display: none;
}

.queue-status.active {
    display: block;
}

.queue-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.queue-timer {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 8px;
}

.queue-message {
    font-size: 14px;
    color: var(--muted);
}

/* ========================================
   MATCH SCREEN
   ======================================== */

.match-container {
    max-width: 900px;
    margin: 0 auto;
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--panel);
    border-radius: 12px;
    margin-bottom: 24px;
}

.match-player {
    flex: 1;
    text-align: center;
}

.match-player.opponent {
    order: 3;
}

.match-vs {
    font-size: 24px;
    font-weight: 700;
    color: var(--muted);
    padding: 0 32px;
}

.match-username {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 4px;
}

.match-elo {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}

.match-score {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.match-target {
    font-size: 12px;
    color: var(--muted);
}

.match-progress {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 8px;
}

.match-progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.match-progress-dot.correct {
    background: #4ade80;
}

.match-progress-dot.incorrect {
    background: #ef4444;
}

.match-game-area {
    /* Training table will be injected here */
    min-height: 500px;
}

.match-timer {
    position: fixed;
    top: 120px;
    right: 32px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--panel);
    border: 4px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.match-timer.warning {
    border-color: #f59e0b;
    color: #f59e0b;
    animation: pulse 0.5s ease-in-out infinite;
}

.match-timer.danger {
    border-color: #ef4444;
    color: #ef4444;
}

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

.opponent-action-flash {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 24px 48px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--primary);
    border-radius: 16px;
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    z-index: 10000;
    animation: flashIn 0.3s ease-out;
    pointer-events: none;
}

@keyframes flashIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ========================================
   LEADERBOARD
   ======================================== */

.leaderboard-container {
    max-width: 1000px;
    margin: 0 auto;
}

.leaderboard-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.leaderboard-filter-btn {
    padding: 8px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-filter-btn:hover {
    border-color: var(--primary);
    color: var(--ink);
}

.leaderboard-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.leaderboard-table {
    width: 100%;
    background: var(--panel);
    border-radius: 12px;
    overflow: hidden;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 60px 1fr 120px 100px 100px 100px;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 60px 1fr 120px 100px 100px 100px;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.leaderboard-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.leaderboard-row.my-rank {
    background: rgba(194, 58, 85, 0.1);
    border-left: 3px solid var(--primary);
}

.leaderboard-rank {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}

.leaderboard-rank.top3 {
    color: #FFD700;
}

.leaderboard-player {
    display: flex;
    align-items: center;
    gap: 12px;
}

.leaderboard-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #b8385a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.leaderboard-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

.leaderboard-tier {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.leaderboard-stat {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
}

/* ========================================
   TOURNAMENTS
   ======================================== */

.tournament-list {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.tournament-card {
    padding: 24px;
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
    cursor: pointer;
}

.tournament-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 16px;
}

.tournament-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 4px;
}

.tournament-status-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.tournament-status-badge.registration {
    background: #4ade80;
    color: #065f46;
}

.tournament-status-badge.in_progress {
    background: #f59e0b;
    color: #78350f;
}

.tournament-status-badge.completed {
    background: var(--muted);
    color: var(--panel);
}

.tournament-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.tournament-info-item {
    display: flex;
    flex-direction: column;
}

.tournament-info-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.tournament-info-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}

.tournament-actions {
    display: flex;
    gap: 12px;
}

.tournament-btn {
    flex: 1;
    padding: 12px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tournament-btn:hover {
    background: #b8385a;
}

.tournament-btn.secondary {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--ink);
}

.tournament-btn.secondary:hover {
    background: var(--hover);
}

/* Bracket View */
.bracket-container {
    overflow-x: auto;
    padding: 20px;
}

.bracket-round {
    display: inline-flex;
    flex-direction: column;
    justify-content: space-around;
    margin-right: 40px;
    min-height: 400px;
}

.bracket-match {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    min-width: 200px;
}

.bracket-player {
    padding: 8px;
    border-radius: 4px;
    margin: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bracket-player.winner {
    background: rgba(74, 222, 128, 0.1);
    border-left: 3px solid #4ade80;
}

.bracket-player-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.bracket-player-score {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}

/* Match End Modal */
.match-end-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
}

.match-end-modal.active {
    display: flex;
}

.match-end-content {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 48px;
    max-width: 500px;
    text-align: center;
    animation: slideUp 0.4s ease-out;
}

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

.match-result-icon {
    font-size: 80px;
    margin-bottom: 16px;
}

.match-result-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 24px;
}

.match-result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.match-result-stat {
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.match-result-stat-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.match-result-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
}

.match-result-actions {
    display: flex;
    gap: 12px;
}

.match-result-btn {
    flex: 1;
    padding: 14px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.match-result-btn.primary {
    background: var(--primary);
    border: none;
    color: white;
}

.match-result-btn.primary:hover {
    background: #b8385a;
}

.match-result-btn.secondary {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--ink);
}

.match-result-btn.secondary:hover {
    background: var(--hover);
}
