:root {
  --bg: #140d2b;
  --bg2: #1f1540;
  --panel: #241a4a;
  --panel2: #2e2360;
  --line: #4a3b8c;
  --text: #f4f1ff;
  --muted: #a99fd6;
  --gold: #ffcf3f;
  --teal: #2fd8c8;
  --red: #ff4d6d;
  --hp: #4be08a;
  --blue: #4fb3ff;
  --purple: #c26bff;
  --orange: #ff8a1f;
  --radius: 14px;
  --font: 'Noto Sans TC', system-ui, sans-serif;
  --display: 'Bungee', 'Noto Sans TC', sans-serif;
  --speed: 1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #07050f; color: var(--text); font-family: var(--font); overflow: hidden; }
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
img { -webkit-user-drag: none; user-select: none; }
.hidden { display: none !important; }

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 60px #000;
}

.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- 通用元件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 22px; border-radius: 999px; font-weight: 900; font-size: 17px;
  background: var(--panel2); box-shadow: 0 4px 0 #0008, inset 0 2px 0 #fff2;
  transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0008; }
.btn.big { width: 78%; padding: 16px; font-size: 22px; letter-spacing: 2px; }
.btn.primary { background: linear-gradient(#ffe066, #ffb400); color: #3a2200; box-shadow: 0 5px 0 #a86a00, inset 0 2px 0 #fff8; }
.btn.ghost { background: #ffffff14; box-shadow: inset 0 0 0 2px #ffffff30; }
.btn.teal { background: linear-gradient(#4ff0de, #14b3a6); color: #042a27; box-shadow: 0 4px 0 #0b6f67, inset 0 2px 0 #fff8; }
.btn.red { background: linear-gradient(#ff7a8f, #e0304e); box-shadow: 0 4px 0 #86152a, inset 0 2px 0 #fff6; }
.btn:disabled { filter: grayscale(1) brightness(.6); pointer-events: none; }

.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: #ffffff14; font-size: 20px; }
.chip { padding: 8px 12px; border-radius: 999px; background: #ffffff18; font-weight: 700; font-size: 14px; min-width: 60px; }
.chip.toggle.on { background: var(--teal); color: #042a27; }

.currency { display: flex; align-items: center; gap: 6px; padding: 5px 14px 5px 6px; border-radius: 999px; background: #0007; font-family: var(--display); font-size: 15px; }
.currency .ico { font-size: 18px; }
.currency.small { font-size: 13px; padding: 4px 10px 4px 5px; }

.sprite { display: block; width: 100%; height: auto; pointer-events: none; }
.shadow { position: absolute; left: 15%; right: 15%; bottom: -4%; height: 9%; border-radius: 50%; background: radial-gradient(#000a, transparent 70%); z-index: -1; }

/* ---------- 大廳 ---------- */
#home { align-items: center; }
.home-bg {
  position: absolute; inset: 0;
  background: url('../assets/bg/street.jpg') 0 center / auto 100% repeat-x;
  filter: brightness(.55) saturate(1.2);
  animation: bgpan 90s linear infinite;
}
.home-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(#140d2bcc, transparent 30%, transparent 55%, #140d2b 92%); }
@keyframes bgpan { from { background-position: 0 center; } to { background-position: calc(-100dvh * 2496 / 864) center; } }
.home-top { position: relative; width: 100%; display: flex; gap: 8px; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.home-top .icon-btn { margin-left: auto; }
.logo { position: relative; text-align: center; margin-top: 2vh; transform: rotate(-4deg); }
.logo-main { font-weight: 900; font-size: clamp(38px, 11vw, 52px); letter-spacing: 4px; color: #fff; text-shadow: 0 4px 0 #7a2cff, 0 0 24px #b56bff, 3px 3px 0 #000; }
.logo-go { font-family: var(--display); font-size: clamp(44px, 13vw, 62px); line-height: .9; color: var(--gold); text-shadow: 0 5px 0 #b35c00, 0 0 30px #ffcf3f88, 3px 3px 0 #000; }
.home-hero { position: relative; width: 46%; max-width: 220px; margin-top: 2vh; animation: breathe 2.4s ease-in-out infinite; transform-origin: bottom center; }
.hero-home { filter: drop-shadow(0 0 16px #2fd8c866); }
@keyframes breathe { 50% { transform: scale(1.02, 0.975); } }
.chapter-card { position: relative; margin-top: 2vh; padding: 10px 26px; border-radius: var(--radius); background: #0009; border: 2px solid var(--line); text-align: center; }
.chapter-tag { font-size: 13px; color: var(--gold); font-weight: 700; }
.chapter-name { font-size: 24px; font-weight: 900; letter-spacing: 3px; }
.chapter-best { font-size: 13px; color: var(--muted); }
.home-actions { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: auto; margin-bottom: 14px; }
.tabbar { position: relative; width: 100%; display: flex; background: #0c0820; border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 0 10px; font-size: 12px; color: var(--muted); font-weight: 700; }
.tabbar button span { font-size: 22px; filter: grayscale(.6); }
.tabbar button.on { color: var(--gold); background: linear-gradient(#ffcf3f22, transparent); }
.tabbar button.on span { filter: none; transform: scale(1.15); }

/* ---------- 冒險頂部 ---------- */
.adv-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg2); }
.dayline { flex: 1; }
.day-label { font-family: var(--display); font-size: 18px; line-height: 1; margin-bottom: 4px; }
.day-label small { font-size: 12px; color: var(--muted); margin-left: 4px; }
.day-track { position: relative; height: 10px; border-radius: 99px; background: #0008; overflow: visible; }
.day-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .4s; }
.day-marks span { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 13px; line-height: 1; filter: drop-shadow(0 1px 1px #000); }

.status { display: flex; align-items: center; gap: 10px; padding: 6px 12px 8px; background: var(--bg2); border-bottom: 2px solid #0006; }
.lv-badge { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(#7a4dff, #4a23c8); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; box-shadow: inset 0 2px 0 #fff4; }
.lv-badge small { font-size: 10px; opacity: .8; }
.lv-badge b { font-family: var(--display); font-size: 18px; }
.bars { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.bar { position: relative; height: 18px; border-radius: 99px; background: #0009; overflow: hidden; box-shadow: inset 0 0 0 1px #fff2; }
.bar-fill { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 99px; transition: width .25s; }
.bar.hp .bar-fill { background: linear-gradient(#7ff5a8, #1fae5c); }
.bar.hp.low .bar-fill { background: linear-gradient(#ff8fa0, #d8203f); }
.bar-shield { position: absolute; inset: 0 auto 0 0; width: 0; background: repeating-linear-gradient(45deg, #9fd8ffcc 0 6px, #6bb8ffcc 6px 12px); border-radius: 99px; transition: width .25s; }
.bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.bar.exp { height: 7px; }
.bar.exp .bar-fill { background: linear-gradient(90deg, #8f6bff, #d7b4ff); }
.mini-stats { display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 64px; }
.mini-stats b { font-family: var(--display); font-size: 13px; margin-left: 4px; }

/* ---------- 場景 ---------- */
.scene { position: relative; height: 40%; min-height: 230px; overflow: hidden; background: #000; }
.scene-bg { position: absolute; inset: 0; background: url('../assets/bg/street.jpg') 0 center / auto 100% repeat-x; }
.scene.walking .scene-bg { transition: background-position calc(.7s / var(--speed)) ease-in-out; }
.scene-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 60%, transparent 55%, #000a); pointer-events: none; }
.actor { position: absolute; bottom: 7%; z-index: 2; transform-origin: bottom center; }
.actor.hero { left: 6%; width: 30%; }
.actor.hero .sprite { transform: scaleX(-1); }
.actor.enemy { right: 6%; width: 33%; }
.actor.enemy.elite { width: 38%; }
.actor.enemy.boss { width: 48%; right: 2%; }
.actor.enemy.boss .sprite { filter: drop-shadow(0 0 14px #c26bff); }
.actor.enemy.elite .sprite { filter: drop-shadow(0 0 8px #ff4d6d99); }

.actor.idle { animation: breathe calc(2.2s) ease-in-out infinite; }
.actor.hero.walk { animation: walkbob calc(.35s / var(--speed)) ease-in-out infinite; }
@keyframes walkbob { 50% { transform: translateY(-6%) rotate(-2deg); } }
.actor.hero.lunge { animation: lungeR calc(.28s / var(--speed)) ease-out; }
.actor.enemy.lunge { animation: lungeL calc(.28s / var(--speed)) ease-out; }
@keyframes lungeR { 40% { transform: translateX(45%) rotate(6deg); } }
@keyframes lungeL { 40% { transform: translateX(-45%) rotate(-6deg); } }
.actor.hit { animation: hitshake calc(.25s / var(--speed)); }
.actor.hit .sprite { filter: brightness(2.2) saturate(0) !important; }
@keyframes hitshake { 25% { transform: translateX(6%); } 60% { transform: translateX(-4%); } }
.actor.enemy.enter { animation: enterR calc(.45s / var(--speed)) cubic-bezier(.2, 1.4, .5, 1); }
@keyframes enterR { from { transform: translateX(120%); opacity: 0; } }
.actor.dead { animation: die .7s ease-in forwards; }
@keyframes die { 30% { transform: rotate(-8deg); } to { transform: translateY(30%) rotate(-25deg) scale(.7); opacity: 0; filter: grayscale(1); } }
.actor.cheer { animation: cheer .5s ease-in-out 2; }
@keyframes cheer { 50% { transform: translateY(-14%) scale(1.04); } }

.enemy-tag { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); width: 120%; text-align: center; font-size: 12px; font-weight: 900; text-shadow: 0 1px 2px #000; margin-bottom: 2px; }
.enemy-tag .bar.mini { height: 8px; margin-top: 2px; }
.boss .enemy-tag { color: #e7b6ff; font-size: 14px; }
.elite .enemy-tag { color: #ff9aaa; }
.status-icons { position: absolute; top: 4%; left: 0; display: flex; gap: 2px; font-size: 16px; z-index: 3; }
.status-icons span { animation: pop .3s; filter: drop-shadow(0 1px 2px #000); }

#fxCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.float { position: absolute; font-family: var(--display); font-size: 20px; white-space: nowrap; transform: translate(-50%, 0); text-shadow: 0 2px 0 #000, 0 0 4px #000; animation: floatup calc(.9s / var(--speed)) ease-out forwards; }
.float.crit { font-size: 30px; color: var(--gold); animation: floatcrit calc(1s / var(--speed)) ease-out forwards; }
.float.txt { font-family: var(--font); font-weight: 900; font-size: 16px; }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } 30% { transform: translate(-50%, -6px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60px); } }
@keyframes floatcrit { 0% { opacity: 0; transform: translate(-50%, 0) scale(2.4) rotate(-8deg); } 20% { opacity: 1; transform: translate(-50%, -4px) scale(1.2) rotate(-6deg); } 100% { opacity: 0; transform: translate(-50%, -70px) scale(1) rotate(-4deg); } }

.scene.shake { animation: sshake .3s; }
.scene.shake-big { animation: sshake-big .45s; }
@keyframes sshake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }
@keyframes sshake-big { 10% { transform: translate(-9px, 4px); } 30% { transform: translate(8px, -5px); } 50% { transform: translate(-6px, 3px); } 70% { transform: translate(5px, -2px); } 90% { transform: translate(-2px, 1px); } }

.banner { position: absolute; left: 0; right: 0; top: 36%; z-index: 7; text-align: center; font-weight: 900; font-size: 30px; letter-spacing: 3px; pointer-events: none; opacity: 0; }
.banner.show { animation: bannerIn 1.4s ease-out forwards; }
.banner.boss { color: #ff4d6d; text-shadow: 0 0 20px #ff0033, 0 3px 0 #000; background: linear-gradient(90deg, transparent, #000c 20%, #000c 80%, transparent); padding: 8px 0; }
.banner.good { color: var(--gold); text-shadow: 0 0 18px #ffb400, 0 3px 0 #000; }
@keyframes bannerIn { 0% { opacity: 0; transform: scaleX(2) scaleY(.3); } 15% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.05); } }
.battle-ctrl { position: absolute; right: 8px; top: 8px; z-index: 8; }

/* 雷擊 / 隕石 特效元素 */
.bolt { position: absolute; top: 0; width: 60px; height: 70%; transform: translateX(-50%); z-index: 4; pointer-events: none; animation: boltflash calc(.35s / var(--speed)) steps(2) forwards; }
@keyframes boltflash { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
.meteor { position: absolute; width: 70px; height: 70px; border-radius: 50%; z-index: 4; background: radial-gradient(circle at 35% 35%, #fff6b0, #ff8a1f 45%, #b3240088 70%, transparent 72%); box-shadow: 0 0 40px #ff6a00; animation: meteorfall calc(.45s / var(--speed)) ease-in forwards; }
@keyframes meteorfall { from { transform: translate(120px, -260px) scale(.6); } to { transform: translate(0, 0) scale(1.2); } }

/* ---------- 事件面板 ---------- */
.panel { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: linear-gradient(var(--bg2), var(--bg)); padding: 8px 12px 0; overflow: hidden; }
.log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; mask-image: linear-gradient(transparent, #000 30%); padding-bottom: 6px; scrollbar-width: none; }
.log::-webkit-scrollbar { display: none; }
.log-line { font-size: 14px; line-height: 1.4; padding: 6px 10px; border-radius: 10px; background: #ffffff0d; animation: logIn .25s ease-out; }
.log-line .d { font-family: var(--display); font-size: 11px; color: var(--muted); margin-right: 6px; }
.log-line.good { border-left: 3px solid var(--hp); }
.log-line.bad { border-left: 3px solid var(--red); }
.log-line.gold { border-left: 3px solid var(--gold); }
.log-line.skill { border-left: 3px solid var(--purple); }
@keyframes logIn { from { opacity: 0; transform: translateY(8px); } }

.event-card { position: absolute; left: 10px; right: 10px; bottom: 8px; background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 0 -10px 30px #0008; animation: cardUp .3s cubic-bezier(.2, 1.3, .5, 1); z-index: 3; }
@keyframes cardUp { from { transform: translateY(40%); opacity: 0; } }
.ec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ec-icon { font-size: 34px; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; border-radius: 14px; background: #0005; }
.ec-title { font-size: 19px; font-weight: 900; }
.ec-desc { font-size: 14px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.ec-opts { display: flex; flex-direction: column; gap: 8px; }
.ec-opts .btn { width: 100%; border-radius: 14px; font-size: 16px; padding: 11px 14px; justify-content: space-between; }
.ec-opts .btn small { font-weight: 700; font-size: 13px; opacity: .85; }
.ec-row { display: flex; gap: 8px; }
.ec-row .btn { flex: 1; }

/* 技能列 */
.skillbar { display: flex; gap: 4px; padding: 6px 12px; min-height: 40px; overflow-x: auto; background: #0c0820; border-top: 1px solid #ffffff12; scrollbar-width: none; cursor: pointer; }
.skillbar::-webkit-scrollbar { display: none; }
.skillbar:empty::after { content: '尚未習得技能'; color: var(--muted); font-size: 13px; align-self: center; }
.sk-mini { position: relative; flex: 0 0 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; background: #0006; border: 2px solid; }
.sk-mini i { position: absolute; right: -3px; bottom: -4px; font-style: normal; font-family: var(--display); font-size: 9px; background: #000; border-radius: 4px; padding: 0 2px; }
.sk-mini.combo { flex-basis: auto; padding: 0 8px; font-size: 12px; font-weight: 900; background: linear-gradient(90deg, #ffb52e44, #ff4d6d44); }

.adv-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: #0c0820; }
.btn.go { flex: 1; flex-direction: column; gap: 0; padding: 10px; border-radius: 18px; font-size: 24px; letter-spacing: 6px; background: linear-gradient(#ffe066, #ffb400); color: #3a2200; box-shadow: 0 6px 0 #a86a00, inset 0 2px 0 #fff8; }
.btn.go small { font-size: 12px; letter-spacing: 1px; font-weight: 700; }
.btn.go.busy { filter: saturate(.3) brightness(.7); pointer-events: none; }
.btn.go:not(.busy) { animation: gopulse 1.6s ease-in-out infinite; }
@keyframes gopulse { 50% { box-shadow: 0 6px 0 #a86a00, inset 0 2px 0 #fff8, 0 0 22px #ffcf3f88; } }

/* ---------- 覆蓋層 / 彈窗 ---------- */
.overlay { position: absolute; inset: 0; z-index: 50; background: #07041acc; backdrop-filter: blur(3px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 14px; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.ov-title { font-family: var(--display); font-size: 30px; color: var(--gold); text-shadow: 0 3px 0 #b35c00, 0 0 20px #ffcf3f88; margin-bottom: 4px; text-align: center; }
.ov-sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; text-align: center; }

.skill-cards { display: flex; gap: 8px; width: 100%; justify-content: center; }
.skill-card { flex: 1; max-width: 150px; min-height: 210px; border-radius: 16px; padding: 12px 8px; background: linear-gradient(170deg, var(--panel2), var(--bg2)); border: 3px solid var(--rc); box-shadow: 0 0 18px color-mix(in srgb, var(--rc) 45%, transparent), inset 0 0 20px #0006; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; animation: cardFlip .45s cubic-bezier(.2, 1.3, .5, 1) backwards; transition: transform .12s; }
.skill-card:nth-child(2) { animation-delay: .08s; }
.skill-card:nth-child(3) { animation-delay: .16s; }
.skill-card:active { transform: scale(.95); }
.skill-card.legendary { animation: cardFlip .45s cubic-bezier(.2, 1.3, .5, 1) backwards, legendGlow 1.2s ease-in-out infinite; }
@keyframes cardFlip { from { transform: rotateY(90deg) scale(.8); opacity: 0; } }
@keyframes legendGlow { 50% { box-shadow: 0 0 34px #ffb52e, inset 0 0 20px #0006; } }
.sc-rarity { font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 99px; background: var(--rc); color: #120b24; }
.sc-icon { width: 58px; height: 58px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 32px; background: radial-gradient(color-mix(in srgb, var(--cc) 55%, transparent), #0008); border: 2px solid var(--cc); }
.sc-name { font-weight: 900; font-size: 16px; }
.sc-lv { font-size: 11px; color: var(--gold); font-weight: 700; }
.sc-desc { font-size: 12.5px; color: #ddd6ff; line-height: 1.45; }
.sc-cat { margin-top: auto; font-size: 11px; color: var(--cc); font-weight: 700; }
.ov-actions { display: flex; gap: 10px; margin-top: 18px; }

.combo-pop { text-align: center; animation: comboIn .6s cubic-bezier(.2, 1.4, .5, 1); }
@keyframes comboIn { from { transform: scale(.3); opacity: 0; } }
.combo-pop .ci { font-size: 70px; filter: drop-shadow(0 0 20px var(--gold)); }
.combo-pop .cn { font-size: 30px; font-weight: 900; color: var(--gold); text-shadow: 0 0 16px #ffb400, 0 3px 0 #000; }
.combo-pop .cd { color: #fff; margin-top: 8px; font-size: 16px; }

/* 轉盤 */
.wheel-wrap { position: relative; width: min(78vw, 300px); aspect-ratio: 1; margin: 6px 0 10px; }
.wheel { width: 100%; height: 100%; border-radius: 50%; border: 6px solid var(--gold); box-shadow: 0 0 30px #ffcf3f66, inset 0 0 20px #0008; transition: transform 3.2s cubic-bezier(.12, .8, .2, 1); }
.wheel-pin { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); font-size: 34px; filter: drop-shadow(0 2px 2px #000); z-index: 2; }
.wheel-hub { position: absolute; inset: 40%; border-radius: 50%; background: radial-gradient(#fff3a0, #ffb400); border: 4px solid #a86a00; display: flex; align-items: center; justify-content: center; font-size: 24px; }

/* 商人 */
.shop-list { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--panel); border: 2px solid var(--rc, var(--line)); }
.shop-item .sc-icon { width: 46px; height: 46px; font-size: 24px; flex: none; }
.shop-item .si-body { flex: 1; min-width: 0; }
.shop-item .si-name { font-weight: 900; }
.shop-item .si-desc { font-size: 12px; color: var(--muted); }
.shop-item .btn { padding: 8px 12px; font-size: 14px; flex: none; }
.shop-item.sold { opacity: .4; pointer-events: none; }

/* 技能總覽 */
.sheet { width: 100%; max-height: 82%; overflow-y: auto; background: var(--panel); border-radius: 20px; padding: 16px; border: 2px solid var(--line); }
.sheet h3 { margin: 0 0 10px; font-size: 18px; }
.cat-block { margin-bottom: 12px; }
.cat-head { display: flex; justify-content: space-between; font-weight: 900; font-size: 14px; margin-bottom: 6px; }
.cat-head .prog { font-size: 12px; color: var(--muted); }
.cat-head .prog.done { color: var(--gold); }
.sk-row { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; background: #0004; margin-bottom: 4px; font-size: 13px; }
.sk-row b { min-width: 86px; }
.sk-row span { color: var(--muted); flex: 1; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; font-size: 14px; }
.stat-grid div { background: #0004; border-radius: 10px; padding: 6px 10px; display: flex; justify-content: space-between; }
.stat-grid b { font-family: var(--display); font-size: 13px; }

/* 結算 */
.result-card { width: 100%; background: var(--panel); border-radius: 22px; padding: 20px 16px; border: 2px solid var(--line); text-align: center; }
.result-card .rc-hero { width: 120px; margin: -70px auto 0; }
.result-card.lose .rc-hero { filter: grayscale(.8); transform: rotate(-8deg); }
.rc-title { font-size: 32px; font-weight: 900; margin: 6px 0; }
.rc-title.win { color: var(--gold); text-shadow: 0 0 20px #ffb400; }
.rc-title.lose { color: var(--red); }
.rc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.rc-stats div { background: #0005; border-radius: 12px; padding: 8px 4px; font-size: 12px; color: var(--muted); }
.rc-stats b { display: block; font-family: var(--display); font-size: 18px; color: var(--text); }
.rc-rewards { display: flex; justify-content: center; gap: 12px; margin: 10px 0 4px; }
.rc-rewards .currency { font-size: 18px; animation: pop .4s backwards; }
.rc-note { font-size: 12px; color: var(--muted); }

.toast { position: absolute; left: 50%; top: 18%; z-index: 90; transform: translate(-50%, -10px); background: #000d; padding: 10px 18px; border-radius: 99px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.flash { position: absolute; inset: 0; z-index: 80; pointer-events: none; background: #fff; opacity: 0; }
.flash.on { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .7; } }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.2); } }

.menu-list { display: flex; flex-direction: column; gap: 12px; width: 80%; }
.menu-list .btn { width: 100%; }

@media (max-height: 640px) {
  .scene { min-height: 200px; }
  .logo { margin-top: 0; }
  .home-hero { width: 36%; }
}

/* ========== 第二階段：大廳分頁 ========== */
.page { position: relative; display: none; flex: 1; min-height: 0; width: 100%; flex-direction: column; align-items: center; }
.page.active { display: flex; animation: fadeIn .2s; }
.page-scroll { width: 100%; height: 100%; overflow-y: auto; padding: 4px 14px 18px; scrollbar-width: none; }
.page-scroll::-webkit-scrollbar { display: none; }
.page-title { font-size: 22px; font-weight: 900; text-align: center; margin: 4px 0 10px; text-shadow: 0 2px 0 #000; }
.power-chip { display: flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 999px; background: linear-gradient(90deg, #ff4d6d55, #ffb40055); font-size: 15px; }
.power-chip b { font-family: var(--display); font-size: 14px; }
.home-top .icon-btn { margin-left: auto; }
.home-stage { position: relative; display: flex; align-items: flex-end; justify-content: center; width: 100%; margin-top: 1vh; }
.home-pet { width: 22%; max-width: 100px; margin-right: -4%; margin-bottom: 1%; animation: petbob 1.6s ease-in-out infinite; z-index: 1; }
.home-pet.hidden { display: block !important; visibility: hidden; }
@keyframes petbob { 50% { transform: translateY(-8%); } }
.chapter-sel { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 1.5vh; }
.chapter-sel .icon-btn { background: #0008; }
.chapter-sel .icon-btn:disabled { opacity: .25; }
.chapter-card { min-width: 190px; }
.chapter-card.locked { filter: grayscale(.8); }
.tabbar button { position: relative; }
.tabbar .dot { position: absolute; top: 6px; right: 26%; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 6px var(--red); }

/* 通用資訊卡 */
.card { background: #120c28e6; border: 2px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.card h4 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-size: 12px; }

/* 裝備 */
.gear-doll { position: relative; display: grid; grid-template-columns: 70px 1fr 70px; gap: 8px; align-items: center; }
.gear-col { display: flex; flex-direction: column; gap: 10px; }
.gear-hero { position: relative; }
.gear-hero img { width: 100%; max-width: 170px; margin: 0 auto; display: block; }
.slot { position: relative; width: 66px; height: 66px; border-radius: 14px; background: #0009; border: 3px solid #ffffff22; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 28px; }
.slot small { font-size: 10px; color: var(--muted); margin-top: -2px; }
.slot.filled { border-color: var(--rc); box-shadow: 0 0 12px color-mix(in srgb, var(--rc) 50%, transparent), inset 0 0 14px color-mix(in srgb, var(--rc) 30%, transparent); }
.slot.empty { opacity: .45; }
.stat-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 13px; margin-top: 8px; }
.stat-line b { font-family: var(--display); font-size: 12px; }
.inv { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.inv .slot { width: 100%; height: auto; aspect-ratio: 1; font-size: 24px; }
.slot .eq { position: absolute; top: -6px; right: -6px; font-size: 10px; font-weight: 900; background: var(--teal); color: #042a27; border-radius: 6px; padding: 1px 4px; }
.slot .rtag { position: absolute; bottom: 2px; font-size: 9px; font-weight: 900; color: var(--rc); }
.slot.new::after { content: 'NEW'; position: absolute; top: -6px; left: -6px; font-size: 9px; font-weight: 900; background: var(--red); border-radius: 6px; padding: 1px 4px; }
.item-pop { width: 100%; max-width: 340px; background: var(--panel); border: 3px solid var(--rc); border-radius: 20px; padding: 18px; text-align: center; box-shadow: 0 0 30px color-mix(in srgb, var(--rc) 50%, transparent); }
.item-pop .big-icon { font-size: 60px; width: 100px; height: 100px; margin: 0 auto 8px; border-radius: 22px; display: flex; align-items: center; justify-content: center; background: radial-gradient(color-mix(in srgb, var(--rc) 50%, transparent), #0008); border: 3px solid var(--rc); }
.item-pop .iname { font-size: 20px; font-weight: 900; color: var(--rc); }
.item-pop .istat { margin: 8px 0; font-size: 15px; }
.item-pop .ispecial { font-size: 13px; color: var(--gold); background: #0005; border-radius: 10px; padding: 6px; }
.item-pop .icmp { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 天賦 */
.talent-row { display: flex; align-items: center; gap: 10px; }
.talent-row .ti { font-size: 30px; width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: #0006; flex: none; }
.talent-row .tb { flex: 1; min-width: 0; }
.talent-row .tn { font-weight: 900; }
.talent-row .tv { font-size: 12px; color: var(--muted); }
.talent-row .btn { padding: 9px 12px; font-size: 14px; flex: none; }
.ms { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 10px; background: #0004; margin-bottom: 5px; font-size: 13px; }
.ms .need { font-family: var(--display); font-size: 11px; min-width: 36px; color: var(--muted); }
.ms.done { background: linear-gradient(90deg, #ffcf3f33, #0004); }
.ms.done .need { color: var(--gold); }
.ms .ck { margin-left: auto; }
.progress { height: 8px; border-radius: 99px; background: #0008; overflow: hidden; margin: 6px 0 10px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); }

/* 寵物 */
.pet-card { display: flex; gap: 12px; align-items: center; }
.pet-card .pimg { width: 88px; flex: none; }
.pet-card.locked .pimg img { filter: brightness(0) opacity(.6); }
.pet-card .pb { flex: 1; min-width: 0; }
.pet-card .pn { font-weight: 900; font-size: 17px; }
.pet-card .prole { font-size: 11px; font-weight: 900; padding: 1px 7px; border-radius: 99px; background: var(--teal); color: #042a27; margin-left: 4px; }
.pet-card .pd { font-size: 12px; color: #ddd6ff; margin: 4px 0 8px; line-height: 1.4; }
.pet-card .pbtns { display: flex; gap: 6px; }
.pet-card .pbtns .btn { padding: 7px 10px; font-size: 13px; flex: 1; }
.card.active-pet { border-color: var(--teal); box-shadow: 0 0 16px #2fd8c855; }

/* 商店 */
.shop-box { display: flex; align-items: center; gap: 12px; }
.shop-box .bx { font-size: 44px; width: 70px; height: 70px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: radial-gradient(#ffffff22, #0008); flex: none; }
.shop-box .bb { flex: 1; }
.shop-box .bn { font-weight: 900; font-size: 16px; }
.shop-box .btn { padding: 10px 14px; font-size: 15px; flex: none; }
.odds { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.odds span { font-size: 10px; font-weight: 700; }

/* 開箱演出 */
.reveal-box { font-size: 96px; animation: boxshake .6s ease-in-out infinite; filter: drop-shadow(0 0 30px #ffcf3f); }
@keyframes boxshake { 25% { transform: rotate(-8deg) scale(1.05); } 75% { transform: rotate(8deg) scale(1.05); } }
.reveal-item { animation: comboIn .5s cubic-bezier(.2, 1.4, .5, 1); }
.drops { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0; }
.drops .slot { width: 46px; height: 46px; font-size: 22px; animation: pop .4s backwards; }
.unlock-note { color: var(--gold); font-weight: 900; font-size: 14px; margin-top: 6px; }

/* 設定 */
.save-text { width: 100%; height: 90px; border-radius: 10px; background: #0008; color: var(--text); border: 1px solid var(--line); font-size: 11px; padding: 8px; resize: none; word-break: break-all; }

/* 冒險中的寵物 */
.actor.pet { left: 0; width: 15%; z-index: 1; animation: petbob 1.4s ease-in-out infinite; }
.actor.pet .sprite { transform: scaleX(-1); }
.actor.pet.act { animation: pethop calc(.4s / var(--speed)) ease-out; }
@keyframes pethop { 40% { transform: translate(40%, -30%) scale(1.15); } }
.actor { bottom: var(--ground, 7%); }
.actor.hero { left: 11%; }
