/*
VOICE: 玩具店櫃台上的掌上電子寵物——活潑、圓潤、按鍵有手感
IDEA: 整個 App 就是一台珊瑚色塑膠機殼，液晶螢幕裡住著寵物
PICTURE: 寵物頁的機殼＋像素液晶螢幕佔第一屏的一半，其餘頁面用同色系卡片
COLOUR and TYPE: 薄荷綠底、珊瑚紅機殼、液晶黃綠、陽光黃點綴；DotGothic16 數字＋Noto Sans TC
LAYOUT: 單欄、手機優先、最寬 560px，底部分頁列像機殼的按鍵帶
*/
:root{color-scheme:light dark;
  --bg:light-dark(#45c7b9,#0f2726);--bg2:light-dark(#3ab4a7,#0b1f1e);
  --card:light-dark(#fffdf7,#173533);--card2:light-dark(#f1f7ef,#1e403d);
  --ink:light-dark(#1b2b2a,#eaf6f3);--muted:light-dark(#5b6f6c,#9db9b4);--line:light-dark(#dfe9e3,#2a4e4a);
  --shell:#ff6b5e;--shell-d:#d94c40;--shell-l:#ff9a8f;
  --lcd:#cfe0a8;--lcd-ink:#26331b;--sun:#ffd23f;--good:#2fa86a;--bad:#e8344e;
  --r:18px;--pix:"DotGothic16",ui-monospace,monospace;
}
:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}
*{box-sizing:border-box;min-width:0}
[hidden]{display:none!important}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.55 "Noto Sans TC",system-ui,sans-serif;overflow-x:clip;-webkit-tap-highlight-color:transparent}
button,input,select{font:inherit;color:inherit}
button{cursor:pointer;border:0;background:none}
:focus-visible{outline:3px solid var(--sun);outline-offset:2px}
img.px,canvas{image-rendering:pixelated;image-rendering:crisp-edges}
#app{max-width:560px;margin:0 auto;min-height:100%;display:flex;flex-direction:column;padding-bottom:calc(76px + env(safe-area-inset-bottom))}
.boot{padding:40vh 0;text-align:center;font-family:var(--pix)}

/* 頂部列 */
.top{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;padding:calc(8px + env(safe-area-inset-top)) 14px 8px;background:var(--bg)}
.brand{font-weight:900;font-size:19px;letter-spacing:.02em;padding:6px 0}
.top-r{display:flex;gap:8px;align-items:center}
.coins{display:inline-flex;align-items:center;gap:6px;background:var(--card);border-radius:99px;padding:6px 12px 6px 8px;font-family:var(--pix);font-size:16px;box-shadow:0 2px 0 rgba(0,0,0,.12)}
.coins img{width:20px;height:20px}
.bell{position:relative;width:44px;height:44px;border-radius:50%;background:var(--card);display:grid;place-items:center;box-shadow:0 2px 0 rgba(0,0,0,.12)}
.bell-ico{width:21px;height:21px;background-size:contain;background-repeat:no-repeat}
.badge{position:absolute;top:2px;right:2px;min-width:18px;height:18px;border-radius:9px;background:var(--bad);color:#fff;font-size:11px;line-height:18px;text-align:center;padding:0 4px;font-family:var(--pix)}

main{flex:1;padding:4px 14px 20px;outline:none}
h1,h2,h3{margin:0;line-height:1.15;text-wrap:balance}
h1{font-size:30px;font-weight:900}h2{font-size:21px;font-weight:900}h3{font-size:17px;font-weight:700}
.sub{color:var(--muted);font-size:14px}
.num{font-family:var(--pix)}
.card{background:var(--card);border-radius:var(--r);padding:16px;box-shadow:0 3px 0 rgba(0,0,0,.08);margin-top:12px}
.row{display:flex;gap:10px;align-items:center}.row.wrap{flex-wrap:wrap}.grow{flex:1}
.between{justify-content:space-between}
.stack>*+*{margin-top:10px}
.pill{display:inline-flex;align-items:center;gap:4px;border-radius:99px;padding:2px 10px;font-size:13px;background:var(--card2);white-space:nowrap}
.el-fire{--el:#ff6b35}.el-water{--el:#2f9be0}.el-leaf{--el:#3fae5a}.el-thunder{--el:#e0a400}
.pill.el{background:var(--el);color:#fff;font-weight:700}
.btn{white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:0 16px;border-radius:14px;background:var(--shell);color:#fff;font-weight:700;box-shadow:0 3px 0 var(--shell-d);transition:transform .06s}
.btn:active{transform:translateY(2px);box-shadow:0 1px 0 var(--shell-d)}
.btn.alt{background:var(--card2);color:var(--ink);box-shadow:0 3px 0 var(--line)}
.btn.sun{background:var(--sun);color:#3a2a00;box-shadow:0 3px 0 #c99d10}
.btn.small{min-height:36px;padding:0 12px;font-size:14px;border-radius:11px}
.btn:disabled{opacity:.45;pointer-events:none}
.btn.full{width:100%}
input[type=text]{width:100%;min-height:46px;border-radius:12px;border:2px solid var(--line);background:var(--card2);padding:0 12px;font-size:16px}
.seg{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.seg button{min-height:52px;border-radius:12px;background:var(--card2);font-weight:700;font-size:14px;line-height:1.2;padding:4px}
.seg button small{display:block;font-weight:400;font-size:11px;color:var(--muted)}
.seg button[aria-pressed=true]{background:var(--shell);color:#fff}
.seg button[aria-pressed=true] small{color:#ffe3df}

/* 機殼 */
.device{margin:6px auto 0;max-width:420px;background:radial-gradient(120% 90% at 30% 10%,var(--shell-l),var(--shell) 45%,var(--shell-d));border-radius:46% 46% 38% 38% / 34% 34% 26% 26%;padding:34px 24px 22px;box-shadow:inset 0 -8px 0 rgba(0,0,0,.12),inset 0 6px 0 rgba(255,255,255,.25),0 10px 0 rgba(0,0,0,.12)}
.bezel{background:#3b3f46;border-radius:18px;padding:10px;box-shadow:inset 0 3px 0 rgba(0,0,0,.4)}
.plate{display:flex;justify-content:space-between;align-items:baseline;color:#e6ecd8;font-size:13px;padding:0 4px 6px;gap:8px}
.plate b{font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.screen{position:relative;border-radius:8px;overflow:hidden;background:var(--lcd);aspect-ratio:4/3}
.screen canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
.screen .bubble{position:absolute;left:50%;top:8%;transform:translateX(-50%);background:#fff;color:#222;border-radius:12px;padding:4px 10px;font-size:13px;font-weight:700;white-space:nowrap;max-width:92%;overflow:hidden;text-overflow:ellipsis;box-shadow:0 2px 0 rgba(0,0,0,.2);transition:opacity .3s}
.expbar{height:6px;border-radius:3px;background:#262a30;margin:8px 4px 0;overflow:hidden}.expbar i{display:block;height:100%;background:var(--sun)}
.keys{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:16px}
.key{display:flex;flex-direction:column;align-items:center;gap:4px;color:#fff;font-weight:700;font-size:13px}
.key span{width:54px;height:54px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff7d0,var(--sun) 55%,#d6a50f);box-shadow:0 4px 0 #a97d00,inset 0 -3px 0 rgba(0,0,0,.12);display:grid;place-items:center;transition:transform .06s}
.key span img{width:26px;height:26px}
.key:active span{transform:translateY(3px);box-shadow:0 1px 0 #a97d00}
.key:disabled{opacity:.45}
.key.glow span{animation:glow 1s ease-in-out infinite alternate;background:radial-gradient(circle at 35% 30%,#fff,#9ff0ff 55%,#3fb9d6);box-shadow:0 4px 0 #2a8aa0}
@keyframes glow{to{box-shadow:0 4px 0 #2a8aa0,0 0 18px 6px #bff6ff}}
.meters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 16px}
.meter{font-size:13px}.meter .row{justify-content:space-between}
.bar{height:12px;border-radius:6px;background:var(--card2);overflow:hidden;margin-top:3px;border:2px solid var(--line)}
.bar i{display:block;height:100%;background:var(--c,var(--good));transition:width .4s}
.warn{color:var(--bad);font-weight:700}
.log{list-style:none;margin:0;padding:0;font-size:14px}.log li{padding:6px 0;border-top:1px dashed var(--line)}.log li:first-child{border:0}

/* 清單 */
.list>*{display:flex;gap:12px;align-items:center;padding:12px 0;border-top:1px solid var(--line)}
.list>*:first-child{border-top:0}
.ava{width:56px;height:56px;flex:none;border-radius:14px;background:var(--lcd);display:grid;place-items:center;overflow:hidden}
.ava img{width:56px;height:56px;transform:scale(1.45) translateY(-7%)}
.flags{display:flex;gap:4px;flex-wrap:wrap;margin-top:3px}
.flag{font-size:11px;padding:1px 7px;border-radius:99px;background:#ffe1e1;color:#b0182f;font-weight:700}
.flag.ok{background:#dff6e8;color:#1b7a46}
.hearts{display:inline-flex;gap:2px}.hearts img{width:16px;height:16px}
.empty{color:var(--muted);text-align:center;padding:18px 6px;font-size:14px}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.tile{background:var(--card);border-radius:16px;padding:14px 10px;text-align:center;box-shadow:0 3px 0 rgba(0,0,0,.08);display:flex;flex-direction:column;align-items:center;gap:4px;font-weight:700;font-size:14px;position:relative}
.tile img{width:40px;height:40px}
.tile .dot{position:absolute;top:8px;right:10px;width:10px;height:10px;border-radius:50%;background:var(--bad)}
.shop-item{display:flex;gap:12px;align-items:center}
.shop-item>img{width:44px;height:44px;background:var(--card2);border-radius:12px;padding:6px}
.btn img{width:18px;height:18px}
.dex{display:grid;grid-template-columns:repeat(auto-fill,minmax(86px,1fr));gap:8px}
.dex>div{background:var(--card2);border-radius:14px;padding:6px 4px;text-align:center;font-size:12px}
.dex img{width:64px;height:64px}
.back{display:inline-flex;align-items:center;gap:4px;min-height:40px;font-weight:700;color:var(--ink)}
.title-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:8px 0 2px}
.code{font-family:var(--pix);font-size:28px;letter-spacing:.12em}

/* 分頁 */
.tabs{position:fixed;left:0;right:0;bottom:0;z-index:30;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));max-width:560px;margin:0 auto;background:var(--shell);padding:6px 6px calc(6px + env(safe-area-inset-bottom));border-radius:22px 22px 0 0;box-shadow:0 -4px 0 var(--shell-d) inset}
.tabs button{display:flex;flex-direction:column;align-items:center;gap:2px;color:#ffe3df;font-size:12px;font-weight:700;min-height:54px;justify-content:center;border-radius:14px}
.tabs button[aria-current=page]{color:#fff;background:rgba(0,0,0,.14)}
.ti{width:22px;height:22px;background-size:contain;background-repeat:no-repeat;background-position:center;opacity:.85}
.tabs button[aria-current=page] .ti{opacity:1}

/* 底部抽屜與全螢幕 */
.sheet-wrap{position:fixed;inset:0;z-index:70;background:rgba(10,25,24,.5);display:flex;align-items:flex-end;justify-content:center}
.sheet{width:100%;max-width:560px;max-height:86vh;overflow:auto;background:var(--card);border-radius:24px 24px 0 0;padding:18px 16px calc(18px + env(safe-area-inset-bottom));animation:up .2s ease-out}
@keyframes up{from{transform:translateY(30px);opacity:.4}}
.overlay{position:fixed;inset:0;z-index:60;background:var(--bg2);overflow:auto;padding:calc(12px + env(safe-area-inset-top)) 14px 24px}
.overlay .inner{max-width:560px;margin:0 auto}
.toast{position:fixed;left:50%;bottom:calc(92px + env(safe-area-inset-bottom));transform:translate(-50%,20px);z-index:80;background:#1b2b2a;color:#fff;padding:10px 16px;border-radius:14px;font-size:14px;font-weight:700;opacity:0;pointer-events:none;transition:.25s;max-width:min(92vw,480px);text-align:center}
.toast.on{opacity:1;transform:translate(-50%,0)}.toast.err{background:var(--bad)}

/* 小遊戲 */
.mg{text-align:center}
.mg canvas{width:100%;max-width:360px;aspect-ratio:4/3;background:var(--lcd);border-radius:12px;border:6px solid #3b3f46}
.mg .big{font-family:var(--pix);font-size:52px;line-height:1}
.tapbtn{width:180px;height:180px;border-radius:50%;margin:16px auto;display:grid;place-items:center;font-size:34px;font-weight:900;color:#fff;background:radial-gradient(circle at 35% 30%,var(--shell-l),var(--shell) 60%,var(--shell-d));box-shadow:0 8px 0 #a83a31;touch-action:manipulation;user-select:none}
.tapbtn:active{transform:translateY(5px);box-shadow:0 3px 0 #a83a31}
.track{position:relative;height:56px;border-radius:14px;background:var(--card2);border:3px solid var(--line);margin:24px 0 18px;overflow:hidden}
.track .zone{position:absolute;top:0;bottom:0;background:#8fe0a8}
.track .zone::after{content:"";position:absolute;left:50%;top:0;bottom:0;width:2px;background:#2fa86a}
.track .needle{position:absolute;top:-2px;bottom:-2px;width:6px;margin-left:-3px;background:var(--ink);border-radius:3px}
.pads{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;max-width:340px;margin:18px auto}
.pads button{aspect-ratio:1.4;border-radius:18px;font-size:30px;font-weight:900;color:#fff;opacity:.55;transition:opacity .1s,transform .1s;box-shadow:0 5px 0 rgba(0,0,0,.2)}
.pads button.on{opacity:1;transform:scale(1.04)}
.lr{display:flex;gap:14px;justify-content:center;margin-top:16px}.lr .btn{min-width:120px;min-height:60px;font-size:22px}
.res{font-size:20px;font-weight:900;min-height:32px;margin-top:8px}

/* 對戰 */
.arena{position:relative;background:#cfe0a8;border-radius:14px;overflow:hidden;border:6px solid #3b3f46;aspect-ratio:16/10}
.arena canvas{position:absolute;inset:0;width:100%;height:100%}
.hpbox{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px;margin:10px 0}
.hpbox .bar{height:14px}.hpbox .bar i{background:var(--good)}
.hpbox .low i{background:var(--sun)}.hpbox .crit i{background:var(--bad)}
.blog{background:var(--card);border-radius:14px;padding:12px 14px;min-height:76px;font-size:15px;font-weight:500}
.result{font-size:40px;font-weight:900;text-align:center;margin:10px 0 0}
.result.win{color:var(--shell)}

/* 登入 */
.hero{text-align:center;padding:24px 4px 8px}
.hero h1{font-size:44px;color:#fff;text-shadow:0 4px 0 var(--shell-d)}
.hero p{color:#0e3a36;font-weight:500;max-width:30em;margin:8px auto 0}
:root[data-theme=dark] .hero p{color:#cfeee8}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]) .hero p{color:#cfeee8}}
.parade{display:flex;justify-content:center;gap:4px;margin:18px 0 6px;flex-wrap:wrap}
.parade img{width:64px;height:64px;animation:hop 1.2s ease-in-out infinite}
.parade img:nth-child(2n){animation-delay:.3s}.parade img:nth-child(3n){animation-delay:.6s}
@keyframes hop{50%{transform:translateY(-8px)}}
.eggs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.eggs button{background:var(--card2);border-radius:16px;padding:10px;border:3px solid transparent;text-align:center}
.eggs button[aria-pressed=true]{border-color:var(--shell);background:var(--card)}
.eggs img{width:80px;height:80px}
.evo{position:fixed;inset:0;z-index:90;background:#0b1020;display:grid;place-items:center;color:#fff;text-align:center}
.evo img{width:192px;height:192px}
.evo.flash{animation:flash .18s 8 alternate}
@keyframes flash{to{background:#fff}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
@media (max-width:380px){.key span{width:46px;height:46px}.device{padding:28px 16px 18px}.code{font-size:22px}}

/* v0.2：世界、結繭、進修、日記、圖鑑 */
.world{display:flex;gap:12px;align-items:center;width:100%;text-align:left;background:var(--card);border-radius:16px;padding:10px 14px;margin:4px 0 10px;box-shadow:0 3px 0 rgba(0,0,0,.08)}
.world .wx{flex:none;width:52px;height:52px;border-radius:14px;display:grid;place-items:center;background:linear-gradient(160deg,#5b7bd6,#2b3f8f);color:#fff;font-weight:900;font-size:15px}
.world b{display:block}
.big-left{font-size:28px;margin:6px 0 0}
.cocoon-card{border:3px dashed var(--line)}
.seg.five{grid-template-columns:repeat(5,minmax(0,1fr))}
.seg button:disabled{opacity:.4}
.xpbars{margin-top:10px}.xpbars .row{gap:8px;margin-top:4px}.xpbars .xl{width:3em;font-size:13px}.xpbars .bar{margin-top:0}
.riddle{margin-top:12px;background:var(--card2);border-radius:14px;padding:10px 12px;border-left:4px solid var(--sun)}
.riddle p{margin:4px 0 0}
.rules{margin:10px 0 0;padding-left:1.2em}.rules li{margin:4px 0;font-weight:700}
.diary{margin:8px 0 0;line-height:1.7}
.row-btn{display:flex;gap:12px;align-items:center;width:100%;text-align:left;padding:12px 0;border-top:1px solid var(--line)}
.list>.row-btn:first-child{border-top:0}
.grid3.four{grid-template-columns:repeat(4,minmax(0,1fr))}
@media (max-width:380px){.seg.five button{font-size:12px;padding:2px}}
/* v0.3：多寵物 */
.pet-strip{display:flex;gap:8px;overflow-x:auto;padding:2px 2px 10px;margin-bottom:2px;scrollbar-width:none}
.pet-strip::-webkit-scrollbar{display:none}
.pet-cell{position:relative;flex:0 0 64px;display:grid;justify-items:center;gap:2px;padding:6px 4px;border-radius:14px;background:var(--card);border:2px solid transparent;color:inherit;font:inherit;cursor:pointer}
.pet-cell img{width:40px;height:40px}
.pet-cell.on{border-color:var(--shell);box-shadow:0 2px 0 rgba(0,0,0,.08)}
.pet-cell .nm{font-size:11px;max-width:58px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pet-cell .crown{position:absolute;top:2px;left:4px}.pet-cell .crown img{width:14px;height:14px}
.pet-cell .dot{position:absolute;top:6px;right:8px;width:9px;height:9px;border-radius:50%;background:var(--bad)}
.pet-cell .tag{position:absolute;top:2px;right:2px;font-size:10px;background:#55607a;color:#fff;border-radius:8px;padding:0 4px}
.pet-cell .tag.up{background:transparent;padding:0}.pet-cell .tag.up img{width:14px;height:14px}
.pet-cell.add .plus{font-size:26px;line-height:40px;height:40px;opacity:.7}
.pet-cell.lock{cursor:default;opacity:.55}.pet-cell.lock img{width:20px;height:20px;margin:10px 0}
.dormant-card img.px{width:72px;height:72px;filter:grayscale(.6)}
.guest-note{background:var(--card2);border-radius:14px;padding:10px 12px}
/* 分享邀請 */
.share-item textarea{width:100%;box-sizing:border-box;resize:none;font:inherit;font-size:14px;line-height:1.5;padding:10px 12px;border-radius:12px;border:1px solid var(--line);background:var(--card2);color:var(--ink)}
.share-list>div{display:block}
.invite-banner{border:2px solid var(--sun)}
.invite-banner img.px{width:56px;height:56px}
/* v0.4：斷線／等待畫面 */
.net{position:fixed;z-index:85;left:0;right:0;display:flex;justify-content:center;pointer-events:none}
.net.offline{inset:0;align-items:center;background:rgba(10,25,24,.55);pointer-events:auto}
.net.wait{bottom:calc(92px + env(safe-area-inset-bottom))}
.net-card{background:var(--card);border-radius:20px;padding:14px 16px;text-align:center;box-shadow:0 6px 0 rgba(0,0,0,.12);max-width:min(92vw,360px)}
.net.wait .net-card{padding:8px 12px;border-radius:16px}
.net canvas{width:320px;height:96px;image-rendering:pixelated;border-radius:12px;display:block;margin:0 auto}
.net.wait canvas{width:160px;height:48px}
.net p{margin:8px 0 0;font-size:15px;line-height:1.6}.net.wait p{font-size:13px;margin-top:4px}
/* v0.4：其他 */
.care-all{gap:6px;margin:-4px 0 10px;flex-wrap:wrap}.care-all img{width:16px;height:16px;vertical-align:-3px}
.checklist{list-style:none;padding:0;margin:8px 0}.checklist li{padding:4px 0;display:flex;gap:6px;align-items:baseline}.checklist li .sub{margin-left:auto}
.checklist li.ok{color:var(--good)}
.pet-cell .nm{font-size:12px}
