/* 折纸花窗 · Ô Cửa Hoa Giấy — 界面样式（竖屏优先；电脑横屏时三栏：托盘 | 花窗 | 目标）
 * 浅色花窗风格：奶白 / 淡紫 / 樱粉 + 金边，阳光从左上照进来。 */
:root {
  --bg-top: #fff4f8;
  --bg-mid: #f3e6fb;
  --bg-bot: #e6d8f6;
  --ink: #4a2c5e;
  --ink-2: #6d5384;
  --muted: #a08cb4;
  --gold: #e9a93a;
  --gold-2: #c9852a;
  --gold-soft: #f6d68a;
  --violet: #8a5ad8;
  --violet-2: #6d40bd;
  --rose: #ff73ad;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-2: rgba(255, 251, 255, 0.9);
  --line: rgba(138, 96, 170, 0.22);
  --shadow: 0 14px 36px rgba(110, 60, 140, 0.22);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--ink);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background:
    radial-gradient(ellipse at 8% 0%, rgba(255, 228, 160, 0.65), transparent 55%),
    radial-gradient(ellipse at 95% 25%, rgba(200, 170, 255, 0.35), transparent 50%),
    radial-gradient(ellipse at 50% 110%, rgba(255, 170, 210, 0.35), transparent 55%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 55%, var(--bg-bot));
  background-attachment: fixed;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.42; cursor: default; }
