*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container { width: 100%; max-width: 900px; }

h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 2rem;
    color: #e8c56d;
    letter-spacing: 2px;
}

.game-area {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

.board-wrapper {
    position: relative;
    width: 580px;
    height: 580px;
    flex-shrink: 0;
}

canvas {
    border: 3px solid #5c3317;
    border-radius: 4px;
    display: block;
    width: 580px;
    height: 580px;
}

.board-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}
.board-overlay.waiting  { cursor: crosshair; }
.board-overlay.thinking { cursor: wait; }

.panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 190px;
    max-width: 220px;
}

button {
    padding: 11px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-computer {
    background: #2a2a2a;
    color: #e8c56d;
    border: 2px solid #555;
}
.btn-computer:hover:not(:disabled)  { background: #3a3a3a; }
.btn-computer:active:not(:disabled) { background: #1a1a1a; }

.btn-you {
    background: #f0f0f0;
    color: #1a1a2e;
    border: 2px solid #aaa;
}
.btn-you:hover:not(:disabled)  { background: #ffffff; }
.btn-you:active:not(:disabled) { background: #ddd; }

.start-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status {
    padding: 12px 14px;
    background: #0f3460;
    border-radius: 8px;
    min-height: 52px;
    line-height: 1.5;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.status.thinking { background: #1a3a60; }
.status.win      { background: #1a5c38; }
.status.lose     { background: #5c1a1a; }
.status.error    { background: #5c3a1a; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    color: #bbb;
}
.legend div { display: flex; align-items: center; gap: 8px; }

.stone-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}
.stone-icon.black { background: radial-gradient(circle at 35% 35%, #666, #111); }
.stone-icon.white { background: radial-gradient(circle at 35% 35%, #fff, #ccc); border: 1px solid #aaa; }

.footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8rem;
    color: #555;
}

@media (max-width: 680px) {
    .board-wrapper { width: 100vw; height: 100vw; max-width: 580px; max-height: 580px; }
    canvas { width: 100%; height: 100%; }
    .panel { max-width: 100%; flex-direction: row; flex-wrap: wrap; }
    .legend { flex-direction: row; }
}
