:root {
    --bg-color: #121212;
    --board-bg: #1e1e1e;
    --board-border: #333;
    --cell-bg: #2a2a2a;
    --cell-hover: #3a3a3a;
    --primary-color: #4CAF50;
    /* Green accent */
    --text-color: #e0e0e0;
    --disc-black: #000;
    --disc-white: #fff;
    --shadow-light: rgba(255, 255, 255, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.5);
    --gap: 4px;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 4vh, 20px);
    padding: clamp(10px, 3vw, 20px);
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

header {
    text-align: center;
    width: 100%;
}

h1 {
    font-weight: 700;
    margin: 0 0 10px 0;
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    letter-spacing: -1px;
}

.accent {
    color: var(--primary-color);
}

.score-board {
    display: flex;
    justify-content: space-around;
    background: var(--board-bg);
    padding: clamp(10px, 3vw, 15px);
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow-dark);
    width: 100%;
    box-sizing: border-box;
}

.player-score {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px clamp(8px, 2vw, 16px);
    border-radius: 8px;
    transition: all 0.3s ease;
    opacity: 0.6;
    flex: 1;
    justify-content: center;
}

.player-score.active {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid var(--primary-color);
    opacity: 1;
    transform: translateY(-2px);
}

.disc-icon {
    width: clamp(16px, 4vw, 20px);
    height: clamp(16px, 4vw, 20px);
    border-radius: 50%;
    box-shadow: 0 1px 3px var(--shadow-dark);
}

.disc-icon.black {
    background: var(--disc-black);
    border: 1px solid #444;
}

.disc-icon.white {
    background: var(--disc-white);
}

.name {
    font-size: clamp(0.9rem, 3.5vw, 1rem);
}

.score {
    font-weight: 700;
    font-size: clamp(1.1rem, 4vw, 1.3rem);
}

/* Board */
.game-board-container {
    position: relative;
    padding: 8px;
    background: var(--board-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-dark);
    width: 100%;
    max-width: 500px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: var(--gap);
    width: 100%;
    height: auto;
    min-height: 300px;
    /* Stronger fallback */
    aspect-ratio: 1 / 1;
    background-color: var(--board-border);
}

.cell {
    background-color: var(--cell-bg);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.2s;
}

/* Increase touch area for mobile */
@media (hover: none) {
    .cell:active {
        background-color: var(--cell-hover);
    }
}

.cell:hover:not(:active) {
    background-color: var(--cell-hover);
}

.cell.valid-move::after {
    content: '';
    width: 25%;
    height: 25%;
    background-color: rgba(76, 175, 80, 0.6);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--primary-color);
}

.cell.last-move {
    background-color: rgba(76, 175, 80, 0.1);
    /* Subtle highlight */
}

/* Disc */
.disc {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s;
    backface-visibility: hidden;
    position: absolute;
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.2),
        inset -2px -2px 5px rgba(0, 0, 0, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.3);
}

.disc.black {
    background-color: var(--disc-black);
    border: 1px solid #222;
}

.disc.white {
    background-color: var(--disc-white);
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    background: var(--board-bg);
    padding: clamp(15px, 4vw, 20px);
    border-radius: 12px;
    box-sizing: border-box;
}

.mode-select,
.difficulty-select {
    display: flex;
    justify-content: center;
    gap: clamp(10px, 4vw, 20px);
    align-items: center;
    flex-wrap: wrap;
}

.mode-select label,
.difficulty-select label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    transition: background 0.2s;
}

.mode-select label:has(input:checked) {
    background: rgba(76, 175, 80, 0.2);
    color: var(--primary-color);
}

input[type="radio"] {
    accent-color: var(--primary-color);
}

select {
    padding: 8px 12px;
    border-radius: 8px;
    background: #2a2a2a;
    color: white;
    border: 1px solid #444;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.96);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.primary:hover:not(:disabled) {
    background-color: #45a049;
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.secondary {
    background-color: transparent;
    border: 2px solid #444;
    color: #bbb;
}

.secondary:hover:not(:disabled) {
    border-color: #666;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 25px 40px;
    border-radius: 16px;
    color: white;
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    backdrop-filter: blur(8px);
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 80%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.hidden {
    display: none;
}

@media (min-width: 600px) {
    .app-container {
        padding: 40px 20px;
    }

    .board {
        width: 440px;
    }

    .controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .btn {
        padding: 12px 28px;
    }
}