:root {
    --bg-color: #eaddcf;
    --accent-red: #b22222;
    --ink-black: #2b2b2b;
    --text-sub: #5c4a3d;
    --paper-yellow: #f0c966;
}

body {
    font-family: 'Noto Serif SC', serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    color: var(--ink-black);
    /* 简单的背景噪点 */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
}

/* 布局控制 */
section {
    display: none; /* 默认隐藏 */
    width: 90%;
    max-width: 450px;
    margin: 0 auto;
    padding-top: 20px;
    animation: fadeIn 0.5s ease-out;
}
section.active-section { display: block; }
section.center-layout {
    min-height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

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

/* 标题 */
.header { text-align: center; margin-bottom: 40px; }
.title { font-family: 'Ma Shan Zheng', cursive; font-size: 3.5rem; margin: 0; letter-spacing: 2px; }
.subtitle { font-size: 0.9rem; color: var(--text-sub); border-top: 1px solid var(--text-sub); border-bottom: 1px solid var(--text-sub); display: inline-block; padding: 5px 15px; margin-top: 10px; letter-spacing: 4px; }

/* 阶段1 & 2 通用 */
.step-box { text-align: center; width: 100%; }
.step-title { font-size: 1.5rem; color: var(--accent-red); font-family: 'Ma Shan Zheng', cursive; display: block; margin-bottom: 10px; }
.step-desc { color: #8c7b70; font-size: 0.9rem; margin-bottom: 30px; }

.input-big {
    width: 100%; border: none; background: transparent;
    border-bottom: 2px solid var(--ink-black);
    font-size: 1.3rem; padding: 10px; text-align: center;
    color: var(--ink-black); outline: none; font-family: 'Noto Serif SC', serif;
}
.char-count { text-align: right; color: #999; font-size: 0.8rem; margin-top: 5px; margin-bottom: 40px; }

/* 阶段2 独有 */
.question-review {
    background: rgba(255,255,255,0.4); padding: 15px;
    border-radius: 5px; border-left: 4px solid var(--accent-red);
    margin-bottom: 30px;
}
.review-label { color: #8c7b70; font-size: 0.8rem; }
.review-text { font-weight: bold; font-size: 1.1rem; display: block; margin-top: 5px;}

.step-title-small { text-align: center; color: var(--accent-red); font-family: 'Ma Shan Zheng', cursive; font-size: 1.2rem; margin-bottom: 15px; }

/* 选项输入与池 */
.input-group { display: flex; border-bottom: 2px solid var(--ink-black); margin-bottom: 20px; padding-bottom: 5px; }
.input-group input { flex: 1; border: none; background: transparent; font-size: 1.1rem; outline: none; }
.btn-icon { background: transparent; border: 1px solid var(--ink-black); width: 35px; height: 35px; border-radius: 50%; font-size: 1.5rem; cursor: pointer; display: flex; justify-content: center; align-items: center; }
.btn-icon:hover { background: var(--ink-black); color: #fff; }

.options-container { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 20px; min-height: 40px; }
.option-tag {
    background: #fffdf5; border: 1px solid #d4c4b7; padding: 10px 8px;
    writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 2px;
    font-family: 'Ma Shan Zheng', cursive; font-size: 1.1rem; color: var(--accent-red);
    position: relative; min-height: 60px; display: flex; align-items: center;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}
.option-tag .delete-x {
    position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
    background: var(--accent-red); color: white; width: 20px; height: 20px;
    font-size: 12px; border-radius: 50%; text-align: center; line-height: 18px;
    cursor: pointer; writing-mode: horizontal-tb; border: 2px solid #fffdf5;
}

/* 按钮 */
.btn-main {
    width: 100%; padding: 15px; background: var(--accent-red); color: #fff;
    font-family: 'Ma Shan Zheng', cursive; font-size: 1.5rem; border: none;
    cursor: pointer; letter-spacing: 5px; box-shadow: 0 4px 0 #800000; border-radius: 4px;
}
.btn-main:active { transform: translateY(2px); box-shadow: 0 2px 0 #800000; }
.btn-back { text-align: center; margin-top: 20px; color: #8c7b70; text-decoration: underline; cursor: pointer; font-size: 0.9rem; }

.divider-text { text-align: center; font-size: 0.8rem; color: #8c7b70; margin-bottom: 10px; }
.preset-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 30px; }
.preset-btn { background: rgba(255,255,255,0.3); border: 1px solid #8c7b70; padding: 10px; cursor: pointer; color: #4a3b32; }
.preset-btn:hover { background: rgba(255,255,255,0.6); border-color: var(--ink-black); }

/* 阶段3：画符 */
.info-bar { display: flex; justify-content: space-between; align-items: center; color: var(--text-sub); margin-bottom: 5px; margin-top: 10px;}
.brush-controls { display: flex; gap: 10px; }
.brush { width: 25px; height: 25px; border: 1px solid #8c7b70; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 12px; cursor: pointer; }
.brush.active { background: var(--accent-red); color: white; border-color: var(--accent-red); }

.mana-container { height: 6px; background: #d4c4b7; margin-bottom: 0; width: 100%; border-radius: 3px; overflow: hidden;}
#manaBar { height: 100%; background: var(--accent-red); width: 100%; transition: width 0.1s linear; }

.canvas-wrapper {
    position: relative; width: 100%; height: 75vh; margin-top: 10px;
    border: 4px double var(--text-sub); box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    /* 关键：防止画画时页面滚动 */
    touch-action: none; 
}
.paper-css-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1;
    background-color: var(--paper-yellow);
    background-image: repeating-linear-gradient(45deg, rgba(92, 74, 61, 0.05) 0px, rgba(92, 74, 61, 0.05) 2px, transparent 2px, transparent 4px),
                      radial-gradient(ellipse at center, transparent 60%, rgba(92, 74, 61, 0.2) 100%);
}
canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; display: block; }

/* 结果展示 */
#resultOverlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10;
    pointer-events: none; display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.result-box {
    background: rgba(255,255,255,0.9); padding: 30px 20px; border: 2px solid var(--ink-black); border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; opacity: 0; transform: scale(0.8); transition: all 0.5s;
}
.result-box.reveal { opacity: 1; transform: scale(1); }
.final-question { font-size: 1rem; color: #555; margin-bottom: 15px; border-bottom: 1px solid #ccc; padding-bottom: 5px; max-width: 200px; text-align: center; word-wrap: break-word;}
.result-text {
    font-family: 'Ma Shan Zheng', cursive; color: var(--ink-black); font-size: 3rem;
    writing-mode: vertical-rl; text-orientation: upright; line-height: 1.4; text-align: center;
}

.talisman-stamp {
    position: absolute; bottom: 30px; right: 20px;
    border: 4px solid var(--accent-red); color: var(--accent-red); padding: 5px 15px;
    font-family: 'Ma Shan Zheng', cursive; font-size: 1.4rem;
    transform: rotate(-15deg) scale(2); opacity: 0; transition: all 0.5s; text-align: center;
}
.talisman-stamp.reveal { opacity: 0.9; transform: rotate(-15deg) scale(1); }
.stamp-domain { font-family: 'Noto Serif SC', serif; font-size: 0.8rem; display: block; font-weight: bold; margin-top: 5px; }

/* 底部操作 */
#resultControls { text-align: center; padding: 20px 0; animation: fadeIn 1s; }
.easter-egg-box { color: var(--accent-red); font-family: 'Ma Shan Zheng', cursive; font-size: 1.2rem; margin-bottom: 15px; }
.btn-secondary { background: var(--ink-black); color: #eaddcf; border: none; padding: 10px 30px; font-weight: bold; cursor: pointer; }
