/* ===== 诗词数独 - 完整样式（含素材集成） ===== */

:root {
    --bg-cream: #FDFBF7;
    --bg-paper: rgba(253, 251, 247, 0.98);
    --text-ink: #1A1A1A;
    --text-ink-light: #3D3D3D;
    --text-ink-muted: #7A7A7A;

    --green-dark: #2D7A66;
    --green-medium: #4A9F8A;
    --green-light: #7BC4B4;
    --green-pale: #A8DDD2;

    --blue-dark: #3A8891;
    --blue-medium: #5BAAB3;
    --blue-light: #8DD0D8;

    --teal-dark: #2E8B7A;
    --teal-medium: #4FB3A0;
    --teal-light: #80D6C7;

    --gold-dark: #8B6914;
    --gold-medium: #C4A35A;
    --gold-light: #E8D5A3;

    --cloud-white: #FFFFFF;
    --cloud-pale: #F0F8F6;

    --border-wood: #8B6914;
    --border-wood-light: #C4A35A;

    --shadow-soft: rgba(45, 122, 102, 0.12);
    --shadow-medium: rgba(45, 122, 102, 0.22);
    --shadow-strong: rgba(45, 122, 102, 0.35);

    --red-seal: #B22222;
    --red-light: #E85555;

    --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-cream);
    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 0 1 0 0 0 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;
}

/* 竹叶装饰 - 仅在非首页/游戏页可见 */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    display: none;
}

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

.page.active {
    display: flex;
    flex-direction: column;
    animation: pageFadeIn 0.5s ease-out;
}

@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 首页 ===== */
#home-page {
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background-image: url('../images/assets/bg-home.png');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-color: #E8F0EE;
}

.home-bg-art {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: none;
}

/* 折扇装饰 */
.home-fan {
    position: absolute;
    width: 110px;
    height: auto;
    opacity: 0.35;
    pointer-events: none;
    z-index: 1;
    filter: drop-shadow(0 2px 8px rgba(45, 122, 102, 0.15));
}

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

.home-fan-right {
    right: -10px;
    bottom: 12%;
    transform: rotate(-20deg) scaleX(-1);
}

.home-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    padding: 24px;
}

/* 卷轴标题区 */
.home-scroll-wrap {
    position: relative;
    width: min(85vw, 340px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.home-scroll-bg {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 4px 16px rgba(45, 122, 102, 0.18));
    opacity: 0.92;
}

.home-scroll-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10% 15%;
}

.home-seal {
    width: 56px;
    height: 56px;
    border: 2.5px solid var(--red-seal);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    position: relative;
    transform: rotate(-8deg);
    animation: sealFloat 4s ease-in-out infinite;
}

.home-seal::before {
    content: '诗';
    font-family: 'Ma Shan Zheng', serif;
    font-size: 1.8rem;
    color: var(--red-seal);
    line-height: 1;
}

.home-seal::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1.5px solid var(--red-seal);
    border-radius: 5px;
    opacity: 0.5;
}

@keyframes sealFloat {
    0%, 100% { transform: rotate(-8deg) translateY(0); }
    50% { transform: rotate(-6deg) translateY(-3px); }
}

.home-title {
    font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', 'KaiTi', 'STKaiti', serif;
    font-size: clamp(2.2rem, 8vw, 3.4rem);
    color: var(--text-ink);
    letter-spacing: 10px;
    margin-bottom: 4px;
    text-shadow: 1px 1px 4px rgba(45, 122, 102, 0.1);
    position: relative;
}

.home-subtitle {
    font-family: 'Ma Shan Zheng', serif;
    font-size: clamp(0.9rem, 3vw, 1.15rem);
    color: var(--text-ink-muted);
    letter-spacing: 6px;
    margin-bottom: 0;
    text-shadow: 0 0 8px rgba(253, 251, 247, 0.8);
}

.ink-divider {
    width: 180px;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--green-light) 15%,
        var(--green-medium) 35%,
        var(--gold-medium) 50%,
        var(--green-medium) 65%,
        var(--green-light) 85%,
        transparent 100%);
    margin-bottom: 28px;
    border-radius: 2px;
    position: relative;
    box-shadow: 0 0 8px rgba(196, 163, 90, 0.3);
}

