/* ===== 诗词华容道 - 暖棕木纹国风样式 ===== */

:root {
    /* 暖棕木纹主色调 */
    --wood-dark: #8B5E3C;
    --wood-medium: #A67C52;
    --wood-light: #C9A67F;
    --wood-pale: #E6D2B8;

    /* 背景色 */
    --bg-warm: #F9F0E7;
    --bg-paper: rgba(249, 240, 231, 0.98);

    /* 文字色 */
    --text-ink: #2D2620;
    --text-ink-light: #5A4A3A;
    --text-ink-muted: #8B7B6B;

    /* 赭红色 - 标题/印章 */
    --red-ochre: #8B3A3A;
    --red-seal: #8B3A3A;
    --red-light: #B85454;

    /* 金色 */
    --gold-dark: #8B6914;
    --gold-medium: #C4A35A;
    --gold-light: #E8D5A3;

    /* 功能色 */
    --success-color: #6B4226;
    --error-color: #B22222;

    /* 阴影 */
    --shadow-soft: rgba(139, 94, 60, 0.12);
    --shadow-medium: rgba(139, 94, 60, 0.22);
    --shadow-strong: rgba(139, 94, 60, 0.35);

    /* 基础色 */
    --white: #FFFFFF;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

@import url('https://fonts.googleapis.cn/css2?family=Ma+Shan+Zheng&family=ZCOOL+KuaiLe&display=swap');

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', 'SimSun', '宋体', serif;
    background: var(--bg-warm);
    color: var(--text-ink);
    position: relative;
}

/* ===== 背景纹理（宣纸质感） ===== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='paper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.025' numOctaves='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0.02 0 1 0 0 0.01 0 0 1 0 0 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23paper)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-position: 0 0;
    background-repeat: repeat;
    pointer-events: none;
    z-index: 0;
}

/* ===== 页面切换 ===== */
.page {
    display: none;
    position: relative;
    z-index: 1;
    height: 100vh;
    height: 100dvh;
}

.page.active {
    display: flex;
}

/* ===== 首页 ===== */
#home-page {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-warm);
    overflow: hidden;
    position: relative;
}

/* 淡粉圆月装饰 */
.home-bg-art {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.home-bg-art::before {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(247, 220, 200, 0.5) 0%, rgba(247, 220, 200, 0.2) 50%, transparent 70%);
    bottom: 15%;
    left: 5%;
}

/* 水墨竹叶装饰 - 右侧 */
.home-bg-art::after {
    content: '';
    position: absolute;
    top: 8%;
    right: 0;
    width: 120px;
    height: 300px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 300'%3E%3Cg fill='none' stroke='%23C4B49A' stroke-width='1.5' opacity='0.3'%3E%3Cpath d='M100 0 Q95 80 80 150 Q70 200 60 300'/%3E%3Cpath d='M80 50 Q60 40 30 35'/%3E%3Cpath d='M75 60 Q55 55 25 52'/%3E%3Cpath d='M85 80 Q65 75 35 70'/%3E%3Cpath d='M75 90 Q55 88 30 85'/%3E%3Cpath d='M80 110 Q60 108 35 105'/%3E%3Cpath d='M70 130 Q50 128 25 125'/%3E%3Cpath d='M90 50 Q95 40 105 30'/%3E%3Cpath d='M88 65 Q95 55 108 48'/%3E%3Cpath d='M85 85 Q92 78 105 70'/%3E%3Cpath d='M82 105 Q90 98 102 90'/%3E%3Cpath d='M78 125 Q86 118 98 112'/%3E%3C/g%3E%3C/svg%3E") no-repeat center/contain;
    opacity: 0.4;
}

.home-fan {
    position: absolute;
    width: 80px;
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}

.home-fan-left {
    top: 8%;
    left: 3%;
    transform: rotate(-15deg);
}

.home-fan-right {
    top: 12%;
    right: 3%;
    transform: rotate(20deg);
}

.home-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 0 24px;
}

.home-scroll-wrap {
    position: relative;
    width: 100%;
    max-width: 340px;
    margin-bottom: 8px;
}

