:root {
    --bg: #f4f1ea;
    --card: #fffaf0;
    --ink: #1f2933;
    --muted: #64748b;
    --line: #5b4636;
    --accent: #8b5a2b;
    --human: #111827;
    --ai: #e8dfd1;
    --danger: #b91c1c;
    --ok: #166534;
    --ai-glow: #f59e0b;
    --ai-glow-soft: rgba(245, 158, 11, .36);
    --ai-glow-strong: rgba(245, 158, 11, .72);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #fff8e7 0, var(--bg) 45%, #e5ded1 100%);
    color: var(--ink);
    min-height: 100vh;
}
.app-header, .app-footer {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}
.brand { display: flex; gap: 16px; align-items: center; }
.logo { max-height: 52px; }
h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.5rem); }
.app-header p { margin: 4px 0 0; color: var(--muted); }
.version { color: var(--muted); font-size: .9rem; }
.app-main { max-width: 1180px; margin: 0 auto; padding: 0 20px 24px; }
.layout { display: grid; grid-template-columns: minmax(320px, 720px) minmax(280px, 380px); gap: 24px; align-items: start; }
.board-card, .panel, .text-card {
    background: rgba(255, 250, 240, .92);
    border: 1px solid rgba(91, 70, 54, .18);
    border-radius: 24px;
    box-shadow: 0 22px 60px rgba(44, 31, 17, .12);
}
.board-card { padding: 18px; }
.board-wrap { position: relative; aspect-ratio: 1 / 1; width: 100%; max-width: 720px; margin: 0 auto; }
.lines { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.lines rect, .lines line { fill: none; stroke: var(--line); stroke-width: 9; stroke-linecap: round; }
.board { position: absolute; inset: 0; z-index: 2; }
.fx-layer {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}
.point {
    position: absolute;
    width: 42px;
    height: 42px;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    border: 3px solid var(--line);
    background: #f7ecd8;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
    touch-action: manipulation;
    z-index: 3;
}
.point:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
.point:hover { transform: translate(-50%, -50%) scale(1.12); box-shadow: 0 0 0 8px rgba(139, 90, 43, .12); }
.stone {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    animation: pop .22s ease-out;
}
.stone.human { background: radial-gradient(circle at 30% 25%, #6b7280, var(--human) 65%); box-shadow: inset -5px -5px 10px rgba(0,0,0,.35), 0 6px 12px rgba(0,0,0,.22); }
.stone.ai { background: radial-gradient(circle at 30% 25%, #fff, var(--ai) 65%); box-shadow: inset -5px -5px 10px rgba(0,0,0,.16), 0 6px 12px rgba(0,0,0,.16); border: 1px solid #c7bba9; }
.point.selected { box-shadow: 0 0 0 9px rgba(22, 101, 52, .18); border-color: var(--ok); }
.point.removable { box-shadow: 0 0 0 9px rgba(185, 28, 28, .16); border-color: var(--danger); }
.point.hint { box-shadow: 0 0 0 10px rgba(37, 99, 235, .18); }
.point.ai-preview-from,
.point.ai-preview-to {
    border-color: var(--ai-glow);
    box-shadow: 0 0 0 13px var(--ai-glow-soft), 0 0 34px var(--ai-glow-strong), 0 0 58px rgba(245, 158, 11, .34);
}
.point.ai-preview-from { animation: pulseFocus 1.25s ease-in-out infinite; }
.point.ai-preview-to { animation: pulseFocus 1.15s ease-in-out infinite; }
.point.ai-trail-from,
.point.ai-trail-to {
    border-color: var(--ai-glow);
    box-shadow: 0 0 0 14px rgba(245, 158, 11, .22), 0 0 32px rgba(245, 158, 11, .64), 0 0 56px rgba(245, 158, 11, .28);
}
.point.ai-remove-target {
    border-color: var(--danger);
    box-shadow: 0 0 0 14px rgba(185, 28, 28, .22), 0 0 36px rgba(185, 28, 28, .62), 0 0 60px rgba(185, 28, 28, .28);
    animation: pulseDanger 1s ease-in-out infinite;
}
.point.ai-removed {
    border-color: #dc2626;
    box-shadow: 0 0 0 12px rgba(220, 38, 38, .14), 0 0 28px rgba(220, 38, 38, .28);
    animation: removedFlash 1.1s ease-out 1;
}
.stone.ai-place-flash {
    animation: pop .22s ease-out, placeGlow 1.35s ease-out 1;
}
.stone.remove-warn {
    animation: dangerShake .46s ease-in-out infinite alternate;
}
.move-trail {
    position: absolute;
    height: 12px;
    transform-origin: left center;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(245, 158, 11, .15) 0%, rgba(245, 158, 11, .95) 52%, rgba(252, 211, 77, .22) 100%);
    box-shadow: 0 0 18px rgba(245, 158, 11, .72), 0 0 36px rgba(245, 158, 11, .42), 0 0 64px rgba(245, 158, 11, .24);
    animation: trailFlow 1.55s ease-out 1;
}
@keyframes pop { from { transform: scale(.25); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@keyframes pulseFocus {
    0%, 100% { box-shadow: 0 0 0 10px rgba(245, 158, 11, .22), 0 0 24px rgba(245, 158, 11, .42), 0 0 44px rgba(245, 158, 11, .18); }
    50% { box-shadow: 0 0 0 17px rgba(245, 158, 11, .34), 0 0 42px rgba(245, 158, 11, .72), 0 0 72px rgba(245, 158, 11, .32); }
}
@keyframes pulseDanger {
    0%, 100% { box-shadow: 0 0 0 10px rgba(185, 28, 28, .2), 0 0 24px rgba(185, 28, 28, .42); }
    50% { box-shadow: 0 0 0 18px rgba(185, 28, 28, .28), 0 0 46px rgba(185, 28, 28, .72); }
}
@keyframes placeGlow {
    0% { box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
    35% { box-shadow: 0 0 0 18px rgba(245, 158, 11, .28), 0 0 44px rgba(245, 158, 11, .72); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0), 0 0 0 rgba(245, 158, 11, 0); }
}
@keyframes removedFlash {
    0% { background: #f7ecd8; }
    35% { background: rgba(220, 38, 38, .18); }
    100% { background: #f7ecd8; }
}
@keyframes dangerShake {
    from { transform: translateX(-1px) scale(1); }
    to { transform: translateX(1px) scale(1.02); }
}
@keyframes trailFlow {
    0% { opacity: 0; transform: translateY(-50%) scaleX(.18); }
    35% { opacity: 1; transform: translateY(-50%) scaleX(1); }
    100% { opacity: 0; transform: translateY(-50%) scaleX(1); }
}
.panel { padding: 22px; }
.status-box h2 { margin: 0 0 6px; }
.status-box p { margin: 0; color: var(--muted); line-height: 1.5; }
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.score-grid div { background: #f6ecd9; border-radius: 16px; padding: 14px; }
.score-grid span { display: block; color: var(--muted); font-size: .88rem; }
.score-grid strong { font-size: 1.8rem; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.strength-control {
    margin: 18px 0 4px;
    padding: 16px;
    border-radius: 18px;
    background: #f6ecd9;
    border: 1px solid rgba(91,70,54,.14);
}
.strength-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.strength-head label { font-weight: 800; }
.strength-head strong { color: #6d3f12; font-size: 1.05rem; }
.strength-control input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}
.strength-control p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: .92rem;
}

button { appearance: none; border: 0; background: var(--accent); color: white; padding: 12px 16px; border-radius: 14px; font-weight: 700; cursor: pointer; }
button.secondary { background: #334155; }
button:disabled { opacity: .55; cursor: not-allowed; }
.rules { margin-top: 20px; color: var(--muted); line-height: 1.55; }
.rules h3 { color: var(--ink); margin-bottom: 6px; }
.log { margin-top: 18px; max-height: 170px; overflow: auto; font-size: .9rem; color: var(--muted); border-top: 1px solid rgba(91,70,54,.18); padding-top: 12px; }
.log p { margin: 0 0 8px; }
.app-footer { color: var(--muted); font-size: .92rem; }
a { color: #6d3f12; }
.text-card { padding: 24px; line-height: 1.6; }
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .app-header, .app-footer { flex-direction: column; align-items: flex-start; }
    .point { width: 34px; height: 34px; }
    .stone { width: 26px; height: 26px; }
}
