:root {
    --ink: #2d2016;
    --ink-soft: #665140;
    --paper-1: #f8efdd;
    --paper-2: #e4cfaa;
    --line: rgba(106, 72, 43, 0.24);
    --panel: rgba(255, 248, 233, 0.84);
    --shadow: 0 14px 32px rgba(62, 39, 20, 0.16);
    --accent: #9b471d;
    --accent-strong: #6f3013;
    --board-size: min(78vw, 730px);
}

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

.wzq-body {
    min-height: 100vh;
    color: var(--ink);
    font-family: "STKaiti", "KaiTi", "SimSun", serif;
    background:
        radial-gradient(circle at 12% 12%, rgba(171, 111, 59, 0.25) 0, transparent 35%),
        radial-gradient(circle at 86% 11%, rgba(107, 62, 32, 0.22) 0, transparent 34%),
        linear-gradient(180deg, var(--paper-1) 0%, var(--paper-2) 100%);
    position: relative;
}

.wzq-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.16;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent 34px,
            rgba(119, 81, 50, 0.05) 35px
        );
}

.wzq-shell {
    width: min(1220px, calc(100% - 2rem));
    margin: 1rem auto 2rem;
    position: relative;
    z-index: 1;
}

.wzq-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    padding: 0.72rem 0.9rem;
    border-radius: 15px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0.8rem;
    z-index: 8;
}

.wzq-top a {
    text-decoration: none;
    border-radius: 999px;
    padding: 0.38rem 0.84rem;
    font-size: 0.96rem;
}

.back-link {
    color: #fff8ee;
    background: linear-gradient(120deg, var(--accent-strong) 0%, var(--accent) 100%);
}

.home-link {
    color: #4a3424;
    border: 1px solid rgba(116, 77, 45, 0.25);
    background: rgba(255, 245, 225, 0.76);
}

.wzq-layout {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 318px 1fr;
    gap: 1rem;
}

.side-panel {
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 1rem;
    align-self: start;
}

.side-panel h1 {
    font-size: 2rem;
    color: var(--accent-strong);
}

.subtitle {
    margin-top: 0.35rem;
    line-height: 1.65;
    color: var(--ink-soft);
}

.turn-box {
    margin-top: 0.9rem;
    border-radius: 13px;
    border: 1px solid rgba(116, 78, 47, 0.22);
    background: rgba(255, 251, 244, 0.84);
    display: flex;
    align-items: center;
    gap: 0.68rem;
    padding: 0.72rem;
}

.label {
    color: var(--ink-soft);
    font-size: 0.92rem;
}

#turnText {
    font-size: 1.2rem;
}

.stone {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex: none;
}

.stone-black {
    background: radial-gradient(circle at 32% 30%, #6f6f6f 0%, #161616 58%, #000 100%);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35);
}

.stone-white {
    background: radial-gradient(circle at 35% 35%, #fff 0%, #f0f0f0 65%, #d6d6d6 100%);
    border: 1px solid #d2d2d2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.stat-grid {
    margin-top: 0.78rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.52rem;
}

.stat-grid article {
    border-radius: 11px;
    border: 1px solid rgba(116, 78, 47, 0.2);
    background: rgba(255, 251, 244, 0.82);
    text-align: center;
    padding: 0.55rem 0.35rem;
}

.stat-grid h3 {
    font-size: 1.4rem;
    line-height: 1;
}

.stat-grid p {
    margin-top: 0.2rem;
    font-size: 0.84rem;
    color: var(--ink-soft);
}

.btn-row {
    margin-top: 0.86rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.54rem;
}

.btn-row button {
    border: 0;
    border-radius: 10px;
    padding: 0.54rem 0.46rem;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

#undoBtn {
    color: #4b3422;
    border: 1px solid rgba(116, 77, 45, 0.25);
    background: rgba(255, 245, 225, 0.78);
}

#restartBtn {
    color: #fff8ed;
    background: linear-gradient(120deg, var(--accent-strong) 0%, var(--accent) 100%);
}

.btn-row button:hover {
    transform: translateY(-2px);
    filter: saturate(1.1);
}

.btn-row button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.tips {
    margin-top: 0.88rem;
    margin-left: 1rem;
    color: #4a3627;
    display: grid;
    gap: 0.32rem;
}

.tips li {
    line-height: 1.58;
}

.board-panel {
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 0.92rem;
}

.board-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.72rem;
}

#statusText {
    font-size: 1.08rem;
    color: #3f2d20;
}

.winner-tag {
    border-radius: 999px;
    padding: 0.25rem 0.68rem;
    color: #fff8ee;
    background: linear-gradient(120deg, #2f6a4d 0%, #3c8d66 100%);
    font-size: 0.9rem;
}

.hidden {
    display: none;
}

#box {
    width: var(--board-size);
    height: var(--board-size);
    max-width: 100%;
    margin: 0 auto;
    border: 1px solid rgba(91, 61, 40, 0.28);
    border-radius: 4px;
    list-style: none;
    font-size: 0;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent calc((100% / 15) / 2 - 0.5px),
            rgba(91, 61, 40, 0.72) calc((100% / 15) / 2 - 0.5px),
            rgba(91, 61, 40, 0.72) calc((100% / 15) / 2 + 0.5px),
            transparent calc((100% / 15) / 2 + 0.5px),
            transparent calc(100% / 15)
        ),
        repeating-linear-gradient(
            180deg,
            transparent 0,
            transparent calc((100% / 15) / 2 - 0.5px),
            rgba(91, 61, 40, 0.72) calc((100% / 15) / 2 - 0.5px),
            rgba(91, 61, 40, 0.72) calc((100% / 15) / 2 + 0.5px),
            transparent calc((100% / 15) / 2 + 0.5px),
            transparent calc(100% / 15)
        ),
        linear-gradient(180deg, rgba(244, 218, 174, 0.88) 0%, rgba(233, 202, 156, 0.92) 100%);
    box-shadow: inset 0 0 0 1px rgba(112, 77, 47, 0.2);
    position: relative;
    overflow: hidden;
}

#box > li {
    width: calc(100% / 15);
    height: calc(100% / 15);
    list-style: none;
    display: block;
    position: absolute;
    left: calc(var(--x) * ((100% - (100% / 15)) / 14));
    top: calc(var(--y) * ((100% - (100% / 15)) / 14));
}

#box > li:hover {
    background: rgba(106, 72, 43, 0.08);
    cursor: pointer;
}

#box > li.is-win {
    background: rgba(255, 227, 150, 0.55);
}

#box > li > .stone {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 72%;
    height: 72%;
    transform: translate(-50%, -50%);
}

@media (max-width: 1080px) {
    :root {
        --board-size: min(76vw, 650px);
    }

    .wzq-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    :root {
        --board-size: min(95vw, 560px);
    }

    .wzq-shell {
        width: calc(100% - 0.8rem);
        margin-top: 0.55rem;
    }

    .wzq-top {
        position: static;
    }

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