/* ============================================================================
   Push Wars Game Page - Aggressive Red Theme
   Requires: game-common.css loaded first
   ============================================================================ */

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

.toast.game-event {
    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.eliminate-event {
    background: linear-gradient(135deg, rgba(255, 82, 82, 0.95), rgba(220, 53, 69, 0.95));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast.winner-event {
    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.game-event {
    background: linear-gradient(135deg, rgba(198, 40, 40, 0.95), rgba(183, 28, 28, 0.95));
    color: white;
}

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

[data-theme="light"] .toast.winner-event {
    background: linear-gradient(135deg, rgba(249, 168, 37, 0.95), rgba(230, 150, 20, 0.95));
    color: white;
}

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

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

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

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

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

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

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

/* ============================================================================
   Right Sidebar (Leaderboard)
   ============================================================================ */

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

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

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

/* ============================================================================
   Game Config Panel (sidebar)
   ============================================================================ */

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

/* Phase display */
.gcb-phase {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.gcb-phase .phase-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.gcb-phase.phase-lobby {
    background: linear-gradient(135deg, rgba(229, 57, 53, 0.12), rgba(198, 40, 40, 0.08));
    border: 1px solid #e53935;
}
.gcb-phase.phase-lobby .phase-name { color: #e53935; }

.gcb-phase.phase-countdown {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 193, 7, 0.1));
    border: 1px solid #ff9800;
    animation: countdown-pulse 0.8s ease-in-out infinite;
}
.gcb-phase.phase-countdown .phase-name { color: #ff9800; }

@keyframes countdown-pulse {
    0%, 100% { border-color: #ff9800; transform: scale(1); }
    50% { border-color: #e53935; transform: scale(1.02); }
}

.gcb-phase.phase-playing {
    background: linear-gradient(135deg, rgba(229, 57, 53, 0.18), rgba(183, 28, 28, 0.12));
    border: 1px solid #e53935;
    animation: battle-pulse 2s ease-in-out infinite;
}
.gcb-phase.phase-playing .phase-name { color: #e53935; }

@keyframes battle-pulse {
    0%, 100% { border-color: #e53935; box-shadow: 0 0 8px rgba(229, 57, 53, 0.2); }
    50% { border-color: #ff5252; box-shadow: 0 0 16px rgba(255, 82, 82, 0.35); }
}

.gcb-phase.phase-finished {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 152, 0, 0.1));
    border: 1px solid var(--accent-orange);
}
.gcb-phase.phase-finished .phase-name { color: var(--accent-orange); }

/* Stats color overrides */
.alive-color { color: #4caf50 !important; }
.eliminated-color { color: #e53935 !important; }

/* Winner display in sidebar */
.winner-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(255, 152, 0, 0.15));
    border: 2px solid var(--accent-orange);
    border-radius: 10px;
    animation: winner-glow 2s ease-in-out infinite;
}

@keyframes winner-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 193, 7, 0.3); }
    50% { box-shadow: 0 0 20px rgba(255, 193, 7, 0.5); }
}

.winner-display .winner-icon { font-size: 1.3rem; }
.winner-display .winner-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-orange);
}

/* ============================================================================
   Settings Panel (sidebar) - Game-Specific
   ============================================================================ */

.settings-panel { flex-shrink: 0; }

.setting-item input[type="number"]:focus {
    outline: none;
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.2);
}

.settings-current {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.7rem;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.72rem;
}

.settings-current .current-label {
    color: var(--text-muted);
    font-weight: 500;
    width: 100%;
    margin-bottom: 0.1rem;
}

.settings-current .current-value { color: var(--text-secondary); }
.settings-current .current-value strong { color: #e53935; font-weight: 600; }

.btn-full { width: 100%; margin-top: 0.5rem; }

.btn-primary {
    background: linear-gradient(135deg, #e53935, #c62828);
    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;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ef5350, #e53935);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.3);
}

.btn-primary:active { transform: translateY(0); }

/* ============================================================================
   Game Control Bar - Theme Overrides
   ============================================================================ */

.gcb-left {
    flex: 1;
    min-width: 0;
}

.gcb-left .players-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gcb-right {
    gap: 0.5rem;
}

/* Buttons - Red theme overrides */
.pushwars-dashboard .btn-start {
    background: linear-gradient(135deg, #e53935, #c62828);
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.35);
}

.pushwars-dashboard .btn-start:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(229, 57, 53, 0.45);
}

.pushwars-dashboard .btn-sound:hover {
    border-color: #e53935;
}

.pushwars-dashboard .btn-outline:hover {
    border-color: #e53935;
    color: #e53935;
}

/* ============================================================================
   History / Ratings Panels (sidebar)
   ============================================================================ */

.history-panel { flex-shrink: 0; }

/* ============================================================================
   Leaderboard Panel
   ============================================================================ */

.leaderboard-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding-right: 0.2rem;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    background: var(--card-hover);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.lb-row.lb-online {
    border-color: rgba(229, 57, 53, 0.25);
    background: linear-gradient(135deg, rgba(229, 57, 53, 0.06), var(--card-hover));
}

.lb-row:first-child {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), var(--card-hover));
    border-color: rgba(255, 193, 7, 0.2);
}