.home-scroll-bg {
    width: 100%;
    display: block;
}

.home-scroll-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
}

.home-seal {
    width: 44px;
    height: 44px;
    background: var(--red-ochre);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    opacity: 0.85;
    transform: rotate(-6deg);
    box-shadow: 0 2px 6px rgba(139, 58, 58, 0.25);
}

.home-seal::after {
    content: '诗';
    color: white;
    font-size: 22px;
    font-family: 'Ma Shan Zheng', serif;
}

.home-title {
    font-size: 32px;
    font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', serif;
    color: var(--red-ochre);
    letter-spacing: 6px;
    margin-bottom: 4px;
}

.home-subtitle {
    font-size: 15px;
    color: var(--wood-dark);
    letter-spacing: 3px;
    font-family: 'ZCOOL KuaiLe', 'Ma Shan Zheng', serif;
}

.ink-divider {
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--wood-medium), transparent);
    margin: 20px 0 28px;
    opacity: 0.4;
}

/* 标题下方白色横线装饰 */
.home-subtitle::after {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    margin: 6px auto 0;
    border-radius: 1px;
}

.home-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 260px;
}

.home-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    border: 1.5px solid var(--wood-light);
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--wood-dark);
    font-family: 'Ma Shan Zheng', serif;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.home-btn:active {
    transform: scale(0.97);
}

.home-btn-primary {
    background: linear-gradient(135deg, var(--wood-dark), var(--wood-medium));
    color: var(--white);
    border-color: var(--wood-dark);
    font-size: 20px;
    padding: 15px 20px;
}

.home-btn-primary:active {
    background: linear-gradient(135deg, var(--wood-dark), #9B6E4C);
}

.btn-decor-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.08;
    pointer-events: none;
}

.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.btn-text {
    position: relative;
    z-index: 1;
}

/* ===== 游戏页 ===== */
#game-page {
    flex-direction: column;
    background: linear-gradient(170deg, #FBF3EB 0%, #F5E6D3 40%, #EEDCC6 100%);
    overflow: hidden;
    position: relative;
    touch-action: none; /* 防止浏览器拦截触摸事件 */
}

/* 游戏页背景装饰容器 */
.game-bg-art {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

/* 右上角淡粉圆月 */
.game-bg-art::before {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(247, 220, 200, 0.45) 0%, rgba(247, 220, 200, 0.15) 50%, transparent 70%);
    top: -20px;
    right: -50px;
}

/* 左下角水墨竹叶 */
.game-bg-art::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 110px;
    height: 280px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 110 280'%3E%3Cg fill='none' stroke='%23B8A48A' stroke-width='1.3' opacity='0.22'%3E%3Cpath d='M22 280 Q27 200 32 130 Q37 70 42 0'/%3E%3Cpath d='M32 55 Q54 45 75 40'/%3E%3Cpath d='M30 70 Q52 62 74 56'/%3E%3Cpath d='M34 85 Q56 77 78 72'/%3E%3Cpath d='M32 100 Q50 94 70 89'/%3E%3Cpath d='M38 45 Q22 34 6 26'/%3E%3Cpath d='M36 65 Q20 55 5 47'/%3E%3Cpath d='M38 82 Q24 74 8 66'/%3E%3C/g%3E%3C/svg%3E") no-repeat center/contain;
}

/* 右下角山峦装饰 */
.game-mountain-decor {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 200px;
    height: 120px;
    pointer-events: none;
}

/* 水墨云气浮动 - 左上 */
.game-bg-art .ink-cloud {
    position: absolute;
    top: 12%;
    left: -10px;
    width: 80px;
    height: 40px;
    background: radial-gradient(ellipse, rgba(212, 197, 169, 0.18) 0%, transparent 70%);
    animation: inkCloudFloat 12s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes inkCloudFloat {
    0% { transform: translateX(0) scale(1); opacity: 0.5; }
    100% { transform: translateX(20px) scale(1.1); opacity: 0.3; }
}

.game-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 6px;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 100%);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.back-btn-text {
    background: none;
    border: none;
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', serif;
    font-size: 16px;
    color: var(--wood-dark);
    cursor: pointer;
    padding: 4px 10px;
    letter-spacing: 2px;
    transition: color 0.2s, opacity 0.2s;
    position: relative;
}

