:root {
    --text: #172033;
    --muted: #667085;
    --glass: rgba(255, 255, 255, 0.55);
    --glass-strong: rgba(255, 255, 255, 0.76);
    --border: rgba(255, 255, 255, 0.72);
    --primary: #4f7cff;
    --primary-2: #8f6cff;
    --shadow: 0 24px 70px rgba(41, 57, 94, 0.18);
    --board: rgba(236, 192, 119, 0.88);
}

body.dark {
    --text: #f4f7ff;
    --muted: #aeb8cc;
    --glass: rgba(15, 20, 35, 0.58);
    --glass-strong: rgba(20, 27, 46, 0.78);
    --border: rgba(255, 255, 255, 0.12);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    min-height: 100vh;
    color: var(--text);
    font-family:
        Inter,
        "PingFang SC",
        "Microsoft YaHei",
        Arial,
        sans-serif;
    overflow-x: hidden;
}

button,
select {
    font: inherit;
}

button {
    color: inherit;
}

.background {
    position: fixed;
    inset: 0;
    z-index: -5;
    background-image:
        url("https://api.imyqf.cn");
    background-size: cover;
    background-position: center;
    transition: background-image 0.7s ease;
}

.background-mask {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(
            135deg,
            rgba(235, 245, 255, 0.72),
            rgba(244, 235, 255, 0.58)
        );
    backdrop-filter: blur(5px);
}

body.dark .background-mask {
    background:
        linear-gradient(
            135deg,
            rgba(7, 11, 24, 0.82),
            rgba(24, 12, 39, 0.76)
        );
}

.aurora {
    position: absolute;
    width: 550px;
    height: 550px;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.35;
    animation: auroraMove 12s ease-in-out infinite alternate;
}

.aurora-one {
    left: -150px;
    top: -100px;
    background: #73b6ff;
}

.aurora-two {
    right: -150px;
    bottom: -150px;
    background: #c077ff;
    animation-delay: -5s;
}

@keyframes auroraMove {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(90px, 70px, 0) scale(1.2);
    }
}

#mouseGlow {
    position: fixed;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    transform: translate(-50%, -50%);
    background:
        radial-gradient(
            circle,
            rgba(118, 168, 255, 0.23),
            transparent 67%
        );
}

.page-shell {
    width: min(1700px, calc(100% - 40px));
    margin: auto;
    padding: 22px 0;
}

.glass {
    background: var(--glass);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(28px) saturate(145%);
    -webkit-backdrop-filter: blur(28px) saturate(145%);
}

.topbar {
    min-height: 82px;
    border-radius: 28px;
    padding: 15px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 17px;
    color: white;
    font-size: 25px;
    font-weight: 800;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-2)
        );
    box-shadow:
        0 12px 30px rgba(79, 124, 255, 0.35);
}

.brand h1 {
    margin: 0;
    font-size: 21px;
}

.brand p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.top-actions {
    display: flex;
    gap: 10px;
}

.icon-button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--glass-strong);
    cursor: pointer;
    transition: 0.25s;
}

.icon-button:hover {
    transform: translateY(-3px) scale(1.04);
}

.game-layout {
    margin-top: 20px;
    display: grid;
    grid-template-columns:
        290px
        minmax(560px, 1fr)
        300px;
    gap: 20px;
    align-items: start;
}

.left-panel,
.board-section,
.info-card {
    border-radius: 28px;
}

.left-panel {
    padding: 22px;
}

.panel-title,
.card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 15px #f59e0b;
}

.status-dot.online {
    background: #2dd4a8;
    box-shadow: 0 0 15px #2dd4a8;
}

.status-dot.offline {
    background: #ff5e72;
    box-shadow: 0 0 15px #ff5e72;
}

.control-group {
    margin-top: 24px;
}

.control-group label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 10px;
}

select {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 15px;
    outline: none;
    background: var(--glass-strong);
}

body.dark select option {
    color: #111827;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.difficulty {
    min-height: 66px;
    padding: 10px;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--glass-strong);
    cursor: pointer;
    transition: 0.25s;
}

.difficulty strong,
.difficulty small {
    display: block;
}

.difficulty small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}

.difficulty:hover {
    transform: translateY(-2px);
}

.difficulty.active {
    color: white;
    border-color: transparent;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-2)
        );
    box-shadow:
        0 12px 30px rgba(79, 124, 255, 0.3);
}

.difficulty.active small {
    color: rgba(255, 255, 255, 0.8);
}

.difficulty.hell {
    grid-column: 1 / -1;
}

.game-buttons {
    display: grid;
    grid-template-columns: 1fr 0.7fr;
    gap: 10px;
    margin-top: 22px;
}

.primary-button,
.secondary-button {
    height: 48px;
    border-radius: 15px;
    cursor: pointer;
    transition: 0.25s;
}

.primary-button {
    color: white;
    border: 0;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-2)
        );
}

.secondary-button {
    border: 1px solid var(--border);
    background: var(--glass-strong);
}

.primary-button:hover,
.secondary-button:hover {
    transform: translateY(-2px);
}

