/* 泡泡炼金屋 · Nhà Giả Kim Bong Bóng — 界面样式（竖屏优先，电脑上居中显示）
 * 配色：薰衣草紫 / 深紫夜色 + 暖金 + 粉色魔法光；标题字体 Baloo 2（圆润可爱，支持越南语声调），正文 Be Vietnam Pro。 */
:root {
  --bg-top: #4a2a86;
  --bg-mid: #2d1a5e;
  --bg-bot: #170c34;
  --ink: #fff8fd;
  --ink-2: #eadcf8;
  --muted: #a996cc;
  --gold: #ffd36e;
  --gold-2: #f2a93b;
  --pink: #ff9ad5;
  --mint: #8ff0c8;
  --panel: rgba(56, 30, 104, 0.74);
  --panel-2: rgba(80, 46, 140, 0.86);
  --line: rgba(255, 220, 255, 0.18);
  --shadow: 0 18px 50px rgba(14, 4, 34, 0.55);
  --paper: #f7ead0;
  --paper-ink: #5a3416;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --title-font: 'Baloo 2', 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
* { 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 18% 0%, rgba(255, 150, 230, 0.28), transparent 55%),
    radial-gradient(ellipse at 90% 25%, rgba(140, 200, 255, 0.16), transparent 50%),
    radial-gradient(ellipse at 50% 112%, rgba(255, 190, 110, 0.22), 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.4; 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(36, 16, 70, 0.3), rgba(20, 8, 44, 0.55)), url(../assets/art/bg-portrait.jpg) center / cover no-repeat;
}
@media (orientation: landscape) {
  .bgArt { background-image: linear-gradient(180deg, rgba(36, 16, 70, 0.3), rgba(20, 8, 44, 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)) 16px 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 22px rgba(14, 4, 34, 0.35);
}
.btn.primary {
  border: 0; color: #4a1f06;
  background: linear-gradient(180deg, #fff0b8, var(--gold) 45%, var(--gold-2));
  box-shadow: 0 10px 26px rgba(243, 170, 70, 0.34), inset 0 -3px 0 rgba(160, 80, 20, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.6);
}
.btn.primary:hover { filter: brightness(1.05); }
.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 { outline: 3px solid var(--mint); 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);
}
.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; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--ink-2); min-height: 36px; }
.langSwitch button[aria-pressed="true"] { background: var(--gold); color: #4a1f06; }
.homeHero { display: flex; flex-direction: column; align-items: center; }
.heroArt { position: relative; }
.logoWrap {
  width: min(46vw, 190px); aspect-ratio: 1; border-radius: 26%; overflow: hidden;
  box-shadow: 0 0 0 3px rgba(255, 226, 150, 0.7), 0 0 60px rgba(255, 140, 230, 0.5), var(--shadow);
  animation: float 4.5s ease-in-out infinite, logoGlow 3.2s ease-in-out infinite;
}
.logoWrap img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.015); }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes logoGlow { 50% { box-shadow: 0 0 0 3px rgba(255, 226, 150, 0.9), 0 0 84px rgba(190, 140, 255, 0.75), 0 18px 50px rgba(14, 4, 34, 0.55); } }
.heroGuide { position: absolute; right: max(-74px, -18vw); bottom: -26px; width: min(30vw, 120px); height: auto; margin: 0; z-index: 2; animation: guideBob 3s ease-in-out infinite; }
.heroGuide.witchSvg { height: min(30vw, 120px); }
@keyframes guideBob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.heroBubble { position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.15) 22%, rgba(200, 160, 255, 0.18) 60%, rgba(255, 180, 240, 0.45) 100%);
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5); animation: heroBub 6s ease-in-out infinite; }
.heroBubble.b1 { width: 34px; height: 34px; left: -44px; top: 30px; }
.heroBubble.b2 { width: 20px; height: 20px; left: -20px; top: -14px; animation-delay: -2s; }
.heroBubble.b3 { width: 26px; height: 26px; right: -36px; top: 6px; animation-delay: -4s; }
@keyframes heroBub { 50% { transform: translateY(-14px) scale(1.08); } }
.homeHero h1 {
  margin: 26px 0 2px; font-family: var(--title-font); font-size: clamp(32px, 9.5vw, 48px); font-weight: 800; letter-spacing: 0; line-height: 1.08;
  background: linear-gradient(180deg, #fff, #ffe6a0 62%, #f6b04c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(90, 30, 140, 0.9)) drop-shadow(0 6px 16px rgba(255, 170, 230, 0.4));
}
.homeHero h1 { white-space: pre-line; }
.subtitle { margin: 12px 0 0; color: var(--ink-2); font-size: 14.5px; }
.homeActions { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
.homeProgress { margin: 4px 0 0; color: var(--gold); font-weight: 700; font-size: 14px; min-height: 20px; }

/* ---------- 顶栏 ---------- */
.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); font-weight: 800; font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; }
.hudTitle strong { font-family: var(--title-font); font-size: 20px; font-weight: 800; line-height: 1.15; 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: 6px; text-align: left;
  min-height: 108px; padding: 14px; border-radius: 20px; border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(110, 64, 180, 0.8), rgba(46, 24, 96, 0.88)); box-shadow: var(--shadow);
  overflow: hidden;
}
.lvCard.done { border-color: rgba(255, 226, 150, 0.45); background: linear-gradient(160deg, rgba(130, 70, 190, 0.85), rgba(60, 28, 110, 0.9)); }
.lvNum { font-family: var(--title-font); font-size: 28px; font-weight: 800; color: var(--gold); line-height: 1; position: relative; z-index: 1; }
.lvName { font-weight: 800; font-size: 14.5px; line-height: 1.3; position: relative; z-index: 1; padding-right: 44px; }
.lvStars { display: flex; gap: 2px; margin-top: auto; position: relative; z-index: 1; }
.lvArt { position: absolute; right: 8px; top: 8px; width: 54px; height: 54px; filter: drop-shadow(0 4px 10px rgba(255, 200, 120, 0.45)); animation: float 3.6s ease-in-out infinite; }
.lvCard.locked { opacity: 0.55; background: rgba(36, 18, 72, 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(255, 255, 255, 0.14); stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; stroke-linejoin: round; }
svg.star.on { fill: var(--gold); stroke: #fff2c4; filter: drop-shadow(0 0 6px rgba(255, 210, 110, 0.7)); }

/* ---------- 游戏 ---------- */
.gameScreen { padding-bottom: calc(8px + var(--safe-b)); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 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: 14px; font-variant-numeric: tabular-nums; }
.pill.gold { color: var(--gold); border-color: rgba(243, 207, 115, 0.4); }
.pill.warn { border-color: rgba(255, 120, 150, 0.7); color: #ffd0dc; }
.pill.warn b { color: #ff9ab2; }
.pill b.bump { display: inline-block; animation: bump 0.35s ease; }
@keyframes bump { 40% { transform: scale(1.45); color: var(--gold); } }

/* 配方栏：羊皮纸（GPT 底纹，缺图时用渐变） */
.recipes {
  margin-top: 8px; padding: 8px 10px 9px; border-radius: 16px; color: var(--paper-ink);
  background-color: #f3e2c0;
  background-image: url(../assets/art/parchment.jpg), linear-gradient(170deg, #fbf1dc, #ecd3a8);
  background-size: cover; background-position: center;
  border: 2px solid rgba(214, 160, 70, 0.9);
  box-shadow: 0 8px 22px rgba(14, 4, 34, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.5), inset 0 0 18px rgba(170, 110, 40, 0.25);
}
.rHead { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.rTitle { display: inline-flex; align-items: center; gap: 4px; font-family: var(--title-font); font-weight: 800; font-size: 16px; margin-right: auto; color: #6b3a14; }
.rTitle svg { width: 18px; height: 18px; fill: none; stroke: #b0702a; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.recipes .pill { background: rgba(90, 50, 20, 0.12); border-color: rgba(120, 70, 20, 0.25); color: #6b3a14; }
.recipes .pill b { color: #4a2408; }
.recipes .pill.gold { color: #9a5a08; background: rgba(255, 200, 80, 0.3); border-color: rgba(190, 120, 20, 0.45); }
.recipes .pill.warn { background: rgba(255, 90, 120, 0.18); border-color: rgba(220, 60, 90, 0.6); color: #a3203f; }
.recipes .pill.warn b { color: #c0183e; }
.rTargets { display: flex; flex-wrap: wrap; gap: 5px 6px; }
.rCard { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 3px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.5); border: 1px solid rgba(160, 100, 40, 0.28); transition: background-color 0.3s; }
.rRes { position: relative; display: block; }
.rRes img { width: 36px; height: 36px; display: block; }
.rCard .rf { display: inline-flex; align-items: center; gap: 1px; }
.ric { width: 22px; height: 22px; display: block; }
.ric.cat { width: 18px; height: 18px; margin-left: 1px; filter: drop-shadow(0 0 4px rgba(255, 210, 90, 0.9)); }
/* V004：目标物品名字 + 30px 配方图标（两行：名字 / 数量 = 材料） */
.rBody { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.rName { font-size: 11.5px; font-weight: 800; line-height: 1.2; color: #7a4416; white-space: nowrap; }
.rLine { display: inline-flex; align-items: center; gap: 3px; }
.rCard .ric { width: 30px; height: 30px; }
.rCard .ric.cat { width: 22px; height: 22px; }
/* 窄屏手机（≤400px，如 360 / 375 / 390 / 393）：图标 26px、间距收紧，保证一行放得下两张配方卡（V005：断点从 389 放宽到 400） */
@media (max-width: 400px) {
  .recipes { padding-left: 8px; padding-right: 8px; }
  .rTargets { gap: 5px 5px; }
  .rCard { gap: 3px; padding: 2px 5px 2px 2px; }
  .rRes img { width: 32px; height: 32px; }
  .rCard .ric { width: 26px; height: 26px; }
  .rCard .ric.cat { width: 19px; height: 19px; }
  .rLine { gap: 2px; }
  .rCount b { font-size: 14px; }
  .rName { font-size: 11px; }
}
.op { font-style: normal; font-weight: 900; font-size: 12px; color: #9a6a3a; padding: 0 1px; }
.op.eq { margin: 0 2px 0 0; color: #b07a40; }
.rCount b { font-weight: 900; font-size: 15px; color: #4a2408; font-variant-numeric: tabular-nums; }
.rCheck { position: absolute; right: -4px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  background: #3cb96a; border: 2px solid #fff; opacity: 0; transform: scale(0.3); transition: 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.6); }
.rCheck svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.rCard.done { background: rgba(190, 255, 210, 0.6); border-color: rgba(60, 170, 100, 0.55); }
.rCard.done .rCheck { opacity: 1; transform: none; }
.rCard.done .rCount b { color: #1f7a40; }
.rCard.got { animation: gotIt 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes gotIt { 35% { transform: scale(1.12); background: rgba(255, 240, 160, 0.9); box-shadow: 0 0 18px rgba(255, 200, 80, 0.9); } }
.rHelpers { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; padding-top: 4px; border-top: 1px dashed rgba(140, 90, 40, 0.35); }
.rMini { display: inline-flex; align-items: center; gap: 1px; opacity: 0.9; }
.rMini .ric { width: 22px; height: 22px; }
.rMini .ric.cat { width: 17px; height: 17px; }
.rMini .op { font-size: 11px; }

.boardWrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 4px 0; }
#board { display: block; touch-action: none; cursor: grab; filter: drop-shadow(0 18px 36px rgba(14, 4, 34, 0.55)); }
#board:active { cursor: grabbing; }
.tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 58px; 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); }
.tool.off .ico { color: var(--muted); }
.tool span { white-space: nowrap; }
.tool.pulse { animation: toolPulse 0.9s ease 3; }
@keyframes toolPulse { 50% { background: rgba(255, 211, 110, 0.3); border-color: var(--gold); transform: scale(1.06); } }

/* 棋盘右下角的小露米（反应：开心跳、哎呀摇头、探头看锅） */
.guideBox { position: absolute; z-index: 3; pointer-events: none; width: 96px; height: 96px; }
.guideMini { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 6px 10px rgba(14, 4, 34, 0.55)); animation: guideBob 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
.guideBox.cheer .guideMini { animation: guideHop 0.8s cubic-bezier(0.3, 0.7, 0.4, 1.4); }
.guideBox.oops .guideMini { animation: guideShake 0.7s ease; }
.guideBox.peek .guideMini { animation: guidePeek 0.6s ease; }
@keyframes guideHop { 30% { transform: translateY(-22%) scale(1.05, 0.95); } 55% { transform: translateY(0) scale(1.08, 0.9); } 75% { transform: translateY(-6%); } }
@keyframes guideShake { 20% { transform: rotate(-8deg); } 40% { transform: rotate(7deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(3deg); } }
@keyframes guidePeek { 40% { transform: translateX(-6%) rotate(-6deg); } }
.guideCheer { position: absolute; inset: 0; width: 100%; height: 100%; }
.say { position: absolute; right: 70%; bottom: 74%; white-space: nowrap; padding: 5px 10px; border-radius: 14px 14px 2px 14px;
  background: #fffaf0; color: #6b2a8a; font-weight: 800; font-size: 13px; box-shadow: 0 6px 16px rgba(14, 4, 34, 0.4);
  opacity: 0; transform: translateY(6px) scale(0.8); transform-origin: 100% 100%; transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.5); }
.say.show { opacity: 1; transform: none; }
.witchSvg { display: block; }
.witchSvg svg { width: 100%; height: 100%; display: block; }
span.robot.witchSvg { width: 92px; height: 92px; }

/* 物品飞向配方栏 */
.flyer { position: fixed; z-index: 60; pointer-events: none; transition: transform 0.6s cubic-bezier(0.5, -0.2, 0.3, 1), opacity 0.6s; filter: drop-shadow(0 0 10px rgba(255, 220, 120, 0.9)); }

/* ---------- 弹层 ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: flex; align-items: safe center; justify-content: center; padding: 20px; overflow-y: auto; background: rgba(20, 6, 40, 0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); 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; margin-top: 34px;
  background: linear-gradient(170deg, rgba(120, 70, 190, 0.97), rgba(54, 26, 104, 0.98));
  border: 2px solid rgba(255, 226, 150, 0.55); box-shadow: var(--shadow), 0 0 50px rgba(255, 140, 230, 0.3);
  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: 110px; height: 110px; margin: -64px auto 0; display: block; object-fit: contain; filter: drop-shadow(0 10px 18px rgba(14, 4, 34, 0.5)); animation: float 3s ease-in-out infinite; }
.tipBody small, .winCard small { color: var(--gold); font-weight: 800; font-size: 12px; letter-spacing: 1px; }
.tipBody h2, .winCard h2, .finaleCard h2 { margin: 4px 0 6px; font-family: var(--title-font); font-size: 24px; font-weight: 800; line-height: 1.15; }
.tipSpeaker { display: inline-block; margin-bottom: 8px; padding: 2px 12px; border-radius: 999px; background: rgba(255, 154, 213, 0.22); color: #ffd0ec; font-weight: 800; font-size: 12.5px; }
.tipBody p, .winCard p, .finaleCard p { margin: 0 0 14px; color: var(--ink-2); line-height: 1.6; font-size: 15px; }
.tipRecipe { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin: 0 0 16px; padding: 8px; border-radius: 14px; background: rgba(255, 245, 225, 0.92); }
.tipRecipe .rMini .ric { width: 26px; height: 26px; }
.tipRecipe .op { color: #9a6a3a; font-size: 13px; }
.tipCard .btn { min-width: 160px; }
.winOverlay, .finaleOverlay { position: fixed; }
.winItems { display: flex; justify-content: center; gap: 8px; margin: 8px 0 2px; flex-wrap: wrap; }
.winItem { position: relative; animation: itemIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.5) both; }
.winItem img { width: 64px; height: 64px; display: block; filter: drop-shadow(0 0 12px rgba(255, 215, 120, 0.8)); animation: float 2.6s ease-in-out infinite; }
.winItem b { position: absolute; right: -4px; bottom: -2px; font-size: 13px; background: var(--gold); color: #4a1f06; border-radius: 999px; padding: 0 6px; }
@keyframes itemIn { from { opacity: 0; transform: scale(0.2) rotate(-30deg); } }
.winStars { display: flex; justify-content: center; gap: 10px; margin: 8px 0 2px; }
.winStars svg.star { width: 50px; height: 50px; }
.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); } }
.winCard p { white-space: pre-line; }
.winRobot { animation: guideHop 1s cubic-bezier(0.3, 0.7, 0.4, 1.4) 0.2s, float 3s ease-in-out 1.2s infinite; }
.winBtns { display: flex; flex-direction: column; gap: 10px; }

/* 终曲：露米被 6 件宝物环绕 */
.finaleCard { margin-top: 0; }
.finaleStage { position: relative; width: 230px; height: 230px; margin: 0 auto 6px; }
.finaleStage::before { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 220, 140, 0.45), rgba(255, 150, 230, 0.15) 55%, transparent 70%); animation: logoGlow 3s ease-in-out infinite; }
.finaleRing { position: absolute; inset: 0; animation: spin 16s linear infinite; }
.finaleRing img { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; transform: rotate(var(--a)) translateY(-92px) rotate(calc(-1 * var(--a))); filter: drop-shadow(0 0 8px rgba(255, 220, 140, 0.8)); }
@keyframes spin { to { transform: rotate(360deg); } }
.finaleGuide { position: absolute; left: 50%; top: 50%; width: 130px; height: 130px; margin: -65px 0 0 -65px; }

/* V005：调试自检结果（?debug=1&selftest=1） */
.selftest { position: fixed; left: 0; right: 0; bottom: 0; z-index: 99; max-height: 45vh; overflow: auto; margin: 0; padding: 6px 8px; background: rgba(10, 50, 20, 0.92); color: #fff; font: 11px/1.45 monospace; white-space: pre-wrap; }

/* V005：引导角色动图 guide-idle.webp 的每一帧左边缘都带着一小块锅把手（可灵原片切帧时带进来的）。
 * 图片左边裁掉 7%（.gClip）；投影改由外层 .gFig 画——投影按裁好后的图计算，不会留下被切断的影子。 */
.gClip { clip-path: inset(-30% -30% -30% 7%); }
.gFig { display: block; filter: drop-shadow(0 10px 18px rgba(14, 4, 34, 0.5)); }
.gFig > .gClip { filter: none; }
.boardFig { position: absolute; inset: 0; filter: drop-shadow(0 6px 10px rgba(14, 4, 34, 0.55)); }
.tipFig { width: 110px; height: 110px; margin: -64px auto 0; }
.tipFig > .robot { margin: 0; }
.tipFig > .witchSvg { margin: 9px auto 0; }
.heroFig { position: absolute; right: max(-74px, -18vw); bottom: -26px; width: min(30vw, 120px); z-index: 2; }
.heroFig > .heroGuide { position: static; width: 100%; height: auto; margin: 0; }
.finaleFig { position: absolute; left: 50%; top: 50%; width: 130px; height: 130px; margin: -65px 0 0 -65px; }
.finaleFig > .finaleGuide { position: static; width: 100%; height: 100%; margin: 0; }
.finaleStars { color: var(--gold); font-weight: 800; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 40; transform: translate(-50%, 20px);
  width: max-content; max-width: min(92vw, 460px); padding: 11px 18px; border-radius: 16px;
  background: rgba(40, 16, 74, 0.95); border: 1px solid rgba(255, 180, 230, 0.45); color: var(--ink);
  font-size: 14px; line-height: 1.5; text-align: center; white-space: pre-line;
  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: 680px) {
  .rHelpers { display: none; }
  .recipes { padding: 6px 8px 7px; }
  .hudTitle strong { font-size: 18px; }
}
@media (max-height: 700px) {
  .homeHero h1 { margin-top: 16px; }
  .logoWrap { width: min(36vw, 140px); }
  .tool { min-height: 50px; }
  .rRes img { width: 30px; height: 30px; }
  .winItem img { width: 52px; height: 52px; }
  .winStars svg.star { width: 42px; height: 42px; }
}

/* ---------- 动效：按钮悬停与点击 / 画面切换 ---------- */
.btn, .iconBtn, .tool, .lvCard, .langSwitch button { 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; }
@media (hover: hover) {
  .btn:hover:not(:disabled), .iconBtn:hover, .tool:hover:not(:disabled), .lvCard:hover:not(.locked), .langSwitch button:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 180, 240, 0.65);
    box-shadow: 0 10px 26px rgba(14, 4, 34, 0.45), 0 0 18px rgba(255, 160, 230, 0.4);
  }
  .btn.primary:hover { box-shadow: 0 12px 30px rgba(243, 170, 70, 0.45), 0 0 22px rgba(255, 220, 140, 0.5); }
  .btn::after, .iconBtn::after, .tool::after, .lvCard::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, 0.32) 50%, transparent 68%);
    transform: translateX(-130%);
  }
  .btn:hover:not(:disabled)::after, .iconBtn:hover::after, .tool:hover:not(:disabled)::after, .lvCard:hover:not(.locked)::after { animation: sheen 0.75s ease; }
  .tool: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 { transform: scale(0.94); transition-duration: 0.08s; }
/* 点击水波纹（像一个泡泡散开） */
.ripple { position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); z-index: 0;
  background: radial-gradient(circle, rgba(255, 235, 255, 0.6), rgba(255, 160, 230, 0.25) 45%, rgba(255, 160, 230, 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); } }

/* ===================== 加载页：烧瓶慢慢装满魔药（纯 CSS，--p = 0…1 为进度） ===================== */
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 50% 40%, rgba(220, 120, 255, 0.4), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(255, 170, 90, 0.25), transparent 55%),
    linear-gradient(180deg, #4a2a86, #2a1658 60%, #160a32);
  transition: opacity 0.6s ease, transform 0.6s ease; }
.boot.leave { opacity: 0; transform: scale(1.04); pointer-events: none; }
.bootBubbles i { position: absolute; bottom: -40px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.1) 24%, rgba(210, 170, 255, 0.15) 62%, rgba(255, 170, 235, 0.5) 100%);
  animation: bootRise 7s linear infinite; }
.bootBubbles i:nth-child(1) { left: 8%; width: 22px; height: 22px; animation-duration: 8s; }
.bootBubbles i:nth-child(2) { left: 18%; width: 12px; height: 12px; animation-delay: -3s; animation-duration: 6s; }
.bootBubbles i:nth-child(3) { left: 30%; width: 30px; height: 30px; animation-delay: -5s; animation-duration: 9s; }
.bootBubbles i:nth-child(4) { left: 44%; width: 14px; height: 14px; animation-delay: -1s; }
.bootBubbles i:nth-child(5) { left: 58%; width: 26px; height: 26px; animation-delay: -6s; animation-duration: 8.5s; }
.bootBubbles i:nth-child(6) { left: 68%; width: 10px; height: 10px; animation-delay: -2s; animation-duration: 5.5s; }
.bootBubbles i:nth-child(7) { left: 78%; width: 20px; height: 20px; animation-delay: -4s; }
.bootBubbles i:nth-child(8) { left: 88%; width: 34px; height: 34px; animation-delay: -7s; animation-duration: 10s; }
.bootBubbles i:nth-child(9) { left: 94%; width: 12px; height: 12px; animation-delay: -1.5s; animation-duration: 6.5s; }
.bootBubbles i:nth-child(10) { left: 3%; width: 16px; height: 16px; animation-delay: -5.5s; animation-duration: 7.5s; }
@keyframes bootRise { from { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 50% { transform: translate(14px, -55vh); } to { transform: translate(-6px, -112vh); opacity: 0.2; } }
.bootInner { position: relative; width: min(360px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; }
.bootFlask { position: relative; width: 150px; height: 196px; margin-bottom: 14px; }
.flaskBody { position: absolute; left: 0; right: 0; bottom: 0; height: 150px; border-radius: 50%; overflow: hidden;
  background: rgba(255, 240, 255, 0.12); border: 4px solid rgba(255, 245, 255, 0.85);
  box-shadow: 0 0 40px rgba(220, 130, 255, 0.55), inset 0 0 22px rgba(255, 255, 255, 0.25); }
.flaskNeck { position: absolute; left: 50%; top: 22px; width: 42px; height: 40px; margin-left: -21px;
  background: rgba(255, 240, 255, 0.12); border: 4px solid rgba(255, 245, 255, 0.85); border-bottom: 0; border-radius: 6px 6px 0 0; }
.flaskCork { position: absolute; left: 50%; top: 4px; width: 50px; height: 22px; margin-left: -25px; border-radius: 6px;
  background: linear-gradient(180deg, #d9a066, #a8682e); box-shadow: inset 0 -3px 0 rgba(90, 40, 10, 0.3); }
.flaskLiquid { position: absolute; left: 0; right: 0; bottom: 0; height: calc(8% + var(--p, 0) * 84%); transition: height 0.4s ease;
  background: linear-gradient(180deg, #e98cff, #9b3fe0 55%, #6a22b8); }
.flaskLiquid .wave { position: absolute; left: -10%; top: -7px; width: 120%; height: 14px; border-radius: 50%;
  background: #f4b4ff; box-shadow: 0 0 10px rgba(255, 200, 255, 0.8); animation: wave 1.4s ease-in-out infinite alternate; }
@keyframes wave { from { transform: translateX(-5%) scaleY(0.7) rotate(-2deg); } to { transform: translateX(5%) scaleY(1.25) rotate(2deg); } }
.flaskLiquid i { position: absolute; bottom: 4px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid rgba(255, 230, 255, 0.85); animation: fRise 1.8s ease-in infinite; }
.flaskLiquid i:nth-of-type(1) { left: 22%; }
.flaskLiquid i:nth-of-type(2) { left: 38%; width: 6px; height: 6px; animation-delay: -0.6s; }
.flaskLiquid i:nth-of-type(3) { left: 52%; width: 12px; height: 12px; animation-delay: -1.1s; }
.flaskLiquid i:nth-of-type(4) { left: 66%; animation-delay: -0.3s; animation-duration: 2.2s; }
.flaskLiquid i:nth-of-type(5) { left: 74%; width: 6px; height: 6px; animation-delay: -1.5s; }
.flaskLiquid i:nth-of-type(6) { left: 30%; width: 7px; height: 7px; animation-delay: -0.9s; animation-duration: 1.5s; }
@keyframes fRise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-120px); opacity: 0; } }
.flaskShine { position: absolute; left: 18px; top: 24px; width: 22px; height: 60px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); transform: rotate(18deg); }
.flaskSteam { position: absolute; left: 50%; top: -6px; width: 0; height: 0; }
.flaskSteam i { position: absolute; left: -10px; top: 0; width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 230, 255, 0.5); filter: blur(2px);
  opacity: var(--p, 0); animation: steam 2.4s ease-out infinite; }
.flaskSteam i:nth-child(2) { animation-delay: -0.8s; left: -4px; }
.flaskSteam i:nth-child(3) { animation-delay: -1.6s; left: -16px; }
@keyframes steam { from { transform: translate(0, 0) scale(0.6); } to { transform: translate(12px, -46px) scale(1.6); opacity: 0; } }
.bootTitle { font-family: var(--title-font); font-size: clamp(28px, 8.5vw, 36px); font-weight: 800; line-height: 1.1; margin-bottom: 18px;
  background: linear-gradient(180deg, #fff6d6, var(--gold) 55%, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(90, 30, 140, 0.85)); }
/* 进度条：一根玻璃试管，五个泡泡依次亮起 */
.bootTrack { position: relative; width: 100%; height: 12px; border-radius: 12px; background: rgba(255, 230, 255, 0.14); border: 2px solid rgba(255, 240, 255, 0.5); margin: 8px 0 12px; }
.bootFill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 10px; transition: width 0.35s ease;
  background: linear-gradient(90deg, #b45cf0, #ff8fd2, var(--gold)); box-shadow: 0 0 12px rgba(255, 150, 230, 0.7); }
.bootTrack i { position: absolute; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; transform: scale(0.65); opacity: 0.5; transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.6), opacity 0.35s;
  background: radial-gradient(circle at 32% 30%, #fff, rgba(255, 255, 255, 0.2) 30%, rgba(230, 180, 255, 0.4) 70%, rgba(255, 170, 230, 0.8)); border: 1px solid rgba(255, 255, 255, 0.6); }
.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 { opacity: 1; transform: scale(1.1); box-shadow: 0 0 10px rgba(255, 210, 120, 0.9); }
.bootPct { font-weight: 800; font-size: 15px; color: var(--gold); font-variant-numeric: tabular-nums; }
.bootTip { margin: 6px 0 18px; min-height: 1.5em; color: var(--ink-2); font-size: 14px; }
.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 4px rgba(255, 211, 110, 0.25), 0 0 34px rgba(255, 211, 110, 0.55); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* 调试截图用（?debug=1&noanim=1）：关掉 CSS 动画与过渡，直接显示最终状态 */
html.noanim *, html.noanim *::before, html.noanim *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition: none !important; }