.back-btn-text::before {
    content: '‹';
    margin-right: 2px;
    font-size: 20px;
    font-weight: 300;
    vertical-align: -1px;
}

.back-btn-text:active {
    opacity: 0.6;
}

.icon-btn-accent {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wood-dark), var(--wood-medium));
    color: var(--white);
}

.icon-btn-accent svg {
    width: 16px;
    height: 16px;
}

.level-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.75);
    border: 1.5px solid var(--wood-light);
    border-radius: 20px;
    padding: 4px 16px 4px 8px;
    font-size: 15px;
    color: var(--wood-dark);
    box-shadow: 0 2px 8px var(--shadow-soft);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    letter-spacing: 1px;
}

.level-badge-icon {
    width: 20px;
    height: 20px;
}

.level-sep {
    color: var(--wood-pale);
    margin: 0 2px;
}

.top-bar-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--wood-light);
    background: rgba(255, 255, 255, 0.8);
    color: var(--wood-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tool-btn svg {
    width: 16px;
    height: 16px;
}

.tool-btn:active {
    transform: scale(0.92);
    background: var(--wood-pale);
}

.tool-btn.test-only {
    display: none;
}

/* ===== 目标诗句展示区 ===== */
.poem-info {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    padding: 6px 16px 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.poem-target {
    flex: 1;
    background: rgba(255, 255, 255, 0.82);
    border: 1.5px solid var(--wood-light);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-right: 12px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    position: relative;
    box-shadow: 0 2px 10px var(--shadow-soft);
}

/* 诗句区域左侧竖线装饰 */
.poem-target::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: linear-gradient(180deg, transparent, var(--wood-light), transparent);
    border-radius: 1px;
}

.poem-target-label {
    font-size: 10px;
    color: var(--wood-medium);
    letter-spacing: 3px;
    margin-bottom: 4px;
    font-family: system-ui, sans-serif;
    padding-left: 8px;
}

.poem-target-text {
    font-size: 20px;
    color: var(--text-ink);
    letter-spacing: 4px;
    line-height: 1.5;
    word-break: break-all;
    padding-left: 8px;
}

.poem-target-meta {
    font-size: 12px;
    color: var(--text-ink-muted);
    margin-top: 4px;
    font-family: system-ui, sans-serif;
    padding-left: 8px;
}

/* ===== 计时器 ===== */
.timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    min-width: 64px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--wood-pale);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 1px 6px var(--shadow-soft);
}

.timer-display {
    font-family: system-ui, sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--wood-dark);
    line-height: 1;
    margin-bottom: 4px;
}

.timer-display.timer-warning {
    color: var(--gold-medium);
}

.timer-display.timer-danger {
    color: var(--error-color);
    animation: timerFlash 0.5s infinite alternate;
}

@keyframes timerFlash {
    from { opacity: 1; }
    to { opacity: 0.4; }
}

.timer-bar {
    width: 54px;
    height: 4px;
    background: var(--wood-pale);
    border-radius: 2px;
    overflow: hidden;
}

.timer-bar-fill {
    height: 100%;
    background: var(--wood-medium);
    border-radius: 2px;
    transition: width 1s linear, background-color 0.5s;
}

.timer-bar-fill.timer-bar-warning {
    background: var(--gold-medium);
}

.timer-bar-fill.timer-bar-danger {
    background: var(--error-color);
}

/* ===== 华容道网格区 ===== */
.grid-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px 20px;
    overflow: hidden;
    min-height: 0;
    position: relative;
    z-index: 1;
}

