:root {
    --bg: #f5efe0;
    --line: #5d4037;
    --stone-dark: #222;
    --stone-light: #f8f8f8;
    --accent: #2b6cb0;
    --text: #1a1a1a;
    --muted: #777;
    --bad: #c0392b;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #faf7f0;
    color: var(--text);
    margin: 0;
    padding: 24px;
    max-width: 1240px;
    margin-left: auto;
    margin-right: auto;
}

.page-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 16px;
}

.main-column { flex: 1; min-width: 0; }

@media (max-width: 800px) {
    .sidebar { position: static; width: 100%; order: 2; }
    .main-column { order: 1; width: 100%; }
}

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 16px 0 8px; }

.row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.card {
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.form-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 10px 16px;
    align-items: center;
    margin-bottom: 14px;
}

button {
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 14px;
    cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:disabled { background: #bbb; cursor: not-allowed; }

.banner {
    padding: 12px 16px;
    border-radius: 6px;
    background: #fff4d6;
    border: 1px solid #e6cf6b;
    margin-bottom: 12px;
    font-size: 14px;
}
.banner.hidden { display: none; }
.hidden { display: none; }
.banner.error { background: #fde8e7; border-color: #eab5b1; color: var(--bad); }
.banner.plain { background: transparent; border-color: transparent; padding: 4px 0; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.status-strip {
    display: flex;
    gap: 24px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}
.status-strip strong { color: var(--text); }

#board-svg {
    display: block;
    border-radius: 8px;
    touch-action: manipulation;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(60, 40, 10, 0.35), 0 2px 4px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 540px;
    height: auto;
    aspect-ratio: 1 / 1;
}
#board-svg:focus { outline: none; }

#winprob-svg { background: #fff; border: 1px solid #eee; border-radius: 4px; }

.footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* 3x3 Go-board spinner — stones fade in/out at staggered intervals. */
.go-spinner {
    display: inline-grid;
    grid-template-columns: repeat(3, 10px);
    grid-template-rows: repeat(3, 10px);
    gap: 2px;
    vertical-align: middle;
    margin-right: 8px;
}
.go-spinner i {
    display: block;
    border-radius: 50%;
    opacity: 0;
    animation: go-stone 2.4s infinite ease-in-out;
}
.go-spinner i:nth-child(odd)  { background: #111; }
.go-spinner i:nth-child(even) { background: #fff; box-shadow: inset 0 0 0 1px #111; }
.go-spinner i:nth-child(1) { animation-delay: 0.00s; }
.go-spinner i:nth-child(2) { animation-delay: 0.90s; }
.go-spinner i:nth-child(3) { animation-delay: 0.30s; }
.go-spinner i:nth-child(4) { animation-delay: 1.50s; }
.go-spinner i:nth-child(5) { animation-delay: 0.55s; }
.go-spinner i:nth-child(6) { animation-delay: 2.05s; }
.go-spinner i:nth-child(7) { animation-delay: 1.20s; }
.go-spinner i:nth-child(8) { animation-delay: 0.40s; }
.go-spinner i:nth-child(9) { animation-delay: 1.80s; }
@keyframes go-stone {
    0%, 100% { opacity: 0; transform: scale(0.55); }
    20%, 55% { opacity: 1; transform: scale(1); }
    75%      { opacity: 0; transform: scale(0.55); }
}