.lb-rank { font-size: 1rem; width: 24px; text-align: center; flex-shrink: 0; }
.lb-rank-num { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); font-family: 'Consolas', 'Monaco', monospace; }

.lb-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lb-name {
    font-size: 0.8rem; font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-games { font-size: 0.55rem; color: var(--text-muted); }

.lb-rating {
    font-size: 0.9rem; font-weight: 700; color: #e53935;
    font-family: 'Consolas', 'Monaco', monospace; flex-shrink: 0;
}

/* Elo badge on player cards */
.elo-badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    background: rgba(229, 57, 53, 0.15);
    color: #e53935;
    border: 1px solid rgba(229, 57, 53, 0.25);
    white-space: nowrap;
    vertical-align: middle;
    flex-shrink: 0;
}

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

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

.player-card.is-selected {
    border-color: #4caf50;
    background: linear-gradient(90deg, rgba(76, 175, 80, 0.1), var(--card-hover));
}

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

.player-card.is-winner {
    border-color: #ffca28;
    background: linear-gradient(90deg, rgba(255, 202, 40, 0.15), var(--card-hover));
    box-shadow: 0 0 14px rgba(255, 202, 40, 0.3);
    opacity: 1;
}

.player-card.has-robot-color {
    border-left: 3px solid rgb(var(--robot-color));
}

.player-card.just-eliminated {
    animation: eliminate-flash 0.6s ease-out;
}

@keyframes eliminate-flash {
    0% { background: rgba(229, 57, 53, 0.5); transform: scale(1.01); }
    100% { transform: scale(1); }
}

/* Color swatch, checkboxes, status badges */
.color-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cb-icon { font-size: 0.9rem; flex-shrink: 0; }

.status-badge { font-size: 0.75rem; flex-shrink: 0; }

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.alive-badge { animation: pulse-badge 1.5s ease-in-out infinite; }
.winner-badge { animation: pulse-badge 1.5s ease-in-out infinite; }

/* Find button red theme */
.pushwars-dashboard .find-btn {
    background: linear-gradient(135deg, #e53935, #c62828);
}

/* Countdown GO color */
.pushwars-dashboard .countdown-text {
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.6), 0 0 80px rgba(229, 57, 53, 0.4);
}

.pushwars-dashboard .countdown-text.go {
    color: #e53935;
    text-shadow: 0 0 40px rgba(229, 57, 53, 0.8), 0 0 80px rgba(229, 57, 53, 0.4);
}

/* ============================================================================
   Results Table (Push Wars specific)
   ============================================================================ */

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.results-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--card-border);
}

.results-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-secondary);
}

.results-table tr:last-child td { border-bottom: none; }

.results-table tr.result-winner td {
    color: var(--text-primary);
    font-weight: 600;
}

.result-place { font-size: 1.2rem; text-align: center; width: 40px; }
.result-name { display: flex; flex-direction: column; gap: 0.15rem; }
.result-robot-name { font-weight: 600; color: var(--text-primary); }

.result-crypto-id {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: 'Consolas', 'Monaco', monospace;
}

.result-elo { font-family: 'Consolas', 'Monaco', monospace; font-weight: 600; }
.result-delta { font-family: 'Consolas', 'Monaco', monospace; font-weight: 700; }

.delta-positive { color: var(--accent-green); }
.delta-negative { color: var(--accent-red); }
.delta-zero { color: var(--text-muted); }

/* ============================================================================
   History Game Cards
   ============================================================================ */

.history-game-card {
    background: var(--card-hover);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--card-border);
}
.history-game-card:last-child { margin-bottom: 0; }

.history-game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.history-game-date { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.history-game-id { font-size: 0.7rem; color: var(--text-muted); font-family: 'Consolas', 'Monaco', monospace; }

.history-table, .ratings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.history-table th, .ratings-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--card-border);
}

