/* ==========================================================================
   AI五子棋 · 单舞台 + 上下文面板 主题
   说明：本文件在 styles.css 之后加载，负责新版布局与视觉；
        styles.css 保留弹窗、日志等既有组件样式。
        所有选择器均针对 JS 的实际控制方式做了适配（内联 style.display /
        强制 className / textContent 覆盖），请勿随意简化。
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --ink: #25303f;
    --muted: #5f6d7e;
    --line: #e3e9f0;
    --accent: #45617e;
    --accent-deep: #34485f;
    --sh-card: 0 6px 22px rgba(30, 41, 59, .06), 0 1px 3px rgba(30, 41, 59, .04);
    --sh-stage: 0 6px 20px rgba(15, 23, 42, .07);
    --r-lg: 16px;
    --r-md: 14px;
}

/* ---------- 基础 ---------- */
body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(900px 500px at 8% 0%, rgba(91, 122, 153, .10), transparent 60%),
        radial-gradient(800px 500px at 95% 8%, rgba(150, 140, 190, .09), transparent 60%);
    background-attachment: fixed;
    color: var(--ink);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

button,
input,
label {
    font-family: inherit;
}

button {
    cursor: pointer;
}

/* ==========================================================================
   顶部工具条 · 毛玻璃
   ========================================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0;
    color: var(--ink);
    background: rgba(255, 255, 255, .88);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(37, 48, 63, .16);
    border-bottom: 2px solid rgba(37, 48, 63, .14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95), 0 6px 24px rgba(37, 48, 63, .12);
    overflow: hidden;
}

.topbar::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(560px 130px at 10% -60%, rgba(91, 122, 153, .20), transparent 72%),
        radial-gradient(520px 130px at 88% -55%, rgba(150, 140, 190, .16), transparent 72%);
}

.tb-inner {
    position: relative;
    z-index: 1;
    max-width: 1520px;
    margin: 0 auto;
    padding: 4px 24px;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* 品牌 */
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(145deg, #334155, #1e293b);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(30, 41, 59, .25), inset 0 1px 0 rgba(255, 255, 255, .25);
}

.brand-mark i {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    display: block;
}

