/* ============================================================================
   Capture the Flag Game Page - Purple / Dual Theme
   Requires: game-common.css loaded first
   ============================================================================ */

/* ============================================================================
   Game-Specific Toast Types
   ============================================================================ */

.toast.ctf-red {
    background: linear-gradient(135deg, rgba(229, 57, 53, 0.95), rgba(198, 40, 40, 0.95));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast.ctf-blue {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.95), rgba(25, 118, 210, 0.95));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast.ctf-event {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.95), rgba(101, 31, 255, 0.95));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast.ctf-score {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.95), rgba(255, 152, 0, 0.95));
    color: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .toast.ctf-red {
    background: linear-gradient(135deg, rgba(198, 40, 40, 0.95), rgba(183, 28, 28, 0.95));
}

[data-theme="light"] .toast.ctf-blue {
    background: linear-gradient(135deg, rgba(21, 101, 192, 0.95), rgba(13, 71, 161, 0.95));
}

[data-theme="light"] .toast.ctf-event {
    background: linear-gradient(135deg, rgba(81, 45, 168, 0.95), rgba(69, 39, 160, 0.95));
}

/* ============================================================================
   Main Dashboard Layout
   ============================================================================ */

.ctf-dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1rem;
    gap: 0;
    max-width: 1800px;
    margin: 0 auto;
}

.ctf-dashboard .header {
    flex-shrink: 0;
    margin-bottom: 0.75rem;
}

/* ============================================================================
   CTF Content (sidebar + main)
   ============================================================================ */

.ctf-content {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ============================================================================
   Sidebar (Left)
   ============================================================================ */

.ctf-dashboard .sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.ctf-dashboard .ble-panel { flex-shrink: 0; }

.ctf-dashboard .device-list {
    max-height: 150px;
    min-height: 60px;
}

/* ============================================================================
   Game Config Panel
   ============================================================================ */

.game-config-panel { flex-shrink: 0; }

.ctf-dashboard .game-stats {
    grid-template-columns: repeat(3, 1fr);
}

.setting-item input[type="number"]:focus {
    outline: none;
    border-color: #7c4dff;
    box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.2);
}

/* Flag Status Panel */
.flag-status-panel {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.6rem;
    background: var(--card-hover);
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

.flag-status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

.flag-icon { font-size: 0.9rem; }
.flag-icon.red-flag { filter: hue-rotate(0deg); }
.flag-icon.blue-flag { filter: hue-rotate(200deg); }
.flag-label { font-weight: 600; color: var(--text-primary); flex: 1; }
.flag-state { color: var(--text-muted); font-size: 0.72rem; }
.flag-state.state-carried { color: #ff9800; font-weight: 700; }
.flag-state.state-dropped { color: #ff5252; font-weight: 700; }

/* ============================================================================
   Score Display
   ============================================================================ */

.score-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1.5rem;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.1), rgba(101, 31, 255, 0.05));
    border: 2px solid rgba(124, 77, 255, 0.3);
    border-radius: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 900;
}

.score-team {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.score-red { color: #e53935; }
.score-blue { color: #2196f3; }
.score-sep { font-size: 1.4rem; color: var(--text-muted); }

/* ============================================================================
   Game Control Bar Overrides (Purple Theme)
   ============================================================================ */

.ctf-dashboard .game-control-bar {
    gap: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 14px;
}

/* Game Timer */
.ctf-dashboard .game-timer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.15), rgba(101, 31, 255, 0.1));
    border: 2px solid #7c4dff;
    border-radius: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 700;
    transition: all 0.3s ease;
}

.ctf-dashboard .game-timer.timer-warning {
    border-color: #ff9800;
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 193, 7, 0.1));
}

.ctf-dashboard .game-timer.timer-critical {
    border-color: #ff5252;
    background: linear-gradient(135deg, rgba(255, 82, 82, 0.15), rgba(220, 53, 69, 0.1));
    animation: timer-pulse 0.5s ease-in-out infinite;
}

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

.ctf-dashboard .timer-icon { font-size: 1rem; }

.ctf-dashboard .timer-value {
    font-size: 1.6rem;
    color: var(--text-primary);
    min-width: 5ch;
    text-align: center;
}