.ink-divider::before,
.ink-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 7px;
    background: var(--gold-medium);
    border-radius: 50%;
    opacity: 0.6;
}

.ink-divider::before { left: 8%; }
.ink-divider::after { right: 8%; }

.home-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 280px;
}

.home-btn {
    font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', 'KaiTi', 'STKaiti', serif;
    font-size: 1.35rem;
    color: var(--text-ink);
    padding: 14px 48px;
    background: rgba(255, 255, 255, 0.88);
    border: 2px solid var(--green-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    letter-spacing: 6px;
    box-shadow:
        0 4px 14px var(--shadow-soft),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

.btn-decor-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: inherit;
}

.home-btn-primary {
    background: linear-gradient(135deg, var(--green-medium) 0%, var(--teal-medium) 100%);
    color: var(--white);
    border-color: var(--green-dark);
    padding: 16px 48px;
    box-shadow:
        0 6px 20px rgba(45, 122, 102, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.home-btn-primary .btn-decor-bg {
    opacity: 0.08;
}

.home-btn-primary .btn-icon {
    stroke: var(--white);
}

.home-btn:not(.home-btn-primary) .btn-icon {
    stroke: var(--green-dark);
}

.home-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.35) 50%,
        transparent 100%);
    transition: left 0.5s ease;
    z-index: 1;
}

.home-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 24px var(--shadow-medium);
    border-color: var(--green-medium);
}

.home-btn-primary:hover {
    box-shadow: 0 10px 28px rgba(45, 122, 102, 0.4);
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--teal-dark) 100%);
}

.home-btn:hover::after {
    left: 100%;
}

.home-btn:active {
    transform: translateY(-1px) scale(0.99);
}

/* ===== 游戏页面 ===== */
#game-page {
    padding: 6px 8px;
    gap: 6px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background-image: url('../images/assets/bg-game.png');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-color: #E8F0EE;
    position: relative;
}

#game-page > * {
    position: relative;
    z-index: 1;
}

/* ===== 顶部栏 ===== */
.game-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0);
    border: 1.5px solid rgba(123, 196, 180, 0.5);
    border-radius: var(--radius-md);
    box-shadow: none;
    flex-shrink: 0;
    gap: 8px;
    backdrop-filter: blur(12px);
}

.icon-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--green-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

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

.icon-btn:active {
    transform: scale(0.92);
    background: rgba(45, 122, 102, 0.08);
}

/* 返回按钮使用素材图 */
.back-btn-img {
    background: transparent;
    padding: 0;
}

.back-btn-img img {
    width: 20px;
    height: auto;
    max-height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(45, 122, 102, 0.2));
}

.back-btn-img:active img {
    transform: scale(0.9);
}

.icon-btn-accent {
    background: linear-gradient(135deg, var(--green-medium), var(--teal-medium));
    color: var(--white);
    border-radius: 10px;
}

.icon-btn-accent svg {
    stroke: var(--white);
}

.icon-btn-accent:active {
    background: linear-gradient(135deg, var(--green-dark), var(--teal-dark));
}

/* 关卡徽章 - 带古书图标 */
.level-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    background: rgba(74, 159, 138, 0.06);
    border-radius: 6px;
}

.level-badge-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(45, 122, 102, 0.15));
    opacity: 0.7;
}

#level-badge-text {
    font-family: 'Ma Shan Zheng', serif;
    font-size: 1.05rem;
    color: var(--text-ink);
    letter-spacing: 2px;
}

.level-sep {
    color: var(--green-light);
    font-size: 0.8rem;
}

#level-title-text {
    font-size: 0.85rem;
    color: var(--green-dark);
    font-weight: bold;
}

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

/* ===== 工具按钮 ===== */
.tool-btn {
    width: 38px;
    height: 38px;
    border: 1.5px solid var(--green-light);
    border-radius: 50%;
    background: var(--cloud-white);
    color: var(--green-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    padding: 0;
    box-shadow: 0 2px 6px var(--shadow-soft);
}

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

.tool-btn:active {
    transform: scale(0.92);
    background: rgba(74, 159, 138, 0.08);
}

.tool-btn:active svg {
    stroke: var(--green-dark);
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, var(--green-medium), var(--teal-medium));
    color: var(--white);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--white);
    font-weight: bold;
    font-family: system-ui, sans-serif;
}

