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

:root {
    --board-green: #1b5e20;
    --board-light: #2e7d32;
    --board-highlight: #388e3c;
    --black: #1a1a1a;
    --white: #f5f5f5;
    --accent: #4caf50;
    --accent-dark: #2e7d32;
    --text-dark: #212121;
    --text-light: #f5f5f5;
    --border-color: #bdbdbd;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-dark);
    min-height: 100vh;
}

body {
    padding: 20px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

main {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Sidebar Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.controls section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.controls h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--text-dark);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
}

fieldset {
    border: none;
    padding: 0;
    margin-bottom: 15px;
}

legend {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-dark);
}

label {
    display: flex;
    align-items: center;
    margin: 8px 0;
    cursor: pointer;
    font-size: 0.95rem;
}

input[type="radio"],
input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

#ai-depth {
    width: 100%;
    margin: 10px 0;
}

#depth-display {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 10px;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-box {
    padding: 12px;
    background: #f5f5f5;
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    font-weight: 500;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.info-panel {
    margin-top: 15px;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.info-panel h3 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--accent-dark);
}

.info-panel div {
    display: flex;
    justify-content: space-around;
    font-weight: 600;
    font-size: 1.1rem;
}

.black-count::before {
    content: "●";
    margin-right: 6px;
    color: var(--black);
}

.white-count::before {
    content: "○";
    margin-right: 6px;
    color: var(--black);
}

.help {
    background: #e8f5e9 !important;
    border-left: 4px solid var(--accent) !important;
}

.help h2 {
    border-color: var(--accent) !important;
}

.help ul {
    list-style: none;
    padding: 0;
}

.help li {
    padding: 6px 0;
    font-size: 0.9rem;
}

kbd {
    display: inline-block;
    background: white;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Board Section */
.board-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.board {
    background: linear-gradient(135deg, var(--board-green) 0%, #1b5e20 100%);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    display: inline-grid;
    grid-template-columns: 50px repeat(8, 50px) 50px;
    grid-template-rows: 50px repeat(8, 50px) 50px;
    gap: 0;
    width: fit-content;
    margin: 0 auto;
}

.board-label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 700;
    font-size: 14px;
    user-select: none;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.board-cell {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--board-light) 0%, var(--board-green) 100%);
    border: 1px solid rgba(0, 0, 0, 0.2);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.board-cell:hover:not(.disabled) {
    background: var(--board-highlight);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 10px rgba(255, 255, 255, 0.2);
}

.board-cell:focus {
    outline: 3px solid #ffeb3b;
    outline-offset: -2px;
}

.board-cell.legal-move::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
}

/* Disk Styles */
.disk {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), inset -1px -1px 2px rgba(0, 0, 0, 0.2);
    transform: perspective(1000px) rotateX(0deg);
}

.disk.black {
    background: radial-gradient(circle at 30% 30%, #424242, #000);
    color: white;
}

.disk.white {
    background: radial-gradient(circle at 30% 30%, #fff, #e0e0e0);
    color: black;
}

.disk.flipping {
    animation: flip-disk 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes flip-disk {
    0% {
        transform: perspective(1000px) rotateY(0deg) scale(1);
    }
    50% {
        transform: perspective(1000px) rotateY(90deg) scale(1.1);
    }
    100% {
        transform: perspective(1000px) rotateY(0deg) scale(1);
    }
}

.disk.placing {
    animation: place-disk 0.3s ease-out forwards;
}

@keyframes place-disk {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.board-cell.selected {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Board Controls */
.board-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.board-controls .btn {
    flex: 1;
    max-width: 150px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0.85;
}

/* Responsive Design */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .controls {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    main {
        grid-template-columns: 1fr;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .board {
        grid-template-columns: 40px repeat(8, 40px) 40px;
        grid-template-rows: 40px repeat(8, 40px) 40px;
        padding: 15px;
    }

    .board-cell {
        width: 40px;
        height: 40px;
    }

    .disk {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .board-label {
        font-size: 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.9rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    html, body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }

    .controls section {
        background: #2a2a3e;
        color: var(--text-light);
    }

    .controls h2 {
        color: #88ccee;
    }

    .status-box {
        background: #1a1a2e;
        color: var(--text-light);
        border-left-color: #88ccee;
    }

    .info-panel {
        background: #1a1a2e;
        border-color: #444;
        color: var(--text-light);
    }

    .info-panel h3 {
        color: #88ccee;
    }

    kbd {
        background: #333;
        border-color: #555;
        color: var(--text-light);
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .controls,
    footer {
        display: none;
    }
}