.brand-mark i.b {
    background: radial-gradient(circle at 32% 30%, #6b7280, #0b1220);
}

.brand-mark i.w {
    background: radial-gradient(circle at 32% 30%, #fff, #cbd5e1);
    border: 1px solid #cbd5e1;
}

.brand-title {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: .3px;
    line-height: 1.1;
}

.brand-sub {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.1;
    margin-top: 3px;
}

/* 设置区（模式 / 规则 / 先手） */
.tb-settings {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, .5);
    border: 1px solid rgba(37, 48, 63, .08);
    border-radius: var(--r-md);
    padding: 5px 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
}

.seg {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border-right: 1.5px solid rgba(37, 48, 63, .3);
}

.seg:last-child {
    border-right: 0;
}

.seg-label {
    font-size: 15px;
    color: #1f2a38;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.seg-buttons {
    display: flex;
    gap: 3px;
    justify-content: center;
}

/* label 包裹的 radio —— JS 依赖 input[name="game-mode"] 等选择器 */
.seg-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.seg-btn input {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.seg-btn span {
    display: block;
    font-size: 15px;
    font-weight: 400;
    color: #7a8899;
    padding: 6px 11px;
    border-radius: 7px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    transition: .18s;
}

.seg-btn:hover span {
    color: var(--ink);
    background: rgba(37, 48, 63, .06);
}

.seg-btn:has(input:checked) span {
    background: linear-gradient(135deg, #415a75, #2f445c);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 7px rgba(47, 68, 92, .35);
}

/* 操作按钮（开始游戏 / 悔棋 / 重开） */
.tb-actions {
    display: flex;
    gap: 9px;
}

.act {
    border: 0;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: .18s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.act:hover {
    transform: translateY(-1px);
}

.act-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    box-shadow: 0 3px 12px rgba(37, 99, 235, .3);
}

.act-primary:hover {
    box-shadow: 0 5px 16px rgba(37, 99, 235, .42);
}

.act-ghost {
    background: rgba(255, 255, 255, .6);
    color: var(--ink);
    border: 1px solid rgba(37, 48, 63, .1);
}

.act-ghost:hover {
    background: rgba(255, 255, 255, .9);
}

.act:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 难度区 */
.tb-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: 20px;
}

.difficulty {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border-left: 1.5px solid rgba(37, 48, 63, .3);
}

.diff-label {
    font-size: 15px;
    color: #1f2a38;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.diff-buttons {
    display: flex;
    gap: 3px;
    background: rgba(37, 48, 63, .06);
    border-radius: 9px;
    padding: 3px;
    justify-content: center;
}

/* JS 会强制 className = 'btn btn-secondary' / 'btn btn-success' 等，
   因此以 .diff-buttons .btn 为基础，用「选中类」还原唯一墨蓝选中态 */
.diff-buttons .btn {
    border: 0;
    background: transparent;
    color: #7a8899;
    font-weight: 400;
    font-size: 15px;
    padding: 6px 9px;
    border-radius: 7px;
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: .18s;
}

.diff-buttons .btn:hover {
    color: var(--ink);
    background: rgba(37, 48, 63, .06);
    transform: none;
}

.diff-buttons .btn.btn-success,
.diff-buttons .btn.btn-expert,
.diff-buttons .btn.btn-danger,
.diff-buttons .btn.btn-master {
    background: linear-gradient(135deg, #415a75, #2f445c);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 7px rgba(47, 68, 92, .35);
}

.diff-buttons .btn.btn-success:hover,
.diff-buttons .btn.btn-expert:hover,
.diff-buttons .btn.btn-danger:hover,
.diff-buttons .btn.btn-master:hover {
    background: linear-gradient(135deg, #4a6685, #354b64);
    color: #fff;
}

/* Rapfi 引擎状态 —— 圆点颜色由 JS 内联 style.background 控制，此处只管形状 */
.rapfi-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--muted);
    background: rgba(255, 255, 255, .55);
    border: 1px solid rgba(37, 48, 63, .1);
    border-radius: 999px;
    padding: 4px 9px;
    max-width: 100%;
}

.rapfi-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #7f8c8d;
    box-shadow: 0 0 0 3px rgba(127, 140, 141, .16);
}

#rapfi-status-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   工作区
   ========================================================================== */
.workspace {
    flex: 1;
    width: 100%;
    max-width: 1520px;
    margin: 0 auto;
    padding: 22px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 322px;
    gap: 22px;
    /* 按内容高度排列：舞台不会被拉伸出多余空白 */
    align-items: start;
}

/* ---------- 舞台 ---------- */
.stage {
    background: var(--surface);
    border-radius: var(--r-md);
    box-shadow: var(--sh-stage);
    padding: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.stage-head {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    /* 锁定高度：思考胶囊与进度条改为绝对定位，避免出现/消失时把棋盘顶下去 */
    min-height: 43px;
}

.stage-title {
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
}

/* 状态胶囊：内部只放 #game-status 文本，JS 用 textContent 覆盖 */
.turn-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    background: #eef3f8;
    border: 1px solid var(--line);
    padding: 6px 13px;
    border-radius: 999px;
}

.turn-badge .dot-live {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .14);
    animation: pulseDot 2s ease-in-out infinite;
}

/* 思考指示器：默认隐藏，JS 以 style.display='flex' 显示
   （styles.css 中同名规则已移除 !important，故内联样式可正常生效）

   文字说明由左侧 .turn-badge 的 #game-status 承担，此处只保留转圈动效，
   避免同一句话出现两次。以 34px 圆形内联在状态胶囊右侧，
   高度小于 .stage-head 的 min-height(43px)，故显示与否都不会改变行高。 */
.thinking {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    gap: 0;
    flex-shrink: 0;
    background: #eef3f8;
    border: 1px solid #c5d6e6;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(52, 72, 95, .10);
    pointer-events: none;
}

/* 「请玩家下棋…」表示轮到人操作，不是系统在忙，
   转圈会造成"还在加载"的误解；该提示已由状态胶囊给出，此处不显示。 */
#player-thinking {
    display: none !important;
}

/* VCF/VCT 检测是 AI 思考的子阶段，状态胶囊已统一显示「AI思考中…」，
   再并列一个转圈只会有两个圆环并排，故不单独提示。 */