#hint-btn.hint-glow {
    animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { box-shadow: 0 2px 6px var(--shadow-soft); }
    50% { box-shadow: 0 2px 6px var(--shadow-soft), 0 0 0 6px rgba(74, 159, 138, 0.15); }
}

.btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.test-only { display: none !important; }
body.test-mode .test-only { display: flex !important; }

/* ===== 诗词信息区 ===== */
.poem-info {
    background: rgba(255, 255, 255, 0);
    padding: 20px 14px 12px;
    border-radius: var(--radius-md);
    border: 1.5px solid rgba(123, 196, 180, 0.5);
    box-shadow: none;
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 30vh;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    backdrop-filter: blur(12px);
    position: relative;
}

.poem-info::-webkit-scrollbar { width: 3px; }
.poem-info::-webkit-scrollbar-thumb { background: var(--green-pale); border-radius: 3px; }

.poem-context {
    min-height: 36px;
    padding: 4px 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    position: relative;
}

.poem-placeholder {
    font-size: 0.9rem;
    color: var(--text-ink-muted);
    letter-spacing: 2px;
}

.poem-line {
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', serif;
    font-size: 1rem;
    color: var(--text-ink-light);
    line-height: 1.8;
    text-align: center;
    letter-spacing: 2px;
    transition: opacity 0.3s ease;
}

.poem-line .filled-char,
.poem-line .user-char,
.poem-line .blank-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.4em;
    vertical-align: text-bottom;
    margin: 0 1px;
}

.poem-line .filled-char {
    color: var(--green-dark);
    font-weight: bold;
}

.poem-line .blank-char {
    border-bottom: 2px dashed var(--green-medium);
}

.poem-line .user-char {
    border-bottom: 2px solid var(--green-medium);
    color: var(--teal-dark);
    font-weight: bold;
}

/* 提交检查按钮 - 定位在诗词显示区右下角 */
.poem-info-actions {
    position: absolute;
    bottom: 6px;
    right: 10px;
    z-index: 2;
}

.btn-submit-check {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1.5px solid var(--green-medium);
    border-radius: 20px;
    background: rgba(74, 159, 138, 0.12);
    color: var(--green-dark);
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

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

.btn-submit-check:active {
    transform: scale(0.95);
    background: rgba(74, 159, 138, 0.25);
}

/* 正确/错误答案标记 */
.cell-answer-correct {
    border-color: #2D7A66 !important;
    border-width: 3px !important;
    box-shadow: 0 0 8px rgba(45, 122, 102, 0.5), inset 0 0 6px rgba(45, 122, 102, 0.15) !important;
    background: rgba(45, 122, 102, 0.08) !important;
}

.cell-answer-wrong {
    border-color: #C0392B !important;
    border-width: 3px !important;
    box-shadow: 0 0 10px rgba(192, 57, 43, 0.6), inset 0 0 8px rgba(192, 57, 43, 0.2) !important;
    background: rgba(192, 57, 43, 0.12) !important;
    animation: cellShake 0.5s ease;
}

.cell-answer-wrong .cell-text,
.cell-answer-wrong {
    color: #A93226 !important;
}

.poem-direction-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 1px 8px;
    border-radius: 3px;
    margin-right: 6px;
    font-family: system-ui, sans-serif;
}

.poem-direction-tag.h-tag {
    background: rgba(74, 159, 138, 0.12);
    color: var(--green-dark);
}

.poem-direction-tag.v-tag {
    background: rgba(58, 136, 145, 0.12);
    color: var(--blue-dark);
}

.timer-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-display {
    font-family: 'Ma Shan Zheng', serif;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--green-dark);
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 2px;
    min-width: 50px;
    text-align: center;
    transition: color 0.3s ease;
}

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

.timer-display.time-danger {
    color: var(--red-seal);
    animation: timerBlink 1s ease-in-out infinite;
}

