:root {
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", var(--serif);
  --ink: #3a2f26; --paper: #f6f0e4; --gold: #f0c56a; --cinnabar: #b3392a;
  --tb: 54px;                                  /* 工具台高 */
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1611; overscroll-behavior: none; }
body { font-family: var(--serif); color: var(--ink); -webkit-user-select: none; user-select: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:active { transform: scale(.92); }

/* ---------- 布局：手机竖屏为主 ---------- */
#app { position: fixed; inset: 0; }
.pane { position: absolute; left: 0; right: 0; overflow: hidden; touch-action: none; }
#boardPane { top: 0; bottom: calc(var(--tb) + var(--safe-b));
  background:
    radial-gradient(ellipse 90% 70% at 40% 30%, rgba(255,214,150,.18), transparent 70%),
    repeating-linear-gradient(91deg, rgba(0,0,0,.05) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #5a3b25, #4a2f1c 50%, #3e2717); }
#sheetPane { bottom: calc(var(--tb) + var(--safe-b)); height: var(--drawer);
  background: linear-gradient(180deg, #3a2618, #2c1d12); box-shadow: 0 -10px 24px rgba(0,0,0,.45); border-radius: 18px 18px 0 0; }
#sheetPane::before { content: ""; position: absolute; left: 50%; top: 7px; width: 44px; height: 4px; margin-left: -22px; border-radius: 2px; background: rgba(255,240,220,.25); z-index: 3; }
.cam { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }

#sheets { position: absolute; left: 0; top: 0; }

/* ---------- 木画板与底卡 ---------- */
#mat { position: absolute; left: 680px; top: 0; width: 994px; height: 676px; border-radius: 14px;
  background:
    repeating-linear-gradient(92deg, rgba(120,72,30,.10) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(88deg, rgba(255,240,210,.10) 0 2px, transparent 2px 19px),
    linear-gradient(180deg, #d9b17c, #cfa26a 45%, #d6ab74 70%, #c99a61);
  box-shadow: inset 0 0 0 3px rgba(140,90,40,.35), inset 0 2px 0 rgba(255,240,210,.5), 0 3px 0 #9c6c38, 0 16px 30px rgba(0,0,0,.45); }
#board { position: absolute; left: 47px; top: 39px; width: 900px; height: 598px; border-radius: 6px; background: var(--paper);
  box-shadow: 0 1px 0 #d8cdb8, 0 2px 0 #c9bca4, 0 3px 0 #b9ab92, 0 10px 18px rgba(0,0,0,.4); transform-style: preserve-3d; }
#board-print { position: absolute; inset: 0; border-radius: 6px; background-size: 100% 100%; }
#board-guides, #board-stickers, #board-fx { position: absolute; inset: 0; }
#board-fx { pointer-events: none; z-index: 5000; }
.board-gloss { position: absolute; inset: 0; border-radius: 6px; pointer-events: none; z-index: 5001;
  background: linear-gradient(115deg, rgba(255,255,255,.08), transparent 35%, transparent 70%, rgba(255,255,255,.05)); }
.guide { position: absolute; pointer-events: none; opacity: .14; transition: opacity .4s, filter .3s; }
.guide.cur { opacity: .85; animation: g-pulse 2.2s ease-in-out infinite; }
.guide.near { opacity: 1; filter: drop-shadow(0 0 1.5px #f6c14b) drop-shadow(0 0 4px #f6c14b) brightness(1.3); animation: none; }
.guide.done { opacity: 0; animation: none; }
@keyframes g-pulse { 0%,100% { opacity: .78; } 50% { opacity: 1; } }
.guide-num { position: absolute; font-size: 5px; line-height: 1; color: rgba(70,60,48,.75); transform: translate(-50%,-50%); font-family: Georgia, serif; pointer-events: none; opacity: 0; transition: opacity .3s; }
.guide-num.cur { opacity: 1; }
#board-guides.hidden { opacity: 0; }

/* ---------- 贴纸 ---------- */
.stk { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; will-change: transform; isolation: isolate; }
.stk::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: rgba(35,20,8,.34); -webkit-mask: var(--mask) center / 100% 100% no-repeat; mask: var(--mask) center / 100% 100% no-repeat;
  filter: blur(1.2px); transform: translateY(1.4px); }
.stk .in { transform-style: preserve-3d; perspective: 1600px; }
.stk .face { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.stk .face img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.stk .flat-front { clip-path: polygon(0 0, 100% 0, 100% 100%, 100% 100%, 0 100%); }
.stk .corner-peel { position: absolute; inset: 0; z-index: 2; transform-origin: 100% 100%; }
.stk .corner-peel .face { clip-path: polygon(100% 100%, 100% 100%, 100% 100%); }
.stk .corner-peel .back { opacity: 0; }
/* 翻起的那块过了 90° 看到的是背面：背面要能从后面看见，并且垫在正面下面 */
.stk .corner-peel .face.back { backface-visibility: visible; -webkit-backface-visibility: visible; transform: translateZ(-.5px); }
.stk .front { transform: translateZ(.7px); }
.stk .front::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(var(--sa, 120deg), transparent 30%, rgba(255,255,255,.6) 48%, transparent 62%); opacity: 0;
  -webkit-mask: var(--mask) center / 100% 100% no-repeat; mask: var(--mask) center / 100% 100% no-repeat; }
.stk .back { transform: translateZ(1px); background: linear-gradient(115deg, #ad9f88 0%, #dccfb8 28%, #eee3cf 46%, #f6eedf 50%, #cbbca3 72%, #9e8e74 100%);
  -webkit-mask: var(--mask) center / 100% 100% no-repeat; mask: var(--mask) center / 100% 100% no-repeat;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), inset 0 -1px 0 rgba(91,72,48,.32); }
.stk .corner-peel .back::after { content: ""; position: absolute; left: -18%; top: 42%; width: 136%; height: 16%;
  transform: rotate(-45deg); transform-origin: center; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(120,100,75,.24) 46%, rgba(255,255,255,.58)); filter: blur(.35px); }
.stk .back img { opacity: .13; filter: grayscale(1) brightness(0) invert(1); }

.stk.held::after { transform: translateY(9px); filter: blur(5px); background: rgba(20,10,0,.32); }
.stk.held .corner-peel .face { filter: drop-shadow(0 5px 3px rgba(20,10,0,.22)); }
.stk.held .front::after { opacity: .42; }
.stk.unsealed .front::after { opacity: .14; }
.stk.dim { filter: saturate(.55) brightness(1.04); }
.stk .curl { position: absolute; width: 22%; aspect-ratio: 1; right: 0; top: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(225deg, rgba(255,255,255,0) 50%, rgba(255,255,255,.95) 51%, #e6e0d6 70%, rgba(0,0,0,.18) 100%);
  -webkit-mask: linear-gradient(225deg, #000 50%, transparent 50.5%); mask: linear-gradient(225deg, #000 50%, transparent 50.5%); }
.stk.curl1 .curl { opacity: .7; width: 14%; }
.stk.curl2 .curl { opacity: 1; width: 24%; }
.stk .bubble { position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.95), rgba(255,255,255,.35) 40%, rgba(255,255,255,.08) 70%, transparent 72%);
  box-shadow: 0 .5px 1px rgba(0,0,0,.18); transition: opacity .25s, transform .25s; }
.stk .bubble.gone { opacity: 0; transform: scale(.2); }
.stk.wrong .front { filter: drop-shadow(0 0 1px #d2402c) drop-shadow(0 0 3px #d2402c); }
/* ---------- 多汁特效 ---------- */
.ripple { position: absolute; border-radius: 50%; border: 1.2px solid rgba(255,214,120,.95); pointer-events: none;
  transform: translate(-50%,-50%) scale(.3); animation: ripple .7s cubic-bezier(.2,.7,.3,1) forwards; box-shadow: 0 0 6px rgba(255,200,90,.7); }
@keyframes ripple { to { transform: translate(-50%,-50%) scale(2.4); opacity: 0; } }
.spark { position: absolute; width: 3px; height: 3px; pointer-events: none; transform: translate(-50%,-50%);
  background: radial-gradient(circle, #fff8d8, #f4c050 55%, transparent 70%); animation: spark .6s ease-out forwards; }
.spark::before, .spark::after { content: ""; position: absolute; left: 50%; top: 50%; width: 9px; height: .7px; margin: -.35px 0 0 -4.5px; background: linear-gradient(90deg, transparent, #fff3c4, transparent); }
.spark::after { transform: rotate(90deg); }
@keyframes spark { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; } }
.tag { position: fixed; z-index: 70; pointer-events: none; padding: 3px 9px; border-radius: 12px; font-size: 13px; white-space: nowrap;
  background: rgba(251,247,238,.95); box-shadow: 0 4px 12px rgba(0,0,0,.3); transform: translate(-50%, 0); animation: tag 1.4s ease-out forwards; }
.tag small { color: #a0442e; margin-left: 4px; }
@keyframes tag { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -26px); } }
.petal { position: fixed; z-index: 69; pointer-events: none; width: 12px; height: 8px; border-radius: 80% 10% 80% 10%;
  background: linear-gradient(135deg, #ffd3dc, #f39aac); box-shadow: inset 0 0 2px rgba(255,255,255,.6); animation: petal var(--t, 2.4s) cubic-bezier(.3,.4,.6,1) forwards; }
@keyframes petal { 0% { transform: translate(0,0) rotate(0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
#sweep { position: absolute; inset: 0; pointer-events: none; z-index: 5002; border-radius: 6px; opacity: 0;
  background: linear-gradient(110deg, transparent 35%, rgba(255,236,170,.55) 48%, rgba(255,255,240,.85) 50%, rgba(255,236,170,.55) 52%, transparent 65%); background-size: 300% 100%; }
#sweep.go { animation: sweep 1.6s ease-in-out forwards; }
@keyframes sweep { 0% { opacity: 1; background-position: 120% 0; } 100% { opacity: 1; background-position: -60% 0; } }

/* ---------- HUD ---------- */
#hud { position: absolute; left: 10px; right: 10px; top: calc(8px + env(safe-area-inset-top, 0px)); z-index: 20; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 5px; }
#step { display: flex; align-items: baseline; gap: 8px; padding: 6px 14px; border-radius: 18px; background: rgba(30,20,12,.72); color: #f3e9d4;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); font-size: 14px; }
#step.pop { animation: pop .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
#step .st-no { color: var(--gold); font-size: 12px; letter-spacing: .1em; }
#step .st-count { font-family: Georgia, serif; font-size: 13px; color: #cdbb98; }
#bar { width: min(260px, 60%); height: 3px; border-radius: 2px; background: rgba(255,255,255,.15); overflow: hidden; }
#bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f0c56a, #ffe7a8); transition: width .5s cubic-bezier(.2,.8,.2,1); }
#combo { font-family: var(--kai); color: var(--gold); font-size: 18px; text-shadow: 0 2px 6px rgba(0,0,0,.6); opacity: 0; transition: opacity .3s; }
#combo.on { opacity: 1; animation: pop .45s cubic-bezier(.3,1.6,.5,1); }
#subtitle { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 20; width: min(560px, 92%); pointer-events: none;
  text-align: center; font-family: var(--kai); font-size: 16px; line-height: 1.6; color: #fff7e4; text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 12px rgba(0,0,0,.6); }
#subtitle div { opacity: 0; transform: translateY(6px); transition: opacity .6s, transform .6s; }
#subtitle div.on { opacity: 1; transform: none; }
#subtitle .t { font-size: 12px; color: var(--gold); letter-spacing: .15em; }
#zoomctl { position: absolute; right: 10px; bottom: 12px; z-index: 20; display: flex; flex-direction: column; gap: 6px; }
#zoomctl button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(30,20,12,.7); color: #f1e8d6; font-size: 17px; box-shadow: 0 3px 10px rgba(0,0,0,.35); }

/* ---------- 撤销 / 重做 / 保存点 ---------- */
#history { position: absolute; right: 12px; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 22; display: flex; gap: 6px; }
#history button { width: 38px; height: 38px; border-radius: 50%; border: 0; font-size: 19px; line-height: 1;
  background: var(--glass, rgba(252,248,241,.8)); color: var(--tx, #3b2d21); box-shadow: inset 0 0 0 1px rgba(96,64,32,.13), 0 6px 14px rgba(80,48,20,.18);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); transition: transform .15s, opacity .2s; }
#history button:active { transform: scale(.9); }
#history button:disabled { opacity: .32; }
#save-dot { position: absolute; left: 12px; top: calc(16px + env(safe-area-inset-top, 0px)); z-index: 22; width: 8px; height: 8px; border-radius: 50%;
  background: #6fae6a; box-shadow: 0 0 0 0 rgba(111,174,106,.6); opacity: 0; pointer-events: none; }
#save-dot.flash { animation: sdot 1.1s ease-out; }
@keyframes sdot { 0% { opacity: 1; box-shadow: 0 0 0 0 rgba(111,174,106,.7); } 100% { opacity: 0; box-shadow: 0 0 0 12px rgba(111,174,106,0); } }

/* ---------- PET 片 ---------- */
#sheet-tabs { position: absolute; left: 0; right: 0; top: 14px; z-index: 4; display: flex; gap: 6px; justify-content: center; }
.tab { border: 0; border-radius: 14px; padding: 4px 12px; font-size: 12px; background: rgba(255,240,220,.12); color: #e9dcc4; }
.tab.on { background: #f3eee2; color: #4a3b2c; }
.tab .count { font-family: Georgia, serif; font-size: 11px; margin-left: 4px; opacity: .7; }
.sheet { position: absolute; left: 0; top: 0; width: 600px; height: 676px; border-radius: 8px;
  background: linear-gradient(118deg, rgba(255,255,255,.55), rgba(255,255,255,0) 30%, rgba(255,255,255,0) 64%, rgba(255,255,255,.35) 78%, rgba(255,255,255,0) 90%),
    repeating-linear-gradient(0deg, rgba(120,150,160,.06) 0 1px, transparent 1px 20px), #eef2f0;
  box-shadow: 0 1px 1px rgba(0,0,0,.25), 0 8px 18px rgba(0,0,0,.35); }
.sheet.behind { display: none; }
.sheet .sheet-head { position: absolute; left: 14px; top: 2px; font-size: 9px; letter-spacing: .1em; color: #7b8a86; }
.slot { position: absolute; pointer-events: none; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.slot .cut { position: absolute; inset: 0; background: rgba(60,80,85,.16); -webkit-mask: inherit; mask: inherit; }
.slot .liner { position: absolute; inset: .6px; background: #f4f7f5; -webkit-mask: inherit; mask: inherit; }

/* ---------- 工具台：底部一条 ---------- */
#toolbar { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--tb) + var(--safe-b)); padding: 5px 8px var(--safe-b);
  display: flex; align-items: center; justify-content: center; gap: 2px; z-index: 30;
  background: linear-gradient(180deg, #34302b, #24211d); border-top: 1px solid rgba(255,255,255,.06); box-shadow: 0 -4px 14px rgba(0,0,0,.35); }
.tool, .tbtn, .go { border: 0; background: transparent; color: #d9d2c4; border-radius: 10px; height: 44px; transition: background .2s, color .2s; }
.tool { display: flex; align-items: center; gap: 4px; padding: 0 9px; }
.tool i, .tbtn i { width: 30px; height: 26px; background: no-repeat center / contain; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); transition: transform .25s cubic-bezier(.3,1.6,.5,1); }
.tool b { font-weight: normal; font-size: 13px; }
.tool.on { background: rgba(240,197,106,.16); color: #f6d58f; }
.tool.on i { transform: translateY(-1px) rotate(-8deg) scale(1.1); }
.go { padding: 0 9px; font-size: 13px; color: #bfb6a6; }
.go:hover, .tbtn:hover { background: rgba(255,255,255,.07); }
.tbtn { width: 40px; display: grid; place-items: center; }
.tb-sep { width: 1px; height: 24px; background: rgba(255,255,255,.12); margin: 0 4px; }
.tbtn i.ic-card { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 30'><rect x='9' y='2' width='22' height='26' rx='2' fill='%23fbf7ee' transform='rotate(6 20 15)'/><g stroke='%23a0442e' stroke-width='1.6'><line x1='14' y1='9' x2='26' y2='10'/><line x1='14' y1='14' x2='26' y2='15'/><line x1='14' y1='19' x2='23' y2='20'/></g></svg>"); }
.tbtn i.ic-menu { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 30'><g fill='%23d9d2c4'><circle cx='12' cy='15' r='2.6'/><circle cx='20' cy='15' r='2.6'/><circle cx='28' cy='15' r='2.6'/></g></svg>"); }
@media (max-width: 520px) {
  .tool b { display: none; }               /* 手机上工具只留图标 */
  .tool { padding: 0 6px; } .go { padding: 0 6px; font-size: 12px; } .tb-sep { margin: 0 2px; }
}

/* ---------- 手里的贴纸、光标 ---------- */
#hand { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 65; }
#cursor { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; display: none; }
@media (hover: hover) and (pointer: fine) { #cursor { display: block; } body, button { cursor: none; } }

/* ---------- 菜单 / 图鉴 / 示意卡 ---------- */
#menu, #book, #order-big { position: fixed; inset: 0; z-index: 75; display: none; place-items: end center; background: rgba(16,10,6,.55); }
#menu.show, #book.show, #order-big.show { display: grid; }
.mn-card { width: min(420px, 100%); background: #fbf7ee; border-radius: 18px 18px 0 0; padding: 14px 16px calc(14px + var(--safe-b)); display: grid; gap: 8px; animation: up .35s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(100%); } }
.mn-card button { border: 0; border-radius: 12px; background: #f0e8d8; padding: 13px; font-size: 15px; text-align: left; }
.mn-card .mn-close { background: transparent; text-align: center; color: #8a7a64; }
.bk-card, .ob-card { width: min(720px, 100%); max-height: 82vh; overflow: auto; background: #fbf7ee; border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); animation: up .35s cubic-bezier(.2,.8,.2,1); touch-action: pan-y; }
.bk-card h3, .ob-card h3 { margin: 0 0 4px; font-weight: 600; letter-spacing: .15em; }
.bk-card p, .ob-card p { margin: 0 0 12px; color: #7a6b58; font-size: 13px; }
.bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.bk-item { border: 0; background: #f0e8d8; border-radius: 10px; padding: 6px 4px; display: grid; justify-items: center; gap: 2px; font-size: 11px; }
.bk-item img { height: 46px; max-width: 70px; object-fit: contain; }
.bk-item.lock { opacity: .35; filter: grayscale(1); }
.ob-layer { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px dashed #dcd2c0; }
.ob-layer .n { width: 22px; font-family: Georgia, serif; font-size: 18px; color: #9a8b76; }
.ob-layer .t { width: 110px; font-size: 13px; }
.ob-layer.cur .t { color: #a0442e; }
.ob-layer .imgs { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }
.ob-layer .imgs img { height: 28px; }

/* ---------- 拆包 ---------- */
#pack { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; align-content: center; gap: 18px;
  background: radial-gradient(ellipse at 50% 40%, #5a3b25, #2a1a10 80%); transition: opacity .6s; }
#pack.gone { opacity: 0; pointer-events: none; }
/* 透明自粘袋：袋子只比底卡大一圈，底卡朝外，贴纸页叠在后面；封口折在袋子上沿 */
.pack-bag { position: relative; width: min(540px, 88vw); aspect-ratio: 900 / 668; cursor: pointer;
  filter: drop-shadow(0 26px 30px rgba(0,0,0,.45));
  transition: transform .8s cubic-bezier(.5,0,.3,1) .55s, opacity .5s .9s; animation: bob 3.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(-3px) rotate(-.8deg); } 50% { transform: translateY(3px) rotate(.6deg); } }
/* 袋子里的东西 */
.pack-inner { position: absolute; left: 2.2%; right: 2.2%; top: 8.5%; bottom: 2.4%; transition: transform .75s cubic-bezier(.3,0,.2,1) .28s; }
.pack-sheet { position: absolute; inset: 0; border-radius: 3px; background: #eef2ee; box-shadow: 0 0 0 .5px rgba(60,70,65,.35); transform: translate(5px, 4px) rotate(.5deg); }
.pack-sheet.s2 { background: #f4f6f2; transform: translate(-3px, 2px) rotate(-.4deg); }
.pack-card { position: absolute; inset: 0; border-radius: 3px; background: url("art/final/cover.jpg") center / cover; box-shadow: 0 0 0 .5px rgba(60,40,20,.4), 0 1px 3px rgba(0,0,0,.3); }
/* 塑料膜：两侧热封边、几道褶皱高光、整体一层反光 */
.pack-film { position: absolute; inset: 0; border-radius: 2px; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,.5) 0, rgba(255,255,255,.14) 1.1%, rgba(255,255,255,0) 2.4%, rgba(255,255,255,0) 97.6%, rgba(255,255,255,.14) 98.9%, rgba(255,255,255,.5) 100%),
    linear-gradient(0deg, rgba(255,255,255,.42) 0, rgba(255,255,255,.1) 1.4%, rgba(255,255,255,0) 2.6%),
    linear-gradient(104deg, rgba(255,255,255,0) 8%, rgba(255,255,255,.32) 13%, rgba(255,255,255,0) 19%, rgba(255,255,255,0) 54%, rgba(255,255,255,.2) 60%, rgba(255,255,255,.05) 64%, rgba(255,255,255,0) 71%),
    linear-gradient(170deg, rgba(255,255,255,.16), rgba(255,255,255,0) 40%),
    rgba(214,228,232,.07);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
/* 封口：膜多出来的一截，折到正面粘住，上面有一条胶 */
.pack-flap { position: absolute; left: 0; right: 0; top: 0; height: 7.2%; border-radius: 2px 2px 0 0; transform-origin: 50% 0;
  background: linear-gradient(180deg, rgba(255,255,255,.34), rgba(236,244,246,.2)); border-bottom: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 2px 3px rgba(0,0,0,.16), inset 0 0 0 1px rgba(255,255,255,.4); transition: transform .45s cubic-bezier(.4,0,.2,1), opacity .3s .3s; }
.pack-flap::after { content: ""; position: absolute; left: 1.5%; right: 1.5%; bottom: 18%; height: 30%; border-radius: 1px; background: rgba(255,255,255,.3); }
/* 贴在袋子正面的小标签 */
.pack-label { position: absolute; left: 5%; bottom: 7%; background: #fbf7ee; padding: 9px 14px 10px; border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .8s cubic-bezier(.5,0,.3,1) .55s, opacity .5s .9s; }
.pack-title { font-size: 24px; letter-spacing: .26em; font-family: var(--kai); }
.pack-sub { font-size: 11px; letter-spacing: .16em; color: #8b6a44; margin-top: 1px; }
.pack-meta { font-size: 10px; color: #8a7f70; margin-top: 5px; }
.pack-hint { color: #d8c7a8; font-size: 13px; letter-spacing: .2em; }
#pack.open .pack-flap { transform: perspective(600px) rotateX(170deg); opacity: 0; }
#pack.open .pack-inner { transform: translateY(-125vh); }
#pack.open .pack-bag { animation: none; transform: translateY(46vh) rotate(-5deg); opacity: 0; }
/* 开袋是用手，不是用镊子 */
body:has(#pack:not(.gone)) #cursor { display: none !important; }
body:has(#pack:not(.gone)), body:has(#pack:not(.gone)) button { cursor: auto; }
body:has(#pack:not(.gone)) .pack-bag { cursor: pointer; }

/* ---------- 提示 ---------- */
#toast { position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -6px); z-index: 80; pointer-events: none;
  padding: 7px 14px; font-size: 13px; background: rgba(251,247,238,.96); border-radius: 16px; box-shadow: 0 6px 14px rgba(0,0,0,.35);
  opacity: 0; transition: opacity .2s, transform .2s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 欣赏模式 ---------- */
#view-exit { position: fixed; right: 14px; top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 76; display: none; border: 1px solid rgba(241,232,214,.6);
  background: rgba(30,22,16,.7); color: #f1e8d6; padding: 7px 14px; border-radius: 18px; font-size: 14px; }
body.viewing #view-exit { display: block; }
body.viewing #toolbar, body.viewing #hud, body.viewing #zoomctl, body.viewing #sheets { display: none; }
body.viewing #boardPane { bottom: 0; }
body.viewing #board { transform: perspective(1600px) rotateX(var(--vrx, 0deg)) rotateY(var(--vry, 0deg)); }
body.viewing #board-guides { opacity: 0; }

/* ---------- 终章 ---------- */
#finale { position: fixed; inset: 0; z-index: 72; display: none; place-items: center; pointer-events: none; }
#finale.show { display: grid; }
.fn-text { writing-mode: vertical-rl; font-family: var(--kai); font-size: clamp(26px, 6vw, 44px); letter-spacing: .3em; color: #fff7e2; line-height: 1.9;
  text-shadow: 0 2px 6px rgba(0,0,0,.8), 0 0 24px rgba(240,190,90,.6); }
.fn-text span { opacity: 0; display: inline-block; animation: ink .7s forwards; }
@keyframes ink { from { opacity: 0; filter: blur(4px); transform: translateY(-6px); } to { opacity: 1; filter: none; transform: none; } }
.fn-btns { position: fixed; left: 50%; bottom: calc(30px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 10px; pointer-events: auto; opacity: 0; animation: fade .6s 3.4s forwards; }
.fn-btns button { white-space: nowrap; border: 0; border-radius: 22px; padding: 11px 18px; font-size: 15px; background: #fbf7ee; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.fn-btns button.main { background: var(--cinnabar); color: #fbf0e0; }
@keyframes fade { to { opacity: 1; } }

/* ---------- 诗笺 ---------- */
#poem { position: fixed; inset: 0; z-index: 82; display: grid; place-items: center; background: rgba(92,60,30,0); pointer-events: none; transition: background .4s; }
#poem.show { background: rgba(92,60,30,.28); pointer-events: auto; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.pm-card { position: relative; display: grid; grid-template-columns: minmax(260px, 420px) auto; grid-template-rows: 100%;
  max-width: 94vw; height: min(560px, 86vh); border-radius: 14px; overflow: hidden;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.9 .04' numOctaves='3' seed='4'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .33  0 0 0 0 .2  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>"),
    #f6efe0;
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 2px 3px rgba(70,40,14,.2), 0 24px 50px rgba(70,40,14,.32);
  transform: translateY(24px) scale(.97); opacity: 0; transition: transform .5s cubic-bezier(.2,.8,.2,1), opacity .4s; }
#poem.show .pm-card { transform: none; opacity: 1; }
.pm-art { position: relative; display: grid; place-items: center; min-height: 0; padding: 44px 40px; border-right: 1px solid rgba(176,60,40,.28); }
.pm-art::after { content: ""; position: absolute; top: 18px; bottom: 18px; right: 3px; border-right: 1px solid rgba(176,60,40,.18); }
.pm-float { position: relative; width: 100%; max-height: 100%; animation: pm-bob 6s ease-in-out infinite; }
.pm-float img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(70,40,14,.3)) drop-shadow(0 10px 14px rgba(70,40,14,.22)); }
@keyframes pm-bob { 0%,100% { transform: translateY(-3px) rotate(-.6deg); } 50% { transform: translateY(3px) rotate(.6deg); } }
.pm-era { position: absolute; left: 20px; top: 22px; font-family: var(--kai); color: #9c8a70; font-size: 14px; line-height: 1.25; }
.pm-paper { position: relative; min-width: 250px; height: 100%; min-height: 0; padding: 44px 40px 64px; display: flex; justify-content: flex-end; }
.pm-cols { height: 100%; writing-mode: vertical-rl; hanging-punctuation: allow-end; line-break: strict; font-family: var(--kai); color: #2e2219; line-height: 46px;
  background: repeating-linear-gradient(90deg, rgba(176,60,40,.24) 0 1px, transparent 1px 46px); background-position: right 0 top 0;
  box-shadow: 1px 0 0 rgba(176,60,40,.24); }
.pm-cols span { opacity: 0; animation: pm-ink .5s forwards; display: inline-block; }
@keyframes pm-ink { from { opacity: 0; filter: blur(2px); transform: translateY(-3px); } to { opacity: 1; filter: none; transform: none; } }
.pm-name { font-size: 32px; letter-spacing: .22em; }
.pm-text { font-size: 18px; letter-spacing: .1em; }
.pm-ptitle { font-size: 14px; color: #a2432e; letter-spacing: .2em; }
.pm-line { font-size: 18px; letter-spacing: .08em; }
.pm-seal { position: absolute; left: 22px; bottom: 22px; width: 44px; height: 44px; border-radius: 4px; background: var(--cinnabar); color: #f8eee0; display: grid; place-items: center;
  font-family: var(--kai); font-size: 15px; line-height: 17px; box-shadow: inset 0 0 0 3px var(--cinnabar), inset 0 0 0 4px rgba(248,238,224,.7);
  animation: seal .5s 1s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes seal { from { transform: rotate(-6deg) scale(1.8); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: .92; } }
.pm-seal.意象, .pm-seal.小物 { background: #6d7a86; box-shadow: inset 0 0 0 3px #6d7a86, inset 0 0 0 4px rgba(248,238,224,.7); }
.pm-seal.传说 { background: #9a6a28; box-shadow: inset 0 0 0 3px #9a6a28, inset 0 0 0 4px rgba(248,238,224,.7); }
.pm-src { position: absolute; left: 76px; right: 40px; bottom: 30px; font-size: 12px; white-space: nowrap; color: #9c8a70; text-align: right; font-family: var(--ui); }
.pm-close { position: absolute; right: 8px; top: 6px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; font-size: 24px; color: #9c8a70; z-index: 2; }
.pm-card.bare .pm-paper { min-width: 120px; }
@media (orientation: portrait) {
  .pm-card { grid-template-columns: 100%; grid-template-rows: minmax(0, 46%) minmax(0, 54%); width: 92vw; height: min(640px, 84vh); }
  .pm-card.bare { grid-template-rows: minmax(0, 72%) minmax(0, 28%); }
  .pm-art { border-right: 0; border-bottom: 1px solid rgba(176,60,40,.28); padding: 36px 28px 24px; }
  .pm-art::after { top: auto; right: 18px; left: 18px; bottom: 3px; border-right: 0; border-bottom: 1px solid rgba(176,60,40,.18); }
  .pm-paper { padding: 20px 20px 54px; justify-content: center; overflow-x: auto; }
  .pm-cols { line-height: 34px; background: repeating-linear-gradient(90deg, rgba(176,60,40,.24) 0 1px, transparent 1px 34px); }
  .pm-name { font-size: 24px; } .pm-text, .pm-line { font-size: 15px; } .pm-ptitle { font-size: 12px; }
  .pm-seal { width: 38px; height: 38px; font-size: 13px; line-height: 15px; left: 16px; bottom: 14px; }
  .pm-src { left: 64px; right: 20px; bottom: 22px; }
}
#hover-name { position: fixed; z-index: 66; pointer-events: none; padding: 3px 8px; font-size: 13px; background: rgba(251,247,238,.95); border-radius: 3px; box-shadow: 0 4px 10px rgba(0,0,0,.3); opacity: 0; transition: opacity .15s; }
#hover-name.show { opacity: 1; }

@property --gx { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --gy { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --mx { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --my { syntax: '<percentage>'; inherits: true; initial-value: 50%; }

/* =====================================================================
   v6 木托盘皮肤
   ===================================================================== */
:root {
  --wood: url("art/wood/oak.jpg");
  --cinnabar: #c0482f; --gold-hair: rgba(150,105,50,.45);
  --glass: rgba(252,248,241,.8); --glass-line: rgba(96,64,32,.13);
  --tx: #3b2d21; --tx-2: #8a7864;
  --ui: "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", system-ui, sans-serif;
  --dock-h: 66px;
}
html, body { background: #b48a5e; }
body { font-family: var(--ui); }

#boardPane { bottom: 0 !important; background: var(--wood) center / 900px #b48a5e; }
#boardPane::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background:
    radial-gradient(ellipse 80% 70% at 30% 20%, rgba(255,246,228,.22), transparent 60%),
    radial-gradient(ellipse 130% 100% at 50% 50%, transparent 60%, rgba(92,56,24,.28) 100%); }
.cam { z-index: 2; }

#mat { background: none; box-shadow: none; }
#board { border-radius: 4px; box-shadow: 0 1px 1px rgba(70,40,14,.28), 0 8px 18px rgba(70,40,14,.3); }

.sheet { border-radius: 14px;
  background:
    linear-gradient(115deg, rgba(255,255,255,.55), rgba(255,255,255,0) 26%, rgba(255,255,255,0) 66%, rgba(255,255,255,.25) 80%, rgba(255,255,255,0) 92%),
    rgba(240,242,238,.9);
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 2px 2px rgba(70,40,14,.18), 0 14px 26px rgba(70,40,14,.28); }
.sheet .sheet-head { color: #8d9590; font-family: var(--ui); letter-spacing: .14em; }

#bar { display: none; }
#step { gap: 9px; padding: 7px 16px 7px 8px; border-radius: 999px; background: var(--glass); color: var(--tx);
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  box-shadow: inset 0 0 0 1px var(--glass-line), inset 0 1px 0 rgba(255,255,255,.7), 0 8px 20px rgba(80,48,20,.18); align-items: center; }
#step .st-ring { width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--cinnabar) var(--p, 0deg), rgba(96,64,32,.14) 0);
  -webkit-mask: radial-gradient(circle, transparent 9px, #000 10px); mask: radial-gradient(circle, transparent 9px, #000 10px); transition: background .5s; }
#step .st-no { color: var(--tx-2); font-size: 11px; letter-spacing: .06em; }
#step .st-name { font-family: var(--kai); font-size: 16px; letter-spacing: .08em; }
#step .st-count { font-family: var(--ui); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--tx-2); }
#combo { font-size: 16px; color: var(--cinnabar); text-shadow: 0 1px 0 rgba(255,248,236,.8); }
#subtitle { bottom: calc(var(--dock-h) + 26px + var(--safe-b)); font-size: 15px; color: var(--tx); text-shadow: none; }
#subtitle div { display: table; margin: 5px auto 0; padding: 6px 15px; border-radius: 14px; background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: inset 0 0 0 1px var(--glass-line), 0 6px 16px rgba(80,48,20,.16); }

/* ---------- 拇指区磨砂坞 ---------- */
#dock { position: fixed; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%); z-index: 30;
  width: min(560px, calc(100vw - 20px)); height: var(--dock-h); padding: 6px;
  display: flex; align-items: center; gap: 6px; border-radius: 999px;
  background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
  box-shadow: inset 0 0 0 1px var(--glass-line), inset 0 1px 0 rgba(255,255,255,.75), 0 14px 32px rgba(80,48,20,.24); }
.dock-tools { display: flex; gap: 2px; flex: 1 1 auto; min-width: 0; }
#dock .tool { flex: 1; min-width: 54px; height: 54px; border: 0; border-radius: 999px; background: transparent; color: var(--tx-2);
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; transition: background .25s, color .25s; }
#dock .tool i { width: 34px; height: 34px; background: no-repeat center / contain; filter: drop-shadow(0 2px 2px rgba(70,40,14,.3)); transition: transform .35s cubic-bezier(.3,1.6,.5,1); }
#dock .tool b { font-weight: 500; font-size: 13px; letter-spacing: .04em; }
#dock .tool.on { background: rgba(96,64,32,.09); color: var(--tx); }
#dock .tool.on i { transform: translateY(-2px) rotate(-10deg) scale(1.12); }
#dock .tool:active { transform: scale(.94); }
/* 跳转：贴纸页 1 / 2 · 底卡 · 贴纸页 3，按桌面上从左到右的顺序排 */
#minimap { display: flex; gap: 2px; flex: none; padding: 3px; border-radius: 999px; background: rgba(96,64,32,.07); }
#minimap button { height: 48px; padding: 0 13px; border: 0; border-radius: 999px; background: transparent; color: var(--tx-2);
  font: 500 13px var(--ui); letter-spacing: .04em; white-space: nowrap; }
#minimap button.mm-b { color: var(--tx); background: rgba(252,248,241,.9); box-shadow: 0 1px 2px rgba(70,40,14,.14); }
#minimap button:active { transform: scale(.96); }
.dock-more { flex: none; width: 54px; height: 54px; border: 0; border-radius: 50%; background: transparent; display: grid; grid-auto-flow: column; place-content: center; gap: 4px; }
.dock-more span { width: 4px; height: 4px; border-radius: 50%; background: var(--tx-2); }
.dock-more:active { background: rgba(96,64,32,.08); }
@media (max-width: 520px) {
  #dock .tool b { display: none; }
  #dock .tool { padding: 0; }
}

/* ---------- 提示、菜单、图鉴、示意卡：同一种浅色磨砂 ---------- */
#toast { font-family: var(--ui); background: var(--glass); color: var(--tx); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px var(--glass-line), 0 8px 20px rgba(80,48,20,.18); border-radius: 999px; }
.tag { font-family: var(--ui); background: rgba(252,248,241,.9); color: var(--tx); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--glass-line), 0 6px 14px rgba(80,48,20,.2); border-radius: 999px; }
.tag small { color: var(--cinnabar); }
#menu, #book, #order-big { background: rgba(92,60,30,.22); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.mn-card, .bk-card, .ob-card, .al-card { background: rgba(252,248,241,.94); color: var(--tx); -webkit-backdrop-filter: blur(24px) saturate(140%); backdrop-filter: blur(24px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 -14px 40px rgba(80,48,20,.22); border-radius: 24px 24px 0 0; font-family: var(--ui); }
.mn-card::before, .bk-card::before, .ob-card::before, .al-card::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: rgba(96,64,32,.2); margin: -4px auto 10px; }
.mn-card button { background: rgba(96,64,32,.06); color: var(--tx); border-radius: 16px; padding: 15px 16px; font-size: 15px; }
.mn-card button:active { background: rgba(96,64,32,.12); }
.mn-card .mn-close { background: transparent; color: var(--tx-2); }
.bk-card p, .ob-card p, .al-card p { color: var(--tx-2); }
.bk-item { background: rgba(96,64,32,.05); color: var(--tx); border-radius: 14px; }
.ob-layer { border-top: 1px solid rgba(96,64,32,.1); }
.ob-layer .n { color: var(--tx-2); font-family: var(--ui); font-variant-numeric: tabular-nums; }
.ob-layer.cur .t { color: var(--cinnabar); }

/* ---------- 拆包 ---------- */
#pack { background: var(--wood) center / 900px #b48a5e; }
#pack::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 70% at 30% 20%, rgba(255,246,228,.22), transparent 60%), radial-gradient(ellipse 130% 100% at 50% 50%, transparent 60%, rgba(92,56,24,.28) 100%); }
.pack-label { background: rgba(252,248,241,.85); color: var(--tx); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px var(--glass-line); border-radius: 12px; }
.pack-sub { color: var(--cinnabar); } .pack-meta { color: var(--tx-2); font-family: var(--ui); }
.pack-hint { color: #fff8ec; font-family: var(--ui); letter-spacing: .3em; font-size: 12px; text-shadow: 0 1px 2px rgba(70,40,14,.5); }
.pack-tear span { font-family: var(--ui); }

/* 欣赏模式：坞收起，只剩画 */
body.viewing #dock { display: none; }
#view-exit { font-family: var(--ui); background: var(--glass); color: var(--tx); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 0; box-shadow: inset 0 0 0 1px var(--glass-line); }
.fn-btns button { font-family: var(--ui); }
.fn-btns { bottom: calc(12px + var(--dock-h) + 16px + var(--safe-b)); }
body.tray-mode .fn-btns { bottom: calc(12px + var(--dock-h) + 130px + var(--safe-b)); }
.fn-btns button:not(.main) { background: var(--glass); color: var(--tx); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: inset 0 0 0 1px var(--glass-line); }
.fn-btns button.main { background: var(--cinnabar); color: #fff6ea; }

/* 透明度、动效偏好 */
@media (prefers-reduced-transparency: reduce) {
  #dock, #step, #toast, #subtitle, .mn-card, .bk-card, .ob-card, .al-card { background: #f8f3ea; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .pack-bag { animation: none; }
}

/* 触屏：手指按下时显示当前工具 */
body.touching #cursor { display: block; }
body:has(#menu.show, #book.show, #order-big.show, #poem.show, #tutorial.show, #finale.show, #finale3d.show, #exportPreview.show, #confirm.show) #cursor { display: none !important; }
body:has(#menu.show, #book.show, #order-big.show, #poem.show, #tutorial.show, #finale.show, #finale3d.show, #exportPreview.show, #confirm.show) { cursor: auto; }
body:has(#menu.show, #book.show, #order-big.show, #poem.show, #tutorial.show, #finale.show, #finale3d.show, #exportPreview.show, #confirm.show) button { cursor: pointer; }

/* =====================================================================
   手机：底部 PET 托盘
   ===================================================================== */
#tray { display: none; }
body.tray-mode #tray { display: block; position: fixed; z-index: 29; left: 10px; right: 10px;
  bottom: calc(12px + var(--dock-h) + 10px + var(--safe-b)); height: 108px; border-radius: 22px; overflow: hidden;
  background:
    linear-gradient(112deg, rgba(255,255,255,.55), rgba(255,255,255,0) 24%, rgba(255,255,255,0) 68%, rgba(255,255,255,.25) 82%, rgba(255,255,255,0) 94%),
    rgba(232,236,232,.94);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6), 0 14px 30px rgba(80,48,20,.28), 0 3px 8px rgba(80,48,20,.18); }
.tray-track { display: flex; align-items: center; gap: 10px; height: 88px; padding: 10px 14px 0; overflow-x: hidden; scroll-behavior: auto; }
.tray-hint { position: absolute; left: 0; right: 0; bottom: 5px; text-align: center; font-size: 10.5px; color: #8b938e; letter-spacing: .08em; pointer-events: none; }
#tray.empty .tray-hint { display: none; }
.ti { position: relative; flex: none; height: 74px; display: grid; place-items: center; border-radius: 14px;
  background: rgba(255,255,255,.55); box-shadow: inset 0 0 0 1px rgba(60,80,85,.1), 0 1px 0 rgba(255,255,255,.8);
  transition: opacity .25s, transform .25s; touch-action: none; }
.ti img { max-width: calc(100% - 12px); max-height: 60px; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(40,25,10,.35)); }
.ti-n { position: absolute; left: 6px; top: 4px; font-size: 9px; color: #8b938e; font-variant-numeric: tabular-nums; }
.ti.taken { opacity: .28; transform: scale(.94); }
.ti.taken img { opacity: 0; }
.ti.enter { animation: ti-in .45s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes ti-in { from { opacity: 0; transform: translateX(40px) scale(.9); } }
.ti:active { transform: scale(.96); }
.guide.hint { opacity: 1 !important; animation: g-hint .5s ease-in-out 3 !important;
  filter: drop-shadow(0 0 1.5px #f6c14b) drop-shadow(0 0 5px #f6c14b) brightness(1.4); }
@keyframes g-hint { 50% { opacity: .2; } }
body.tray-mode #sheets { display: none; }
.dock-fit { display: none; }
body.tray-mode #minimap { display: none; }
body.tray-mode .dock-fit { display: block; flex: none; height: 54px; padding: 0 16px; border: 0; border-radius: 999px; background: rgba(96,64,32,.07); color: var(--tx); font-size: 13px; }
body.tray-mode #subtitle { bottom: calc(12px + var(--dock-h) + 130px + var(--safe-b)); }
body.viewing #tray { display: none !important; }

/* =====================================================================
   扩展功能
   ===================================================================== */

/* ---------- 夜景模式 ---------- */
body.night #boardPane { background: #1a2233; }
body.night #boardPane::after {
  background:
    radial-gradient(ellipse 80% 70% at 30% 20%, rgba(120,160,255,.10), transparent 60%),
    radial-gradient(ellipse 130% 100% at 50% 50%, transparent 40%, rgba(4,8,20,.72) 100%); }
body.night #board-print { filter: brightness(.62) saturate(.72) hue-rotate(18deg) contrast(1.05); }
body.night .board-gloss { background: linear-gradient(115deg, rgba(160,190,255,.06), transparent 40%, transparent 70%, rgba(160,190,255,.04)); }
/* 灯笼亮起来 */
body.night .stk[data-lantern] .front { filter: drop-shadow(0 0 6px rgba(255,196,110,.95)) drop-shadow(0 0 16px rgba(255,150,60,.6)) brightness(1.25); }
body.night .stk[data-lantern] .in::after { content: ""; position: absolute; inset: -30%; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255,190,100,.5), rgba(255,150,60,.12) 45%, transparent 70%);
  mix-blend-mode: screen; animation: lantern-flicker 3.4s ease-in-out infinite; }
@keyframes lantern-flicker { 0%,100% { opacity: .75; } 42% { opacity: 1; } 58% { opacity: .86; } 71% { opacity: 1; } }
/* 窗户透光 */
body.night .stk[data-window] .front { filter: drop-shadow(0 0 5px rgba(255,220,150,.8)) brightness(1.35) saturate(1.1); }
body.night #step .st-name { color: #ffe6b8; }
/* 天水融成一片 */
body.night #board::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 46%; pointer-events: none; z-index: 4999;
  background: linear-gradient(180deg, transparent, rgba(90,130,200,.16) 55%, rgba(180,200,240,.22)); mix-blend-mode: screen; }

/* ---------- 3D 终章 ---------- */
#finale3d { position: fixed; inset: 0; z-index: 74; display: none; }
#finale3d.show { display: block; }
.f3-stage { position: absolute; inset: 0; display: grid; place-items: center; perspective: 1800px; perspective-origin: 50% 42%;
  background: radial-gradient(ellipse 70% 55% at 50% 38%, rgba(60,40,80,.55), rgba(8,6,16,.92) 75%); overflow: hidden; }
.f3-sky { position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 68% 30%, rgba(255,150,90,.5), transparent 60%),
    radial-gradient(ellipse 40% 30% at 30% 26%, rgba(255,190,120,.32), transparent 65%),
    linear-gradient(180deg, #2a1f3d 0%, #6b3f5a 42%, #c97a52 68%, #e8a05c 100%); }
.f3-water { position: absolute; left: 0; right: 0; bottom: 0; height: 34%; pointer-events: none;
  background: linear-gradient(180deg, rgba(232,160,92,.1), rgba(90,70,110,.55) 40%, rgba(20,16,40,.9));
  mix-blend-mode: screen; }
.f3-board { position: relative; width: 900px; height: 598px; transform-style: preserve-3d; will-change: transform;
  box-shadow: 0 40px 90px rgba(0,0,0,.6); border-radius: 6px; }
.f3-board img { position: absolute; border-radius: 6px; }
.f3-board .f3-print { position: absolute; inset: 0; border-radius: 6px; background-size: 100% 100%;
  box-shadow: 0 1px 1px rgba(70,40,14,.28); }
.f3-stk { position: absolute; transform-style: preserve-3d; will-change: transform; }
.f3-stk img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-radius: 0; filter: drop-shadow(0 2px 2px rgba(40,25,10,.4)); }
.f3-stk.lantern img { filter: drop-shadow(0 0 8px rgba(255,196,110,.95)) drop-shadow(0 0 20px rgba(255,150,60,.65)) brightness(1.3); }
.f3-stk.walkers { animation: f3-walk 5.5s ease-in-out infinite; }
@keyframes f3-walk { 0%,100% { margin-left: 0; } 50% { margin-left: 16px; } }
.f3-hint { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); z-index: 3;
  padding: 7px 16px; border-radius: 999px; background: var(--glass); color: var(--tx); font-size: 13px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: inset 0 0 0 1px var(--glass-line); }
.f3-btns { position: fixed; left: 50%; bottom: calc(56px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 10px; z-index: 3; }
.f3-btns button { white-space: nowrap; border: 0; border-radius: 22px; padding: 11px 18px; font-size: 15px; font-family: var(--ui);
  background: var(--glass); color: var(--tx); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px var(--glass-line), 0 6px 16px rgba(0,0,0,.35); }
.f3-btns button.main { background: var(--cinnabar); color: #fff6ea; }
/* 落霞孤鹜飞过 */
.f3-duck { position: absolute; left: -140px; top: 26%; width: 120px; height: 74px; pointer-events: none;
  background: radial-gradient(ellipse 40% 55% at 50% 50%, rgba(255,236,190,.85), rgba(255,180,120,.25) 55%, transparent 72%);
  -webkit-mask: radial-gradient(ellipse 40% 55% at 50% 50%, #000 40%, transparent 72%);
  mask: radial-gradient(ellipse 40% 55% at 50% 50%, #000 40%, transparent 72%);
  animation: f3-fly 16s linear infinite; }
.f3-duck::after { content: ""; position: absolute; left: 18%; top: 34%; width: 64%; height: 32%;
  background: radial-gradient(ellipse at 50% 50%, rgba(255,246,220,.95), transparent 70%); border-radius: 50%; }
@keyframes f3-fly { 0% { transform: translate(0,0) scale(.85); opacity: 0; } 8% { opacity: 1; } 50% { transform: translate(100vw,-9vh) scale(1.05); } 92% { opacity: 1; } 100% { transform: translate(210vw,-16vh) scale(1.2); opacity: 0; } }

/* ---------- 收纳册 ---------- */
.al-card { width: min(860px, 100%); max-height: 84vh; overflow: auto; padding: 20px 22px calc(20px + var(--safe-b)); touch-action: pan-y; }
.al-binder { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 12px; }
.al-page { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; background:
    linear-gradient(160deg, #fbf7ee, #efe6d4); box-shadow: inset 0 0 0 1px rgba(150,105,50,.2), 0 4px 10px rgba(80,48,20,.16);
  display: grid; place-items: center; padding: 12px; overflow: hidden; }
.al-page::before { content: ""; position: absolute; left: 8px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: rgba(150,105,50,.35); box-shadow: 0 -46px 0 rgba(150,105,50,.3), 0 46px 0 rgba(150,105,50,.3); }
.al-page.filled::before { background: var(--cinnabar); box-shadow: 0 -46px 0 rgba(192,72,47,.6), 0 46px 0 rgba(192,72,47,.6); }
.al-page img { max-width: 100%; max-height: 74%; object-fit: contain; filter: drop-shadow(0 3px 5px rgba(70,40,14,.28)); }
.al-name { position: absolute; left: 0; right: 0; bottom: 9px; text-align: center; font-size: 11px; color: var(--tx-2); letter-spacing: .06em; }
.al-empty { color: #b9a88e; font-size: 13px; }
.al-progress { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; font-size: 13px; color: var(--tx-2); }
.al-progress .bar { flex: 1; height: 5px; border-radius: 3px; background: rgba(96,64,32,.12); overflow: hidden; }
.al-progress .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cinnabar), #e08a5a); transition: width .5s; }

/* ---------- 新手引导 ---------- */
#tutorial { position: fixed; inset: 0; z-index: 84; display: none; place-items: center; background: rgba(20,12,6,.66); padding: 20px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#tutorial.show { display: grid; }
.tu-card { width: min(520px, 100%); max-height: 88vh; overflow: auto; border-radius: 22px; padding: 24px 24px calc(24px + var(--safe-b));
  background: rgba(252,248,241,.97); color: var(--tx); box-shadow: 0 24px 60px rgba(0,0,0,.45); animation: up .4s cubic-bezier(.2,.8,.2,1); }
.tu-card h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: .12em; font-family: var(--kai); }
.tu-card .tu-sub { color: var(--cinnabar); font-size: 13px; letter-spacing: .2em; margin-bottom: 16px; }
.tu-row { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid rgba(96,64,32,.1); align-items: flex-start; }
.tu-row .ic { flex: none; width: 42px; height: 42px; border-radius: 12px; background: rgba(96,64,32,.07); display: grid; place-items: center;
  font-size: 20px; color: var(--cinnabar); }
.tu-row b { display: block; font-size: 15px; margin-bottom: 2px; font-weight: 600; }
.tu-row p { margin: 0; font-size: 13px; color: var(--tx-2); line-height: 1.5; }
.tu-keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tu-keys span { font-size: 11px; padding: 4px 9px; border-radius: 8px; background: rgba(96,64,32,.06); color: var(--tx-2);
  border: 1px solid rgba(96,64,32,.1); }
.tu-go { margin-top: 18px; width: 100%; border: 0; border-radius: 16px; padding: 15px; font-size: 16px; font-family: var(--ui);
  background: var(--cinnabar); color: #fff6ea; }

/* ---------- 导出预览 ---------- */
#exportPreview { position: fixed; inset: 0; z-index: 83; display: none; place-items: center; background: rgba(20,12,6,.7); padding: 20px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#exportPreview.show { display: grid; }
.ep-card { width: min(760px, 100%); border-radius: 18px; overflow: hidden; background: #fbf7ee; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.ep-card img { display: block; width: 100%; height: auto; }
.ep-btns { display: flex; gap: 10px; padding: 14px 16px calc(14px + var(--safe-b)); }
.ep-btns button { flex: 1; border: 0; border-radius: 14px; padding: 13px; font-size: 15px; font-family: var(--ui); background: rgba(96,64,32,.08); color: var(--tx); }
.ep-btns button.main { background: var(--cinnabar); color: #fff6ea; }

/* ---------- 统计 chip ---------- */
#stats { position: absolute; left: 12px; bottom: calc(12px + var(--dock-h) + 10px + var(--safe-b)); z-index: 21;
  display: flex; gap: 8px; font-size: 11px; color: var(--tx-2); pointer-events: none; }
#stats span { padding: 4px 10px; border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font-variant-numeric: tabular-nums; }
@media (max-width: 680px) { #stats { display: none; } }

/* 叠层立体感：贴到底卡上的贴纸按图层抬高，投影随层数变长，视线偏移时上层挪得更多 */
#board-stickers .stk:not(.held):not(.wrong)::after { background: rgba(40,25,10,.3);
  filter: blur(calc(.8px + var(--d, 0) * .45px)); transform: translate(calc(var(--d, 0) * .16px), calc(.6px + var(--d, 0) * .42px)); }

/* ---------- 手机端 ---------- */
/* 引导卡：内容自己滚，「开始贴」始终留在卡片底部看得见 */
.tu-card { display: flex; flex-direction: column; overflow: hidden; max-height: min(88vh, 88dvh); }
.tu-card .tu-body { overflow: auto; min-height: 0; }
.tu-card .tu-go { flex: none; }
/* 窄屏：步骤条靠左，让开右上角的撤销 / 重做 */
@media (max-width: 560px) {
  #hud { align-items: flex-start; right: 100px; }
  #step { max-width: 100%; }
  #step .st-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tu-card { padding: 20px 18px calc(18px + var(--safe-b)); }
}
/* 贴完以后托盘是空的，收起来 */
body.tray-mode #tray.empty { display: none; }
/* 终章按钮：窄屏换行，不出屏 */
@media (max-width: 680px) {
  .fn-btns { flex-wrap: wrap; justify-content: center; width: calc(100vw - 28px); gap: 8px; }
  .fn-btns button { padding: 10px 15px; font-size: 14px; }
  body.tray-mode .fn-btns { bottom: calc(12px + var(--dock-h) + 18px + var(--safe-b)); }
}
/* 3D 终章：底卡比屏幕宽的时候也居中 */
.f3-board { position: absolute; left: 50%; top: 45%; margin: -299px 0 0 -450px; }

/* ---------- 贴近实物 ---------- */
/* 离型底纸是透明的：能透出下面的桌面 */
.sheet { background:
    linear-gradient(115deg, rgba(255,255,255,.5), rgba(255,255,255,0) 26%, rgba(255,255,255,0) 66%, rgba(255,255,255,.24) 80%, rgba(255,255,255,0) 92%),
    rgba(246,249,246,.3);
  box-shadow: 0 0 0 1px rgba(255,255,255,.6) inset, 0 1px 2px rgba(70,40,14,.14), 0 10px 20px rgba(70,40,14,.2); }
.sheet .sheet-head { color: #5d655f; }
.slot .liner { background: rgba(255,255,255,.2); }
.slot .cut { background: rgba(50,60,60,.2); }
/* 反复揭贴：泛白、翘边 */
.stk.curl1 .front { filter: brightness(1.05) saturate(.9); }
.stk.curl2 .front { filter: brightness(1.12) saturate(.74) contrast(.94); }

/* 夹起零件时底纸弯一下 */
.sheet.flex { animation: sheet-flex .42s ease-out; }
@keyframes sheet-flex { 35% { transform: perspective(1400px) rotateX(6deg) scaleY(.985); } }
/* 贴完装进分层相框：木框立在最前面一层，侧着看能看到贴纸叠出来的厚度 */
.f3-frame { position: absolute; inset: -26px; border: 26px solid #6b4a2f; border-radius: 4px; pointer-events: none;
  border-image: linear-gradient(135deg, #8a6240, #5a3c24 45%, #7a5536 70%, #4a301c) 1;
  box-shadow: 0 0 0 1px rgba(40,24,12,.6), inset 0 0 0 1px rgba(30,18,8,.55), inset 0 0 26px rgba(20,10,4,.4), 0 26px 50px rgba(0,0,0,.45); }
.f3-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(112deg, rgba(255,255,255,.2), rgba(255,255,255,0) 28%, rgba(255,255,255,0) 62%, rgba(255,255,255,.1) 76%, rgba(255,255,255,0)); }

/* 底部坞：图鉴入口 */
.dock-book { flex: none; padding: 0 24px; height: 54px; border: 0; border-radius: 999px; background: rgba(96,64,32,.07); color: var(--tx);
  font: 500 13px var(--ui); letter-spacing: .1em; }
.dock-book:active { transform: scale(.96); }
#dock .dock-tools { flex: none; }
/* 坞按内容宽度居中；用 left/right + margin 居中，left:50% 会把可用宽度砍成半屏 */
#dock { left: 0; right: 0; margin: 0 auto; transform: none; width: max-content; max-width: calc(100vw - 20px); }

/* 测试项只在网址带 ?debug 时出现 */
.mn-debug { display: none; }
body.debug .mn-debug { display: block; }
.dock-book .book-n { font-weight: 400; color: var(--tx-2); margin-left: 3px; font-variant-numeric: tabular-nums; }
/* 贴完时报一次用时 */
.fn-time { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--dock-h) + 74px + var(--safe-b)); color: #fff6ea; font: 500 13px var(--ui); letter-spacing: .12em;
  text-shadow: 0 1px 6px rgba(40,20,8,.6); opacity: 0; animation: fade .6s 3.2s forwards; white-space: nowrap; }
@media (max-width: 680px) { .fn-time { bottom: calc(12px + var(--dock-h) + 118px + var(--safe-b)); } }

/* ---------- 分层款：底卡 + 两张透明卡 ---------- */
/* 三张卡叠在同一个位置。视线偏一点，上面的卡整张跟着挪；点「摊开看」时三张错开 */
.card-layer { position: absolute; inset: 0; isolation: isolate; --cd: calc(var(--cn) * 3);
  translate: calc(var(--px, 0) * var(--cd) * 1px + var(--fan, 0) * var(--cn) * var(--fanx, 78px)) calc(var(--py, 0) * var(--cd) * 1px - var(--fan, 0) * var(--cn) * var(--fany, 52px));
  transition: translate .45s cubic-bezier(.3,0,.2,1), opacity .45s, transform .65s cubic-bezier(.2,.9,.3,1); }
.card-layer > * { position: absolute; inset: 0; }
/* 透明卡还没用到的时候不在桌上；用到时从右上方盖下来 */
.card-layer:not(.on) { opacity: 0; transform: translate(260px, -40px) rotate(5deg) scale(.86); pointer-events: none; }
.film { border-radius: 4px; pointer-events: none;
  background: linear-gradient(112deg, rgba(255,255,255,.2), rgba(255,255,255,0) 22%, rgba(255,255,255,0) 58%, rgba(255,255,255,.12) 72%, rgba(255,255,255,0) 86%), rgba(232,243,246,.04);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6), 0 1px 2px rgba(40,25,10,.22), 0 calc(var(--cn) * 3px) calc(var(--cn) * 7px) rgba(40,25,10,.14);
  transition: background .4s; }
/* 卡角的标签：哪张是哪张 */
.film-tab { position: absolute; top: -13px; right: calc(16px + (var(--cn) - 1) * 62px); padding: 2px 8px 3px; border-radius: 4px 4px 0 0;
  font: 500 8px var(--ui); letter-spacing: .1em; color: #fff; white-space: nowrap; }
.guide.tint { -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.no-guides .guides, body.viewing .guides { opacity: 0; }
body.viewing .film-tab { opacity: 0; }
/* 摊开看 */
/* 相框里的透明卡 */
.f3-film { position: absolute; inset: 0; border-radius: 4px; pointer-events: none;
  background: linear-gradient(112deg, rgba(255,255,255,.16), rgba(255,255,255,0) 26%, rgba(255,255,255,0) 60%, rgba(255,255,255,.1) 74%, rgba(255,255,255,0));
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.55); }
/* 手机屏窄：摊开时主要往上错，少往右错 */
body.tray-mode #board-stickers { --fanx: 24px; --fany: 84px; }

/* 贴纸页上的贴纸是实心的；还没轮到的只是颜色淡一点。揭走以后，底纸上留下一块白色的形状 */
.slot .liner { background: #f7f8f5; }
.slot .cut { background: rgba(60,70,66,.28); }

/* ---------- 透明卡架 ---------- */
/* 宽屏：竖着摆在底卡右边。窄屏：横着摆在步骤条下面 */
#rack { position: fixed; z-index: 28; right: 18px; top: 50%; transform: translateY(-60%); display: flex; flex-direction: column; gap: 14px; }
.rk { position: relative; display: grid; grid-template-columns: auto; justify-items: center; gap: 5px; padding: 10px 12px 9px; border: 0; border-radius: 16px; cursor: grab; touch-action: none;
  background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-line), 0 8px 18px rgba(80,48,20,.2); color: var(--tx); font-family: var(--ui);
  transition: transform .25s cubic-bezier(.3,1.4,.5,1), box-shadow .25s; }
.rk:active { cursor: grabbing; transform: scale(.97); }
/* 小卡片：一张带反光的透明片，边上是这张卡定位线的颜色 */
.rk-card { display: block; width: 116px; aspect-ratio: 900 / 598; border-radius: 4px;
  background: linear-gradient(112deg, rgba(255,255,255,.75), rgba(255,255,255,.12) 30%, rgba(255,255,255,.06) 60%, rgba(255,255,255,.45) 76%, rgba(255,255,255,.1)), rgba(226,238,242,.4);
  box-shadow: inset 0 0 0 1.5px var(--cc), 0 3px 7px rgba(60,40,20,.22); transition: opacity .3s, transform .35s cubic-bezier(.3,1.4,.5,1); }
.rk-name { font-size: 13px; font-weight: 600; letter-spacing: .08em; white-space: nowrap; }
.rk-state { font-size: 11px; color: var(--tx-2); white-space: nowrap; }
/* 盖上以后，架子上只剩一个空位 */
.rk.on .rk-card { opacity: .28; transform: scale(.9); box-shadow: inset 0 0 0 1.5px var(--cc); background: transparent; border-style: dashed; }
/* 轮到这张卡了：晃一晃提醒 */
.rk.want { box-shadow: inset 0 0 0 2px var(--cc), 0 10px 22px rgba(80,48,20,.28); animation: rk-want 1.6s ease-in-out infinite; }
.rk.want .rk-state { color: var(--cc); font-weight: 600; }
@keyframes rk-want { 50% { transform: translateX(-7px); } }
.rk.nudge { animation: rk-nudge .5s ease-in-out 2; }
@keyframes rk-nudge { 25% { transform: translateX(-10px) scale(1.05); } 75% { transform: translateX(4px) scale(1.05); } }
/* 拖着走的那张卡 */
.rk-ghost { position: fixed; left: 0; top: 0; z-index: 95; pointer-events: none; border-radius: 6px;
  background: linear-gradient(112deg, rgba(255,255,255,.6), rgba(255,255,255,.08) 30%, rgba(255,255,255,.05) 60%, rgba(255,255,255,.35) 76%, rgba(255,255,255,.08)), rgba(226,238,242,.28);
  box-shadow: inset 0 0 0 2px var(--cc), 0 18px 30px rgba(40,25,10,.35); }
body:has(#pack:not(.gone)) #rack, body.viewing #rack { display: none; }
@media (max-width: 760px), (orientation: portrait) {
  #rack { right: auto; left: 50%; top: calc(56px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); flex-direction: row; gap: 8px; }
  .rk { grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 8px; row-gap: 1px; justify-items: start; align-items: center; padding: 7px 11px 7px 8px; border-radius: 14px; }
  .rk-card { width: 44px; grid-row: 1 / 3; }
  .rk-name { font-size: 12px; align-self: end; }
  .rk-state { font-size: 10px; align-self: start; }
  @keyframes rk-want { 50% { transform: translateY(5px); } }
}
/* 电脑上的托盘：居中，不铺满整个屏幕 */
@media (min-width: 761px) and (orientation: landscape) {
  body.tray-mode #tray { left: 50%; right: auto; width: min(760px, calc(100vw - 280px)); transform: translateX(-50%); }
}

/* ====================================================================
   底卡 + 一张透明贴纸页
   ==================================================================== */
#rack, .film { display: none !important; }
:root { --tray-h: 0px; }
/* 贴纸页：一张透明的 PET 片，贴纸排在上面。紧挨在底卡下面 */
body.tray-mode #tray { display: block; left: 50%; right: auto; transform: translateX(-50%); width: min(760px, calc(100vw - 20px)); height: auto; overflow: visible;
  border-radius: 12px; padding: 20px 12px 12px;
  background: linear-gradient(112deg, rgba(255,255,255,.5), rgba(255,255,255,.04) 26%, rgba(255,255,255,0) 62%, rgba(255,255,255,.26) 78%, rgba(255,255,255,.03) 92%), rgba(244,249,248,.34);
  -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.75), inset 0 0 22px rgba(255,255,255,.12), 0 2px 3px rgba(70,40,14,.16), 0 12px 24px rgba(70,40,14,.24); }
body.tray-mode #tray.empty { display: none; }
.tray-head { position: absolute; left: 14px; top: 5px; font: 500 10px var(--ui); letter-spacing: .12em; color: #5d655f; pointer-events: none; }
.tray-track { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px; height: auto; padding: 0; overflow: visible; }
/* 一片贴纸：实心的，直接放在透明片上，没有格子 */
.ti { position: relative; flex: none; height: 62px; display: grid; place-items: center; background: none; box-shadow: none; border-radius: 0; touch-action: none; cursor: grab;
  transition: transform .2s cubic-bezier(.3,1.4,.5,1); }
.ti img { position: relative; max-width: calc(100% - 4px); max-height: 58px; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 .6px .5px rgba(40,25,10,.4)) drop-shadow(0 2px 2.5px rgba(40,25,10,.2)); transition: opacity .15s; }
.ti:active { transform: scale(.96); }
/* 揭走以后留在页上的白色形状 */
.ti-slot { position: absolute; inset: 0; opacity: 0; background: #f8f9f6; pointer-events: none;
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat;
  -webkit-mask-size: calc(100% - 4px) 58px; mask-size: calc(100% - 4px) 58px; filter: drop-shadow(0 0 .6px rgba(60,70,66,.7)); }
.ti.taken { opacity: 1; transform: none; cursor: default; }
/* 揭走后的空位：就用贴纸图本身压成白色剪影，形状、大小和贴纸一模一样（原来单独画的白块尺寸写死，会大一圈） */
.ti.taken img { opacity: .6; filter: brightness(0) invert(.985) drop-shadow(0 0 .6px rgba(60,70,66,.55)); }
.ti.taken .ti-slot { opacity: 0; }
/* 点了一下、被镊子夹住的那一片：翘起来 */
.ti.picked { transform: translateY(-9px) rotate(-4deg) scale(1.08); }
.ti.picked img { filter: drop-shadow(0 1px 1px rgba(40,25,10,.4)) drop-shadow(0 9px 8px rgba(40,25,10,.3)); }
.ti.enter { animation: ti-in .45s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes ti-in { from { opacity: 0; transform: translateY(18px) scale(.92); } }
/* 夹住的那片该去的位置：一直亮着 */
.guide.picked { opacity: 1 !important; animation: g-pulse 1.1s ease-in-out infinite !important;
  filter: drop-shadow(0 0 1.5px #f6c14b) drop-shadow(0 0 6px #f6c14b) brightness(1.35); }
/* 字幕、终章按钮在贴纸页上面 */
body.tray-mode #subtitle { bottom: calc(12px + var(--dock-h) + var(--tray-h) + 24px + var(--safe-b)); }
/* 按住看成品 */
#preview { position: absolute; inset: 0; z-index: 4000; opacity: 0; pointer-events: none; transition: opacity .18s; }
#preview img { position: absolute; }
body.peek #preview { opacity: 1; }
body.peek .guides, body.peek #board-guides { opacity: 0; }
body.peek #tray { opacity: .35; }
/* 贴完一张贴纸页：底卡侧一下 */
#board.tiltfx { animation: board-tilt 1.4s cubic-bezier(.4,0,.3,1); }
@keyframes board-tilt { 0%, 100% { transform: perspective(1500px) rotateX(0) rotateY(0); } 45% { transform: perspective(1500px) rotateX(5deg) rotateY(-9deg); } }
@media (max-width: 560px) {
  .ti { height: 54px; } .ti img { max-height: 50px; } .ti-slot { -webkit-mask-size: calc(100% - 4px) 50px; mask-size: calc(100% - 4px) 50px; }
  body.tray-mode #tray { padding: 18px 8px 9px; }
}

/* ---------- 翻页 ---------- */
body.tray-mode #tray { padding-top: 10px; }
.tray-pager { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 0 4px; }
.tray-pager button { flex: none; width: 40px; height: 34px; border: 0; border-radius: 10px; background: rgba(255,255,255,.55); color: var(--tx);
  font: 400 22px/1 var(--ui); box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 1px 2px rgba(70,40,14,.14); }
.tray-pager button:active { transform: scale(.94); }
.tray-pager button:disabled { opacity: .3; }
.pg-label { flex: 1; text-align: center; font: 500 11px var(--ui); letter-spacing: .08em; color: var(--tx-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-label b { display: block; font: 600 14px var(--kai); letter-spacing: .12em; color: var(--tx); margin-top: 1px; }
.pg-dots { display: flex; justify-content: center; gap: 5px; margin: 0 0 8px; }
.pg-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(96,64,32,.2); }
.pg-dots i.full { background: rgba(96,64,32,.5); }
.pg-dots i.on { background: var(--cinnabar); transform: scale(1.25); }
.tray-track.slide-l { animation: pg-l .32s cubic-bezier(.2,.8,.3,1); }
.tray-track.slide-r { animation: pg-r .32s cubic-bezier(.2,.8,.3,1); }
@keyframes pg-l { from { opacity: 0; transform: translateX(40px); } }
@keyframes pg-r { from { opacity: 0; transform: translateX(-40px); } }
/* 横屏：贴纸页竖在右边 */
body.tray-mode #tray.side { left: auto; right: 14px; transform: none; width: clamp(230px, 26vw, 330px);
  top: calc(64px + env(safe-area-inset-top, 0px)); bottom: calc(12px + var(--dock-h) + 14px + var(--safe-b)); overflow-y: auto; overflow-x: hidden; }
#tray.side .tray-track { gap: 10px 10px; }
#tray.side .ti { height: 70px; }
#tray.side .ti img { max-height: 66px; }
#tray.side .ti-slot { -webkit-mask-size: calc(100% - 4px) 66px; mask-size: calc(100% - 4px) 66px; }
body.tray-mode:has(#tray.side) #subtitle { bottom: calc(var(--dock-h) + 26px + var(--safe-b)); }

/* ---------- 手感：揭起、对位、落下、抹平 ---------- */
/* 夹着的贴纸：离定位线越近放得越低，投影越短越实 */
.stk.held::after { transform: translateY(calc(14px - 7px * var(--low, 0))); filter: blur(calc(9px - 4px * var(--low, 0))); }
/* 刚贴好：一道光从膜面上抹过去，像指腹把它压实。光只落在贴纸本身（按贴纸外形裁），不露出方形 */
.stk.smooth .front::after { opacity: .75; transition: none;
  background: linear-gradient(115deg, transparent 0%, transparent 38%, rgba(255,255,255,.85) 50%, transparent 62%, transparent 100%);
  background-size: 300% 100%; animation: smooth-sweep .6s cubic-bezier(.4,0,.3,1) forwards;
  -webkit-mask: var(--mask) center / 100% 100% no-repeat; mask: var(--mask) center / 100% 100% no-repeat; }
@keyframes smooth-sweep { from { background-position: 100% 0; } to { background-position: 0% 0; opacity: 0; } }
#board-stickers .stk.fly::after { filter: blur(4px); transform: translateY(5px); }

/* ---------- 11-30 桌面换胡桃木（无限桌面，跟着镜头走） ---------- */
:root { --wood: url("art/wood/walnut.jpg?v=2"); }
html, body { background: #4a2e1c; }
#boardPane { background-color: #4a2e1c; background-image: var(--wood); }
#pack { background: var(--wood) center / 900px #4a2e1c; }
/* 胡桃木偏暗：桌面上的光再柔一点，四角压暗少一点 */
#boardPane::after { background:
    radial-gradient(ellipse 80% 70% at 30% 20%, rgba(255,236,206,.16), transparent 60%),
    radial-gradient(ellipse 130% 100% at 50% 50%, transparent 62%, rgba(20,10,4,.3) 100%); }

/* ---------- 11-30 第二版胡桃木：油蜡、浅中棕、细软山纹（上一张太黑太粗） ---------- */
:root { --wood: url("art/wood/walnut.jpg?v=3"); }
html, body { background: #8d6545; }
#boardPane { background-color: #8d6545; }
#pack { background: var(--wood) center / 900px #8d6545; }
#boardPane::after { background:
    radial-gradient(ellipse 80% 70% at 30% 20%, rgba(255,246,228,.18), transparent 60%),
    radial-gradient(ellipse 130% 100% at 50% 50%, transparent 62%, rgba(60,34,14,.22) 100%); }

/* ---------- 放大后清晰（11-30） ---------- */
/* will-change: transform 会让浏览器按开始那一刻的大小把整层画成一张位图，之后放大只是把位图拉伸，所以糊。
   平时不加；只在拖动 / 缩放进行中由脚本临时加上，停下来就去掉，浏览器按新倍数重画一遍。 */
.cam { will-change: auto; }
.stk { will-change: auto; }
.stk.held { will-change: transform; }

/* 换一个造景 */
.kit-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 10px; }
.kit-item { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.6); color: var(--tx); text-decoration: none; box-shadow: inset 0 0 0 1px var(--glass-line); }
.kit-item img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; }
.kit-item small { color: var(--tx-2); font-size: 12px; }
.kit-item.cur { box-shadow: inset 0 0 0 2px var(--cinnabar); }

/* 揭的阶段：贴纸大半还粘在页上，不能有整片拿起来的投影（会像外面多一圈灰白），只有翻起那块投一点小影子 */
.stk.peel-stuck::after, #board-stickers .stk.peel-stuck::after { opacity: 0 !important; }
.stk.peel-stuck .corner-peel .face { filter: drop-shadow(0 1.5px 1.5px rgba(20,10,0,.28)); }
.stk.peel-stuck .front::after { opacity: 0 !important; }

/* ---------- 界面减法：常用的露出来，不常用的进「更多」，用不上的不显示 ---------- */
/* 撤销、重做：能用的时候才出现（重做只在撤销过之后出现） */
#history button:disabled { display: none; }
/* 「全图」只在放大或拖动过画面之后出现 */
body:not(.off-fit) .dock-fit { display: none !important; }
.mn-card .mn-danger { color: #b0412e; }
/* 还没动过鼠标时镊子不显示（不然停在左上角） */
#cursor { visibility: hidden; }
body.moved #cursor, body.touching #cursor { visibility: visible; }

/* 3D 相框的四面内壁：从底卡一直围到前框，斜着看时挡住框外，卡片不会探出相框 */
.f3-wall { position: absolute; pointer-events: none; transform-origin: 0 0; background: linear-gradient(90deg, #4f3520, #6b4a2f); }
.f3-wall.l { left: 0; top: 0; width: var(--d); height: 100%; transform: rotateY(-90deg); }
.f3-wall.r { left: 100%; top: 0; width: var(--d); height: 100%; transform: rotateY(-90deg); }
.f3-wall.t { left: 0; top: 0; width: 100%; height: var(--d); transform: rotateX(90deg); background: linear-gradient(180deg, #4f3520, #6b4a2f); }
.f3-wall.b { left: 0; top: 100%; width: 100%; height: var(--d); transform: rotateX(90deg); background: linear-gradient(180deg, #4f3520, #6b4a2f); }

/* 二次确认：和「更多」菜单同一种底部卡片 */
#confirm { position: fixed; inset: 0; z-index: 96; display: none; align-items: flex-end; justify-content: center; background: rgba(40,28,16,.28); }
#confirm.show { display: flex; }
.cf-card p { margin: 4px 4px 6px; font-size: 15px; line-height: 1.6; color: var(--tx); }
.cf-card button { text-align: center; }

@media (max-width: 520px) { .fn-text { font-size: clamp(20px, 5.2vw, 26px); letter-spacing: .22em; line-height: 1.75; } }

/* 用鼠标玩的时候只显示镊子：贴纸页上的贴纸、空位都不能再冒出系统的手形 / 箭头光标 */
@media (hover: hover) and (pointer: fine) {
  .ti, .ti.taken, .ti img, #app, #app * { cursor: none; }
  body:has(#menu.show, #book.show, #order-big.show, #poem.show, #tutorial.show, #finale.show, #finale3d.show, #exportPreview.show, #confirm.show) #app * { cursor: auto; }
}

/* 拿在手上的贴纸不提前定格成图像：从托盘的小尺寸放大到底卡尺寸时，浏览器要按新尺寸重新画，不然发糊 */
.stk.held { will-change: auto !important; }

/* 拿在手上：只留一点很淡的膜面反光，不把颜色冲灰 */
.stk.held .front::after { opacity: .1; }
.stk.held.peel-stuck .front::after { opacity: 0; }

/* 镊子光标：照片质感的金属镊子，下方一点柔和投影 */
#cursor .tw { position: absolute; filter: drop-shadow(2px 5px 3px rgba(30,24,16,.3)) drop-shadow(0 1px .5px rgba(30,24,16,.25)); pointer-events: none; }
#cursor .tw img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
#cursor .tw .tw-b { position: absolute; inset: 0; -webkit-mask: var(--m) 0 0 / 100% 100% no-repeat; mask: var(--m) 0 0 / 100% 100% no-repeat;
  background: linear-gradient(135deg, #8d949b 0%, #c3c8cd 40%, #9aa1a8 60%, #6f767d 100%); }

/* 手层：只在用鼠标、拆开袋子以后出现；盖住游戏（≤66），在终章、菜单、弹窗（≥72）之下 */
#hand-layer { position: fixed; inset: 0; z-index: 68; display: none; cursor: none; touch-action: none; }
body.fine.opened.tool-bent #hand-layer { display: block; }
.mn-card button[hidden] { display: none; }
/* 用鼠标时镊尖在手指左上方约 60px：托盘离右边留出这段距离，最右一列贴纸整片都能用手 1:1 对准，不用把手挤到屏幕边上 */
body.fine.tray-mode #tray.side { right: 60px; }

/* 货架：好几包造景并排，横屏一排、竖屏上下摆 */
.pack-shelf { display: flex; align-items: center; justify-content: center; gap: clamp(18px, 4vw, 56px); }
#pack.multi .pack-bag { width: min(420px, 40vw); }
#pack.multi .pack-bag.other { animation-delay: -1.7s; }
#pack.open .pack-bag.other { transform: none; opacity: 0; transition: opacity .3s; }
@media (orientation: portrait) {
  .pack-shelf { flex-direction: column; gap: 16px; }
  #pack.multi .pack-bag { width: min(330px, 76vw, 34vh * 900 / 668); }
}