#vct-detection {
    display: none !important;
}

/* AI 思考通常 1–2 秒，进度条与转圈分离在栏位最右端显得孤立、也无实际参考价值，
   状态胶囊 + 转圈已足够表达"正在计算"。JS 仍会设置 display，此处隐藏无副作用。 */
#thinking-progress {
    display: none !important;
}

/* 文案节点保留（JS 会用 querySelector('i + span') 更新它），仅视觉隐藏 */
.thinking > span {
    display: none;
}

.thinking .spin {
    width: 17px;
    height: 17px;
    border: 2.5px solid #b9cbe0;
    border-top-color: var(--accent-deep);
    border-radius: 50%;
    flex-shrink: 0;
    animation: spin .8s linear infinite;
}

.thinking i.spin {
    display: block;
    font-style: normal;
}

/* 思考进度条：JS 以 style.display='block' 显示
   同样绝对定位在标题栏下沿的留白里，不占用布局高度；
   宽度收窄并与思考胶囊右对齐，避免横贯整栏抢视线 */
.thinking-progress {
    position: absolute;
    right: 0;
    bottom: -8px;
    width: 180px;
    max-width: 100%;
    display: none;
    height: 3px;
    background: #e6edf5;
    border-radius: 999px;
    overflow: hidden;
}

.thinking-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #5f7f9e, #34485f);
    border-radius: 999px;
    transition: width .3s ease;
}

/* ---------- 棋盘 ---------- */
.board-wrap {
    width: 100%;
    max-width: 660px;
}

#board-container {
    width: 100%;
    max-width: none;
    height: auto;
    aspect-ratio: auto;
    display: block;
}

#gobang-board {
    width: 100%;
    height: auto;
    max-width: none;
    display: block;
    background-color: #c2a85b;
    border: 0;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 8px 22px rgba(0, 0, 0, .12);
}

#gobang-board:hover {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 10px 26px rgba(0, 0, 0, .16);
}

/* ---------- 状态消息 ---------- */
/* JS: messageArea.className = `status-message status-${type}`; textContent = text
   因此图标一律用 ::before，不能用 DOM 节点（会被 textContent 清空） */
.status-message {
    --msg: #1d4ed8;
    width: 100%;
    max-width: 660px;
    margin: 14px 0 0;
    padding: 11px 15px 11px 42px;
    position: relative;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    line-height: 1.5;
    display: block;
    transition: background-color .2s, border-color .2s;
}

.status-message:empty {
    display: none;
}

.status-message::before {
    content: "i";
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    line-height: 17px;
    text-align: center;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
    font-style: normal;
    background: var(--msg);
    color: #fff;
}

