:root {
  --bg: #1b1530; --panel: #271f45; --panel2: #322857; --line: #44397a;
  --text: #f5f0ff; --muted: #b3a9d6; --gold: #ffd25e; --pink: #ff8fb8;
  --green: #6be3a4; --red: #ff6b7d; --blue: #7cc4ff; --purple: #b58cff;
  --up: #ff6b7d; --down: #4fd18b; /* 台股習慣：紅漲綠跌 */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", sans-serif; }
body { padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom)); }
#app { max-width: 520px; margin: 0 auto; padding: 0 14px; }
.tab { display: none; animation: fade .25s; } .tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 2px 8px; }
.pet-name { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.sub { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.lv { background: var(--gold); color: #3a2a00; font-weight: 900; padding: 4px 12px; border-radius: 999px; }

.stage-box { position: relative; height: 280px; border-radius: 22px; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #3d3270, #241c42 70%); border: 2px solid var(--line); }
.ground { position: absolute; bottom: 0; left: 0; right: 0; height: 46px;
  background: repeating-linear-gradient(90deg, #2f6b4f 0 14px, #34775a 14px 28px); border-top: 4px solid #4c9c74; }
.pet { position: absolute; left: 50%; bottom: 30px; width: 170px; height: 170px; transform: translateX(-50%); }
.pet svg { width: 100%; height: 100%; overflow: visible; }
.pet .body-grp { transform-origin: 50% 90%; animation: bounce 1.8s ease-in-out infinite; }
.pet.sad .body-grp { animation-duration: 3.2s; }
.pet.happy .body-grp { animation: hop 1s ease-in-out infinite; }
.pet .eye { animation: blink 4s infinite; transform-origin: center; transform-box: fill-box; }
@keyframes bounce { 0%,100% { transform: scale(1,1); } 50% { transform: scale(1.04,.95); } }
@keyframes hop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-14px) scale(.97,1.03); } }
@keyframes blink { 0%,94%,100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.pet.tap .body-grp { animation: wiggle .5s; }
@keyframes wiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

.bubble { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); max-width: 86%;
  background: #fff; color: #2b2150; padding: 8px 14px; border-radius: 16px; font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.bubble::after { content: ""; position: absolute; bottom: -8px; left: 50%; border: 8px solid transparent; border-top-color: #fff; border-bottom: 0; transform: translateX(-50%); }
.hidden { display: none !important; }

.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 12px 2px; }
.bar { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.bar span { width: 32px; color: var(--muted); }
.track { flex: 1; height: 12px; background: #120d22; border-radius: 6px; border: 2px solid var(--line); overflow: hidden; }
.fill { height: 100%; width: 0; transition: width .6s; }
.fill.hunger { background: var(--gold); } .fill.mood { background: var(--pink); }
.fill.health { background: var(--green); } .fill.xp { background: var(--blue); }

.card { background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 14px; margin: 12px 0; }
.card .label { color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.networth .big { font-size: 32px; font-weight: 900; color: var(--gold); letter-spacing: .5px; }
.up { color: var(--up); } .down { color: var(--down); }

.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--panel2); color: var(--text); font-weight: 800; font-size: 15px; padding: 12px 16px; border-radius: 14px;
  box-shadow: 0 4px 0 #15102a; margin: 4px 4px 4px 0; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #15102a; }
.btn.primary { background: linear-gradient(#ffcf55, #f6a823); color: #3a2400; box-shadow: 0 4px 0 #a86a08; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.actions .btn { width: 100%; }
.danger .btn { background: #5a2436; }

.chart svg { width: 100%; height: 120px; }
.alloc-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
.alloc-row .track { height: 14px; }
.alloc-row .name { width: 64px; } .alloc-row .pct { width: 52px; text-align: right; color: var(--muted); }

.group-title { margin: 16px 2px 6px; font-weight: 800; color: var(--muted); }
.item { display: flex; justify-content: space-between; align-items: center; background: var(--panel);
  border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 6px 0; }
.item .n { font-weight: 800; } .item .s { color: var(--muted); font-size: 12px; }
.item .r { text-align: right; } .item .v { font-weight: 800; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

textarea, input, select { width: 100%; background: #120d22; color: var(--text); border: 2px solid var(--line);
  border-radius: 12px; padding: 10px; font-size: 16px; font-family: inherit; }
.field { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin: 8px 0; }
.field input, .field select { margin-top: 4px; }
.help ol { margin: 6px 0 6px 18px; padding: 0; line-height: 1.6; font-size: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px; font-size: 14px; }
.seg input { width: auto; }
#parseResult table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
#parseResult td, #parseResult th { padding: 4px; border-bottom: 1px solid var(--line); }
#parseResult input { padding: 6px; font-size: 14px; }
#parseResult .warn { color: var(--gold); font-size: 12px; }

.obs { margin: 4px 0 0; padding-left: 18px; line-height: 1.6; font-size: 15px; }
.obs li { margin: 6px 0; }
.obs .tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; margin-right: 4px; background: var(--panel2); color: var(--gold); }
.news-hero { border-color: var(--gold); }
details.card summary { cursor: pointer; list-style: none; font-weight: 800; }
details.card summary::after { content: " ▾"; color: var(--muted); }
details.card[open] summary::after { content: " ▴"; }
.sec-lines { font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; margin-top: 6px; }
.sec-lines a { color: var(--blue); }
.recent-day { margin: 10px 0; } .recent-day b { color: var(--gold); }
.news-peek #newsPeekText { font-size: 14px; line-height: 1.6; margin-bottom: 6px; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around;
  background: #140f26; border-top: 2px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.tabbar button { background: none; border: 0; color: var(--muted); font-size: 22px; display: flex; flex-direction: column; align-items: center; }
.tabbar button span { font-size: 11px; font-weight: 700; margin-top: 2px; }
.tabbar button.active { color: var(--gold); }

dialog { background: var(--panel); color: var(--text); border: 2px solid var(--line); border-radius: 20px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--gold); color: #3a2400;
  padding: 10px 18px; border-radius: 999px; font-weight: 800; box-shadow: 0 4px 0 #a86a08; z-index: 9; }

/* ===================================================================== 手遊風介面 */
body { font-family: -apple-system, "PingFang TC", "Noto Sans TC", sans-serif; }
.hud { display: flex; align-items: center; gap: 10px; padding: 12px 0 8px; }
.avatar-ring { position: relative; width: 62px; height: 62px; border-radius: 50%; flex: none;
  background: conic-gradient(#7cc4ff var(--xp, 0%), #2b2350 0); padding: 5px; box-shadow: 0 3px 0 #0e0a1c; }
.avatar { width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6cf, #ffd25e 60%, #e09b10);
  display: grid; place-items: center; font-size: 28px; border: 3px solid #1b1530; }
.lvtag { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: linear-gradient(#ffe27a, #f6a823);
  color: #3a2400; font-weight: 900; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 2px solid #1b1530; white-space: nowrap; }
.hud-name { flex: 1; min-width: 0; }
.hud-name #petName { font-size: 20px; font-weight: 900; -webkit-text-stroke: .6px #0e0a1c; text-shadow: 0 2px 0 #0e0a1c; }
.hud-stage { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 6px; background: #3b2f6e; color: #d9ccff; }
.res { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.pill { display: flex; align-items: center; gap: 4px; min-width: 96px; justify-content: space-between; padding: 2px 10px 2px 4px;
  border-radius: 999px; background: #120d22; border: 2px solid #3b2f6e; box-shadow: inset 0 2px 0 rgba(0,0,0,.4); }
.pill i { font-style: normal; font-size: 16px; } .pill b { font-size: 14px; font-weight: 900; }
.pill.gold b { color: var(--gold); } .pill.fire b { color: #ff9d5c; }

/* 場景 */
.scene { position: relative; height: 330px; border-radius: 26px; overflow: hidden; border: 3px solid #0e0a1c;
  box-shadow: 0 6px 0 #0e0a1c, inset 0 0 0 3px rgba(255,255,255,.12); }
.sky { position: absolute; inset: 0; background: linear-gradient(#5ec8ff, #b9ecff 70%); transition: background 1s; }
.scene.dusk .sky { background: linear-gradient(#ff8a6b, #ffcf8f 60%, #ffe6b8); }
.scene.night .sky { background: linear-gradient(#0d1035, #2a2466 70%); }
.stars { position: absolute; inset: 0; opacity: 0; transition: opacity 1s;
  background-image: radial-gradient(2px 2px at 20% 20%, #fff, transparent), radial-gradient(2px 2px at 70% 15%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 45% 35%, #fff, transparent), radial-gradient(1.5px 1.5px at 85% 40%, #fff, transparent),
    radial-gradient(2px 2px at 10% 45%, #fff, transparent), radial-gradient(1.5px 1.5px at 60% 8%, #fff, transparent); }
.scene.night .stars { opacity: 1; animation: twinkle 3s infinite alternate; }
@keyframes twinkle { to { opacity: .55; } }
.sun { position: absolute; top: 26px; right: 34px; width: 54px; height: 54px; border-radius: 50%;
  background: radial-gradient(circle, #fff7c2, #ffd25e 70%); box-shadow: 0 0 30px 10px rgba(255,220,90,.55); }
.scene.dusk .sun { top: 120px; background: radial-gradient(circle, #ffe3b0, #ff8a4c 70%); }
.scene.night .sun { background: radial-gradient(circle at 35% 35%, #fffbe8, #e9e4c8 70%); box-shadow: 0 0 24px 6px rgba(255,255,220,.3); }
.cloud { position: absolute; height: 22px; background: #fff; border-radius: 22px; opacity: .9; animation: drift linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 30px; height: 30px; top: -14px; left: 12px; } .cloud::after { width: 22px; height: 22px; top: -9px; left: 36px; }
.c1 { width: 80px; top: 50px; animation-duration: 38s; } .c2 { width: 64px; top: 100px; animation-duration: 52s; animation-delay: -20s; }
.c3 { width: 96px; top: 24px; animation-duration: 64s; animation-delay: -40s; }
.scene.night .cloud { opacity: .18; }
@keyframes drift { from { transform: translateX(-140px); } to { transform: translateX(560px); } }
.hill { position: absolute; border-radius: 50%; }
.h1 { width: 420px; height: 200px; left: -120px; bottom: -110px; background: #5fc77e; }
.h2 { width: 380px; height: 180px; right: -140px; bottom: -100px; background: #4fb56e; }
.scene.night .h1 { background: #2e5f4a; } .scene.night .h2 { background: #274f3e; }
.grass { position: absolute; left: 0; right: 0; bottom: 0; height: 54px;
  background: repeating-linear-gradient(90deg, #6bd68a 0 16px, #62cc81 16px 32px); border-top: 5px solid #8be6a2; }
.scene.night .grass { background: repeating-linear-gradient(90deg, #335f4b 0 16px, #2f5846 16px 32px); border-top-color: #3f7a60; }
.scene .pet { bottom: 34px; width: 180px; height: 180px; z-index: 2; }
.scene .bubble { top: 16px; z-index: 3; }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.float { position: absolute; font-size: 22px; animation: floatUp 1.8s ease-out forwards; }
@keyframes floatUp { from { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: 1; transform: translateY(-20px) scale(1); }
  to { transform: translateY(-140px) scale(1.1); opacity: 0; } }

/* 兩側浮動按鈕 */
.side { position: absolute; top: 64px; display: flex; flex-direction: column; gap: 12px; z-index: 5; }
.side.left { left: 10px; } .side.right { right: 10px; }
.sbtn { position: relative; width: 56px; height: 58px; border-radius: 16px; border: 3px solid #0e0a1c; cursor: pointer;
  background: linear-gradient(#fff 0 6%, #ffe08a 6%, #f6b737); box-shadow: 0 4px 0 #0e0a1c; font-size: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; }
.sbtn span { font-size: 11px; font-weight: 900; color: #3a2400; margin-top: 1px; }
.sbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0e0a1c; }
.sbtn:disabled { filter: grayscale(.7) brightness(.85); }
.dot { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; background: #ff3b5c;
  border: 2px solid #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.25); } }

/* 狀態條 */
.statbars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 14px 0 4px; }
.sbar { display: flex; align-items: center; gap: 6px; }
.sbar i { font-style: normal; font-size: 18px; width: 26px; height: 26px; display: grid; place-items: center; background: #120d22;
  border-radius: 50%; border: 2px solid #3b2f6e; }
.sbar .track { height: 14px; border-radius: 8px; border: 2px solid #0e0a1c; background: #120d22; }
.fill { background-image: linear-gradient(rgba(255,255,255,.35) 0 35%, transparent 35%); }

/* 面板 */
.panel { position: relative; background: linear-gradient(#352a66, #2a2152); border: 3px solid #0e0a1c; border-radius: 20px;
  padding: 22px 14px 14px; margin: 18px 0; box-shadow: 0 5px 0 #0e0a1c, inset 0 2px 0 rgba(255,255,255,.12); }
.panel-title { position: absolute; top: -13px; left: 14px; background: linear-gradient(#b58cff, #7d55e0); color: #fff; font-weight: 900;
  font-size: 13px; padding: 3px 14px; border-radius: 10px; border: 2px solid #0e0a1c; box-shadow: 0 2px 0 #0e0a1c; }
.panel .big { font-size: 34px; font-weight: 900; color: var(--gold); -webkit-text-stroke: 1px #3a2400; text-shadow: 0 3px 0 #0e0a1c; }
.evo { margin-top: 10px; } .evo .track { height: 12px; border-radius: 8px; border: 2px solid #0e0a1c; }
.evo-fill { background-color: #ff8fb8; }
.card { border: 3px solid #0e0a1c; box-shadow: 0 4px 0 #0e0a1c; }

/* 按鈕 */
.btn { border: 3px solid #0e0a1c; box-shadow: 0 4px 0 #0e0a1c; font-weight: 900; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn.primary { background: linear-gradient(#fff2a8 0 8%, #ffd25e 8%, #f6a823); box-shadow: 0 4px 0 #0e0a1c; text-shadow: none; }
.btn.wide { width: 100%; margin-top: 10px; }

/* 底部導覽 */
.tabbar { background: linear-gradient(#2a2152, #160f2c); border-top: 3px solid #0e0a1c; }
.tabbar button { position: relative; flex: 1; }
.tabbar button.center b { display: grid; place-items: center; width: 62px; height: 62px; margin-top: -30px; border-radius: 50%; font-size: 28px;
  background: linear-gradient(#fff2a8 0 8%, #ffd25e 8%, #f6a823); border: 3px solid #0e0a1c; box-shadow: 0 4px 0 #0e0a1c; }
.tabbar .dot { top: 0; right: calc(50% - 22px); }

/* 遊戲對話框 */
.game-dlg { border: 3px solid #0e0a1c; border-radius: 24px; background: linear-gradient(#3d3075, #2a2152); padding: 34px 18px 18px;
  box-shadow: 0 6px 0 #0e0a1c; overflow: visible; }
.ribbon { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); background: linear-gradient(#ff8fb8, #e0457a); color: #fff;
  font-weight: 900; font-size: 18px; padding: 6px 26px; border-radius: 12px; border: 3px solid #0e0a1c; white-space: nowrap; box-shadow: 0 3px 0 #0e0a1c; }
.chest { font-size: 76px; text-align: center; animation: shake 1.2s infinite; }
.chest.open { animation: pop .6s forwards; }
@keyframes shake { 0%,70%,100% { transform: rotate(0); } 75% { transform: rotate(-10deg); } 85% { transform: rotate(10deg); } }
@keyframes pop { 50% { transform: scale(1.4); } to { transform: scale(1); } }
.login-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 10px 0; }
.login-days div { text-align: center; font-size: 11px; font-weight: 800; padding: 6px 0; border-radius: 10px; background: #120d22; border: 2px solid #3b2f6e; }
.login-days div.done { background: #f6a823; color: #3a2400; border-color: #0e0a1c; }
.login-days div.today { outline: 3px solid #fff; }
.quest { display: flex; align-items: center; gap: 10px; background: #120d22; border: 2px solid #3b2f6e; border-radius: 14px; padding: 10px; margin: 8px 0; }
.quest .qi { font-size: 24px; } .quest .qt { flex: 1; font-weight: 800; font-size: 14px; } .quest .qt small { display: block; color: var(--muted); font-weight: 600; }
.quest .btn { margin: 0; padding: 8px 12px; font-size: 13px; }
.quest.claimed { opacity: .5; }

/* 升級彩帶 */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ===================================================================== 族群地圖 */
.map-mode, .lands { justify-content: center; }
.chip { border: 3px solid #0e0a1c; border-radius: 999px; background: #2a2152; color: var(--muted); font-weight: 900; font-size: 13px;
  padding: 6px 12px; box-shadow: 0 3px 0 #0e0a1c; cursor: pointer; }
.chip.active { background: linear-gradient(#fff2a8 0 8%, #ffd25e 8%, #f6a823); color: #3a2400; }
.world { position: relative; border-radius: 26px; padding: 16px 10px; border: 3px solid #0e0a1c; box-shadow: 0 6px 0 #0e0a1c;
  background: radial-gradient(circle at 20% 15%, #3aa0d8 0 2px, transparent 3px) 0 0/46px 46px,
              radial-gradient(circle at 70% 60%, #3aa0d8 0 2px, transparent 3px) 0 0/58px 58px,
              linear-gradient(#2a7fc0, #1d5e99); }
.island { position: relative; margin: 14px 2px 22px; padding: 26px 10px 12px; border-radius: 34px 26px 38px 24px;
  background: linear-gradient(#f3e3a6, #e6cf86); border: 3px solid #0e0a1c; box-shadow: 0 6px 0 rgba(0,0,0,.35), inset 0 0 0 6px rgba(120,200,110,.55); }
.island:nth-child(even) { border-radius: 26px 38px 24px 34px; }
.island-name { position: absolute; top: -15px; left: 16px; font-weight: 900; font-size: 13px; color: #fff; padding: 3px 12px;
  border-radius: 10px; border: 2px solid #0e0a1c; box-shadow: 0 2px 0 #0e0a1c; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { position: relative; border: 3px solid #0e0a1c; border-radius: 16px; padding: 8px 4px 6px; text-align: center; cursor: pointer;
  box-shadow: 0 4px 0 #0e0a1c; color: #1b1530; min-height: 86px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 #0e0a1c; }
.tile .em { font-size: 26px; line-height: 1; }
.tile .nm { font-size: 11px; font-weight: 900; margin-top: 3px; line-height: 1.15; }
.tile .vl { font-size: 13px; font-weight: 900; margin-top: 2px; }
.tile .flags { position: absolute; top: -9px; right: -6px; display: flex; gap: 2px; }
.tile .flags span { background: #fff; border: 2px solid #0e0a1c; border-radius: 9px; font-size: 10px; font-weight: 900; padding: 0 4px; }
.tile.mine::after { content: "★"; position: absolute; top: -10px; left: -6px; background: var(--gold); border: 2px solid #0e0a1c;
  border-radius: 50%; width: 20px; height: 20px; font-size: 12px; display: grid; place-items: center; }

/* 族群分析頁 */
.sec-hero { display: flex; align-items: center; gap: 12px; }
.sec-hero .em { font-size: 44px; } .sec-hero .nm { font-size: 22px; font-weight: 900; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv div { background: #120d22; border: 2px solid #3b2f6e; border-radius: 12px; padding: 8px 6px; text-align: center; }
.kv b { display: block; font-size: 17px; font-weight: 900; } .kv small { color: var(--muted); font-size: 11px; font-weight: 700; }
.flowbar { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; font-weight: 800; }
.flowbar .lbl { width: 72px; color: var(--muted); }
.flowbar .axis { flex: 1; position: relative; height: 16px; background: #120d22; border-radius: 8px; border: 2px solid #0e0a1c; overflow: hidden; }
.flowbar .axis::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: #3b2f6e; }
.flowbar .bar { position: absolute; top: 0; bottom: 0; }
.flowbar .val { width: 72px; text-align: right; }
.rank-spark svg { width: 100%; height: 70px; }
.mlist .item { padding: 8px 10px; }
.warn-box { background: #4a2a14; border: 2px solid #ff9d5c; border-radius: 12px; padding: 8px 10px; font-size: 13px; margin-top: 8px; }

/* ===================================================================== 帳本 */
#tab-ledger .topbar { justify-content: space-between; }
.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.cat { border: 3px solid #0e0a1c; border-radius: 14px; background: #2a2152; color: var(--text); padding: 6px 2px; text-align: center;
  font-size: 11px; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 #0e0a1c; }
.cat i { display: block; font-style: normal; font-size: 22px; }
.cat.active { background: linear-gradient(#fff2a8 0 8%, #ffd25e 8%, #f6a823); color: #3a2400; }
.big-amt { font-size: 28px !important; font-weight: 900; text-align: center; margin: 8px 0; }
#ledgerDlg input, #tradeDlg input, #recurDlg input, #recurDlg select { margin: 6px 0; }
.seg.kind { justify-content: center; }
.donut-wrap { display: flex; justify-content: center; } .donut-wrap svg { width: 180px; height: 180px; }
.catrow { display: flex; align-items: center; gap: 8px; margin: 7px 0; font-size: 14px; }
.catrow .ic { width: 26px; text-align: center; font-size: 18px; } .catrow .nm { width: 44px; font-weight: 800; }
.catrow .track { flex: 1; height: 12px; border-radius: 7px; border: 2px solid #0e0a1c; }
.catrow .am { width: 74px; text-align: right; font-weight: 800; } .catrow .cmp { width: 54px; text-align: right; font-size: 12px; }
.budget { margin: 8px 0; } .budget .top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; }
.budget .track { height: 16px; border-radius: 9px; border: 2px solid #0e0a1c; margin-top: 3px; }
.trend { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend .bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.trend .b { width: 12px; border-radius: 5px 5px 0 0; border: 2px solid #0e0a1c; border-bottom: 0; }
.trend .m { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 800; }
.dayhead { margin: 12px 2px 4px; font-size: 12px; font-weight: 800; color: var(--muted); display: flex; justify-content: space-between; }
.spend { color: #ff9d5c; } .earn { color: #7cc4ff; }

/* ===================================================================== 手遊首頁版面（原創美術） */
.home { --ink: #0b0820; }
.topres { display: flex; gap: 6px; padding-top: 10px; }
.rbar { flex: 1; position: relative; display: flex; align-items: center; height: 34px; padding: 0 8px 0 30px; border-radius: 10px;
  background: linear-gradient(#141033, #221a4d); border: 3px solid var(--ink); box-shadow: inset 0 2px 0 rgba(255,255,255,.08); }
.rbar b { flex: 1; text-align: right; font-size: 16px; font-weight: 900; color: #fff; -webkit-text-stroke: .6px var(--ink); text-shadow: 0 2px 0 var(--ink); }
.rbar b.up { color: #ff8b9a; } .rbar b.down { color: #6ff0a6; }
.rico { position: absolute; left: -6px; top: 50%; transform: translateY(-50%); font-size: 26px; filter: drop-shadow(0 2px 0 var(--ink)); }
.rplus { margin-left: 4px; color: #fff; font-weight: 900; font-size: 18px; cursor: pointer; }

.banner-row { display: flex; gap: 8px; margin: 12px 0 8px; align-items: stretch; }
.profile { flex: 1.25; position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 8px; border-radius: 0 18px 18px 0;
  margin-left: -14px; padding-left: 20px; background: linear-gradient(100deg, #ff7a59, #ff4f8b 60%, #b84bff); border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink); }
.profile .avatar-ring { width: 58px; height: 58px; }
.pinfo { flex: 1; min-width: 0; }
.pinfo #petName { font-size: 19px; font-weight: 900; color: #fff; -webkit-text-stroke: .8px var(--ink); text-shadow: 0 2px 0 var(--ink); }
.pstage { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 900; color: #fff; background: rgba(11,8,32,.45); padding: 1px 8px; border-radius: 6px; }
.medal { width: 46px; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 40% 30%, #fff6c9, #ffcc3d 55%, #d48a00); border: 3px solid var(--ink); border-radius: 50% 50% 46% 46%;
  box-shadow: 0 3px 0 var(--ink); color: #3a2400; line-height: 1; }
.medal span { font-size: 10px; font-weight: 900; } .medal b { font-size: 18px; font-weight: 900; }
.right-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sq-row { display: flex; gap: 6px; justify-content: flex-end; }
.sq { position: relative; width: 44px; height: 44px; border-radius: 10px; font-size: 22px; cursor: pointer;
  background: linear-gradient(#4d63e6, #2c3fb0); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink), inset 0 2px 0 rgba(255,255,255,.3); }
.pass { position: relative; border-radius: 12px; padding: 4px 8px 6px; cursor: pointer;
  background: linear-gradient(#ffe48a, #f5b632); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.pass-title { font-size: 12px; font-weight: 900; color: #6b3d00; }
.pass-bar { display: flex; align-items: center; gap: 6px; }
.pass-bar .track { flex: 1; height: 14px; border-radius: 8px; border: 2px solid var(--ink); background: #5a3600; }
.pass-bar span { font-size: 12px; font-weight: 900; color: #3a2400; }

/* 中央舞台（聚光燈） */
.arena { position: relative; height: 360px; border-radius: 26px; overflow: hidden; border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
  background: radial-gradient(ellipse at 50% 110%, #ff5fa2 0%, transparent 55%), radial-gradient(ellipse at 15% 0%, rgba(90,170,255,.85), transparent 55%),
    radial-gradient(ellipse at 85% 0%, rgba(255,90,140,.85), transparent 55%), linear-gradient(#3b2bb0, #6b2bb8 60%, #c2378f); }
.arena.night { filter: saturate(.85) brightness(.85); }
.spot { position: absolute; top: -40px; width: 120px; height: 420px; background: linear-gradient(rgba(255,255,255,.35), transparent 80%); filter: blur(6px); }
.spot.s1 { left: 18%; transform: rotate(18deg); animation: sweep 6s ease-in-out infinite alternate; }
.spot.s2 { right: 18%; transform: rotate(-18deg); animation: sweep 7s ease-in-out infinite alternate-reverse; }
@keyframes sweep { to { transform: rotate(-6deg); } }
.pedestal { position: absolute; left: 50%; bottom: 46px; width: 220px; height: 64px; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(ellipse at 50% 35%, #8a7bff, #4a33c9 60%, #2a1d80); border: 4px solid var(--ink); box-shadow: 0 8px 0 var(--ink); }
.arena .pet { bottom: 76px; width: 190px; height: 190px; z-index: 2; }
.arena .bubble { top: 12px; z-index: 6; max-width: 62%; font-size: 13px; }
.nameplate { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; padding: 6px 26px; border-radius: 12px;
  font-size: 22px; font-weight: 900; color: #fff; -webkit-text-stroke: 1px var(--ink); text-shadow: 0 3px 0 var(--ink);
  background: linear-gradient(#ffe48a, #f0a91f); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); white-space: nowrap;
  clip-path: polygon(6% 0, 94% 0, 100% 50%, 94% 100%, 6% 100%, 0 50%); }
.arena .side { top: 28px; gap: 14px; }
.rbtn { position: relative; width: 64px; height: 64px; border-radius: 50%; font-size: 28px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: radial-gradient(circle at 40% 30%, #9fd8ff, #3a8ef0 55%, #1d4fb0);
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink), inset 0 0 0 3px rgba(255,255,255,.35); }
.rbtn span { position: absolute; bottom: -16px; font-size: 11px; font-weight: 900; color: #fff; white-space: nowrap;
  -webkit-text-stroke: .5px var(--ink); text-shadow: 0 2px 0 var(--ink); }
.rbtn:active, .sq:active, .act-main:active, .act-card:active, .act-ticket:active { transform: translateY(3px); }

/* 每日任務條 */
.event { margin: 14px auto 0; width: 82%; border-radius: 16px 16px 14px 14px; background: linear-gradient(#7c4dff, #5a2fd6);
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); padding: 4px 8px 8px; cursor: pointer; }
.event-title { text-align: center; font-weight: 900; color: #fff; -webkit-text-stroke: .5px var(--ink); text-shadow: 0 2px 0 var(--ink); }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.slot { height: 46px; border-radius: 10px; display: grid; place-items: center; font-size: 24px; background: #3a2196; border: 3px solid var(--ink); }
.slot.done { background: #2a1a6e; color: #8b7bd8; font-size: 22px; }
.slot.ready { background: linear-gradient(#ffe48a, #f0a91f); animation: pulse 1.2s infinite; }

/* 大按鈕列 */
.action-row { display: flex; align-items: stretch; margin: 14px 0 6px; filter: drop-shadow(0 4px 0 var(--ink)); }
.act-card { width: 74px; border-radius: 16px 0 0 16px; background: linear-gradient(#3b8af2, #2257c4); border: 3px solid var(--ink); border-right: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 30px; cursor: pointer; }
.act-card small, .act-ticket small { font-size: 11px; font-weight: 900; color: #fff; -webkit-text-stroke: .4px var(--ink); }
.act-main { flex: 1; height: 78px; border: 3px solid var(--ink); cursor: pointer; font-size: 30px; font-weight: 900; color: #fff;
  -webkit-text-stroke: 1.2px var(--ink); text-shadow: 0 3px 0 var(--ink); letter-spacing: 2px;
  background: linear-gradient(#fff3a6 0 10%, #ffcf3a 10%, #f2a10f); box-shadow: inset 0 -6px 0 rgba(150,80,0,.35); }
.act-ticket { width: 74px; border-radius: 0 16px 16px 0; background: linear-gradient(#ff6b7d, #d9364f); border: 3px solid var(--ink); border-left: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 30px; cursor: pointer;
  clip-path: polygon(0 0, 100% 0, 92% 25%, 100% 50%, 92% 75%, 100% 100%, 0 100%); }

/* 底部導覽列：圖示磚 */
.tabbar { padding: 0 0 env(safe-area-inset-bottom); background: #2b3e8f; border-top: 3px solid var(--ink, #0b0820); }
.tabbar button { height: 64px; justify-content: center; font-size: 30px; border-right: 2px solid rgba(0,0,0,.25);
  background: linear-gradient(#3e56b8, #2b3e8f); filter: saturate(.8); }
.tabbar button span { display: none; }
.tabbar button.active { filter: none; background: linear-gradient(#6f8cff, #3e56b8); transform: translateY(-6px); border-radius: 12px 12px 0 0; }
.tabbar button.active span { display: block; color: #fff; -webkit-text-stroke: .4px #0b0820; text-shadow: 0 2px 0 #0b0820; }
.tabbar button.center b { width: 58px; height: 58px; margin-top: -26px; }
.tabbar button.center span { display: block; color: #fff; }
/* 調整：一列 5 格任務、不暗化舞台、讓大按鈕在 iPhone 首屏可見 */
.slots { grid-template-columns: repeat(5, 1fr); }
.slot { height: 40px; font-size: 20px; }
.arena.night { filter: none; }
.arena { height: 318px; }
.arena .pet { bottom: 66px; width: 170px; height: 170px; }
.pedestal { bottom: 40px; width: 200px; height: 56px; }
.arena .side { top: 20px; gap: 12px; }
.rbtn { width: 58px; height: 58px; font-size: 25px; }
.event { margin-top: 10px; }
.action-row { margin-top: 10px; }
.act-main { height: 70px; }
.banner-row { margin: 10px 0 8px; }

/* ===================================================================== 底部功能切換（手遊式圖示磚＋左右滑動） */
.swipe-nav { display: flex; padding: 0 0 env(safe-area-inset-bottom); background: #24357f; border-top: 3px solid #0b0820; gap: 0; }
.swipe-nav button { position: relative; flex: 1; height: 72px; padding: 0; border: 0; border-right: 2px solid #1a2766; cursor: pointer;
  background: linear-gradient(#3d55b5, #2a3c8f); display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: flex .25s, background .25s; filter: none; transform: none; border-radius: 0; }
.swipe-nav button b { font-size: 32px; line-height: 1; filter: drop-shadow(0 3px 0 #0b0820); transition: transform .25s; }
.swipe-nav button span { display: none; }
.swipe-nav button.active { flex: 1.7; background: linear-gradient(#7a95ff, #4560c9); transform: none; border-radius: 0; }
.swipe-nav button.active b { transform: translateY(-6px) scale(1.18); }
.swipe-nav button.active span { display: block; position: absolute; bottom: 6px; font-size: 13px; font-weight: 900; color: #fff;
  -webkit-text-stroke: .5px #0b0820; text-shadow: 0 2px 0 #0b0820; }
.swipe-nav button.active::before, .swipe-nav button.active::after { position: absolute; top: 50%; transform: translateY(-60%);
  font-size: 13px; color: #cfe0ff; text-shadow: 0 2px 0 #0b0820; }
.swipe-nav button.active::before { content: "◀"; left: 6px; }
.swipe-nav button.active::after { content: "▶"; right: 6px; }
.swipe-nav button:first-child.active::before, .swipe-nav button:last-child.active::after { content: ""; }
.swipe-nav .dot { top: 6px; right: 10px; }

/* 頁面滑入動畫 */
.tab.slide-left { animation: inFromRight .28s ease-out; }
.tab.slide-right { animation: inFromLeft .28s ease-out; }
@keyframes inFromRight { from { transform: translateX(40%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes inFromLeft { from { transform: translateX(-40%); opacity: 0; } to { transform: none; opacity: 1; } }
html, body { overflow-x: hidden; }

/* 右上快報方塊（主要快報入口）＋更新倒數 */
.news-sq { width: 52px !important; background: linear-gradient(#5a74ff, #3346c4) !important; }
.news-sq small { position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 900; color: #fff;
  white-space: nowrap; -webkit-text-stroke: .4px #0b0820; text-shadow: 0 1px 0 #0b0820; }
.sq-row { margin-bottom: 8px; }
.ledger-add { width: 100%; border-radius: 16px; height: 58px; font-size: 22px; margin: 4px 0 6px; box-shadow: 0 4px 0 #0b0820; }
.statbars { grid-template-columns: 1fr 1fr; }
.subs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.sub-add { display: flex; gap: 6px; align-items: center; }
.sub-add button { white-space: nowrap; flex: none; }
.hits button { width: 100%; display: flex; justify-content: space-between; gap: 8px; text-align: left; color: var(--text); font: inherit; margin: 4px 0; }
.gauges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 10px 0; text-align: center; }
.gauge svg { width: 100%; max-width: 130px; } .gauge text { font-size: 19px; font-weight: 900; fill: currentColor; }
.gauge b { display: block; font-size: 12px; } .gauge small { color: var(--muted); font-size: 11px; }
.pnl-chart svg { width: 100%; height: 90px; } .pnl-chart line { stroke: var(--muted); stroke-width: .5; }
.pnl-chart rect.up { fill: var(--up); } .pnl-chart rect.down { fill: var(--down); }
/* 大陸：不規則海岸線的一整塊陸地，區域畫在上面 */
.continent { position: relative; margin: 6px 0; padding: 34px 6px 18px; border: 4px solid #6b3f1d; background: #d9c98a;
  border-radius: 90px 40px 110px 55px / 60px 90px 50px 100px; box-shadow: 0 0 0 7px rgba(255,255,255,.35), 0 10px 0 7px rgba(0,0,0,.18); }
.world.us .continent { border-radius: 45px 110px 50px 120px / 90px 55px 110px 60px; background: #d8b98a; }
.land-name { position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-weight: 900; color: #4a2a0a; }
.continent .island { margin: 20px 4px 14px; }
#mapQ { width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 10px 14px; border-radius: 14px; border: 2px solid #6b3f1d; font-size: 16px; background: #fff8e6; color: #3a2208; }
#mapHits:not(:empty) { margin-bottom: 10px; max-height: 50vh; overflow-y: auto; }
#mapHits button { display: block; width: 100%; text-align: left; line-height: 1.6; }
.stock-price { font-size: 30px; font-weight: 900; margin-top: 6px; }
.stock-price small { font-size: 16px; }
.stock-chart { width: 100%; background: #fff8e6; border-radius: 12px; margin-top: 8px; }
.stock-chart text { font-size: 10px; fill: #6b3f1d; }
table.inst { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 14px; }
table.inst th, table.inst td { text-align: right; padding: 4px 2px; border-bottom: 1px solid rgba(0,0,0,.12); }
.item[data-stock] { cursor: pointer; }
.blk-row { display: flex; gap: 8px; justify-content: space-between; margin: 4px 0; }
#blockDlg .subs { flex-wrap: wrap; margin: 6px 0; }
#blkHits button { display: block; width: 100%; text-align: left; }
#kline { height: 380px; background: #fff; border-radius: 12px; margin: 8px 0; touch-action: none; }
.ocr-pick { display: block; text-align: center; margin: 8px 0 4px; }