@keyframes timerBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#timer-bar {
    flex: 1;
    height: 5px;
    background: rgba(168, 221, 210, 0.4);
    border-radius: 3px;
    overflow: hidden;
}

/* ===== 网格区 ===== */
.grid-area {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: rgba(255, 255, 255, 0);
    border: 1.5px solid rgba(123, 196, 180, 0.5);
    border-radius: var(--radius-lg);
    box-shadow: none;
    overflow: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    backdrop-filter: blur(12px);
}

#crossword-grid {
    display: grid;
    gap: 2px;
    padding: 4px;
    min-width: 0;
}

/* ===== 网格格子 ===== */
.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', 'SimSun', '宋体', serif;
    border-radius: var(--radius-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}

.cell-empty {
    visibility: hidden;
}

.cell-filled {
    background: rgba(255, 255, 255, 0.85);
    border: 1.5px solid var(--green-pale);
    color: var(--text-ink);
    box-shadow: 0 1px 4px rgba(45, 122, 102, 0.06);
}

.cell-blank {
    background: rgba(255, 255, 255, 0.85);
    border: 2px dashed var(--green-light);
    cursor: pointer;
    transition: all 0.25s ease;
}

.cell-blank:hover {
    border-color: var(--green-medium);
    background: rgba(240, 248, 246, 0.8);
}

.cell-cross {
    border: 2px solid var(--teal-medium);
    background: rgba(79, 179, 160, 0.04);
}

.cell-selected {
    border-color: var(--green-dark) !important;
    border-style: solid !important;
    box-shadow:
        0 0 0 4px rgba(45, 122, 102, 0.2),
        0 2px 8px rgba(45, 122, 102, 0.2) !important;
    z-index: 10;
    transform: scale(1.06);
    background: rgba(255, 255, 255, 0.92) !important;
}

.cell-highlight-h,
.cell-highlight-v {
    background: rgba(74, 159, 138, 0.08) !important;
}

.cell-highlight-h {
    border-color: rgba(74, 159, 138, 0.4) !important;
}

.cell-highlight-v {
    border-color: rgba(58, 136, 145, 0.4) !important;
}

.cell-user-filled {
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(240,248,246,0.9) 100%) !important;
    border-style: solid !important;
    border-color: var(--green-medium) !important;
}

.cell-user-filled.cell-correct {
    animation: correctPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.cell-error {
    background: rgba(178, 34, 34, 0.08) !important;
    border-color: var(--red-light) !important;
    animation: cellShake 0.4s ease-in-out;
}

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

.cell-shake {
    animation: cellShake 0.4s ease-in-out;
}

.test-hint {
    color: var(--green-light) !important;
    font-size: 0.7em;
    position: absolute;
    bottom: 1px;
    right: 2px;
}

/* ===== 候选字区 ===== */
.char-pool-area {
    padding: 4px 8px 6px;
    z-index: 1;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0);
    border: 1.5px solid rgba(123, 196, 180, 0.5);
    border-radius: var(--radius-lg);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(12px);
}

.char-pool-top {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.char-pool-title {
    font-family: 'Ma Shan Zheng', serif;
    font-size: 1rem;
    color: var(--green-dark);
    letter-spacing: 4px;
}

#char-pool {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    overflow-y: auto;
    max-height: 20vh;
    min-height: 60px;
    align-content: start;
    padding: 2px;
}

#char-pool::-webkit-scrollbar { display: none; }
#char-pool { -ms-overflow-style: none; scrollbar-width: none; }

.char-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', 'SimSun', '宋体', serif;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.85);
    border: 1.5px solid var(--green-pale);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    user-select: none;
    min-width: 34px;
    min-height: 34px;
    max-width: 48px;
    box-shadow: 0 1px 4px rgba(45, 122, 102, 0.06);
    position: relative;
    overflow: hidden;
}

.char-btn:active {
    transform: scale(0.94);
    background: rgba(74, 159, 138, 0.08);
    border-color: var(--green-medium);
}

.char-hint {
    opacity: 0.55;
    border-color: var(--gold-light);
    background: rgba(196, 163, 90, 0.06);
}