/* 四色语义（修复旧版四种状态全绿无法区分的问题） */
.status-info {
    --msg: #1d4ed8;
    background-color: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.status-info::before {
    content: "i";
}

.status-success {
    --msg: #047857;
    background-color: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.status-success::before {
    content: "\2713";
}

.status-warning {
    --msg: #b45309;
    background-color: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}

.status-warning::before {
    content: "!";
}

.status-danger {
    --msg: #b91c1c;
    background-color: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.status-danger::before {
    content: "\00D7";
}

/* ---------- 舞台底部工具条 ---------- */
.stage-foot {
    width: 100%;
    max-width: 660px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tools {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(255, 255, 255, .6);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 9px 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 2px 10px rgba(37, 48, 63, .05);
}

.tool {
    border: 1px solid #d5dfea;
    background: linear-gradient(180deg, #fff, #f5f8fb);
    color: #45566b;
    font-size: 13.5px;
    font-weight: 500;
    padding: 9px 15px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 1px 2px rgba(37, 48, 63, .06);
    transition: .18s;
}

.tool svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    stroke: var(--accent);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tool:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(37, 48, 63, .13);
    border-color: #b9c9da;
}

.tool.danger svg {
    stroke: #c05656;
}

/* 自动保存提示：JS 用 textContent 覆盖，故小圆点用 ::before */
.auto-save-notice {
    display: none;
    align-self: center;
    font-size: 12.5px;
    color: var(--accent-deep);
    background: #eef3f8;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px 6px 28px;
    position: relative;
    margin: 0;
}

.auto-save-notice::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
}

/* ==========================================================================
   上下文面板
   ========================================================================== */
.context {
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-width: 0;
}

.card {
    background: linear-gradient(155deg, #ffffff, #f6f9fc);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px;
    box-shadow: var(--sh-card);
    color: var(--ink);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    top: -45%;
    right: -28%;
    width: 170px;
    height: 170px;
    background: radial-gradient(circle, rgba(91, 122, 153, .10), transparent 70%);
    pointer-events: none;
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    color: #5c6b7d;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.card h3 .tag {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: #eef3f8;
    border: 1px solid #d5e0ec;
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0;
}

/* 当前执棋 */
.hero {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    position: relative;
}

/* JS: currentPieceIndicator.className = 'piece-indicator' 后再 classList.add('black-piece')
   会清掉除 piece-indicator / 颜色类之外的所有类，故必须用 ID 定尺寸与配色 */
#current-piece-indicator {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    display: inline-block;
    margin: 0;
    vertical-align: middle;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .32);
}

#current-piece-indicator.black-piece {
    background: radial-gradient(circle at 33% 33%, #2c3e50 0%, #000 75%);
}

#current-piece-indicator.black-piece::after {
    content: "";
    position: absolute;
    top: 22%;
    left: 22%;
    width: 25%;
    height: 25%;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
}

#current-piece-indicator.white-piece {
    background: radial-gradient(circle at 33% 33%, #fff 0%, #bdc3c7 75%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .16), inset 0 0 0 1px rgba(0, 0, 0, .06);
}

.hero-role {
    font-size: 13px;
    color: #5c6b7d;
    margin-bottom: 2px;
}

.hero-name {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: .5px;
    color: var(--ink);
}

.hero-sub {
    font-size: 13px;
    color: var(--accent);
    margin-top: 6px;
    font-weight: 600;
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    position: relative;
}

.stat {
    background: #f5f8fb;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 13px;
}

.stat span {
    display: block;
    font-size: 13px;
    color: #5c6b7d;
    margin-bottom: 4px;
}

.stat b {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: .5px;
}

.player-color-line {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #5c6b7d;
    margin-top: 12px;
    position: relative;
}

#player-piece-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
    flex-shrink: 0;
}

/* 尚未确定执棋方时（无颜色类）不留空位 */
#player-piece-indicator:not(.black-piece):not(.white-piece) {
    display: none;
}

#player-piece-indicator.black-piece {
    background: radial-gradient(circle at 33% 33%, #2c3e50 0%, #000 75%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    border: 0;
}

#player-piece-indicator.white-piece {
    background: radial-gradient(circle at 33% 33%, #fff 0%, #cdd5dd 72%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(37, 48, 63, .28);
}

/* AI 策略 */
.strategy {
    display: flex;
    gap: 7px;
    margin-bottom: 13px;
    position: relative;
}

.chip {
    flex: 1;
    text-align: center;
    font-size: 13.5px;
    padding: 10px 4px;
    border-radius: 10px;
    border: 1px solid var(--line);
    color: #5c6b7d;
    background: #f5f8fb;
    transition: .2s;
}