.klotski-grid {
    display: grid;
    gap: 6px;
    justify-content: center;
    align-content: center;
    padding: 16px;
    background:
        linear-gradient(145deg, #DCC9AB 0%, #C9A67F 40%, #BC9568 100%);
    border: 3px solid var(--wood-medium);
    border-radius: var(--radius-lg);
    box-shadow:
        0 8px 32px var(--shadow-medium),
        0 2px 8px var(--shadow-soft),
        inset 0 2px 4px rgba(255, 255, 255, 0.15),
        inset 0 -2px 6px rgba(139, 94, 60, 0.2);
    position: relative;
    touch-action: none; /* 防止浏览器拦截触摸事件 */
}

/* 网格内部木纹纹理 */
.klotski-grid::before {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: calc(var(--radius-lg) - 3px);
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='wood'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.04 0.008' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23wood)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

/* 四角装饰 */
.klotski-grid::after {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(139, 94, 60, 0.15);
    border-radius: calc(var(--radius-lg) - 6px);
    pointer-events: none;
}

/* ===== 字块样式 ===== */
.tile {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.2s ease,
                background-color 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', serif;
    touch-action: none;
    z-index: 1; /* 确保在网格纹理之上 */
}

/* 诗句字块 - 浅木色底 + 深棕内框，仿活字印刷 */
.tile-char {
    background: linear-gradient(160deg, #EDE0CC 0%, #E2D1B6 100%);
    border: 1.5px solid var(--wood-light);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.3),
        inset 0 -1px 2px rgba(139, 94, 60, 0.12),
        0 2px 6px var(--shadow-soft);
    color: var(--text-ink);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.tile-char:active {
    box-shadow:
        inset 0 2px 4px rgba(139, 94, 60, 0.2),
        0 1px 3px var(--shadow-soft);
}

/* 可移动字块高亮 - 淡金微光 */
.tile-movable {
    border-color: var(--wood-medium);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.3),
        inset 0 -1px 2px rgba(139, 94, 60, 0.12),
        0 2px 12px rgba(166, 124, 82, 0.35),
        0 0 0 1px rgba(166, 124, 82, 0.15);
}

.tile-movable::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 8px;
    border: 1.5px solid rgba(166, 124, 82, 0.3);
    animation: movableGlow 1.5s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes movableGlow {
    from { box-shadow: 0 0 4px rgba(166, 124, 82, 0.15); }
    to { box-shadow: 0 0 10px rgba(166, 124, 82, 0.3); }
}

/* 空格 - 凹陷感 */
.tile-empty {
    background: rgba(166, 124, 82, 0.25);
    border: 1.5px dashed rgba(139, 94, 60, 0.18);
    cursor: default;
    box-shadow: inset 0 3px 8px rgba(139, 94, 60, 0.18);
}

.tile-empty::after {
    content: '';
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(139, 94, 60, 0.06);
}

/* 位置正确的字块 */
.tile-correct {
    color: var(--wood-dark);
    border-color: var(--wood-medium);
    background: linear-gradient(160deg, #E8D9C0 0%, #DDD0B8 100%);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* 拖动中的字块 */
.tile-dragging {
    z-index: 50 !important;
    box-shadow: 
        0 8px 20px rgba(139, 94, 60, 0.35),
        0 2px 8px rgba(139, 94, 60, 0.2) !important;
    opacity: 0.9;
    transition: none !important; /* 拖动时禁止transition，保证跟手 */
}

.tile-shake {
    animation: tileShake 0.35s ease;
}

@keyframes tileShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* ===== 弹窗 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(45, 38, 32, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 340px;
    background: var(--bg-paper);
    border-radius: var(--radius-xl);
    padding: 28px 24px 22px;
    box-shadow: 0 12px 40px rgba(139, 94, 60, 0.2);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    text-align: center;
}

@keyframes modalPop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-frame-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.06;
    pointer-events: none;
}

.modal-seal {
    position: relative;
    width: 40px;
    height: 40px;
    background: var(--red-ochre);
    color: var(--white);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-family: 'Ma Shan Zheng', serif;
    margin-bottom: 10px;
    transform: rotate(-6deg);
    box-shadow: 0 2px 6px rgba(139, 58, 58, 0.2);
}

.modal-title {
    position: relative;
    font-size: 22px;
    color: var(--text-ink);
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.modal-body {
    position: relative;
    margin-bottom: 18px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-ink-light);
}

.modal-level-text {
    font-size: 14px;
    color: var(--text-ink-muted);
    margin-bottom: 8px;
    font-family: system-ui, sans-serif;
}

.poem-list {
    text-align: center;
}

.poem-list-item {
    font-size: 18px;
    color: var(--wood-dark);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.poem-list-meta {
    font-size: 12px;
    color: var(--text-ink-muted);
    font-family: system-ui, sans-serif;
}

.modal-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 28px;
    border: 1.5px solid var(--wood-light);
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--wood-dark);
    font-family: 'Ma Shan Zheng', serif;
    font-size: 17px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.modal-btn:active {
    transform: scale(0.96);
}

.modal-btn-primary {
    background: linear-gradient(135deg, var(--wood-dark), var(--wood-medium));
    color: var(--white);
    border-color: var(--wood-dark);
}

.modal-btn-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.1;
    pointer-events: none;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ===== 结果统计 ===== */
.result-status {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-ink);
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 10px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-ink-muted);
    margin-bottom: 2px;
    font-family: system-ui, sans-serif;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--wood-dark);
    font-family: system-ui, sans-serif;
}