.char-used {
    visibility: hidden;
    pointer-events: none;
}

/* ===== 拖拽幽灵 ===== */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    width: 52px;
    height: 52px;
    background: var(--cloud-white);
    border: 2px solid var(--green-medium);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', serif;
    font-size: 1.5rem;
    box-shadow: 0 8px 24px rgba(45, 122, 102, 0.35);
    opacity: 0.95;
    color: var(--green-dark);
}

.drag-over {
    background: rgba(74, 159, 138, 0.15) !important;
    border-color: var(--green-dark) !important;
    box-shadow: 0 0 0 4px rgba(45, 122, 102, 0.2) !important;
}

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

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

.modal-content {
    background: var(--cloud-white);
    padding: 28px 24px;
    border-radius: var(--radius-xl);
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.08);
    border: 2px solid var(--green-light);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 弹窗背景框装饰 */
.modal-frame-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.06;
    pointer-events: none;
    border-radius: inherit;
}

@keyframes modalPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-seal {
    width: 56px;
    height: 56px;
    border: 2.5px solid var(--red-seal);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-family: 'Ma Shan Zheng', serif;
    font-size: 1.5rem;
    color: var(--red-seal);
    transform: rotate(-6deg);
    position: relative;
}

.modal-seal::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid var(--red-seal);
    border-radius: 4px;
    opacity: 0.4;
}

.modal-title {
    font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', serif;
    font-size: 1.6rem;
    color: var(--text-ink);
    margin-bottom: 18px;
    letter-spacing: 4px;
}

.modal-body {
    font-size: 1rem;
    color: var(--text-ink-light);
    line-height: 1.8;
    margin-bottom: 22px;
}

.modal-body p {
    margin-bottom: 12px;
    text-align: left;
}

.modal-level-text {
    font-size: 1.1rem;
    color: var(--green-dark);
    font-weight: bold;
    text-align: center;
    margin-bottom: 16px;
}

.poem-list p {
    text-align: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(74, 159, 138, 0.1);
    font-size: 1rem;
}

.poem-list p:last-child {
    border-bottom: none;
}

.result-status {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.result-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    background: rgba(74, 159, 138, 0.06);
    border-radius: var(--radius-md);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-ink-muted);
}

.stat-value {
    font-size: 1.2rem;
    color: var(--green-dark);
    font-weight: bold;
}

.instructions-section-title {
    font-family: 'Ma Shan Zheng', serif;
    font-size: 1.15rem;
    color: var(--green-dark);
    margin: 16px 0 8px;
    padding-left: 10px;
    border-left: 3px solid var(--green-medium);
    text-align: left;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 14px 0;
    padding: 8px 0;
}

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

/* 自定义开关 */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

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

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

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

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

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

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

.modal-btn {
    font-family: 'Ma Shan Zheng', 'ZCOOL KuaiLe', serif;
    font-size: 1.15rem;
    padding: 12px 32px;
    background: var(--cloud-white);
    border: 1.5px solid var(--green-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    letter-spacing: 3px;
    transition: all 0.3s ease;
    min-width: 100px;
    box-shadow: 0 2px 8px var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

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

/* 弹窗按钮素材图 */
.modal-btn-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    border-radius: inherit;
}

.modal-btn-primary .modal-btn-img {
    opacity: 0.1;
}

.modal-btn-primary {
    background: linear-gradient(135deg, var(--green-medium), var(--teal-medium));
    color: var(--white);
    border-color: var(--green-dark);
    box-shadow: 0 4px 14px rgba(45, 122, 102, 0.3);
}

.modal-btn-primary:active {
    background: linear-gradient(135deg, var(--green-dark), var(--teal-dark));
}

.bold-font {
    font-family: 'Ma Shan Zheng', 'KaiTi', 'STKaiti', 'FangSong', '仿宋', serif;
}

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

@keyframes particleFly {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(0);
    }
}