.chip.on {
    background: linear-gradient(135deg, #eef3f8, #dfe9f3);
    color: var(--accent-deep);
    border-color: #a9c0d6;
    font-weight: 600;
    box-shadow: 0 0 0 1px #c5d6e6, 0 4px 12px rgba(91, 122, 153, .14);
}

.ai-strategy-hint {
    margin: 13px 0 0;
    padding: 12px 13px;
    background: #f5f8fb;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: #5c6b7d;
    position: relative;
}

.ai-strategy-hint p {
    margin: 0;
}

/* 高级设置 —— 开关行 */
.adv {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.adv-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    color: var(--ink);
    background: #f5f8fb;
    border: 1px solid var(--line);
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
    margin: 0;
    transition: .18s;
}

.adv-row:hover {
    background: #eef3f8;
    border-color: #d5e0ec;
}

.adv-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.adv-row .switch {
    margin-left: auto;
    width: 34px;
    height: 19px;
    border-radius: 999px;
    background: #c9d4e0;
    position: relative;
    transition: .22s;
    flex-shrink: 0;
    display: block;
}

.adv-row .switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    transition: .22s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.adv-row input:checked + .switch {
    background: var(--accent);
}

.adv-row input:checked + .switch::after {
    left: 18px;
}

/* 小贴士卡 —— 内边距与其它卡一致，高度由内容决定；
   通过 .context 的间距收紧来抵消，使面板底部与舞台底部齐平。 */
.tip-card {
    padding: 12px 18px;
}

.tip-card h3 {
    margin-bottom: 5px;
}

.tip-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.tip-item {
    display: flex;
    gap: 9px;
    font-size: 13px;
    line-height: 1.45;
    color: #5c6b7d;
}

.tip-item i {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    margin-top: 2px;
    border-radius: 50%;
    background: #eef3f8;
    border: 1px solid #d5e0ec;
    color: var(--accent);
    font-style: normal;
    font-size: 10.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   弹窗微调（结构沿用 styles.css）
   ========================================================================== */
.modal-header {
    background: linear-gradient(135deg, #33475f, #22303f);
}

.modal-content,
.match-log-content,
.log-detail-content {
    border-radius: 14px;
}

/* ==========================================================================
   动效
   ========================================================================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulseDot {
    50% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0), 0 0 10px rgba(16, 185, 129, .6);
    }
}

/* ==========================================================================
   响应式
   ========================================================================== */
/* 宽屏：状态提示浮到舞台右上角，让棋盘与工具条直接相连；
   绝对定位不占布局流，文案长短变化不会推动任何元素 */
@media (min-width: 1320px) {
    .stage {
        position: relative;
    }

    .status-message {
        position: absolute;
        top: 23px;
        right: 22px;
        width: auto;
        max-width: 420px;
        margin: 0;
        font-size: 13px;
        padding: 8px 14px 8px 36px;
        box-shadow: 0 4px 14px rgba(37, 48, 63, .10);
        z-index: 3;
    }

    .status-message::before {
        left: 12px;
        width: 15px;
        height: 15px;
        line-height: 15px;
        font-size: 10px;
    }

    /* 提示条脱离流后，棋盘与工具条之间补足呼吸空间 */
    .stage-foot {
        margin-top: 20px;
    }
}

@media (max-width: 1560px) and (min-width: 1081px) {
    /* 空间不足以单行时，难度组整体落到第二行并占满宽度，
       左端放难度、右端放引擎状态，形成平衡的次级工具条 */
    .tb-right {
        flex: 1 0 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .difficulty {
        border-left: 0;
        padding-left: 2px;
    }
}

@media (max-width: 1240px) {
    .tb-inner {
        gap: 14px;
    }

    .seg,
    .difficulty {
        padding: 0 10px;
    }
}

@media (max-width: 1080px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .context {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        align-items: start;
    }

    .tb-right {
        margin-left: 0;
    }
}

@media (max-width: 760px) {
    .tb-inner {
        gap: 10px;
        padding: 10px 14px;
    }

    .tb-settings {
        order: 3;
        width: 100%;
    }

    .tb-actions {
        order: 2;
    }

    .tb-right {
        order: 4;
        width: 100%;
    }

    .difficulty {
        width: 100%;
        padding: 0;
        border-left: 0;
        overflow-x: auto;
    }

    .seg {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        padding: 4px 7px;
        gap: 6px;
        border-right: 0;
        background: rgba(255, 255, 255, .55);
        border-radius: 9px;
    }

    .seg-label {
        font-size: 14px;
    }

    .seg-btn span {
        font-size: 14px;
        padding: 5px 10px;
    }

    .stage {
        padding: 14px;
    }

    .workspace {
        padding: 14px;
        gap: 14px;
    }

    .stage-title {
        font-size: 17px;
    }

    .thinking {
        width: 30px;
        height: 30px;
    }

    .thinking .spin {
        width: 15px;
        height: 15px;
    }
}

@media (max-width: 520px) {
    .brand-sub {
        display: none;
    }

    .stage-head {
        gap: 10px;
    }

    .tool {
        padding: 8px 11px;
        font-size: 12.5px;
    }

    .tool svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 460px) {
    /* 极窄屏下状态胶囊可能换行，此时以固定行高预留，
       保证 AI 转圈的显示/隐藏不会带动棋盘位移 */
    .stage-head {
        align-items: flex-start;
    }
}