[hidden] { display: none !important; }
svg.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* GPT 背景图（竖屏 / 横屏各一张），上面压一层奶白，保证花窗和文字清晰 */
.bgArt {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 248, 252, 0.35), rgba(243, 232, 251, 0.55)), url(../assets/art/bg-portrait.jpg) center / cover no-repeat;
}
@media (orientation: landscape) {
  .bgArt { background-image: linear-gradient(180deg, rgba(255, 248, 252, 0.35), rgba(243, 232, 251, 0.55)), url(../assets/art/bg-landscape.jpg); }
}
#fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
#app { position: fixed; inset: 0; max-width: 640px; margin: 0 auto; z-index: 2; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 14px calc(10px + var(--safe-b)); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 22px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  font-weight: 800; font-size: 15px; letter-spacing: 0.2px;
  box-shadow: 0 8px 20px rgba(110, 60, 140, 0.16);
}
.btn.primary {
  border: 1px solid rgba(255, 220, 140, 0.9); color: #fffaf0;
  background: linear-gradient(180deg, #b791f3, var(--violet) 55%, var(--violet-2));
  box-shadow: 0 10px 24px rgba(120, 70, 200, 0.32), inset 0 -3px 0 rgba(70, 30, 140, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 2px rgba(60, 20, 110, 0.4);
}
.btn.ghost { background: transparent; box-shadow: none; }
a.btn { text-decoration: none; }
.btn.lg { min-height: 54px; font-size: 17px; border-radius: 18px; }
.btn:focus-visible, .iconBtn:focus-visible, .tool:focus-visible, .lvCard:focus-visible, .langSwitch button:focus-visible,
.sbtn:focus-visible, .sheetCard:focus-visible, .targetCard:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.iconBtn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.iconSpacer { width: 44px; flex: none; }
[data-act="sound"] .ico.off, [data-act="sound"].off .ico.on, [data-act="music"] .ico.off, [data-act="music"].off .ico.on { display: none; }
[data-act="sound"].off .ico.off, [data-act="music"].off .ico.off { display: block; }
.topBtns { display: flex; gap: 8px; }

/* ---------- 首页 ---------- */
.homeScreen { align-items: center; justify-content: space-between; text-align: center; }
.homeTop { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.homeTop .topBtns { margin-left: auto; }
.langSwitch { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.langSwitch button { border: 0; background: transparent; padding: 8px 14px; min-height: 36px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.langSwitch button[aria-pressed="true"] { background: linear-gradient(180deg, #b791f3, var(--violet)); color: #fff; }
.homeHero { display: flex; flex-direction: column; align-items: center; }
.logoWrap {
  width: min(48vw, 200px); aspect-ratio: 1; border-radius: 28%; overflow: hidden;
  box-shadow: 0 0 0 3px rgba(255, 230, 160, 0.95), 0 0 50px rgba(255, 200, 120, 0.55), var(--shadow);
}
.logoWrap img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.015); }
@keyframes float { 50% { transform: translateY(-8px); } }
.homeHero h1 {
  margin: 24px 0 2px; font-size: clamp(32px, 9.5vw, 48px); font-weight: 900; letter-spacing: -0.5px; line-height: 1.12;
  background: linear-gradient(180deg, #fffbe8, #ffd76a 55%, #f0a43a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #7b4cc6) drop-shadow(0 -1px 0 #7b4cc6) drop-shadow(1px 0 0 #7b4cc6) drop-shadow(-1px 0 0 #7b4cc6) drop-shadow(0 6px 14px rgba(120, 70, 200, 0.35));
}
.subtitle { margin: 12px 0 0; color: var(--ink-2); font-size: 14.5px; font-weight: 700; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.55); }
.homeActions { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 1; }
.homeProgress { margin: 4px 0 0; color: var(--gold-2); font-weight: 800; font-size: 14px; min-height: 20px; }
.homeLantern:not(.ok) { visibility: hidden; }
.homeLantern { position: absolute; right: 6px; bottom: calc(18px + var(--safe-b)); width: 74px; height: auto; pointer-events: none; opacity: 0.95;
  filter: drop-shadow(0 0 18px rgba(255, 200, 120, 0.6)); animation: sway 5s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes sway { 50% { transform: rotate(4deg); } }
.homeGuide { position: absolute; right: -6px; top: -92px; width: 96px; height: 96px; pointer-events: none; filter: drop-shadow(0 8px 12px rgba(110, 60, 140, 0.3)); animation: float 3.4s ease-in-out infinite; }

/* ---------- 引导角色：小纸鹤（可灵动图 / GPT 图 / SVG） ---------- */
.guide { display: grid; place-items: center; }
.guide img { width: 100%; height: 100%; object-fit: contain; display: block; opacity: 0; }
.guide.imgOk img { opacity: 1; }
.guide.svgMode img { display: none; }
.guide svg.crane { width: 100%; height: 100%; overflow: visible; }
.crane .body { animation: craneBob 2.8s ease-in-out infinite; transform-origin: 60px 100px; }
.crane .wingL { transform-origin: 58px 68px; animation: wingL 2.8s ease-in-out infinite; }
.crane .wingR { transform-origin: 62px 68px; animation: wingR 2.8s ease-in-out infinite; }
.crane .eye { transform-box: fill-box; transform-origin: center; animation: blink 4.2s infinite; }
@keyframes craneBob { 50% { transform: translateY(-3px); } }
@keyframes wingL { 50% { transform: rotate(-8deg); } }
@keyframes wingR { 50% { transform: rotate(8deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
.guide.cheer .crane .body { animation: craneHop 0.9s ease-in-out infinite; }
.guide.cheer .crane .wingL { animation: cheerL 0.45s ease-in-out infinite alternate; }
.guide.cheer .crane .wingR { animation: cheerR 0.45s ease-in-out infinite alternate; }
@keyframes craneHop { 30% { transform: translateY(-9px); } 60% { transform: translateY(0); } }
@keyframes cheerL { from { transform: rotate(-4deg); } to { transform: rotate(-30deg); } }
@keyframes cheerR { from { transform: rotate(4deg); } to { transform: rotate(30deg); } }

/* ---------- 顶栏 ---------- */
.hud { display: flex; align-items: center; gap: 10px; }
.hudTitle { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.hudTitle small { color: var(--gold-2); font-weight: 800; font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; }
.hudTitle strong { font-size: 18px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.levelsScreen .hudTitle small { text-transform: none; letter-spacing: 0; }

/* ---------- 选关 ---------- */
.levelGrid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px 2px 8px; align-content: start; }
.lvCard {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  min-height: 118px; padding: 12px; border-radius: 18px; border: 1px solid var(--line); overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(246, 236, 255, 0.9)); box-shadow: var(--shadow);
}
.lvCard.done { border-color: rgba(233, 169, 58, 0.6); }
.lvArt { position: absolute; right: -10px; bottom: -10px; width: 92px; height: 92px; transform: rotate(-8deg); border-radius: 8px; pointer-events: none;
  box-shadow: 0 6px 16px rgba(110, 60, 140, 0.25); }
.lvCard.done .lvArt { box-shadow: 0 6px 18px rgba(233, 169, 58, 0.45); }
.lvNum { font-size: 26px; font-weight: 900; color: var(--violet); line-height: 1; position: relative; }
.lvName { font-weight: 800; font-size: 14.5px; line-height: 1.3; position: relative; max-width: 62%; }
.lvMech { position: relative; font-size: 11px; font-weight: 800; color: #fff; background: var(--rose); padding: 2px 8px; border-radius: 999px; }
.lvStars { display: flex; gap: 2px; margin-top: auto; position: relative; }
.lvCard.locked { opacity: 0.6; background: rgba(240, 232, 248, 0.85); }
.lvCard.locked .lvNum { color: var(--muted); }
svg.lock { position: absolute; right: 12px; top: 12px; width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.star { width: 18px; height: 18px; fill: rgba(150, 110, 180, 0.15); stroke: rgba(150, 110, 180, 0.4); stroke-width: 1; stroke-linejoin: round; }
svg.star.on { fill: var(--gold); stroke: #fff2c4; filter: drop-shadow(0 0 5px rgba(240, 180, 70, 0.7)); }

/* ---------- 游戏 ---------- */
.gameScreen { padding-bottom: calc(8px + var(--safe-b)); }
.gameMain { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.infoBar { display: flex; gap: 10px; align-items: stretch; }
.targetCard {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 6px 4px; border-radius: 14px;
  border: 1px solid rgba(233, 169, 58, 0.55); background: var(--panel-2); box-shadow: 0 6px 16px rgba(110, 60, 140, 0.18);
}
.targetCard canvas { width: 88px; height: 88px; display: block; border-radius: 4px; }
.targetCard span { font-size: 11.5px; font-weight: 800; color: var(--gold-2); }
/* V004：目标图下面写明“可以点”——「Mẫu · chạm để so」，太窄时在“·”前换行 */
.targetCard .tgtLabel { max-width: 100%; text-align: center; line-height: 1.2; }
.tgtLabel b, .tgtLabel small { white-space: nowrap; }
.tgtLabel b { font-weight: 900; }
.tgtLabel small { font-size: 10.5px; font-weight: 700; color: #a8742a; }
.targetCard.on { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(233, 169, 58, 0.35); }
.infoSide { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.hudStats { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); font-weight: 700; white-space: nowrap; }
.pill b { color: var(--ink); font-size: 15px; }
.pill.match b { color: var(--violet); }
.pill.gold { color: var(--gold-2); border-color: rgba(233, 169, 58, 0.45); background: rgba(255, 249, 232, 0.85); }
/* V004：混色小图例（第 4 关起；代替原来的“对称 / 配色 / 叠层”检查项），颜色与 render.js 的 PAL 一致 */
.mixLegend { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.mixLegend[hidden] { display: none; }
.mix { display: inline-flex; align-items: center; gap: 3px; padding: 3px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.7); border: 1px solid var(--line); font-size: 12px; font-weight: 900; color: var(--muted); line-height: 1; }
.dot { width: 13px; height: 13px; border-radius: 4px; transform: rotate(45deg) scale(0.86); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 1px 2px rgba(80, 40, 110, 0.25); }
.dot.c1 { background: #ff73ad; }
.dot.c2 { background: #ffd23e; }
.dot.c3 { background: #ff9440; }
.dot.c4 { background: #46bff0; }
.dot.c5 { background: #a173ee; }
.dot.c6 { background: #4fcf8b; }
.boardWrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 2px 0; }
#board { display: block; touch-action: none; cursor: pointer; filter: drop-shadow(0 16px 30px rgba(110, 60, 140, 0.28)); }
.trayArea { display: flex; flex-direction: column; gap: 6px; }
.tray { display: grid; grid-template-columns: repeat(var(--count, 4), minmax(0, 64px)); justify-content: center; gap: 6px; }
.sheetCard {
  position: relative; aspect-ratio: 1; min-height: 48px; padding: 0; border-radius: 14px; display: grid; place-items: center;
  border: 1px solid var(--line); background: linear-gradient(170deg, rgba(255, 255, 255, 0.95), rgba(244, 234, 255, 0.92));
  box-shadow: 0 6px 14px rgba(110, 60, 140, 0.16); touch-action: none;
}
.sheetCard canvas { width: 56px; height: 56px; max-width: 88%; max-height: 88%; display: block; pointer-events: none; }
.sheetCard canvas.spin { animation: spin90 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes spin90 { from { transform: rotate(-90deg); } }
.sheetCard.sel { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(233, 169, 58, 0.45), 0 10px 20px rgba(110, 60, 140, 0.25); transform: translateY(-4px); }
.sheetCard.placed { background: rgba(240, 232, 250, 0.7); }
.sheetCard.placed canvas { opacity: 0.45; }
.sheetCard .layer { position: absolute; left: 4px; top: 3px; font-style: normal; font-size: 11px; font-weight: 900; color: var(--violet); }
/* 纸片操作栏（V004：图标 + 小字，手机矮屏和 3 条以上折线时也保留文字；一行放不下就把字折成两行） */
.sheetBar { display: flex; justify-content: center; gap: 5px; flex-wrap: nowrap; }
.sbtn {
  flex: 1 1 0; min-width: 0; max-width: 92px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; padding: 4px 3px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); font-size: 11.5px; font-weight: 800; color: var(--ink);
  line-height: 1.1; text-align: center;
}
.sbtn .ico { width: 20px; height: 20px; flex: none; }
.sbtn span { overflow-wrap: anywhere; }
.sbtn.on { background: linear-gradient(180deg, #ffe9b0, var(--gold-soft)); border-color: var(--gold); color: #6b4310; }
.sbtn.implied { border-style: dashed; border-color: var(--gold); }
.sheetBar.active .sbtn:not(:disabled) { border-color: rgba(138, 90, 216, 0.45); }
.tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 56px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel);
  font-size: 12px; font-weight: 700; color: var(--ink-2);
}
.tool .ico { width: 22px; height: 22px; color: var(--ink); }
.tool[data-act="hint"] .ico { color: var(--gold-2); }
.tool.off .ico { color: var(--muted); }
.tool span { white-space: nowrap; }
.pulse { animation: toolPulse 0.9s ease 3; }
@keyframes toolPulse { 50% { background: rgba(255, 220, 140, 0.55); border-color: var(--gold); transform: scale(1.06); } }

/* 拖动时跟着手指的纸片 */
.dragGhost { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; opacity: 0; transition: opacity 0.12s; filter: drop-shadow(0 12px 16px rgba(80, 30, 110, 0.35)); }
.dragGhost.on { opacity: 0.92; }
.dragGhost.on.over { opacity: 0.35; }
.dragGhost canvas { display: block; }

/* ---------- 弹层 ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(80, 40, 110, 0.32); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.tipCard, .winCard, .finaleCard {
  width: min(420px, 100%); border-radius: 24px; padding: 22px; text-align: center; position: relative;
  background: linear-gradient(170deg, rgba(255, 253, 248, 0.98), rgba(246, 236, 255, 0.98));
  border: 2px solid rgba(233, 169, 58, 0.6); box-shadow: var(--shadow), 0 0 50px rgba(255, 210, 130, 0.45);
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.robot { width: 96px; height: 96px; margin: -54px auto 2px; filter: drop-shadow(0 10px 14px rgba(110, 60, 140, 0.35)); animation: float 3s ease-in-out infinite; }
.tipCard, .winCard { margin-top: 34px; }
.tipBody small, .winCard small { color: var(--gold-2); font-weight: 800; font-size: 12px; letter-spacing: 1px; }
.tipBody h2, .winCard h2, .finaleCard h2 { margin: 4px 0 8px; font-size: 21px; font-weight: 900; color: var(--violet-2); }
.tipBody p, .winCard p, .finaleCard p { margin: 0 0 14px; color: var(--ink-2); line-height: 1.6; font-size: 15px; white-space: pre-line; }
.tipBody .tipRules { font-size: 13px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.7); border: 1px dashed var(--line); }
.tipCard .btn { min-width: 160px; }
.winOverlay, .finaleOverlay { position: fixed; }
.winArt { width: min(170px, 46vw); aspect-ratio: 1; margin: 6px auto 4px; border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 3px rgba(233, 169, 58, 0.75), 0 0 34px rgba(255, 200, 110, 0.55); animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.winArt canvas { width: 100%; height: 100%; display: block; }
.winStars { display: flex; justify-content: center; gap: 10px; margin: 8px 0 2px; }
.winStars svg.star { width: 48px; height: 48px; }
.winStars svg.star:nth-child(2) { transform: translateY(-10px); }
.winStars svg.star.pop { animation: starPop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.5); }
.winStars svg.star:nth-child(2).pop { animation-name: starPop2; }
@keyframes starPop { from { transform: scale(0.2) rotate(-40deg); } }
@keyframes starPop2 { from { transform: translateY(-10px) scale(0.2) rotate(-40deg); } }
.winBtns { display: flex; flex-direction: column; gap: 10px; }
.finaleCard { padding-top: 14px; }
.finaleWindow { position: relative; width: min(280px, 70vw); aspect-ratio: 1; margin: 0 auto 8px; }
.finaleGuide { position: absolute; right: -26px; bottom: -14px; width: 92px; height: 92px; filter: drop-shadow(0 8px 12px rgba(110, 60, 140, 0.35)); }
.dbgErr { position: fixed; left: 4px; right: 4px; bottom: 4px; z-index: 99; background: #b00020; color: #fff; font: 12px/1.4 monospace; padding: 6px; white-space: pre-wrap; border-radius: 6px; }
.finaleWindow canvas { width: 100%; height: 100%; display: block; }
.finaleCard h2 { font-size: 24px; background: linear-gradient(180deg, #b98af5, var(--violet-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- 提示条（V004：从托盘上方移到花窗上方，不再挡住提示里闪动的纸卡） ---------- */
.toast {
  position: fixed; left: 50%; top: calc(62px + var(--safe-t)); z-index: 40; transform: translate(-50%, -14px);
  width: max-content; max-width: min(92vw, 460px); padding: 11px 18px; border-radius: 14px;
  background: rgba(74, 44, 94, 0.94); border: 1px solid rgba(255, 220, 140, 0.55); color: #fff8ee;
  font-size: 14px; line-height: 1.5; text-align: center; white-space: pre-line; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 尺寸适配 ---------- */
@media (min-width: 560px) {
  .levelGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-height: 740px) {
  .targetCard canvas { width: 70px; height: 70px; }
  .tool { min-height: 50px; }
  .tool span { font-size: 11px; }
  .sbtn { min-height: 44px; padding: 3px 3px; font-size: 10.5px; }
  .sbtn .ico { width: 18px; height: 18px; }
  .tray { grid-template-columns: repeat(var(--count, 4), minmax(0, 54px)); }
  .sheetCard canvas { width: 46px; height: 46px; }
}
@media (max-height: 640px) {
  .homeHero h1 { margin-top: 12px; }
  .logoWrap { width: min(34vw, 120px); }
}
/* 窄手机（360px 左右）：底部工具栏与纸片操作栏的字再小一点，保证不溢出 */
@media (max-width: 400px) {
  .tools { gap: 4px; }
  .tool span { font-size: 10.5px; }
  .sheetBar { gap: 4px; }
  .sbtn { font-size: 10.5px; }
  .pill { padding: 4px 8px; font-size: 12px; }
}
/* 电脑横屏：三栏（托盘 | 花窗 | 目标），与宣传图一致 */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  #app { max-width: 1240px; }
  .gameScreen { padding: 16px 24px 14px; }
  .gameMain { display: grid; grid-template-columns: 210px minmax(0, 1fr) 230px; grid-template-areas: "tray board info"; gap: 18px; margin-top: 8px; }
  .boardWrap { grid-area: board; }
  .infoBar { grid-area: info; flex-direction: column; justify-content: center; gap: 14px; }
  .targetCard { padding: 10px 10px 8px; }
  .targetCard canvas { width: 200px; height: 200px; }
  .targetCard span { font-size: 14px; }
  .infoSide { justify-content: flex-start; }
  .mixLegend { flex-direction: column; align-items: flex-start; }
  .mix { font-size: 14px; padding: 6px 10px; gap: 5px; }
  .dot { width: 16px; height: 16px; }
  /* V004：托盘面板只包住内容（原来被拉成整列高，看起来像一大块空的半透明白板） */
  .trayArea { grid-area: tray; align-self: center; justify-content: center; gap: 12px; padding: 12px; border-radius: 22px; background: rgba(255, 255, 255, 0.45); border: 1px solid var(--line); }
  .tray { grid-template-columns: repeat(2, minmax(0, 84px)); }
  .sheetCard canvas { width: 66px; height: 66px; }
  .sheetBar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sbtn { max-width: none; min-height: 54px; padding: 6px 6px; gap: 3px; font-size: 12.5px; }
  .tools { max-width: 640px; margin: 10px auto 0; width: 100%; }
  .toast { top: 64px; }
  .homeLantern { width: 110px; right: 30px; }
  .levelGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; max-width: 1100px; margin: 0 auto; gap: 16px; padding-top: 24px; }
  .lvCard { min-height: 168px; }
  .lvArt { width: 112px; height: 112px; }
  .homeGuide { width: 120px; height: 120px; right: -130px; top: -40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
html.still *, html.still *::before, html.still *::after { animation: none !important; transition: none !important; }

/* ---------- 动效：按钮悬停与点击 / 画面切换 ---------- */
.btn, .iconBtn, .tool, .lvCard, .langSwitch button, .sbtn, .sheetCard, .targetCard { position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s, background-color 0.2s, border-color 0.2s, filter 0.2s, opacity 0.2s; }
@media (hover: hover) {
  .btn:hover:not(:disabled), .iconBtn:hover, .tool:hover:not(:disabled), .lvCard:hover:not(.locked), .langSwitch button:hover, .sbtn:hover:not(:disabled), .sheetCard:hover, .targetCard:hover {
    transform: translateY(-2px);
    border-color: rgba(233, 169, 58, 0.7);
    box-shadow: 0 10px 24px rgba(110, 60, 140, 0.22), 0 0 18px rgba(255, 210, 120, 0.55);
  }
  .btn.primary:hover { box-shadow: 0 12px 28px rgba(120, 70, 200, 0.4), 0 0 22px rgba(255, 220, 140, 0.6); filter: brightness(1.05); }
  .btn::after, .iconBtn::after, .tool::after, .lvCard::after, .sbtn::after, .sheetCard::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, 0.65) 50%, transparent 68%);
    transform: translateX(-130%);
  }
  .btn:hover:not(:disabled)::after, .iconBtn:hover::after, .tool:hover:not(:disabled)::after, .lvCard:hover:not(.locked)::after, .sbtn:hover:not(:disabled)::after, .sheetCard:hover::after { animation: sheen 0.75s ease; }
  .tool:hover:not(:disabled) .ico, .sbtn:hover:not(:disabled) .ico { animation: icoBounce 0.5s ease; }
}
@keyframes sheen { to { transform: translateX(130%); } }
@keyframes icoBounce { 40% { transform: translateY(-3px) scale(1.12); } }
.btn:active:not(:disabled), .iconBtn:active, .tool:active:not(:disabled), .lvCard:active:not(.locked), .langSwitch button:active, .sbtn:active:not(:disabled), .targetCard:active { transform: scale(0.94); transition-duration: 0.08s; }
.sheetCard:active { transform: scale(0.96); }
/* 点击水波纹（樱花色） */
.ripple { position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); z-index: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85), rgba(255, 170, 210, 0.35) 45%, rgba(255, 170, 210, 0) 70%); animation: ripple 0.6s ease-out forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
.screen:not([hidden]) { animation: screenIn 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } }
.lvCard { animation: cardIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(0.92); } }
.pill b.bump { display: inline-block; animation: bump 0.35s ease; }
@keyframes bump { 40% { transform: scale(1.4); color: var(--rose); } }
.logoWrap { animation: float 4.5s ease-in-out infinite, logoGlow 3.2s ease-in-out infinite; }
@keyframes logoGlow { 50% { box-shadow: 0 0 0 3px rgba(255, 236, 180, 1), 0 0 80px rgba(255, 200, 120, 0.8), 0 14px 36px rgba(110, 60, 140, 0.22); } }

/* ===================== 加载页：彩纸花窗逐片展开 ===================== */
body.booting #app { display: none; }
body.booting #fx, body.booting .bgArt { visibility: hidden; }
.boot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px 20px calc(24px + var(--safe-b)); overflow: hidden;
  background: radial-gradient(ellipse at 15% 0%, rgba(255, 226, 150, 0.8), transparent 55%),
    radial-gradient(ellipse at 90% 90%, rgba(255, 170, 210, 0.45), transparent 55%),
    linear-gradient(180deg, #fff6f9, #f1e3fb 60%, #e4d4f6);
  transition: opacity 0.6s ease, transform 0.6s ease; }
.boot.leave { opacity: 0; transform: scale(1.04); pointer-events: none; }
.bootRays { position: absolute; left: -20%; top: -30%; width: 140%; height: 160%; pointer-events: none; }
.bootRays i { position: absolute; left: 0; top: 0; width: 160%; height: 14%; transform-origin: 0 0;
  background: linear-gradient(180deg, rgba(255, 240, 200, 0), rgba(255, 240, 200, 0.55), rgba(255, 240, 200, 0)); animation: rayShift 6s ease-in-out infinite alternate; }
.bootRays i:nth-child(1) { transform: rotate(28deg); }
.bootRays i:nth-child(2) { transform: rotate(38deg); height: 8%; animation-delay: -2s; }
.bootRays i:nth-child(3) { transform: rotate(48deg); height: 12%; animation-delay: -4s; }
.bootRays i:nth-child(4) { transform: rotate(60deg); height: 6%; animation-delay: -1s; }
@keyframes rayShift { from { opacity: 0.35; } to { opacity: 1; } }
.bootInner { position: relative; width: min(360px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; }
.bootWindow { position: relative; width: 210px; height: 210px; margin-bottom: 14px; border-radius: 24px; padding: 14px;
  background: linear-gradient(180deg, #fffaf1, #efdfcc); box-shadow: 0 16px 34px rgba(110, 60, 140, 0.28), inset 0 0 0 2px rgba(214, 170, 90, 0.9); }
.bootRose { position: relative; width: 100%; height: 100%; border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, #fffaf0, #efe2fb); box-shadow: inset 0 0 0 1px rgba(214, 170, 90, 0.7); }
.bootRose b { position: absolute; left: 50%; top: 50%; width: 32%; height: 32%; margin: -16% 0 0 -16%; border-radius: 0 60% 0 60%;
  transform: rotate(calc(var(--i) * 45deg)) translate(0, -46%) rotate(45deg) scale(0.15); transform-origin: 50% 50%; opacity: 0;
  mix-blend-mode: multiply; border: 1.5px solid rgba(255, 255, 255, 0.85);
  transition: transform 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.35), opacity 0.35s; }
.bootRose b:nth-child(4n+1) { background: rgba(255, 115, 173, 0.75); }
.bootRose b:nth-child(4n+2) { background: rgba(255, 210, 62, 0.8); }
.bootRose b:nth-child(4n+3) { background: rgba(70, 191, 240, 0.72); }
.bootRose b:nth-child(4n+4) { background: rgba(161, 115, 238, 0.7); }
.bootRose b.on { opacity: 1; transform: rotate(calc(var(--i) * 45deg)) translate(0, -46%) rotate(45deg) scale(1); }
.bootCore { position: absolute; left: 50%; top: 50%; width: 18%; height: 18%; margin: -9% 0 0 -9%; border-radius: 50%;
  background: radial-gradient(circle, #fff6d0, #ffd76a 60%, rgba(255, 215, 106, 0)); transform: scale(calc(0.4 + var(--p, 0) * 0.9)); transition: transform 0.4s;
  box-shadow: 0 0 calc(10px + var(--p, 0) * 30px) rgba(255, 210, 110, 0.9); }
.boot.ready .bootRose { animation: roseGlow 1.6s ease-in-out infinite; }
@keyframes roseGlow { 50% { box-shadow: inset 0 0 0 1px rgba(214, 170, 90, 0.7), 0 0 30px rgba(255, 210, 120, 0.9); filter: brightness(1.08); } }
.bootGuide { position: absolute; right: -46px; bottom: -26px; width: 92px; height: 92px; filter: drop-shadow(0 8px 12px rgba(110, 60, 140, 0.35)); animation: float 3.2s ease-in-out infinite; }
.bootTitle { font-size: clamp(28px, 8.5vw, 36px); font-weight: 900; letter-spacing: 0.3px; margin: 8px 0 14px;
  background: linear-gradient(180deg, #fffbe8, #ffd76a 55%, #f0a43a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #7b4cc6) drop-shadow(0 -1px 0 #7b4cc6) drop-shadow(1px 0 0 #7b4cc6) drop-shadow(-1px 0 0 #7b4cc6); }
/* 进度条：一条纸带，五个菱形依次点亮 */
.bootTrack { position: relative; width: 100%; height: 8px; border-radius: 8px; background: rgba(138, 96, 170, 0.16); margin: 8px 0 12px; }
.bootFill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 8px; transition: width 0.3s ease;
  background: linear-gradient(90deg, #ff9cc6, #ffd76a 50%, #8fd6f7); box-shadow: 0 0 12px rgba(255, 200, 120, 0.8); }
.bootTrack i { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; transform: rotate(45deg) scale(0.7); opacity: 0.55; transition: transform 0.35s, opacity 0.35s;
  background: #fff; border: 2px solid rgba(160, 130, 190, 0.6); border-radius: 3px; }
.bootTrack i:nth-of-type(1) { left: 0; } .bootTrack i:nth-of-type(2) { left: 25%; } .bootTrack i:nth-of-type(3) { left: 50%; }
.bootTrack i:nth-of-type(4) { left: 75%; } .bootTrack i:nth-of-type(5) { left: 100%; }
.bootTrack i.on { background: #ffd76a; border-color: #fff; opacity: 1; transform: rotate(45deg) scale(1.1); box-shadow: 0 0 8px rgba(240, 170, 60, 0.9); }
.bootPct { font-weight: 800; font-size: 15px; color: var(--violet); font-variant-numeric: tabular-nums; }
.bootTip { margin: 6px 0 18px; min-height: 1.5em; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.bootGo { min-width: 200px; animation: bootPulse 1.6s ease-in-out infinite; }
.boot.ready .bootPct { opacity: 0.6; }
@keyframes bootPulse { 50% { box-shadow: 0 0 0 5px rgba(183, 145, 243, 0.3), 0 0 34px rgba(255, 210, 120, 0.7); } }
@media (prefers-reduced-motion: reduce) { .bootRays i, .bootGuide, .bootGo, .boot.ready .bootRose { animation: none; } }

/* V002：加载页 8 片花瓣的角度（原来写在 style 属性里，服务器 CSP 不允许内联样式） */
.bootRose b:nth-of-type(1) { --i: 0; }
.bootRose b:nth-of-type(2) { --i: 1; }
.bootRose b:nth-of-type(3) { --i: 2; }
.bootRose b:nth-of-type(4) { --i: 3; }
.bootRose b:nth-of-type(5) { --i: 4; }
.bootRose b:nth-of-type(6) { --i: 5; }
.bootRose b:nth-of-type(7) { --i: 6; }
.bootRose b:nth-of-type(8) { --i: 7; }