.player-count {
    display: inline-block;
    background: #7c4dff;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

/* ============================================================================
   Buttons (Purple Theme Overrides)
   ============================================================================ */

.ctf-dashboard .btn-primary {
    background: linear-gradient(135deg, #7c4dff, #651fff);
    color: white;
    border: none;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ctf-dashboard .btn-primary:hover {
    background: linear-gradient(135deg, #9a75ff, #7c4dff);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.3);
}

.ctf-dashboard .btn-start {
    padding: 0.6rem 2rem;
    background: linear-gradient(135deg, #7c4dff, #651fff);
    font-size: 1.05rem;
    box-shadow: 0 4px 15px rgba(124, 77, 255, 0.35);
}

.ctf-dashboard .btn-start:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(124, 77, 255, 0.45);
}

.ctf-dashboard .btn-reset {
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
}

.ctf-dashboard .btn-sound {
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
    border-radius: 10px;
}

.ctf-dashboard .btn-sound:hover {
    border-color: #7c4dff;
}

.ctf-dashboard .btn-outline:hover {
    border-color: #7c4dff;
    color: #7c4dff;
}

/* ============================================================================
   Role Selector (Lobby)
   ============================================================================ */

.role-select {
    padding: 0.15rem 0.25rem;
    font-size: 0.7rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 600;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    min-width: 95px;
    transition: border-color 0.2s;
}

.role-select:focus {
    outline: none;
    border-color: #7c4dff;
    box-shadow: 0 0 0 2px rgba(124, 77, 255, 0.2);
}

.role-select.role-red-base,
.role-select.role-red-player { border-color: #e53935; }
.role-select.role-blue-base,
.role-select.role-blue-player { border-color: #2196f3; }

/* ============================================================================
   Player Card Game-Specific States
   ============================================================================ */

.player-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #7c4dff;
}

.player-card.team-red {
    border-color: #e53935;
    background: linear-gradient(90deg, rgba(229, 57, 53, 0.1), var(--card-hover));
}

.player-card.team-blue {
    border-color: #2196f3;
    background: linear-gradient(90deg, rgba(33, 150, 243, 0.1), var(--card-hover));
}

.player-card.is-base {
    border-width: 3px;
    border-style: dashed;
}

.player-card.is-base.team-red {
    background: linear-gradient(90deg, rgba(229, 57, 53, 0.15), var(--card-hover));
}

.player-card.is-base.team-blue {
    background: linear-gradient(90deg, rgba(33, 150, 243, 0.15), var(--card-hover));
}

.player-card.is-carrier {
    box-shadow: 0 0 12px rgba(255, 193, 7, 0.3);
}

.player-card.is-fallen-carrier {
    opacity: 0.8;
    animation: fallen-pulse 1.5s ease-in-out infinite;
}

@keyframes fallen-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(33, 150, 243, 0.3); }
    50% { box-shadow: 0 0 20px rgba(33, 150, 243, 0.5); }
}

.player-card.just-scored {
    animation: score-flash 1s ease-out;
}

@keyframes score-flash {
    0% { background: rgba(255, 193, 7, 0.5); transform: scale(1.02); box-shadow: 0 0 30px rgba(255, 193, 7, 0.5); }
    100% { transform: scale(1); box-shadow: none; }
}

.player-card.just-pickup {
    animation: pickup-flash 0.8s ease-out;
}

@keyframes pickup-flash {
    0% { background: rgba(124, 77, 255, 0.5); transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Team & status badges */
.team-badge {
    font-size: 0.7rem;
    flex-shrink: 0;
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    font-weight: 700;
    font-family: 'Consolas', 'Monaco', monospace;
}

.team-badge.badge-red-base {
    background: rgba(229, 57, 53, 0.2);
    color: #e53935;
    border: 1px solid rgba(229, 57, 53, 0.3);
}

.team-badge.badge-blue-base {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.team-badge.badge-red-player {
    background: rgba(229, 57, 53, 0.15);
    color: #e53935;
    border: 1px solid rgba(229, 57, 53, 0.25);
}

.team-badge.badge-blue-player {
    background: rgba(33, 150, 243, 0.15);
    color: #2196f3;
    border: 1px solid rgba(33, 150, 243, 0.25);
}

.flag-carry-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    animation: carry-glow 1.5s ease-in-out infinite;
}

.flag-carry-badge.carry-red {
    background: rgba(229, 57, 53, 0.25);
    color: #ff5252;
    border: 1px solid rgba(229, 57, 53, 0.4);
}

.flag-carry-badge.carry-blue {
    background: rgba(33, 150, 243, 0.25);
    color: #42a5f5;
    border: 1px solid rgba(33, 150, 243, 0.4);
}

@keyframes carry-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.fallen-badge {
    font-size: 0.65rem;
    color: #42a5f5;
    font-weight: 700;
    font-family: 'Consolas', 'Monaco', monospace;
    padding-top: 0.15rem;
}

/* Find button purple theme */
.ctf-dashboard .find-btn {
    background: linear-gradient(135deg, #7c4dff, #651fff);
}

/* Countdown GO color */
.ctf-dashboard .countdown-text {
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.6), 0 0 80px rgba(124, 77, 255, 0.4);
}

.ctf-dashboard .countdown-text.go {
    color: #7c4dff;
    text-shadow: 0 0 40px rgba(124, 77, 255, 0.8), 0 0 80px rgba(124, 77, 255, 0.4);
}

/* ============================================================================
   Results Overlay
   ============================================================================ */

.results-title.red-wins { color: #e53935; }
.results-title.blue-wins { color: #2196f3; }
.results-title.draw-result { color: #7c4dff; }

.results-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.results-score-big {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 900;
    font-family: 'Consolas', 'Monaco', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.results-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--card-border);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
}

.result-row.result-red {
    background: rgba(229, 57, 53, 0.08);
    border: 1px solid rgba(229, 57, 53, 0.15);
}

.result-row.result-blue {
    background: rgba(33, 150, 243, 0.08);
    border: 1px solid rgba(33, 150, 243, 0.15);
}

.result-icon { font-size: 1.1rem; flex-shrink: 0; }
.result-name { font-weight: 700; color: var(--text-primary); flex: 1; }
.result-role { color: var(--text-muted); font-size: 0.7rem; }

/* ============================================================================
   Fullscreen / Projector Mode
   ============================================================================ */

.fs-mode .header { display: none !important; }
.fs-mode .sidebar { display: none !important; }

.fs-mode {
    max-width: none;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
}

.fs-mode .ctf-content { flex-direction: column; }

.fs-mode .game-control-bar {
    padding: 1rem 2rem;
    border-radius: 18px;
    gap: 2rem;
    margin-bottom: 1rem;
    border-width: 2px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.fs-mode .game-timer { padding: 0.7rem 1.5rem; border-radius: 14px; }
.fs-mode .timer-value { font-size: 2.5rem; }
.fs-mode .timer-icon { font-size: 1.3rem; }

.fs-mode .score-display { padding: 0.6rem 2rem; border-radius: 16px; }
.fs-mode .score-team { font-size: 2.8rem; }
.fs-mode .score-sep { font-size: 2rem; }

.fs-mode .btn-start { padding: 0.8rem 3rem; font-size: 1.3rem; border-radius: 14px; }
.fs-mode .btn-reset { padding: 0.8rem 2rem; font-size: 1.1rem; border-radius: 14px; }
.fs-mode .btn-sound { width: 48px; height: 48px; font-size: 1.3rem; border-radius: 14px; }

.fs-mode .players-area { border-radius: 20px; padding: 1.5rem; }
.fs-mode .players-grid { grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 0.75rem; }
.fs-mode .player-card { padding: 0.6rem 0.8rem; border-radius: 10px; }
.fs-mode .pc-row { font-size: 0.95rem; min-height: 34px; }
.fs-mode .pc-name { font-size: 1.1rem; }
.fs-mode .team-badge { font-size: 0.85rem; }
.fs-mode .flag-carry-badge { font-size: 0.85rem; }
.fs-mode .find-btn { width: 30px; height: 30px; font-size: 0.9rem; }
.fs-mode .pc-reported { font-size: 0.82rem; }
.fs-mode .led-dot { width: 10px; height: 10px; }

:fullscreen .results-card { max-width: 700px; padding: 2.5rem; }
:fullscreen .results-title { font-size: 2rem; margin-bottom: 2rem; }
:fullscreen .results-score-big { font-size: 3.5rem; }

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

@media (max-width: 1200px) {
    .ctf-dashboard .sidebar { width: 260px; }
    .players-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .game-control-bar { flex-direction: column; align-items: center; gap: 0.75rem; }
    .gcb-center { flex-wrap: wrap; justify-content: center; }
    .gcb-right { justify-content: center; }
    .ctf-content { flex-direction: column; }

    .ctf-dashboard .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .ctf-dashboard .ble-panel,
    .ctf-dashboard .game-config-panel {
        flex: 1;
        min-width: 280px;
    }

    .players-area { min-height: 400px; }
}

/* ============================================================================
   Light Theme Adjustments
   ============================================================================ */

[data-theme="light"] .player-card:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #7c4dff;
}

[data-theme="light"] .player-card.team-red {
    border-color: #c62828;
    background: linear-gradient(90deg, rgba(198, 40, 40, 0.08), rgba(255, 255, 255, 0.95));
}

[data-theme="light"] .player-card.team-blue {
    border-color: #1565c0;
    background: linear-gradient(90deg, rgba(21, 101, 192, 0.08), rgba(255, 255, 255, 0.95));
}

[data-theme="light"] .player-card.is-base.team-red {
    background: linear-gradient(90deg, rgba(198, 40, 40, 0.12), rgba(255, 255, 255, 0.95));
}

[data-theme="light"] .player-card.is-base.team-blue {
    background: linear-gradient(90deg, rgba(21, 101, 192, 0.12), rgba(255, 255, 255, 0.95));
}

[data-theme="light"] .find-btn {
    background: linear-gradient(135deg, #651fff, #512da8);
}

[data-theme="light"] .btn-start {
    background: linear-gradient(135deg, #651fff, #512da8);
}

[data-theme="light"] .btn-primary {
    background: linear-gradient(135deg, #651fff, #512da8);
}

[data-theme="light"] .flag-status-panel {
    background: rgba(248, 246, 242, 0.9);
    border-color: rgba(140, 125, 105, 0.15);
}

[data-theme="light"] .score-display {
    background: linear-gradient(135deg, rgba(101, 31, 255, 0.08), rgba(81, 45, 168, 0.04));
    border-color: rgba(101, 31, 255, 0.25);
}
