/* General Styles */
body {
    background: #121212;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    text-align: center;
    background: #1e1e1e;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 800px;
}

h1 {
    margin-bottom: 30px;
    color: #ffffff;
    font-size: 3em;
    font-weight: bold;
}

h2 {
    margin-bottom: 20px;
    color: #e0e0e0;
}

/* Buttons */
button {
    padding: 12px 25px;
    font-size: 16px;
    background: #444;
    color: #e0e0e0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    margin: 10px 5px;
    width: auto;
}

button:hover {
    background: #555;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.start-game-btn {
    background: #2e7d32;
    color: white;
}

.start-game-btn:hover {
    background: #388e3c;
}

/* Inputs */
input[type="text"] {
    padding: 12px;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid #444;
    background: #2a2a2a;
    color: #e0e0e0;
    width: calc(100% - 24px);
    font-size: 16px;
    box-sizing: border-box;
}

input[type="text"]::placeholder {
    color: #888;
}

/* Sections */
.mode-selection, .player-setup, .game-container {
    display: none; /* Initially hidden */
}

#modeSelection {
    display: block;
}

.player-setup div {
    margin-top: 15px;
}

/* Game Board */
.game-area {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: center;
    align-items: flex-start;
}

.board {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.grid {
    display: grid;
    grid-template-columns: repeat(7, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 8px;
    background: #1a1a1a;
    padding: 15px;
    border-radius: 10px;
}

.cell {
    background: #333;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #444;
    position: relative;
}

.cell:hover {
    background: #4a4a4a;
    transform: scale(1.05);
}

.cell.red {
    background: #c62828;
    border-color: #d32f2f;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cell.yellow {
    background: #f57c00;
    border-color: #ff9800;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cell.win {
    animation: win-pulse 1s infinite;
    border-color: #4caf50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
}

.cell.lose {
    animation: lose-pulse 1s infinite;
    border-color: #f44336;
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.6);
}

@keyframes win-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.8);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    }
}

@keyframes lose-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Side Panel */
.side-panel {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 15px;
    min-width: 250px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.status {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #e0e0e0;
    font-weight: bold;
}

/* Player Info */
.player-info {
    margin: 10px 0;
    padding: 15px;
    background: #333;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-details {
    display: flex;
    align-items: center;
    gap: 20px;
}

.player-name {
    margin-bottom: 0;
}

.score-display {
    font-size: 1.2em;
    color: #e0e0e0;
}

.opponent-info {
    color: #e0e0e0;
    font-style: italic;
}

/* Online Controls */
.online-controls {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.room-input {
    width: 250px;
    text-align: center;
}

.room-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
}

.room-btn {
    min-width: 120px;
    background: #1976d2;
    color: white;
}

.room-btn:hover {
    background: #2196f3;
}

.share-link {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.share-link input {
    width: 80%;
    text-align: center;
    background: #333;
    border-color: #555;
}

.waiting-message {
    color: #ff9800;
    margin: 15px 0;
    font-size: 1.1em;
    font-weight: bold;
}

/* Game History */
.game-history {
    margin-top: 20px;
    padding: 15px;
    background: #333;
    border-radius: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.game-history h3 {
    margin-top: 0;
    color: #e0e0e0;
    margin-bottom: 15px;
}

.history-item {
    padding: 8px;
    border-bottom: 1px solid #444;
    color: #e0e0e0;
}

.history-item:last-child {
    border-bottom: none;
}

/* Error Messages */
.error-message {
    color: #f44336;
    font-size: 0.9em;
    margin-top: 5px;
    display: none;
}

/* Popup/Modal for Winner */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background: #2c2c2c;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: #fff;
    max-width: 400px;
}

#winnerText {
    font-size: 2.5em;
    margin-bottom: 25px;
    font-weight: bold;
}

/* Controls */
.controls {
    margin-top: 20px;
}

.back-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 25px;
    background: #666;
    color: #e0e0e0;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.3s, transform 0.2s;
}

.back-btn:hover {
    background: #777;
    transform: translateY(-2px);
    text-decoration: none;
    color: #e0e0e0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        width: 95%;
    }
    
    .game-area {
        flex-direction: column;
        align-items: center;
    }
    
    .grid {
        grid-template-columns: repeat(7, 45px);
        grid-template-rows: repeat(6, 45px);
        gap: 5px;
        padding: 10px;
    }
    
    .side-panel {
        width: 100%;
        max-width: 400px;
    }
    
    h1 {
        font-size: 2em;
    }
}