:root{--red:#9e1b1b;--dark:#641414;--cream:#f6ebd6;--gold:#c9a24a;--ink:#542b25;--serif:'Noto Serif SC',serif;font-family:var(--serif);color:var(--ink)}
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden}body{background:#e7a68e}
/* One phone-shaped layout everywhere: on a wide screen the game sits in a centred phone-width column. */
/* The game is locked to the design's 9:16 frame on every screen; extra space becomes a letterbox. */
body{display:grid;place-items:center;background:radial-gradient(circle at 50% 30%,#8f2421,#4a0f10 75%)}
#stage{position:relative;width:min(100vw,calc(100dvh*941/1672));aspect-ratio:941/1672;margin:0 auto;overflow:hidden;background:#e7a68e;container-type:size}
button{font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}button:focus-visible{outline:3px solid #fff;outline-offset:3px}[hidden]{display:none!important}
#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none}
#creator,#hud{position:absolute;inset:0;pointer-events:none}#creator>*,#hud>*{pointer-events:auto}
.creator-title{position:absolute;top:calc(env(safe-area-inset-top) + 2.5%);left:50%;transform:translateX(-50%);white-space:nowrap;background:linear-gradient(160deg,#af2927,#781719);border:3px solid #f1c977;border-radius:20px;padding:9px 33px 12px;color:#ffe7aa;font-size:clamp(29px,8vw,42px);font-weight:900;letter-spacing:.1em;box-shadow:0 6px 0 #67201a,0 13px 22px #52201660;text-shadow:0 2px #63221a}
.preview-arrows{position:absolute;top:38%;left:5%;right:5%;display:flex;justify-content:space-between}.preview-arrows button{width:58px;height:58px;border:2px solid #f6d587;border-radius:50%;background:linear-gradient(#aa2e2a,#7c1719);color:#ffe2a0;font-size:32px;box-shadow:0 3px 12px #40201c55}
.creator-panel{position:absolute;left:0;right:0;bottom:0;height:min(49%,470px);padding:0 12px calc(env(safe-area-inset-bottom) + 12px);background:linear-gradient(155deg,#fff5e4,#f6dfbe);border:3px solid #d6ad64;border-bottom:0;border-radius:23px 23px 0 0;box-shadow:0 -5px 25px #65392550;display:flex;flex-direction:column;gap:8px}
.tabs{display:grid;grid-template-columns:repeat(5,1fr);gap:2px;flex:none;margin:0 -7px}.tabs button{border:0;border-bottom:3px solid transparent;min-height:61px;background:transparent;color:#78442e;font-size:13px;font-weight:900;padding:4px 0}.tabs button span{display:block;font-size:24px;line-height:1.1}.tabs button.active{background:linear-gradient(#b52b29,#851819);color:#ffe6aa;border:2px solid #e0b667;border-radius:13px;box-shadow:0 2px 6px #713b2866}
.choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px;overflow-y:auto;align-content:start;flex:1;min-height:62px;padding:5px}.choice{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:4px 2px;min-height:96px;border:2px solid #e4bd8e;border-radius:14px;background:#fff2de;color:#734734;font-size:13px;font-weight:700;box-shadow:0 2px 3px #92654d44}.choice.selected{border:3px solid #ac2824;background:#ffe0bc;color:#781719;box-shadow:0 0 0 2px #ebbf70}
.swatches{min-height:48px;display:flex;align-items:center;justify-content:space-evenly;gap:3px}.swatches:empty{min-height:0}.swatch{width:44px;height:44px;border:3px solid #e9d0ad;border-radius:50%;background:var(--swatch);box-shadow:0 2px 3px #8e694c66}.swatch.selected{border-color:#ae2622;outline:2px solid #e7b854;outline-offset:2px}
.enter{width:100%;min-height:64px;flex:none;border:3px solid #f4cd78;border-radius:18px;background:linear-gradient(#bc322e,#881517);color:#ffe6aa;font-size:32px;font-weight:900;letter-spacing:.22em;text-shadow:0 2px #641314;box-shadow:0 4px 0 #622020,0 6px 12px #673e3066}
.portrait{position:absolute;top:calc(env(safe-area-inset-top) + 14px);left:16px;width:62px;height:62px;border:4px solid #f5d483;border-radius:50%;background:linear-gradient(#ffefcc,#d7a279);box-shadow:0 4px 11px #63302788;color:#642924}.portrait span{font-size:39px;line-height:1}
.task-card{position:absolute;top:calc(env(safe-area-inset-top) + 13px);right:13px;max-width:64%;min-width:190px;padding:12px 19px 14px;border:3px solid #c89e4f;border-radius:14px;background:linear-gradient(135deg,#fff4df,#f2dfbc);box-shadow:0 4px 0 #8e3226,0 8px 14px #52251c66;text-align:center;color:#781b1b}.task-card:before,.task-card:after{content:'';position:absolute;top:6px;bottom:6px;width:9px;border-radius:7px;background:linear-gradient(90deg,#9e1b1b,#d7944b,#9e1b1b)}.task-card:before{left:-9px}.task-card:after{right:-9px}.task-card small{display:block;font-size:11px;letter-spacing:.15em;color:#8f6346}.task-card strong{font-size:clamp(17px,5vw,22px);line-height:1.3;font-weight:900}
.hud-bottom{position:absolute;left:0;right:0;bottom:0;padding:0 13px calc(env(safe-area-inset-bottom) + 13px);background:linear-gradient(transparent,#f6e4c8 45%,#f6e4c8);pointer-events:none}.actions{display:flex;align-items:end;justify-content:space-around;gap:7px;pointer-events:auto}.action{border-radius:50%;border:4px solid #d5a653;background:linear-gradient(#fff4dd,#e8c99a);color:#7c211b;box-shadow:0 4px 0 #9c6f42,0 5px 11px #5b302166;font-weight:900}.action span{display:block;font-size:25px;line-height:1.05}.action.small{width:min(26vw,106px);height:min(26vw,106px);min-width:82px;min-height:82px;font-size:17px}.action.big{width:min(35vw,137px);height:min(35vw,137px);min-width:110px;min-height:110px;background:linear-gradient(#bb302b,#84171a);color:#ffe6af;border-color:#f4cb71;font-size:29px;text-shadow:0 2px #631b18}.action.big span{font-size:38px}.hint{text-align:center;margin:19px 0 0;font-size:13px;font-weight:900;letter-spacing:.04em;color:#7b2b24;pointer-events:none}
#toast{position:absolute;left:50%;bottom:calc(env(safe-area-inset-bottom) + 175px);transform:translate(-50%,12px);opacity:0;pointer-events:none;background:#6e231f;color:#fff0cf;border:2px solid #dfbb71;border-radius:14px;padding:10px 18px;white-space:nowrap;font-size:16px;font-weight:900;transition:opacity .2s,transform .2s;z-index:9}#toast.show{opacity:1;transform:translate(-50%,0)}
@media(max-height:690px){.creator-panel{height:53%}.creator-title{top:calc(env(safe-area-inset-top) + 1%)}.preview-arrows{top:32%}.choices{min-height:50px}.choice{min-height:55px}.enter{min-height:56px}.swatches{min-height:38px}}


.choice img{width:100%;max-width:66px;aspect-ratio:1;object-fit:contain;pointer-events:none}.choice span{font-size:12px;line-height:1.15}
/* ritual guide bubble (怎么做 / 为什么) */
.task-card .task-title{display:block;font-size:clamp(16px,4.6vw,20px);line-height:1.3;font-weight:900}
.guide{position:absolute;left:12px;right:12px;bottom:calc(env(safe-area-inset-bottom) + 178px);max-height:38%;overflow-y:auto;padding:12px 14px;border:3px solid #c89e4f;border-radius:16px;background:linear-gradient(135deg,#fff7e8,#f4e2c2);box-shadow:0 4px 0 #8e3226,0 8px 16px #52251c55;color:#5a2a22;font-size:15px;line-height:1.55}
.guide p{margin:0}.guide-why{margin-top:8px!important;padding-top:8px;border-top:1px dashed #c89e4f;color:#7a3b2b}
.why-toggle{margin-top:8px;min-height:44px;padding:0 14px;border:2px solid #c89e4f;border-radius:22px;background:#fff3dc;color:#8a2a22;font-size:14px;font-weight:900}
.wishes{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}.wish{min-width:64px;min-height:44px;padding:0 12px;border:2px solid #b52b29;border-radius:22px;background:#fff;color:#8a1f1c;font-size:16px;font-weight:900}
.action:disabled{opacity:.6}
.main-label{font-weight:900}

/* ===== 捏人物 screen, matched to design/temple_ui_avatar.png ===== */
#creator-bg{position:absolute;left:0;right:0;top:-24%;height:125%;background:url(../assets/ui/creator_bg.webp) center/cover no-repeat}
.creator-title{top:calc(env(safe-area-inset-top) + 1.2%);width:min(80%,330px);aspect-ratio:900/188;padding:0;border:0;border-radius:0;background:url(../assets/ui/banner.webp) center/contain no-repeat;box-shadow:none;display:flex;align-items:center;justify-content:center}
.creator-title span{transform:translateY(-4%);font-size:clamp(28px,8.5vw,40px);font-weight:900;letter-spacing:.08em;color:#ffe3a3;text-shadow:0 2px 0 #6e1512,0 0 8px #0003}
.preview-arrows{top:31%;left:20%;right:20%}
.preview-arrows button{width:48px;height:48px;padding:0;font-size:24px;line-height:1;border:2px solid #f0c46f;background:linear-gradient(#b2302b,#7e1a19);box-shadow:0 3px 0 #5d1714,0 5px 10px #0004}
.creator-panel{height:57%;max-height:none;padding:0 10px calc(env(safe-area-inset-bottom) + 10px);background:linear-gradient(#a92b26,#8d1e1b);border:0;border-radius:22px 22px 0 0;box-shadow:0 -4px 18px #4a161255;gap:0}
.tabs{display:flex;gap:3px;margin:8px 0 0;padding:0}
.tabs button{flex:1;display:flex;align-items:center;justify-content:center;gap:2px;min-height:48px;padding:4px 1px;white-space:nowrap;letter-spacing:0;font-size:13px;min-width:0;border:2px solid #e3c48e;border-bottom:0;border-radius:14px 14px 0 0;background:linear-gradient(#fff6e6,#f3e3c6);color:#6b3a28;font-size:13px;font-weight:900}
.tabs button img{width:22px;height:22px;object-fit:contain;flex:none}
.tabs button.active{background:linear-gradient(#c33a32,#951d1b);color:#ffe6a8;border-color:#f0c46f;transform:translateY(-3px);box-shadow:0 3px 8px #0003}
.panel-card{flex:1 1 auto;min-height:0;justify-content:space-between;display:flex;flex-direction:column;background:linear-gradient(#fbf1df,#f3e3c6);border:2px solid #e3c48e;border-radius:0 0 16px 16px;padding:10px 8px 6px;box-shadow:inset 0 2px 6px #b98a5a33}
.choices{gap:9px;padding:2px;flex:1 1 auto;grid-auto-rows:1fr}
.choice{position:relative;min-height:0;aspect-ratio:1/1.05;padding:4px;border:2px solid #e8d2ad;border-radius:14px;background:linear-gradient(#fff9ee,#f6e8cf);box-shadow:0 2px 4px #8e694c33}
.choice img{width:100%;height:100%;max-width:none;object-fit:contain}
.choice span{position:absolute;bottom:3px;left:0;right:0;font-size:11px}
.choice.selected{border:3px solid #a8231f;background:linear-gradient(#fff4e2,#fbe2bf);box-shadow:0 0 0 2px #f0c46f}
.choice .check{position:absolute;top:-8px;right:-8px;width:26px;height:26px;border-radius:50%;background:#a8231f;color:#fff;font-style:normal;font-size:15px;line-height:26px;font-weight:900;border:2px solid #fff3dc}
.swatches{padding:6px 0 2px}
.enter{margin-top:8px;min-height:62px;border:0;border-radius:0;background:url(../assets/ui/button.webp) center/100% 100% no-repeat;box-shadow:none;text-shadow:0 2px #5b1210}
.enter span{font-size:34px;letter-spacing:.3em;color:#ffe3a3}
.tabs button span{display:inline;font-size:13px;line-height:1}

.panel-card .choice{aspect-ratio:auto;min-height:0}

/* ===== 捏人物: every element placed at the design's coordinates (design 941x1672, % of the 9:16 stage) ===== */
#creator-bg{top:0;height:100%;background:url(../assets/ui/design_top_bg.webp) top center/100% auto no-repeat,#c99a83}
#creator-bg.design-exact{background-image:url(../assets/ui/design_full.webp);background-size:100% 100%}
.creator-title{top:1.25%;left:20.2%;width:59.7%;height:7.05%;transform:none;aspect-ratio:auto;background-size:100% 100%}
.creator-title span{font-size:9.3cqw;letter-spacing:.06em;transform:translateY(-3%)}
.preview-arrows{top:31.6%;left:20.2%;right:20.4%;height:4.3%}
.preview-arrows button{width:9.1cqw;height:auto;aspect-ratio:85/72;border-radius:30%;font-size:5cqw}
.creator-panel{position:absolute;inset:0;height:auto;max-height:none;padding:0;background:none;box-shadow:none;border-radius:0;pointer-events:none}
.creator-panel>*{pointer-events:auto}
.creator-panel::before{content:'';position:absolute;left:0;right:0;top:42.4%;bottom:0;background:linear-gradient(#b3302a,#8c1d1b);border-radius:3cqw 3cqw 0 0;pointer-events:none}
.creator-panel::after{content:'';position:absolute;left:2.2%;right:2.1%;top:48.2%;height:35.4%;background:linear-gradient(#fbf2e2,#f2e2c4);border:.3cqw solid #e3c48e;border-radius:0 0 2cqw 2cqw;pointer-events:none}
.panel-card{display:contents}
.tabs{position:absolute;left:2.1%;top:42.6%;width:96.2%;height:max(44px,5.7%);margin:0;padding:0;gap:.3cqw;z-index:1}
.tabs button{height:100%;min-height:0;border-radius:2.2cqw 2.2cqw 0 0;font-size:4.3cqw;gap:1cqw;padding:0}
.tabs button span{font-size:4.3cqw}
.tabs button img{width:6.4cqw;height:6.4cqw;clip-path:inset(17% round 20%);transform:scale(1.45)}
.tabs button[data-tab=hair]{flex:200}.tabs button[data-tab=face]{flex:158}.tabs button[data-tab=skin]{flex:172}.tabs button[data-tab=outfit]{flex:184}.tabs button[data-tab=accessory]{flex:180}
.tabs button.active{transform:translateY(-.5cqh);height:calc(100% + .5cqh);min-height:44px}
.choices{position:absolute;left:7.1%;top:51.2%;width:84.9%;height:24.2%;z-index:1;display:grid;grid-template-columns:repeat(4,1fr);grid-auto-rows:1fr;column-gap:2.3cqw;row-gap:1.4cqh;padding:0;overflow:hidden}
.choices::after{content:'';position:absolute}
.panel-card .choice{border-radius:2.4cqw;padding:1cqw}
.choice .check{width:6.4cqw;height:6.4cqw;line-height:6.4cqw;font-size:3.6cqw;top:-1.6cqw;right:-1.6cqw}
.swatches{position:absolute;left:16.6%;width:66.7%;top:77.2%;height:4.8%;z-index:1;padding:0;display:flex;justify-content:space-between;align-items:center}
.swatch{width:8.3cqw;height:8.3cqw}
.enter{position:absolute;left:4.3%;top:84.2%;width:91.4%;height:12.2%;margin:0;min-height:0;z-index:1}
.enter span{font-size:10.6cqw;letter-spacing:.32em}
.scrollbar-deco{position:absolute;left:94.4%;top:50.8%;width:1.1%;height:25.4%;border-radius:1cqw;background:#e6d4b4;z-index:1;pointer-events:none}
.scrollbar-deco::after{content:'';position:absolute;left:0;right:0;top:0;height:55%;border-radius:1cqw;background:#c9ab7f}

#creator.exact .creator-title,#creator.exact .preview-arrows button,#creator.exact .creator-panel::before,#creator.exact .creator-panel::after,#creator.exact .tabs button,#creator.exact .choice,#creator.exact .swatch,#creator.exact .enter,#creator.exact .scrollbar-deco{opacity:0}
/* swatch: visible circle = design size (8.3cqw); touch area never smaller than 44px */
.swatches .swatch{position:relative;width:max(44px,8.3cqw);height:max(44px,8.3cqw);margin:0 calc((8.3cqw - max(44px,8.3cqw))/2);border:0;outline:0;background:transparent;box-shadow:none}
.swatches .swatch::after{content:'';position:absolute;left:50%;top:50%;width:8.3cqw;height:8.3cqw;transform:translate(-50%,-50%);border-radius:50%;background:var(--swatch);border:.6cqw solid #efdcbc;box-shadow:0 .4cqw .8cqw #8e694c55}
.swatches .swatch.selected::after{border-color:#e7b854;box-shadow:0 0 0 .5cqw #b8312c55,0 .4cqw .8cqw #8e694c55}
/* arrows: visible pill = design size, touch area at least 44px */
.preview-arrows button{position:relative;width:max(44px,9.1cqw);height:max(44px,7.7cqw);aspect-ratio:auto;border:0;background:transparent;box-shadow:none;color:transparent;font-size:0}
.preview-arrows button::after{content:'';position:absolute;left:50%;top:50%;width:9.1cqw;height:7.7cqw;transform:translate(-50%,-50%);border-radius:30%;border:.45cqw solid #f0c46f;background:linear-gradient(#b2302b,#7e1a19);box-shadow:0 .6cqw 0 #5d1714,0 1cqw 2cqw #0004}
.preview-arrows button span{position:absolute;left:50%;top:50%;transform:translate(-50%,-55%);z-index:1;color:#ffe2a0;font-size:5cqw;line-height:1}
.preview-arrows{display:flex;justify-content:space-between;align-items:center}
/* live mode: background = the design itself with the character painted out, so title + arrows are the design's own pixels;
   our title / arrow buttons stay on top as invisible click targets */
#creator-bg{background-size:100% 100%!important}
#creator .creator-title,#creator .preview-arrows button::after,#creator .preview-arrows button span{opacity:0}
/* ===== 捏人物 option A (11/16): the screen IS the design; picked outfit / colour = small cut-outs on top (js/avatar/creator.js) ===== */
#creator-bg{background:url(../assets/ui/design_full.webp) 0 0/100% 100% no-repeat!important}
#creator-bg .art{position:absolute;display:block;pointer-events:none;user-select:none}
#creator-bg .art[hidden]{display:none}
#creator .tabs button span,#creator .choice,#creator .swatch{color:transparent}
/* the panel box covers the whole stage (children sit at design coordinates): only its buttons take taps, so the
   arrows and the canvas (drag to turn) above it stay reachable */
#creator>.creator-panel,#creator>.preview-arrows{pointer-events:none}
#creator>.creator-panel>*,#creator>.preview-arrows>button{pointer-events:auto}
#creator .creator-panel .panel-card{pointer-events:none}#creator .creator-panel .panel-card>*>button{pointer-events:auto}
