/* ================= 喵喵消消乐 · 深夜猫咖 ================= */
:root {
            --night-0: #1c1220;
            --night-1: #251828;
            --night-2: #31203a;
            --honey: #ffc15e;
            --rose: #ff7b9c;
            --cream: #fff3e4;
            --muted: #a98fa8;
        }

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

        body {
            font-family: 'Noto Sans SC', sans-serif;
            background:
                radial-gradient(80% 55% at 50% -5%, rgba(255, 193, 94, 0.10), transparent 65%),
                radial-gradient(60% 45% at 85% 100%, rgba(255, 123, 156, 0.08), transparent 70%),
                linear-gradient(175deg, var(--night-1), var(--night-0) 70%);
            color: var(--cream);
            height: 100vh;
            overflow: hidden;
            overscroll-behavior: none;
            touch-action: none;
            user-select: none;
            -webkit-user-select: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        ::selection { background: rgba(255, 123, 156, 0.35); }
        button { font-family: inherit; }
        :focus-visible { outline: 2px solid var(--honey); outline-offset: 2px; border-radius: 8px; }

        /* ---- 星空背景 ---- */
        #bgCanvas {
            position: fixed;
            inset: 0;
            z-index: 0;
            pointer-events: none;
        }

        /* ---- 彩灯串 ---- */
        .lights {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 26px;
            z-index: 1;
            pointer-events: none;
            background:
                radial-gradient(circle 4px at 5% 20px, #ffc15e 98%, transparent) 0 0 / 10% 100%,
                radial-gradient(circle 4px at 5% 20px, #ff7b9c 98%, transparent) 5% 0 / 10% 100%,
                linear-gradient(transparent 3px, rgba(255, 243, 228, 0.18) 3.5px, transparent 4.5px);
            background-repeat: repeat-x;
            animation: lightsTwinkle 2.4s ease-in-out infinite alternate;
        }

        @keyframes lightsTwinkle {
            from { opacity: 0.75; filter: drop-shadow(0 0 4px rgba(255, 193, 94, 0.6)); }
            to { opacity: 1; filter: drop-shadow(0 0 10px rgba(255, 193, 94, 0.9)); }
        }

        .stage {
            position: relative;
            z-index: 2;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            width: 100%;
            max-width: 520px;
            padding: 0 14px;
        }

        /* ---- 顶栏 ---- */
        .topbar {
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .level-chip {
            background: rgba(49, 32, 58, 0.8);
            border: 1px solid rgba(255, 193, 94, 0.25);
            border-radius: 999px;
            padding: 5px 14px;
            display: flex;
            align-items: baseline;
            gap: 6px;
        }

        .level-chip .lbl {
            font-size: 0.65rem;
            letter-spacing: 0.2em;
            color: var(--muted);
        }

        .level-chip .val {
            font-family: 'Fredoka One', cursive;
            font-size: 1.3rem;
            color: var(--honey);
            text-shadow: 0 0 12px rgba(255, 193, 94, 0.5);
        }

        .game-title {
            font-family: 'Fredoka One', 'Noto Sans SC', cursive;
            font-size: 1.5rem;
            letter-spacing: 0.08em;
            background: linear-gradient(120deg, var(--honey), var(--rose));
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            filter: drop-shadow(0 2px 10px rgba(255, 123, 156, 0.3));
        }

        .icon-btn {
            width: 38px;
            height: 38px;
            border-radius: 12px;
            border: 1px solid rgba(255, 193, 94, 0.25);
            background: rgba(49, 32, 58, 0.8);
            color: var(--honey);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }

        .icon-btn:hover {
            border-color: rgba(255, 193, 94, 0.6);
            box-shadow: 0 0 16px -4px rgba(255, 193, 94, 0.6);
            transform: translateY(-1px);
        }

        .icon-btn:active { transform: scale(0.92); }
        .icon-btn svg { width: 18px; height: 18px; }
        .icon-btn .ic-off { display: none; }
        .icon-btn.muted { color: var(--muted); }
        .icon-btn.muted .ic-on { display: none; }
        .icon-btn.muted .ic-off { display: block; }

        .top-actions { display: flex; gap: 8px; }

        /* ---- 信息栏 ---- */
        .hud {
            width: 100%;
            display: flex;
            gap: 8px;
        }

        .hud-card {
            flex: 1;
            background: rgba(49, 32, 58, 0.65);
            border: 1px solid rgba(255, 243, 228, 0.08);
            border-radius: 14px;
            padding: 8px 4px 7px;
            text-align: center;
            backdrop-filter: blur(6px);
        }

        .hud-card .lbl {
            display: block;
            font-size: 0.6rem;
            letter-spacing: 0.25em;
            text-indent: 0.25em;
            color: var(--muted);
            margin-bottom: 2px;
        }

        .hud-card .val {
            font-family: 'Fredoka One', cursive;
            font-size: 1.35rem;
            line-height: 1;
            font-variant-numeric: tabular-nums;
        }

        .hud-card.moves .val { color: #9bb8e8; text-shadow: 0 0 10px rgba(155, 184, 232, 0.5); }
        .hud-card.target .val { font-size: 1.05rem; color: var(--cream); padding-top: 4px; display: inline-block; }
        .hud-card.score .val { color: var(--rose); text-shadow: 0 0 10px rgba(255, 123, 156, 0.5); }

        /* ---- 进度条 ---- */
        .progress {
            width: 100%;
            height: 6px;
            border-radius: 4px;
            background: rgba(255, 243, 228, 0.08);
            overflow: hidden;
        }

        #progressBar {
            height: 100%;
            width: 0%;
            border-radius: 4px;
            background: linear-gradient(90deg, var(--honey), var(--rose));
            box-shadow: 0 0 12px rgba(255, 123, 156, 0.7);
            transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        }

        /* ---- 棋盘 ---- */
        #gameContainer {
            position: relative;
            padding: 8px;
            border-radius: 22px;
            background: linear-gradient(160deg, #3a2544, var(--night-2) 55%, #241629);
            border: 1px solid rgba(255, 193, 94, 0.2);
            box-shadow:
                0 24px 50px -16px rgba(0, 0, 0, 0.75),
                0 0 60px -20px rgba(255, 123, 156, 0.35),
                inset 0 1px 0 rgba(255, 243, 228, 0.08);
            transition: transform 0.1s;
        }

        canvas#gameCanvas {
            display: block;
            border-radius: 14px;
            touch-action: none;
            -webkit-tap-highlight-color: transparent;
        }

        @keyframes shake {
            0%, 100% { transform: translate(0, 0) rotate(0deg); }
            20% { transform: translate(-4px, 2px) rotate(-0.6deg); }
            40% { transform: translate(4px, -2px) rotate(0.6deg); }
            60% { transform: translate(-3px, -1px) rotate(-0.4deg); }
            80% { transform: translate(3px, 1px) rotate(0.4deg); }
        }
        .shake { animation: shake 0.4s; }

        /* ---- 底部提示 ---- */
        .footer-note {
            font-size: 0.7rem;
            letter-spacing: 0.2em;
            color: rgba(169, 143, 168, 0.7);
        }

        /* ---- 弹窗 ---- */
        .modal-overlay {
            position: fixed;
            inset: 0;
            z-index: 50;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(20, 12, 24, 0.75);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            opacity: 1;
            transition: opacity 0.3s;
        }

        .modal-overlay.hidden { opacity: 0; pointer-events: none; }

        .modal-card {
            background: linear-gradient(165deg, #3a2544, var(--night-2));
            border: 1px solid rgba(255, 193, 94, 0.3);
            border-radius: 24px;
            padding: 30px 26px 26px;
            max-width: 300px;
            width: 88%;
            text-align: center;
            box-shadow: 0 30px 60px -18px rgba(0, 0, 0, 0.8), 0 0 60px -20px rgba(255, 193, 94, 0.4);
            transform: scale(1);
            transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        .modal-overlay.hidden .modal-card { transform: scale(0.85) translateY(16px); }

        .modal-icon { width: 64px; height: 64px; margin: 0 auto 12px; display: block; }

        .modal-card h2 {
            font-family: 'Fredoka One', 'Noto Sans SC', cursive;
            font-size: 1.8rem;
            letter-spacing: 0.06em;
            margin-bottom: 6px;
            background: linear-gradient(120deg, var(--honey), var(--rose));
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .modal-card p {
            color: var(--muted);
            font-size: 0.9rem;
            margin-bottom: 20px;
        }

        .modal-card p strong { color: var(--honey); font-family: 'Fredoka One', cursive; }

        .btn-main {
            width: 100%;
            padding: 13px;
            border: none;
            border-radius: 14px;
            font-size: 1rem;
            font-weight: 900;
            letter-spacing: 0.15em;
            cursor: pointer;
            color: #3a2005;
            background: linear-gradient(135deg, var(--honey), #f09c3d);
            box-shadow: 0 8px 20px -6px rgba(255, 193, 94, 0.6);
            transition: all 0.2s;
        }

        .btn-main:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -6px rgba(255, 193, 94, 0.8); }
        .btn-main:active { transform: scale(0.96); }

        .btn-sub {
            width: 100%;
            padding: 13px;
            border-radius: 14px;
            font-size: 1rem;
            font-weight: 700;
            letter-spacing: 0.15em;
            cursor: pointer;
            color: var(--cream);
            background: transparent;
            border: 1px solid rgba(255, 243, 228, 0.2);
            transition: all 0.2s;
        }

        .btn-sub:hover { border-color: rgba(255, 193, 94, 0.5); color: var(--honey); }

        @media (max-height: 720px) {
            .game-title { display: none; }
            .stage { gap: 7px; }
        }

        @media (prefers-reduced-motion: reduce) {
            .lights { animation: none; }
            * { transition-duration: 0.01ms !important; }
        }