/* ===== 设置 ===== */
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(139, 94, 60, 0.08);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-label {
    font-size: 16px;
    color: var(--text-ink);
}

.toggle-switch {
    position: relative;
    width: 46px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 13px;
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--wood-medium);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ===== 游戏说明 ===== */
.instructions-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--wood-dark);
    margin: 12px 0 4px;
    letter-spacing: 1px;
}

.instructions-section-title:first-child {
    margin-top: 0;
}

/* ===== 通关庆祝特效 ===== */
.celebrate-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 200;
    animation: celebrateFloat 1.5s ease-out forwards;
}

@keyframes celebrateFloat {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0.3);
    }
}

/* ===== 通关弹跳动画 ===== */
.tile-bounce {
    animation: tileBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tileBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.15); }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* ===== 响应式 ===== */

/* 平板 */
@media (min-width: 768px) {
    .home-content {
        max-width: 500px;
    }

    .home-scroll-wrap {
        max-width: 380px;
    }

    .home-title {
        font-size: 38px;
    }

    .klotski-grid {
        max-width: 420px;
        max-height: 420px;
    }
}

/* 大屏 */
@media (min-width: 1024px) {
    .home-content {
        max-width: 560px;
    }

    .klotski-grid {
        max-width: 460px;
        max-height: 460px;
    }
}

/* 小屏 */
@media (max-width: 375px) {
    .home-title {
        font-size: 26px;
        letter-spacing: 4px;
    }

    .home-subtitle {
        font-size: 13px;
    }

    .home-scroll-wrap {
        max-width: 280px;
    }

    .home-btn {
        padding: 11px 16px;
        font-size: 16px;
    }

    .home-btn-primary {
        font-size: 18px;
        padding: 13px 16px;
    }

    .poem-target-text {
        font-size: 17px;
        letter-spacing: 2px;
    }

    .klotski-grid {
        padding: 8px;
        gap: 4px;
    }

    .tile {
        border-radius: 5px;
    }
}

/* 极小屏 */
@media (max-width: 320px) {
    .home-subtitle {
        display: none;
    }

    .home-scroll-wrap {
        max-width: 250px;
    }

    .ink-divider {
        margin: 12px 0 18px;
    }
}

/* 横屏手机 */
@media (max-height: 500px) and (orientation: landscape) {
    .game-top-bar {
        padding: 4px 12px 2px;
    }

    .poem-info {
        padding: 2px 16px 4px;
    }

    .poem-target {
        padding: 4px 10px;
    }

    .poem-target-text {
        font-size: 16px;
    }

    .grid-area {
        padding: 4px 16px 8px;
    }

    .klotski-grid {
        padding: 8px;
    }
}

/* 刘海屏安全区域 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .grid-area {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
