:root {
    --bg-color: #121212;
    --board-bg: #228b22;
    --board-border: #111;
    --cell-border: rgba(0, 0, 0, 0.2);
    --text-color: #fff;
    --black-disc: #111;
    --white-disc: #ffffff;
    --valid-move: rgba(0, 0, 0, 0.15);
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    touch-action: manipulation;
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header { text-align: center; }
h1 { font-size: 2rem; margin-bottom: 15px; color: var(--board-bg); }

.status-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 15px;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 20px;
    border-radius: 12px;
}

.score {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.score.active { opacity: 1; }

.disc {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.disc.black { background: var(--black-disc); }
.disc.white { 
    background: var(--white-disc); 
    border: 1px solid rgba(0,0,0,0.1);
}

.status-message {
    font-size: 1rem;
    font-weight: 500;
}

.board.setup {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.5);
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    background-color: var(--board-border);
    border: 4px solid var(--board-border);
    border-radius: 8px;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
}

.cell {
    background-color: var(--board-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.cell:active { filter: brightness(0.9); }

.cell-disc {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.6s, opacity 0.3s;
    transform: scale(0) rotateY(0deg);
}

.cell-disc.black {
    background-color: var(--black-disc);
    transform: scale(1) rotateY(0deg);
}

.cell-disc.white {
    background-color: var(--white-disc);
    transform: scale(1) rotateY(0deg);
    border: 1px solid rgba(0,0,0,0.2);
}

.cell-disc.valid-move {
    background-color: var(--valid-move);
    transform: scale(0.3);
    box-shadow: none;
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.selection-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 15px;
    border-radius: 12px;
}

.selection-group span {
    font-size: 0.9rem;
    font-weight: 500;
}

.button-group {
    display: flex;
    gap: 8px;
}

.color-btn, .setting-btn, .engine-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 80px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-btn.active, .setting-btn.active, .engine-btn.active {
    background: var(--primary) !important;
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 12px var(--primary);
    font-weight: bold;
    transform: scale(1.05);
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(1);
}

.primary-btn {
    width: 100%;
    margin-top: 5px;
    background-color: var(--primary);
}

.btn {
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:not(.color-btn):not(.setting-btn):not(.engine-btn) {
    background-color: var(--primary);
}

.btn:hover:not(:disabled) { 
    background-color: var(--primary-hover);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.btn:active:not(:disabled) { transform: scale(0.98); }

.cell-disc.last-move {
    box-shadow: 0 0 0 4px var(--primary);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0px rgba(74, 222, 128, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0px rgba(74, 222, 128, 0); }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
        gap: 15px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .status-bar {
        padding: 8px 12px;
        display: grid;
        grid-template-columns: 1fr 2fr 1fr;
        gap: 5px;
    }

    .status-message {
        font-size: 0.8rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .score {
        font-size: 1rem;
        gap: 5px;
    }

    .disc {
        width: 15px;
        height: 15px;
    }

    .selection-group {
        padding: 6px 10px;
    }

    .selection-group span {
        font-size: 0.8rem;
    }

    .color-btn, .setting-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
        min-width: 65px;
    }

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

footer {
    text-align: center;
    margin-top: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #ff4444;
}