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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 800px;
    width: 100%;
}

h1 {
    text-align: center;
    color: white;
    font-size: 2.5em;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.screen {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.screen.hidden {
    display: none;
}

/* Menu Screen */
.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.menu-content h2 {
    color: #333;
    margin-bottom: 10px;
}

/* Mode Sections */
.mode-section {
    width: 100%;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-section h3 {
    margin: 0 0 15px 0;
    color: #333;
    text-align: center;
    font-size: 1.2em;
}

.ai-mode {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

.multiplayer-mode {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
}

/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.difficulty-selector label {
    font-weight: bold;
    color: #555;
}

.difficulty-selector select,
.select {
    padding: 8px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    background: white;
    transition: border-color 0.3s;
}

.difficulty-selector select:focus,
.select:focus {
    outline: none;
    border-color: #667eea;
}

/* Resume Prompt */
.resume-prompt {
    width: 100%;
    padding: 15px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.resume-prompt.hidden {
    display: none;
}

.resume-prompt p {
    color: #856404;
    font-weight: bold;
    margin-bottom: 10px;
}

.resume-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.resume-buttons .btn {
    min-width: 150px;
}

.btn-small {
    padding: 8px 20px;
    font-size: 0.9em;
}

.divider {
    color: #999;
    font-weight: bold;
    margin: 10px 0;
    text-align: center;
}

/* Active Games List */
.active-games {
    width: 100%;
    margin-bottom: 20px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.active-games.hidden {
    display: none;
}

.active-games h3 {
    margin: 0 0 15px 0;
    color: #333;
}

#games-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.game-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-item-id {
    font-weight: bold;
    color: #667eea;
}

.game-item-status {
    font-size: 0.85em;
    color: #666;
}

.game-item-status.waiting {
    color: #f39c12;
}

.game-item-status.active {
    color: #27ae60;
}

/* Join Confirmation Screen */
.confirmation-content {
    text-align: center;
}

.confirmation-content h2 {
    color: #333;
    margin-bottom: 20px;
}

.confirmation-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

/* Waiting Screen */
.waiting-content {
    text-align: center;
}

.waiting-content h2 {
    color: #333;
    margin-bottom: 20px;
}

.game-id-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.url-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.url-display input {
    flex: 1;
    padding: 12px;
    font-size: 0.9em;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #f9f9f9;
    text-align: center;
    font-family: monospace;
}

.url-display input:focus {
    outline: none;
    border-color: #667eea;
}

#waiting-board-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
}

#waiting-canvas {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.2);
}

/* Game Screen */
.game-info {
    margin-bottom: 20px;
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.player {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-label {
    font-weight: bold;
    font-size: 1.1em;
}

.red-player .player-label {
    color: #d32f2f;
}

.black-player .player-label {
    color: #333;
}

.status {
    font-size: 0.9em;
    color: #666;
}

.game-id-small {
    font-size: 0.9em;
    color: #666;
}

.turn-indicator {
    text-align: center;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1em;
}

.turn-indicator.red-turn {
    background: #ffebee;
    color: #d32f2f;
}

.turn-indicator.black-turn {
    background: #f5f5f5;
    color: #333;
}

/* AI Thinking Indicator */
.ai-thinking {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    margin-top: 10px;
    border-radius: 8px;
    font-weight: bold;
}

.ai-thinking.hidden {
    display: none;
}

/* AI is actively thinking (yellow with spinner) */
.ai-thinking.ai-thinking-active {
    background: #fff3cd;
    border: 2px solid #ffc107;
    color: #856404;
    animation: pulse 2s ease-in-out infinite;
}

/* AI is waiting for player (green, no spinner) */
.ai-thinking.ai-waiting {
    background: #d4edda;
    border: 2px solid #28a745;
    color: #155724;
}

.thinking-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #ffc107;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Board Container */
#board-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
}

#board-canvas {
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

/* Game Over Overlay */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-overlay.hidden {
    display: none;
}

.game-over-content {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
}

.game-over-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2em;
}

#game-over-message {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 30px;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

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

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.waiting-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.input {
    padding: 12px 20px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    width: 300px;
    text-align: center;
    transition: border-color 0.3s;
}

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

#join-game-btn {
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 0;
        align-items: flex-start;
    }

    .container {
        max-width: 100%;
    }

    h1 {
        font-size: 1.5em;
        margin-bottom: 15px;
        padding: 15px 10px 0;
    }

    .screen {
        padding: 15px 10px;
        border-radius: 0;
        min-height: 100vh;
    }

    /* Make board container take full width with minimal padding */
    #board-container, #waiting-board-container {
        margin: 10px -10px;
        padding: 10px;
        background: #f5f5f5;
        border-radius: 0;
    }

    /* Scale canvas to full width on mobile */
    #board-canvas, #waiting-canvas {
        max-width: 100%;
        width: 100%;
        height: auto;
    }

    /* Compact game info on mobile */
    .game-info {
        margin-bottom: 10px;
    }

    .player-info {
        flex-direction: column;
        gap: 8px;
        font-size: 0.9em;
    }

    .game-id-small {
        font-size: 0.8em;
    }

    .turn-indicator {
        padding: 8px;
        font-size: 0.95em;
    }

    /* Compact controls */
    .game-controls, .waiting-controls {
        flex-direction: column;
        gap: 8px;
        margin-top: 15px;
    }

    .game-controls .btn, .waiting-controls .btn {
        width: 100%;
        padding: 12px;
    }

    /* Smaller inputs and buttons */
    .input {
        width: 100%;
        padding: 10px;
        font-size: 0.9em;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }

    /* URL display */
    .url-display {
        flex-direction: column;
        gap: 8px;
    }

    .url-display input {
        width: 100%;
        font-size: 0.75em;
        padding: 10px;
    }

    /* Game ID display */
    .game-id-display {
        font-size: 1.2em;
        padding: 12px;
        margin: 15px 0;
    }

    /* Active games list */
    .active-games {
        padding: 15px;
        margin-bottom: 15px;
    }

    .game-item {
        padding: 10px;
    }

    .game-item-id {
        font-size: 0.95em;
    }

    .game-item-status {
        font-size: 0.8em;
    }

    /* Menu content */
    .menu-content {
        gap: 15px;
    }

    .menu-content h2 {
        font-size: 1.3em;
    }

    /* Join confirmation */
    .confirmation-content h2 {
        font-size: 1.3em;
    }

    /* Game over overlay */
    .game-over-content {
        padding: 30px 20px;
        margin: 0 15px;
    }

    .game-over-content h2 {
        font-size: 1.5em;
    }

    #game-over-message {
        font-size: 1em;
    }

    /* Mode sections */
    .mode-section {
        padding: 15px;
    }

    .mode-section h3 {
        font-size: 1.1em;
    }

    /* Difficulty selector */
    .difficulty-selector {
        flex-direction: column;
        gap: 8px;
    }

    .difficulty-selector select {
        width: 100%;
    }

    /* AI thinking indicator */
    .ai-thinking {
        padding: 8px;
        font-size: 0.9em;
    }

    .thinking-spinner {
        width: 16px;
        height: 16px;
    }

    /* Resume prompt */
    .resume-prompt {
        padding: 12px;
        margin-bottom: 15px;
    }

    .resume-prompt p {
        font-size: 0.9em;
    }

    .resume-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .btn-small {
        width: 100%;
    }
}
