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

        html { scroll-snap-type: y mandatory; }
        /* 隐藏滚动条（保留滚动能力，米哈游官网风格） */
        html {
            scrollbar-width: none;
            -ms-overflow-style: none;
        }
        html::-webkit-scrollbar { display: none; }
        body {
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
            min-height: 100vh;
            font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
            overflow-x: hidden;
            position: relative;
        }

        .container {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .stars {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 0;
        }

        .star {
            position: absolute;
            background: white;
            border-radius: 50%;
            animation: twinkle var(--duration) ease-in-out infinite;
            opacity: 0;
        }

        @keyframes twinkle {
            0%, 100% { opacity: 0; transform: scale(0.5); }
            50% { opacity: 1; transform: scale(1.2); }
        }

        .container {
            flex: 1;
            width: 100%;
            position: relative;
            z-index: 1;
            text-align: center;
            padding: 2rem;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        h1 {
            font-size: 3.5rem;
            color: #ffffff;
            margin-bottom: 0.5rem;
            text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
            animation: float 3s ease-in-out infinite;
        }

        .subtitle {
            font-size: 1.2rem;
            color: #a0c4ff;
            margin-bottom: 3rem;
            letter-spacing: 2px;
            font-weight: 300;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
        }

        .card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 2rem;
            max-width: 1000px;  /* 稍微放宽以容纳更多卡片 */
            margin: 0 auto;
        }

        .card {
            background: rgba(255, 255, 255, 0.08);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            padding: 2rem 1rem;
            text-decoration: none;
            color: #fff;
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1rem;
        }

        .card:hover {
            transform: translateY(-8px) scale(1.02);
            background: rgba(255, 255, 255, 0.15);
            border-color: rgba(255, 255, 255, 0.3);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4),
                        0 0 20px rgba(100, 180, 255, 0.3);
        }

        .card .emoji {
            font-size: 3rem;
            filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
        }

        .card .label {
            font-size: 1.3rem;
            font-weight: 600;
        }

        .card .desc {
            font-size: 0.8rem;
            color: rgba(255, 255, 255, 0.6);
        }

        footer {
            position: relative;
            z-index: 1;
            margin-top: 4rem;
            color: rgba(255, 255, 255, 0.4);
            font-size: 0.8rem;
        }

        @media (max-width: 600px) {
            h1 {
                font-size: 2.5rem;
            }
            .card-grid {
                grid-template-columns: 1fr 1fr;
                gap: 1rem;
            }
        }

        /* ============ 贪吃蛇游戏区 ============ */
        .game-section {
            flex: 1;
            width: 100%;
            position: relative;
            z-index: 1;
            display: flex;
            flex-direction: column;
            justify-content: safe center;
            align-items: center;
            padding: 1.2rem 1rem 1rem;
            gap: 0.9rem;
            /* 容器查询的容器必须是「被查询元素」的祖先：挂在 .game-shell 自身上会让
               @container 里的 .game-shell 规则整块失效（容器查询不能给容器自己设样式） */
            container-type: inline-size;
            container-name: gameshell;
            min-height: 0;
        }
        .game-hud {
            display: flex;
            align-items: baseline;
            gap: 2rem;
        }
        /* 网络延迟指示（原神式：绿/黄/红 + 毫秒） */
        .net-ind {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.75rem;
            color: rgba(255, 255, 255, 0.5);
            font-variant-numeric: tabular-nums;
        }
        .net-ind::before {
            content: '';
            width: 0.55rem;
            height: 0.55rem;
            border-radius: 50%;
            background: #555;
            transition: background 0.3s;
        }
        .net-ind.good::before { background: #3ddc84; box-shadow: 0 0 6px rgba(61, 220, 132, 0.8); }
        .net-ind.mid::before { background: #ffc94d; box-shadow: 0 0 6px rgba(255, 201, 77, 0.7); }
        .net-ind.bad::before { background: #ff5c5c; box-shadow: 0 0 6px rgba(255, 92, 92, 0.8); }
        .game-title {
            font-size: 2rem;
            color: #fff;
            text-shadow: 0 0 16px rgba(0, 255, 200, 0.6);
            letter-spacing: 2px;
        }
        .game-stats {
            font-size: 1rem;
            color: #a0c4ff;
            display: flex;
            gap: 1.5rem;
        }
        .game-stats.pulse { animation: statPulse 1.5s ease-in-out infinite; }
        @keyframes statPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
        .room-spin {
            position: absolute; inset: 0; z-index: 40;
            display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8rem;
            background: rgba(24, 20, 12, 0.55); backdrop-filter: blur(2px);
            border-radius: 14px;
        }
        .room-spin[hidden] { display: none; }
        .room-spinner {
            width: 46px; height: 46px;
            border: 5px solid rgba(255, 255, 255, 0.22);
            border-top-color: #ffd54a;
            border-radius: 50%;
            animation: roomSpin 0.9s linear infinite;
        }
        @keyframes roomSpin { to { transform: rotate(360deg); } }
        .room-spin-text {
            color: #ffe9b8; font-size: 15px; letter-spacing: 1px;
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
        }
        .game-stats b {
            color: #fff;
            font-size: 1.2rem;
        }
        .game-wrap {
            position: relative;
            width: min(78vmin, 540px);
            aspect-ratio: 1 / 1;
            border-radius: 18px;
            overflow: hidden;
            box-shadow: 0 0 40px rgba(0, 229, 255, 0.25), inset 0 0 60px rgba(0, 0, 0, 0.4);
            border: 1px solid rgba(0, 229, 255, 0.25);
            background: rgba(0, 0, 0, 0.45);
            touch-action: none;
        }
        #snakeCanvas {
            width: 100%;
            height: 100%;
            display: block;
        }
        .game-overlay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(10, 12, 30, 0.78);
            backdrop-filter: blur(4px);
            z-index: 2;
            text-align: center;
            transition: opacity 0.3s ease;
        }
        .game-overlay.hidden { opacity: 0; pointer-events: none; }
        .overlay-title { font-size: 2.2rem; color: #fff; text-shadow: 0 0 18px rgba(0, 255, 200, 0.7); }
        .overlay-sub { margin: 0.8rem 0 1.4rem; color: #a0c4ff; font-size: 0.95rem; line-height: 1.6; }
        .overlay-btns {
            display: flex;
            gap: 1rem;
            justify-content: center;
        }
        #restartBtn, #resumeBtn {
            padding: 0.6rem 2rem;
            font-size: 1rem;
            border: none;
            border-radius: 30px;
            background: linear-gradient(135deg, #00e5ff, #00b3a4);
            color: #06222a;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
            transition: transform 0.2s;
        }
        #resumeBtn { background: linear-gradient(135deg, #ffe08a, #ffb347); }
        #restartBtn:hover, #resumeBtn:hover { transform: scale(1.06); }
        .game-overlay > div { max-height: 92vh; overflow-y: auto; overflow-x: hidden; padding-bottom: 0.8rem; }
        /* 排行榜 */
        .rank-btn {
            width: 2.2rem;
            height: 2.2rem;
            border-radius: 50%;
            border: 1px solid rgba(255, 200, 60, 0.45);
            background: rgba(255, 200, 60, 0.1);
            font-size: 1.1rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        .rank-btn:hover { background: rgba(255, 200, 60, 0.25); transform: scale(1.08); }
        /* 排行榜弹出窗：页面水平居中，位于 🏆 按钮下方 */
        .rank-popup {
            position: fixed;
            top: 4.2rem;
            left: 50%;
            transform: translateX(-50%);
            width: min(90vw, 360px);
            max-height: 62vh;
            overflow-y: auto;
            z-index: 60;
            display: none;
            flex-direction: column;
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(255, 200, 60, 0.3);
            border-radius: 16px;
            box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 20px rgba(0, 229, 255, 0.12);
            padding: 0.7rem;
            animation: rankIn 0.18s ease;
        }
        .rank-popup.open { display: flex; }
        @keyframes rankIn {
            from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
            to { opacity: 1; transform: translateX(-50%) translateY(0); }
        }
        .rank-popup-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: #ffe08a;
            font-weight: 700;
            font-size: 1rem;
            margin-bottom: 0.5rem;
        }
        .rank-popup-close {
            width: 1.7rem;
            height: 1.7rem;
            border-radius: 50%;
            border: 1px solid rgba(255, 255, 255, 0.25);
            background: rgba(255, 255, 255, 0.08);
            color: #fff;
            cursor: pointer;
            font-size: 0.85rem;
            line-height: 1;
            transition: all 0.2s;
        }
        .rank-popup-close:hover { background: rgba(255, 100, 100, 0.35); }
        /* 背景音乐开关 */
        .music-btn {
            position: fixed;
            top: 0.8rem;
            right: 0.9rem;
            z-index: 80;
            width: 2.6rem;
            height: 2.6rem;
            border-radius: 50%;
            border: 1px solid rgba(0, 229, 255, 0.35);
            background: rgba(0, 229, 255, 0.12);
            color: #fff;
            font-size: 1.25rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        .music-btn:hover { background: rgba(0, 229, 255, 0.25); transform: scale(1.06); }
        .music-btn.off { opacity: 0.5; filter: grayscale(0.85); }

        /* 终局动画：胜利/失败/和棋 */
        .end-overlay {
            position: fixed;
            inset: 0;
            z-index: 70;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.35s ease;
        }
        .end-overlay.show { opacity: 1; }
        .end-box {
            position: relative;
            background: linear-gradient(160deg, rgba(16, 28, 54, 0.94), rgba(12, 20, 40, 0.94));
            border: 1px solid rgba(0, 229, 255, 0.35);
            border-radius: 24px;
            padding: 1.5rem 2.8rem;
            text-align: center;
            box-shadow: 0 0 60px rgba(0, 229, 255, 0.28);
            transform: scale(0.3);
            opacity: 0;
            animation: endPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }
        @keyframes endPop {
            60% { transform: scale(1.08); opacity: 1; }
            100% { transform: scale(1); opacity: 1; }
        }
        .end-title {
            font-size: 2.6rem;
            font-weight: 800;
            color: #fff;
            letter-spacing: 4px;
            text-shadow: 0 0 26px rgba(0, 229, 255, 0.85);
        }
        .end-box.win .end-title { color: #ffd54a; text-shadow: 0 0 34px rgba(255, 213, 74, 0.95); }
        .end-sub { margin-top: 0.6rem; color: rgba(255, 255, 255, 0.75); font-size: 0.95rem; }
        /* 终局彩带：从中心向上方绽开（扇形上冲） */
        .end-confetti {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 1.6rem;
            opacity: 0;
            animation: burstUp 1.6s ease-out forwards;
        }
        @keyframes burstUp {
            0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
            55% { opacity: 1; }
            100% { transform: translate(calc(-50% + var(--dx, 0vw)), calc(-50% - var(--dy, 60vh))) scale(1.15) rotate(40deg); opacity: 0; }
        }
        /* 贪吃蛇失败标题弹跳 */
        .game-overlay.end .overlay-title { animation: titlePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
        @keyframes titlePop {
            from { transform: scale(0.4); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }
        .rank-submit {
            display: flex;
            gap: 0.5rem;
            align-items: center;
            justify-content: center;
            margin-bottom: 0.6rem;
            flex-wrap: wrap;
        }
        .rank-score-tip { color: #ffe08a; font-size: 0.9rem; }
        .rank-name {
            width: 7.5rem;
            padding: 0.4rem 0.6rem;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.3);
            background: rgba(255, 255, 255, 0.1);
            color: #fff;
            font-size: 0.9rem;
            text-align: center;
        }
        .rank-go {
            padding: 0.4rem 1rem;
            font-size: 0.9rem;
            border: none;
            border-radius: 16px;
            background: linear-gradient(135deg, #ffe08a, #ffb347);
            color: #06222a;
            font-weight: 700;
            cursor: pointer;
        }
        .rank-row {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.32rem 0.5rem;
            border-radius: 8px;
            font-size: 0.92rem;
            color: rgba(255, 255, 255, 0.9);
        }
        .rank-row.me { background: rgba(0, 229, 255, 0.15); outline: 1px solid rgba(0, 229, 255, 0.4); }
        .rank-pos { width: 1.8rem; text-align: center; flex-shrink: 0; }
        .rank-name-col { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .rank-score { color: #ffe08a; font-weight: 700; }
        .rank-empty { color: rgba(255, 255, 255, 0.45); font-size: 0.85rem; padding: 0.5rem; }
        .game-tips {
            color: rgba(255, 255, 255, 0.55);
            font-size: 0.8rem;
            letter-spacing: 1px;
            cursor: pointer;
            max-width: min(92vw, 560px);
            text-align: center;
            padding: 0.25rem 0.7rem;
            border-radius: 12px;
            transition: background 0.2s;
        }
        .game-tips:hover { background: rgba(255, 255, 255, 0.06); }
        .game-tips.tip-flip { animation: tipIn 0.35s ease; }
        @keyframes tipIn {
            from { opacity: 0; transform: translateY(6px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .dpad {
            position: fixed;
            bottom: 1.2rem;
            left: 50%;
            transform: translateX(-50%);
            display: none;
            grid-template-columns: repeat(3, min(26vw, 6.5rem));
            grid-template-rows: repeat(3, min(26vw, 6.5rem));
            gap: 0.5rem;
            z-index: 5;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }
        .dpad button {
            font-size: 2.4rem;
            border: 1px solid rgba(0, 229, 255, 0.35);
            background: rgba(0, 229, 255, 0.1);
            color: #fff;
            border-radius: 16px;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
            touch-action: manipulation;
            box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
        }
        .dpad button:active {
            background: rgba(0, 229, 255, 0.35);
            transform: scale(0.95);
        }
        /* 十字键布局：3x3 网格，上下左右占中间十字 */
        .dpad [data-d="up"]    { grid-column: 2; grid-row: 1; }
        .dpad [data-d="left"]  { grid-column: 1; grid-row: 2; }
        .dpad [data-d="down"]  { grid-column: 2; grid-row: 3; }
        .dpad [data-d="right"] { grid-column: 3; grid-row: 2; }
        .dpad [data-d="pause"] {
            grid-column: 2;
            grid-row: 2;
            border-color: rgba(255, 200, 60, 0.45);
            background: rgba(255, 200, 60, 0.12);
            color: #ffe08a;
            font-size: 2rem;
        }
        .dpad [data-d="pause"]:active { background: rgba(255, 200, 60, 0.32); }
        @media (pointer: coarse) {
            .dpad { display: grid; }
            body.game-on .dpad { opacity: 1; pointer-events: auto; }
        }
        /* 竖屏：底部预留十字键高度，操作提示与悬浮键不重叠 */
        @media (pointer: coarse) and (orientation: portrait) {
            .game-section { padding-bottom: calc(3 * min(26vw, 6.5rem) + 3.2rem); }
        }
        /* 横屏：十字键靠左（垂直居中），暂停/继续靠右 */
        @media (pointer: coarse) and (orientation: landscape) {
            .dpad {
                left: 1.2rem;
                bottom: auto;
                top: 50%;
                transform: none;
                margin-top: -10.25rem; /* 键区高度(3*6.5rem+2*0.5rem=20.5rem)的一半 */
            }
            .dpad [data-d="pause"] {
                position: fixed;
                left: auto;
                right: 1.5rem;
                top: 50%;
                transform: translateY(-50%);
                grid-column: auto;
                grid-row: auto;
                font-size: 2.6rem;
                width: min(26vw, 6.5rem);   /* 与竖屏键尺寸一致 */
                height: min(26vw, 6.5rem);
            }
            .dpad [data-d="pause"]:active {
                transform: translateY(-50%) scale(0.95); /* 按下保持垂直居中，不跳动 */
            }
        }

        /* ============ 全屏滚动页（米哈游官网风格） ============ */
        /* 布局轴由 <html class="ng-horizontal"> 决定：默认纵向，横向时页面左右并排 */
        .pages { display: block; }
        html.ng-horizontal { scroll-snap-type: x mandatory; }
        /* body 的 overflow-x 会传播给视口，横向模式必须放开，否则文档无法横向滚动 */
        html.ng-horizontal body { overflow-x: auto; }
        html.ng-horizontal .pages {
            display: flex;
            flex-direction: row;
            /* 不拉伸：各页保持自身高度，页内内容在视口内居中的表现与纵向模式一致 */
            align-items: flex-start;
        }
        html.ng-horizontal .page {
            flex: 0 0 100vw;
            width: 100vw;
            min-width: 100vw;
        }
        .page {
            min-height: 100vh;
            min-height: 100dvh;
            scroll-snap-align: start;
            scroll-snap-stop: always;
            display: flex;
            flex-direction: column;
            justify-content: safe center;
            align-items: center;
            padding: 1rem;
            position: relative;
            z-index: 1;
        }
        /* 每页内容入场动画 */
        .page .container,
        .page .game-section {
            opacity: 0;
            transform: translateY(34px);
            transition: opacity 0.7s ease, transform 0.7s ease;
        }
        .page.active .container,
        .page.active .game-section {
            opacity: 1;
            transform: none;
        }
        /* 横向模式：入场位移改为沿 X 轴 */
        html.ng-horizontal .page .container,
        html.ng-horizontal .page .game-section { transform: translateX(34px); }
        html.ng-horizontal .page.active .container,
        html.ng-horizontal .page.active .game-section { transform: none; }
        /* 贪吃蛇页不做整体位移（避免影响悬浮十字键定位基准），仅淡入 */
        #panel-snake .game-section { transform: none; }
        /* 首页彩蛋提示（含蓄版：微光 🌈🥚 + 悄悄话） */
        .scroll-hint {
            position: absolute;
            bottom: 1rem;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.15rem;
            color: rgba(255, 255, 255, 0.38);
            font-size: 0.78rem;
            letter-spacing: 1px;
            cursor: pointer;
            z-index: 2;
            white-space: nowrap;
            animation: hintBounce 2.8s ease-in-out infinite;
            user-select: none;
        }
        .hint-egg {
            font-size: 1.05rem;
            animation: eggGlow 3.2s ease-in-out infinite;
        }
        .hint-text { opacity: 0.85; }
        @keyframes hintBounce {
            0%, 100% { transform: translateX(-50%) translateY(0); }
            50% { transform: translateX(-50%) translateY(7px); }
        }
        @keyframes eggGlow {
            0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.12)); opacity: 0.75; }
            50% { filter: drop-shadow(0 0 12px rgba(255, 200, 120, 0.5)); opacity: 1; }
        }

        /* ============ 棋盘游戏 ============ */
        /* 棋盘页除棋盘外的高度（标题行 + 控制行 + 提示行 + 内边距），用于把整页压进一屏 */
        :root { --board-chrome: 290px; }
        .board-wrap {
            position: relative;
            /* 100%：三列布局打开侧栏后棋盘列会变窄；100dvh - chrome：保证控制按钮不被挤到屏幕外 */
            width: min(86vmin, 620px, 100%, calc(100dvh - var(--board-chrome)));
            aspect-ratio: 1 / 1;
            border-radius: 18px;
            overflow: hidden;
            box-shadow: 0 0 30px rgba(0, 229, 255, 0.15), inset 0 0 40px rgba(0, 0, 0, 0.4);
            border: 1px solid rgba(0, 229, 255, 0.2);
            background: rgba(0, 0, 0, 0.45);
            touch-action: none;
        }
        /* 象棋棋盘与五子棋/围棋一致：正方形（格子自动略宽于高） */
        .board-wrap canvas, .board-wrap svg { width: 100%; height: 100%; display: block; }
        /* 象棋棋盘为 8:9 矩形，容器比例与 SVG viewBox 一致，避免黑边 */
        .board-wrap.xq {
            aspect-ratio: 800 / 890;
            /* 高度 = 宽度 ÷ 0.899，同样要保证整页进得去一屏 */
            width: min(86vmin, 620px, 100%, calc((100dvh - var(--board-chrome)) * 0.899));
            background: #D4A574;
        }
        .board-area {
            position: relative;
            flex: 1 1 auto;
            min-height: 0;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 0.7rem;
        }
        .board-ctrl {
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.5rem;
            max-width: min(94vw, 600px);
        }
        .ctrl-row {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-items: center;
            gap: 0.5rem;
        }
        /* 棋盘下操作行与底部按钮区共用同一套按钮样式 */
        .board-ctrl button,
        .board-actions button {
            padding: 0.5rem 1.2rem;
            font-size: 0.95rem;
            border: 1px solid rgba(0, 229, 255, 0.35);
            background: rgba(0, 229, 255, 0.1);
            color: #fff;
            border-radius: 20px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .board-ctrl button:hover,
        .board-actions button:hover { background: rgba(0, 229, 255, 0.25); }
        .board-ctrl .leave-btn,
        .board-actions .leave-btn { border-color: rgba(255, 100, 100, 0.4); background: rgba(255, 100, 100, 0.1); }
        .board-ctrl .leave-btn:hover,
        .board-actions .leave-btn:hover { background: rgba(255, 100, 100, 0.25); }
        /* 再来一局：金色区分 */
        .board-ctrl .reset-btn,
        .board-actions .reset-btn { border-color: rgba(255, 200, 60, 0.4); background: rgba(255, 200, 60, 0.1); color: #ffe08a; }
        .board-ctrl .reset-btn:hover,
        .board-actions .reset-btn:hover { background: rgba(255, 200, 60, 0.25); }
        .board-ctrl .reset-btn:disabled,
        .board-actions .reset-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
        /* 悔棋：蓝色区分于认输 */
        .board-ctrl .undo-btn,
        .board-actions .undo-btn { border-color: rgba(100, 180, 255, 0.4); background: rgba(100, 180, 255, 0.12); }
        .board-ctrl .undo-btn:hover,
        .board-actions .undo-btn:hover { background: rgba(100, 180, 255, 0.28); }
        .board-actions { margin-top: 0.15rem; }
        /* ===== 表情包系统 ===== */
        .sticker-btn { font-size: 1rem; }
        /* ===== 席位交换 ===== */
        .swap-btn { font-size: 0.9rem; border-color: rgba(160, 120, 255, 0.4); background: rgba(160, 120, 255, 0.12); color: #d8c8ff; }
        .swap-btn:hover { background: rgba(160, 120, 255, 0.25); }
        .swap-panel {
            position: fixed;
            z-index: 66;
            display: none;
            flex-direction: column;
            gap: 0.4rem;
            padding: 0.6rem;
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(160, 120, 255, 0.3);
            border-radius: 14px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        }
        .swap-panel.open { display: flex; }
        .swap-opt {
            padding: 0.45rem 1rem;
            border-radius: 12px;
            border: 1px solid rgba(160, 120, 255, 0.3);
            background: rgba(160, 120, 255, 0.1);
            color: #e8e0ff;
            cursor: pointer;
            white-space: nowrap;
            font-size: 0.9rem;
        }
        .swap-opt:hover { background: rgba(160, 120, 255, 0.24); }
        .swap-prompt {
            position: fixed;
            top: 4.5rem;
            left: 50%;
            transform: translateX(-50%);
            z-index: 68;
            display: none;
            align-items: center;
            gap: 0.6rem;
            padding: 0.55rem 0.9rem;
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(255, 200, 60, 0.45);
            border-radius: 14px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
            font-size: 0.9rem;
            color: #ffe9b0;
            white-space: nowrap;
        }
        .swap-prompt.show { display: flex; }
        .swap-prompt button {
            padding: 0.3rem 0.9rem;
            border-radius: 12px;
            border: none;
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 700;
        }
        .swap-prompt .swap-yes { background: linear-gradient(135deg, #6dd5a0, #4caf84); color: #0f1a14; }
        .swap-prompt .swap-no { background: rgba(255, 80, 80, 0.2); color: #ffc4c4; border: 1px solid rgba(255, 80, 80, 0.4); }
        /* ===== 房间列表 ===== */
        .room-list-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.55rem 0.9rem;
            color: #bfdcff;
            font-weight: 700;
            font-size: 0.95rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }
        .room-list-close {
            width: 1.6rem;
            height: 1.6rem;
            border-radius: 50%;
            border: 1px solid rgba(255, 255, 255, 0.25);
            background: rgba(255, 255, 255, 0.08);
            color: #fff;
            cursor: pointer;
        }
        .room-list-body { overflow-y: auto; padding: 0.4rem; }
        .room-loading {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.6rem;
            padding: 1.7rem 0;
            color: rgba(255, 255, 255, 0.65);
            font-size: 0.85rem;
        }
        .room-loading .room-spinner { width: 34px; height: 34px; border-width: 4px; }
        .room-row {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.4rem 0.6rem;
            border-radius: 10px;
            font-size: 0.85rem;
        }
        .room-row:hover { background: rgba(255, 255, 255, 0.06); }
        .room-game { width: 3.6rem; color: #ffe08a; }
        .room-id { font-family: 'Courier New', monospace; color: #fff; font-weight: 700; letter-spacing: 1px; }
        .room-st { color: rgba(255, 255, 255, 0.55); }
        .room-cnt { color: rgba(255, 255, 255, 0.45); margin-left: auto; }
        .room-empty { color: rgba(255, 255, 255, 0.45); font-size: 0.85rem; padding: 0.6rem; text-align: center; }
        .room-empty-row { opacity: 0.55; }
        .room-over-row { opacity: 0.6; }
        .room-seats { letter-spacing: 2px; font-size: 0.9rem; }
        .room-owner { color: rgba(255, 224, 138, 0.85); white-space: nowrap; max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; }
        .room-time { color: rgba(255, 255, 255, 0.35); font-size: 0.75rem; white-space: nowrap; }
        .room-enter {
            padding: 0.25rem 0.7rem;
            border-radius: 10px;
            border: 1px solid rgba(0, 229, 255, 0.35);
            background: rgba(0, 229, 255, 0.1);
            color: #bfdcff;
            cursor: pointer;
            font-size: 0.8rem;
        }
        .room-enter:hover { background: rgba(0, 229, 255, 0.25); }
        .room-enter:disabled { opacity: 0.4; cursor: not-allowed; }
        .sticker-panel {
            position: fixed;
            left: 0.75rem;
            bottom: 5.2rem;
            transform: none;
            z-index: 66;
            display: none;
            grid-template-columns: repeat(6, 2.4rem);
            gap: 0.35rem;
            padding: 0.6rem;
            max-height: min(65vh, 27rem);
            overflow-y: auto;
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(0, 229, 255, 0.25);
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        }
        .sticker-panel.open { display: grid; }
        .sticker-cell {
            width: 2.4rem;
            height: 2.4rem;
            font-size: 1.45rem;
            line-height: 1;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: rgba(255, 255, 255, 0.06);
            border-radius: 10px;
            cursor: pointer;
            transition: transform 0.15s, background 0.15s;
        }
        .sticker-cell:hover { transform: scale(1.15); background: rgba(255, 255, 255, 0.16); }
        .sticker-stage {
            position: fixed;
            left: 50%;
            top: 28%;
            transform: translateX(-50%);
            z-index: 65;
            pointer-events: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.5rem;
        }
        .sticker-float {
            display: flex;
            flex-direction: column;
            align-items: center;
            animation: stickerPop 2.4s ease forwards;
        }
        .sticker-emoji { font-size: 3.4rem; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5)); }
        .sticker-who {
            font-size: 0.72rem;
            color: rgba(255, 255, 255, 0.8);
            background: rgba(0, 0, 0, 0.45);
            padding: 0.1rem 0.6rem;
            border-radius: 10px;
        }
        @keyframes stickerPop {
            0% { transform: scale(0.2); opacity: 0; }
            14% { transform: scale(1.15); opacity: 1; }
            24% { transform: scale(1); }
            78% { opacity: 1; transform: translateY(0); }
            100% { opacity: 0; transform: translateY(-46px); }
        }
        .room-input {
            width: 7rem;
            padding: 0.5rem;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.25);
            background: rgba(255, 255, 255, 0.08);
            color: #fff;
            text-align: center;
            font-size: 1rem;
            letter-spacing: 2px;
            font-family: inherit;           /* 占位符与页面字体一致 */
        }
        .room-input::placeholder { color: rgba(255, 255, 255, 0.45); }
        .room-input.locked {
            width: 8.4rem;
            border-color: rgba(255, 224, 138, 0.55);
            background: rgba(255, 224, 138, 0.08);
            color: #ffe08a;
            font-weight: 700;
            letter-spacing: 3px;
        }
        .board-ctrl .rules-btn {
            padding: 0.5rem 1.2rem;
            font-size: 0.95rem;
            border: 1px solid rgba(255, 200, 60, 0.4);
            background: rgba(255, 200, 60, 0.1);
            color: #ffe08a;
            border-radius: 20px;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        .board-ctrl .rules-btn:hover { background-color: rgba(255, 200, 60, 0.25); }

        /* 难度滑块：按钮在轨道内滑动 */
        .lvl-slider {
            position: relative;
            display: inline-flex;
            border-radius: 20px;
            overflow: hidden;
            border: 1px solid rgba(0, 229, 255, 0.35);
            background: rgba(0, 229, 255, 0.1);
        }
        .lvl-thumb {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            width: 33.333%;
            background: linear-gradient(135deg, #00e5ff, #00b3a4);
            border-radius: 20px;
            transition: transform 0.3s ease;
            z-index: 0;
            pointer-events: none;
        }
        .lvl-slider .lvl-seg {
            position: relative;
            z-index: 1;
            width: 4.2rem;
            padding: 0.5rem 0;
            font-size: 0.95rem;
            border: none;
            background: transparent;
            color: rgba(255, 255, 255, 0.75);
            cursor: pointer;
            transition: color 0.3s;
        }
        /* 激活段文字颜色由 data-level 驱动，与滑块位置永远一致 */
        .lvl-slider[data-level="easy"] .lvl-seg[data-level="easy"],
        .lvl-slider[data-level="normal"] .lvl-seg[data-level="normal"],
        .lvl-slider[data-level="hard"] .lvl-seg[data-level="hard"] {
            color: #06222a;
            font-weight: 700;
        }
        .lvl-slider[data-level="easy"] .lvl-thumb { transform: translateX(0); }
        .lvl-slider[data-level="normal"] .lvl-thumb { transform: translateX(100%); }
        .lvl-slider[data-level="hard"] .lvl-thumb { transform: translateX(200%); }
        /* 对局中难度锁定 */
        .lvl-slider.locked { opacity: 0.45; pointer-events: none; filter: grayscale(0.4); }

        /* ============ 规则侧栏共用样式 ============ */
        .rules-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.9rem 1.2rem;
            font-size: 1.15rem;
            font-weight: 700;
            color: #fff;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
            background: rgba(0, 229, 255, 0.06);
        }
        .rules-close {
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.06);
            color: #fff;
            width: 2rem;
            height: 2rem;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1rem;
            line-height: 1;
            transition: all 0.2s;
        }
        .rules-close:hover { background: rgba(255, 100, 100, 0.35); border-color: rgba(255, 100, 100, 0.5); }
        .rules-body {
            overflow-y: auto;
            padding: 1rem 1.2rem 1.2rem;
            color: rgba(255, 255, 255, 0.85);
            font-size: 0.92rem;
            line-height: 1.75;
        }
        .rules-body h4 {
            margin: 0.9rem 0 0.35rem;
            font-size: 1rem;
            color: #00e5ff;
            letter-spacing: 1px;
        }
        .rules-body h4:first-child { margin-top: 0; }
        .rules-body ul { margin: 0; padding-left: 1.1rem; }
        .rules-body li { margin: 0.15rem 0; }
        .rules-koujue {
            margin: 0.8rem 0 0.2rem;
            padding: 0.8rem 1rem;
            background: rgba(0, 229, 255, 0.08);
            border: 1px dashed rgba(0, 229, 255, 0.35);
            border-radius: 12px;
            font-size: 0.92rem;
            color: #ffe08a;
            line-height: 1.9;
        }
        .rules-koujue b { color: #fff; }
        /* ===== 玩家资料面板 ===== */
        .profile-btn {
            position: fixed;
            right: 0.9rem;
            bottom: 5.9rem;
            z-index: 70;
            width: 2.6rem;
            height: 2.6rem;
            border-radius: 50%;
            border: 1px solid rgba(0, 229, 255, 0.3);
            background: rgba(0, 229, 255, 0.12);
            color: #fff;
            font-size: 1.25rem;
            cursor: pointer;
        }
        .profile-panel {
            position: fixed;
            left: 0.75rem;
            bottom: 8.8rem;
            z-index: 67;
            display: none;
            flex-direction: column;
            width: min(88vw, 320px);
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(0, 229, 255, 0.25);
            border-radius: 14px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            padding: 0.8rem;
            gap: 0.5rem;
        }
        .profile-panel.open { display: flex; }
        .profile-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: #bfdcff;
            font-weight: 700;
            font-size: 0.95rem;
        }
        .profile-body { display: flex; flex-direction: column; gap: 0.45rem; }
        .profile-body label {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.85rem;
            color: rgba(255, 255, 255, 0.75);
        }
        .profile-body input, .profile-body textarea {
            flex: 1;
            min-width: 0;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 8px;
            color: #fff;
            padding: 0.35rem 0.55rem;
            font-size: 0.85rem;
        }
        .profile-body textarea { width: 100%; resize: vertical; font-family: monospace; }
        .profile-actions { display: flex; gap: 0.4rem; }

        /* ===== 游戏大厅（首页） ===== */
        .hall {
            width: 100%;
            max-width: 980px;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }
        .hall-head { text-align: center; margin-bottom: 0.4rem; }
        .hall-head h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 0 0 0.3rem; }
        .hall-head .subtitle { color: rgba(255, 255, 255, 0.65); margin: 0; }
        .hall-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 0.8rem;
        }
        .hall-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.3rem;
            padding: 1.1rem 0.8rem;
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(0, 229, 255, 0.25);
            border-radius: 14px;
            color: #fff;
            cursor: pointer;
            transition: transform 0.15s, box-shadow 0.15s;
        }
        .hall-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 229, 255, 0.2); }
        .hall-card .emoji { font-size: 2rem; }
        .hall-card .label { font-weight: 700; }
        .hall-card .desc { color: rgba(255, 255, 255, 0.55); font-size: 0.8rem; }
        .hall-rooms {
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(0, 229, 255, 0.25);
            border-radius: 14px;
            overflow: hidden;
        }

        /* ===== 游戏页侧栏布局（容器查询断点 1200px） ===== */
        .game-shell {
            width: 100%;
            display: grid;
            grid-template-columns: minmax(0, 1fr);
            grid-template-rows: auto auto;
            gap: 0.9rem;
            max-width: 1400px;
        }
        .rooms-side, .rules-side {
            background: linear-gradient(160deg, #1b2a4a, #12203c);
            border: 1px solid rgba(0, 229, 255, 0.25);
            border-radius: 14px;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }
        .side-head, .rules-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.5rem 0.8rem;
            color: #bfdcff;
            font-weight: 700;
            font-size: 0.9rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }
        .side-close, .rules-close {
            border: 1px solid rgba(255, 255, 255, 0.25);
            background: rgba(255, 255, 255, 0.08);
            color: #fff;
            border-radius: 50%;
            width: 1.5rem;
            height: 1.5rem;
            cursor: pointer;
        }
        .side-body, .rooms-side .room-list-body, .rules-side .rules-body, .hall-rooms .room-list-body {
            overflow-y: auto;
            padding: 0.4rem;
        }

        /* 宽容器（≥1200px）：固定在左右两侧，可展开/合拢 */
        @container gameshell (min-width: 1200px) {
            /* auto 轨道 + 侧栏自身定宽：侧栏关闭（display:none）时轨道塌缩为 0，
               棋盘独占整行并居中；打开时才让出 290 / 340 px */
            .game-shell { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "rooms board rules" "ctrl ctrl ctrl"; }
            .rooms-side { grid-area: rooms; width: 290px; align-self: start; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); }
            .rules-side { grid-area: rules; width: 340px; align-self: start; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); }
            .board-area { grid-area: board; }
            .board-ctrl { grid-area: ctrl; width: 100%; }
            .rooms-side:not(.open), .rules-side:not(.open) { display: none; }
        }

        /* 窄容器（<1200px）：悬浮抽屉，点击出现、点外部消失 */
        @container gameshell (max-width: 1199.9px) {
            .game-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "board" "ctrl"; }
            .board-area { grid-area: board; }
            .board-ctrl { grid-area: ctrl; width: 100%; }
            .rooms-side, .rules-side {
                position: fixed;
                top: 4rem;
                bottom: 1rem;
                width: min(86%, 340px);
                z-index: 80;
                display: flex;
                flex-direction: column;
                visibility: hidden;
                opacity: 0;
                pointer-events: none;
                box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
                transition: transform 0.18s ease, opacity 0.18s ease, visibility 0.18s;
            }
            .rooms-side { left: 0.6rem; transform: translateX(-110%); }
            .rules-side { right: 0.6rem; transform: translateX(110%); }
            .rooms-side.open, .rules-side.open { visibility: visible; opacity: 1; transform: none; pointer-events: auto; }
        }

        /* ============ 矮视口（笔记本小窗、手机横屏、嵌入 iframe） ============
           iframe 有自己的视口，媒体查询在嵌入框内同样生效：
           压缩棋盘页的固定开销，把省下的高度让给棋盘（560px 框里棋盘 270 → 约 350） */
        @media (max-height: 720px) {            /* 215 = 实测固定开销（标题 45 + 控制行 ~76 + 内边距/gap ~72）+ 页面上下内边距余量 */
            :root { --board-chrome: 218px; }
            .page { padding: 0.6rem; }
            .game-section { padding: 0.75rem 0.75rem 0.6rem; gap: 0.6rem; }
            .game-tips { display: none; }
            .board-ctrl { gap: 0.35rem; }
            .board-ctrl button,
            .board-actions button { padding: 0.35rem 0.8rem; font-size: 0.85rem; }
            .game-hud { font-size: 0.95rem; }
        }

        /* 触屏设备：按钮做到 44px 触摸目标下限。
           只对 coarse 指针生效——鼠标用户不需要更大的点击区，
           而这些高度是从棋盘那里借来的（560px 高的嵌入框里差 40px 棋盘）。 */
        @media (pointer: coarse) {
            .board-ctrl button,
            .board-actions button { min-height: 44px; }
        }

        /* 窄且矮（手机上的嵌入框）：控制按钮会换行成 3 行，把固定开销再压一档 */
        @media (max-height: 720px) and (max-width: 420px) {
            .board-ctrl { gap: 0.3rem; max-width: 100%; }
            .ctrl-row { gap: 0.3rem; }
            /* 这里放弃 44px 触摸目标：311px 宽的框里，装得下比点得准更重要 */
            .board-ctrl button,
            .board-actions button { padding: 0.25rem 0.5rem; font-size: 0.75rem; border-radius: 14px; min-height: 0; }
            .game-hud .game-title { font-size: 0.95rem; }
            .game-stats { font-size: 0.8rem; }
        }

        /* 手机横屏：高度只有 390 上下，纵向堆叠会让棋盘缩到 170px 左右。
           把控制行移到棋盘右侧竖排，高度全留给棋盘（同一份 .game-shell 换模板）。 */
        @media (max-height: 480px) and (orientation: landscape) {
            :root { --board-chrome: 90px; }
            .game-shell {
                grid-template-columns: minmax(0, 1fr) auto;
                grid-template-areas: "board ctrl";
                align-items: center;
            }
            .board-area { grid-area: board; }
            .board-ctrl { grid-area: ctrl; }
            /* 两组控制各自竖排、彼此并排：总高度降到 max(两组) 而不是相加 */
            .board-ctrl { flex-direction: row; align-items: center; gap: 0.6rem; }
            .board-ctrl .ctrl-row { flex-direction: column; flex-wrap: nowrap; }
            /* 右下角固定悬浮的音乐/资料按钮会压到控制列上，给控制列让出位置 */
            .board-ctrl { padding-right: 2.9rem; }
            /* 横屏是横向排布，按钮可以做得够大：44px 是触摸目标的下限 */
            .board-ctrl button,
            .board-actions button { min-height: 44px; padding: 0.3rem 0.7rem; }
        }

