/**
 * 4-Player Reactor - Styles
 * Based on whiteboard styling patterns
 */

/* ============================================
   BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #333;
    overflow: hidden;
    height: 100vh;
}

/* ============================================
   MODAL (Same as Whiteboard)
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2rem;
    text-align: center;
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: #666;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.status-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
}

.status-message.info {
    background: #dbeafe;
    color: #1e40af;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
}

.status-message.success {
    background: #d1fae5;
    color: #065f46;
}

/* ============================================
   GAME CONTAINER
   ============================================ */

#gameContainer {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#gameContainer.hidden {
    display: none;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid #667eea;
}

.game-info h1 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.room-badge {
    background: rgba(102, 126, 234, 0.3);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
}

.game-status {
    display: flex;
    gap: 2rem;
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;
}

.share-btn {
    padding: 8px 16px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.indicator {
    font-size: 1.5rem;
}

.indicator.connected {
    color: #10b981;
}

.indicator.disconnected {
    color: #ef4444;
}

/* ============================================
   GAME ARENA
   ============================================ */

.game-arena {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    background: #0f0f1e;
    padding: 2px;
    position: relative;
}

/* Reaction Zones */
.reaction-zone {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
}

.reaction-zone:hover {
    transform: scale(0.98);
}

.reaction-zone.ready {
    border-color: #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        border-color: #10b981;
        box-shadow: inset 0 0 20px rgba(16, 185, 129, 0.3);
    }
    50% {
        border-color: #34d399;
        box-shadow: inset 0 0 40px rgba(16, 185, 129, 0.5);
    }
}

/* Zone Colors */
.zone-blue {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.zone-red {
    background: linear-gradient(135deg, #991b1b 0%, #ef4444 100%);
}

.zone-green {
    background: linear-gradient(135deg, #065f46 0%, #10b981 100%);
}

.zone-yellow {
    background: linear-gradient(135deg, #92400e 0%, #f59e0b 100%);
}

/* Zone Content */
.zone-content {
    text-align: center;
    color: white;
}

.zone-light {
    width: 150px;
    height: 150px;
    margin: 0 auto 2rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 4px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s;
}

.zone-light.active {
    background: white;
    box-shadow: 0 0 60px rgba(255, 255, 255, 0.9),
                0 0 100px rgba(255, 255, 255, 0.6),
                inset 0 0 40px rgba(255, 255, 255, 0.8);
    animation: glow 0.3s ease-in-out;
    transform: scale(1.1);
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 60px rgba(255, 255, 255, 0.9),
                    0 0 100px rgba(255, 255, 255, 0.6),
                    inset 0 0 40px rgba(255, 255, 255, 0.8);
    }
    50% {
        box-shadow: 0 0 80px rgba(255, 255, 255, 1),
                    0 0 120px rgba(255, 255, 255, 0.8),
                    inset 0 0 60px rgba(255, 255, 255, 1);
    }
}

.zone-player {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.zone-score {
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

/* Control Panel (Center) */
.control-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    min-width: 300px;
    border: 2px solid #667eea;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.control-panel.hidden {
    display: none;
}

.control-panel button {
    pointer-events: all;
}

.game-message {
    color: white;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.btn-ready,
.btn-start {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    margin: 0.5rem;
}

.btn-ready:hover,
.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-ready.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-ready.hidden,
.btn-start.hidden {
    display: none;
}

/* Stage Display in Control Panel */
.stage-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    pointer-events: all;
}

#currentStageDisplay {
    color: #fbbf24;
    font-size: 1.5rem;
    font-weight: bold;
}

.btn-stage-select {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: all !important;
    cursor: pointer;
    position: relative;
    z-index: 100;
}

.btn-stage-select:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-stage-select.hidden {
    display: none;
}

.stage-info {
    color: #9ca3af;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    max-width: 280px;
}

/* Target Color Display (Color Match Mode) */
.target-color-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 6px solid white;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
    z-index: 10;
}

.target-color-display.hidden {
    display: none;
}

/* ============================================
   STAGE SELECTION MODAL
   ============================================ */

#stageModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

#stageModal:not(.hidden) {
    display: flex !important;
}

.stage-modal-content {
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    background: white;
    padding: 2rem;
    border-radius: 12px;
}

.stage-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.stage-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.stage-card:hover {
    border-color: #667eea;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.stage-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}

.stage-icon {
    font-size: 2.5rem;
    min-width: 60px;
    text-align: center;
}

.stage-info {
    flex: 1;
}

.stage-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.stage-desc {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.4;
}

.stage-number {
    font-size: 1.25rem;
    font-weight: bold;
    color: #9ca3af;
    min-width: 40px;
    text-align: center;
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

/* ============================================
   SCOREBOARD PANEL
   ============================================ */

.scoreboard-panel {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    border-top: 2px solid #667eea;
    display: flex;
    gap: 2rem;
    align-items: center;
}

.scoreboard-panel h3 {
    color: white;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.scoreboard-panel h4 {
    color: white;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

#leaderboard {
    flex: 1;
    display: flex;
    gap: 1rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
}

.rank {
    font-size: 1.5rem;
    min-width: 40px;
}

.player-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
}

.player-name {
    flex: 1;
    font-weight: 600;
}

.player-score {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fbbf24;
}

.stats-panel {
    width: 300px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

#gameStats {
    color: #9ca3af;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.stat-row span:last-child {
    color: white;
    font-weight: bold;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .scoreboard-panel {
        flex-direction: column;
        align-items: stretch;
    }

    #leaderboard {
        flex-direction: column;
    }

    .stats-panel {
        width: 100%;
    }

    .zone-light {
        width: 100px;
        height: 100px;
    }

    .zone-score {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .game-status {
        flex-direction: column;
        gap: 0.5rem;
        font-size: 1rem;
    }

    .control-panel {
        min-width: 250px;
        padding: 1.5rem;
    }

    .game-message {
        font-size: 1rem;
    }

    .zone-player {
        font-size: 1.125rem;
    }

    .zone-light {
        width: 80px;
        height: 80px;
        margin-bottom: 1rem;
    }
}