.player-card {
    margin-top: 22px;
    padding: 7px 14px;
    border-radius: 19px;
    background: rgba(255, 255, 255, 0.18);
}

.player-row {
    padding: 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-row + .player-row {
    border-top: 1px solid var(--border);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 11px;
}

.player-info strong,
.player-info small {
    display: block;
}

.player-info small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.stone {
    width: 29px;
    height: 29px;
    border-radius: 50%;
}

.stone.black {
    background:
        radial-gradient(
            circle at 35% 30%,
            #5b6372,
            #080b10 65%
        );
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
}

.stone.white {
    background:
        radial-gradient(
            circle at 35% 30%,
            white,
            #dbe2ed 70%
        );
    box-shadow:
        0 5px 12px rgba(0, 0, 0, 0.18);
}

.turn-tag {
    color: var(--muted);
    font-size: 11px;
    padding: 6px 9px;
    border-radius: 10px;
    background: rgba(128, 128, 128, 0.1);
}

.turn-tag.active {
    color: white;
    background: var(--primary);
}

.board-section {
    padding: 22px;
}

.board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.board-header h2 {
    margin: 0;
    font-size: 21px;
}

.board-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.move-counter {
    text-align: center;
    min-width: 72px;
    padding: 9px 13px;
    border-radius: 16px;
    background: var(--glass-strong);
}

.move-counter span,
.move-counter strong {
    display: block;
}

.move-counter span {
    color: var(--muted);
    font-size: 10px;
}

.move-counter strong {
    font-size: 21px;
    margin-top: 2px;
}

.board-wrapper {
    position: relative;
    width: min(100%, 760px);
    margin: auto;
    padding: 16px;
    border-radius: 26px;
    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.5),
            rgba(255, 255, 255, 0.14)
        );
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

#gomokuBoard {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 18px;
    cursor: crosshair;
    touch-action: none;
}

.thinking-overlay {
    position: absolute;
    inset: 16px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    background: rgba(13, 18, 33, 0.56);
    backdrop-filter: blur(12px);
    transition: 0.3s;
}

.thinking-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.thinking-overlay strong {
    margin-top: 20px;
    letter-spacing: 2px;
}

.thinking-overlay p {
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
}

.ai-orb {
    display: flex;
    gap: 7px;
}

.ai-orb span {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: white;
    animation: aiPulse 1s infinite ease-in-out;
}

.ai-orb span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-orb span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes aiPulse {
    0%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    50% {
        transform: translateY(-12px);
        opacity: 1;
    }
}

.right-panel {
    display: grid;
    gap: 20px;
}

.info-card {
    padding: 21px;
}

.live-badge {
    color: #13a980;
    font-size: 9px;
    letter-spacing: 1px;
    padding: 5px 7px;
    border-radius: 8px;
    background: rgba(45, 212, 168, 0.13);
}

.ai-brain {
    height: 130px;
    display: grid;
    place-items: center;
}

.brain-core {
    width: 75px;
    height: 75px;
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    font-size: 22px;
    border-radius: 27px;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-2)
        );
    box-shadow:
        0 0 0 12px rgba(79, 124, 255, 0.08),
        0 0 0 25px rgba(143, 108, 255, 0.05),
        0 20px 45px rgba(79, 124, 255, 0.35);
    animation: brainFloat 3s ease-in-out infinite;
}

@keyframes brainFloat {
    0%,
    100% {
        transform: translateY(0) rotate(-3deg);
    }

    50% {
        transform: translateY(-8px) rotate(3deg);
    }
}

.analysis-text {
    min-height: 85px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 17px;
}

.stat-item {
    padding: 13px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.17);
}

.stat-item span,
.stat-item strong {
    display: block;
}

.stat-item span {
    color: var(--muted);
    font-size: 10px;
}

.stat-item strong {
    margin-top: 6px;
    font-size: 14px;
}

.tips-card p {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

footer {
    padding: 22px;
    color: var(--muted);
    text-align: center;
    font-size: 11px;
}

#toast {
    position: fixed;
    left: 50%;
    top: 28px;
    z-index: 100;
    transform: translate(-50%, -30px);
    padding: 12px 20px;
    border-radius: 14px;
    color: white;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(15px);
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

#toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

@media (max-width: 1250px) {
    .game-layout {
        grid-template-columns: 260px 1fr;
    }

    .right-panel {
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 850px) {
    .page-shell {
        width: min(100% - 20px, 700px);
        padding-top: 10px;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .right-panel {
        grid-column: auto;
        grid-template-columns: 1fr;
    }

    .board-section {
        padding: 12px;
    }

    .board-wrapper {
        padding: 8px;
    }

    .thinking-overlay {
        inset: 8px;
    }
}

@media (max-width: 520px) {
    .topbar {
        border-radius: 20px;
    }

    .brand p {
        display: none;
    }

    .brand h1 {
        font-size: 17px;
    }

    .brand-icon {
        width: 44px;
        height: 44px;
    }

    .left-panel,
    .board-section,
    .info-card {
        border-radius: 21px;
    }

    .difficulty-grid {
        grid-template-columns: 1fr 1fr;
    }
}