.history-table td, .ratings-table td {
    padding: 0.4rem 0.5rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.hist-name { font-weight: 600; color: var(--text-primary); display: block; }
.hist-id { font-size: 0.6rem; color: var(--text-muted); font-family: 'Consolas', 'Monaco', monospace; display: block; }

.rating-value { font-family: 'Consolas', 'Monaco', monospace; font-weight: 700; color: #e53935; }

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

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

.fs-mode .sidebar-right {
    width: 280px;
    display: flex !important;
}

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

.fs-mode .pushwars-content { flex-direction: row; }

.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 .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 .btn-outline { font-size: 0.85rem; padding: 0.5rem 1rem; }

.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 .elo-badge { font-size: 0.8rem; }
.fs-mode .status-badge { font-size: 0.95rem; }
.fs-mode .find-btn { width: 30px; height: 30px; font-size: 0.9rem; }
.fs-mode .cb-icon { font-size: 1.1rem; }
.fs-mode .color-swatch { width: 13px; height: 13px; }
.fs-mode .pc-reported { font-size: 0.82rem; }
.fs-mode .led-dot { width: 10px; height: 10px; }
.fs-mode .player-card.has-robot-color { border-left-width: 4px; }

.fs-mode .player-card.just-eliminated {
    animation: fs-eliminate-flash 0.8s ease-out;
}

@keyframes fs-eliminate-flash {
    0% { background: rgba(229, 57, 53, 0.6); transform: scale(1.04); box-shadow: 0 0 40px rgba(229, 57, 53, 0.5); }
    100% { transform: scale(1); box-shadow: none; }
}

.fs-mode .player-card.is-winner {
    box-shadow: 0 0 40px rgba(255, 202, 40, 0.4);
    border-width: 3px;
}

.fs-mode .sidebar-right { width: 300px; }
.fs-mode .leaderboard-panel h2 { font-size: 1.15rem; }

.fs-mode .lb-row { padding: 0.55rem 0.7rem; border-radius: 10px; gap: 0.6rem; }
.fs-mode .lb-rank { font-size: 1.2rem; width: 30px; }
.fs-mode .lb-name { font-size: 0.95rem; }
.fs-mode .lb-games { font-size: 0.65rem; }
.fs-mode .lb-rating { font-size: 1.05rem; }

:fullscreen .results-card { max-width: 700px; padding: 2.5rem; }
:fullscreen .results-title { font-size: 2rem; margin-bottom: 2rem; }
:fullscreen .results-table { font-size: 1.05rem; }
:fullscreen .results-table th { font-size: 0.8rem; padding: 0.75rem 1rem; }
:fullscreen .results-table td { padding: 0.75rem 1rem; }
:fullscreen .result-place { font-size: 1.5rem; }
:fullscreen .result-robot-name { font-size: 1.1rem; }
:fullscreen .result-crypto-id { font-size: 0.75rem; }

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

@media (max-width: 1400px) {
    .sidebar-right { width: 220px; }
}

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

@media (max-width: 1000px) {
    .sidebar-right { display: none; }
}

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

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

    .pushwars-dashboard .ble-panel,
    .pushwars-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: #c62828;
}

[data-theme="light"] .player-card.is-selected {
    border-color: #2e7d32;
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.1), rgba(255, 255, 255, 0.95));
    box-shadow: 0 0 12px rgba(46, 125, 50, 0.15);
}

[data-theme="light"] .player-card.is-eliminated {
    border-color: #c62828;
    background: linear-gradient(135deg, rgba(198, 40, 40, 0.1), rgba(255, 255, 255, 0.95));
}

[data-theme="light"] .player-card.is-winner {
    border-color: #f9a825;
    background: linear-gradient(135deg, rgba(249, 168, 37, 0.15), rgba(255, 255, 255, 0.95));
    box-shadow: 0 0 20px rgba(249, 168, 37, 0.2);
}

[data-theme="light"] .player-card.has-robot-color {
    background: linear-gradient(135deg, rgba(var(--robot-color), 0.1), rgba(255, 255, 255, 0.9));
}

[data-theme="light"] .player-card.has-robot-color.is-eliminated {
    background: linear-gradient(135deg, rgba(var(--robot-color), 0.05), rgba(255, 255, 255, 0.9));
}

[data-theme="light"] .player-card.has-robot-color.is-winner {
    background: linear-gradient(135deg, rgba(var(--robot-color), 0.15), rgba(255, 255, 255, 0.9));
}

[data-theme="light"] .gcb-phase.phase-lobby {
    background: linear-gradient(135deg, rgba(198, 40, 40, 0.1), rgba(198, 40, 40, 0.05));
}

[data-theme="light"] .gcb-phase.phase-playing {
    background: linear-gradient(135deg, rgba(198, 40, 40, 0.15), rgba(183, 28, 28, 0.08));
}

[data-theme="light"] .gcb-phase.phase-finished {
    background: linear-gradient(135deg, rgba(249, 168, 37, 0.12), rgba(249, 168, 37, 0.05));
}

[data-theme="light"] .winner-display {
    background: linear-gradient(135deg, rgba(249, 168, 37, 0.15), rgba(249, 168, 37, 0.08));
    border-color: #f9a825;
}

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

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

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

[data-theme="light"] .settings-current .current-value strong { color: #c62828; }

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

[data-theme="light"] .lb-row {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(140, 125, 105, 0.1);
}

[data-theme="light"] .lb-row.lb-online {
    border-color: rgba(198, 40, 40, 0.25);
    background: linear-gradient(135deg, rgba(198, 40, 40, 0.06), rgba(255, 255, 255, 0.8));
}

[data-theme="light"] .lb-row:first-child {
    background: linear-gradient(135deg, rgba(249, 168, 37, 0.1), rgba(255, 255, 255, 0.9));
    border-color: rgba(249, 168, 37, 0.2);
}

[data-theme="light"] .elo-badge {
    background: rgba(198, 40, 40, 0.12);
    color: #c62828;
    border-color: rgba(198, 40, 40, 0.25);
}

[data-theme="light"] .lb-rating { color: #c62828; }