/* ===== 响应式：平板 (>= 768px) ===== */
@media (min-width: 768px) {
    #game-page {
        padding: 10px 16px;
        gap: 8px;
        max-width: 560px;
        margin: 0 auto;
    }

    .game-top-bar {
        padding: 8px 14px;
    }

    .icon-btn {
        width: 42px;
        height: 42px;
    }

    .tool-btn {
        width: 42px;
        height: 42px;
    }

    .char-btn {
        min-width: 48px;
        min-height: 48px;
        font-size: 1.3rem;
    }

    .home-title {
        letter-spacing: 16px;
    }

    .home-buttons {
        max-width: 320px;
    }

    .home-fan {
        width: 140px;
    }

    .home-scroll-wrap {
        width: min(85vw, 400px);
    }
}

/* ===== 响应式：大屏 (>= 1024px) ===== */
@media (min-width: 1024px) {
    #game-page {
        max-width: 600px;
    }

    .home-scroll-wrap {
        width: min(85vw, 440px);
    }
}

/* ===== 响应式：小屏手机 (<= 375px) ===== */
@media (max-width: 375px) {
    #game-page {
        padding: 4px 4px;
        gap: 4px;
    }

    .game-top-bar {
        padding: 4px 8px;
        gap: 4px;
    }

    .icon-btn {
        width: 32px;
        height: 32px;
    }

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

    .back-btn-img img {
        width: 16px;
        max-height: 30px;
    }

    .tool-btn {
        width: 32px;
        height: 32px;
    }

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

    .badge {
        width: 16px;
        height: 16px;
        font-size: 0.65rem;
        top: -4px;
        right: -4px;
    }

    #level-badge-text {
        font-size: 0.9rem;
    }

    #level-title-text {
        font-size: 0.75rem;
    }

    .level-badge {
        padding: 2px 8px;
    }

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

    .poem-info {
        padding: 6px 10px;
    }

    .poem-line {
        font-size: 0.9rem;
    }

    .timer-display {
        font-size: 1.2rem;
    }

    .char-btn {
        min-width: 34px;
        min-height: 34px;
        font-size: 1rem;
    }

    .home-title {
        letter-spacing: 8px;
    }

    .home-subtitle {
        letter-spacing: 4px;
    }

    .home-btn {
        padding: 12px 32px;
        font-size: 1.2rem;
    }

    .home-fan {
        width: 80px;
        opacity: 0.25;
    }

    .home-scroll-wrap {
        width: min(90vw, 300px);
    }

    .home-seal {
        width: 44px;
        height: 44px;
    }

    .home-seal::before {
        font-size: 1.4rem;
    }
}

/* ===== 响应式：极小屏 (<= 320px) ===== */
@media (max-width: 320px) {
    .level-sep,
    #level-title-text {
        display: none;
    }

    .level-badge-icon {
        display: none;
    }

    .char-pool-title {
        font-size: 0.85rem;
    }

    .modal-content {
        padding: 20px 16px;
    }

    .home-fan {
        display: none;
    }

    .home-subtitle {
        display: none;
    }
}

/* ===== 响应式：横屏手机 ===== */
@media (max-height: 500px) and (orientation: landscape) {
    #game-page {
        padding: 2px 8px;
        gap: 3px;
    }

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

    .poem-context {
        min-height: 24px;
        margin-bottom: 4px;
    }

    .poem-line {
        font-size: 0.85rem;
    }

    .timer-display {
        font-size: 1.1rem;
    }

    .game-top-bar {
        padding: 3px 8px;
    }

    .icon-btn {
        width: 30px;
        height: 30px;
    }

    .tool-btn {
        width: 30px;
        height: 30px;
    }

    .char-pool-area {
        padding: 4px 8px;
    }

    .char-pool-top {
        margin-bottom: 4px;
    }

    .char-pool-title {
        font-size: 0.85rem;
    }

    .char-btn {
        min-width: 30px;
        min-height: 30px;
        font-size: 0.9rem;
    }

    #char-pool {
        max-height: 18vh;
    }

    .home-fan {
        display: none;
    }

    .home-scroll-wrap {
        width: min(70vw, 320px);
    }
}

/* ===== 安全区域适配 (刘海屏) ===== */
@supports (padding: env(safe-area-inset-bottom)) {
    .char-pool-area {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    #home-page {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ===== 适配 prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}