* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: #17102a; color: #f2eefc; max-width: 520px; margin: 0 auto; padding-bottom: 84px; }
header#hud { background: #241647; padding: 10px 12px; position: sticky; top: 0; z-index: 5; border-bottom: 2px solid #3d2a6e; }
.hudrow { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.hudrow.small { font-weight: 500; font-size: 13px; opacity: 0.9; margin-top: 4px; }
#guideBar { background: #3a2a12; color: #ffd98a; padding: 8px 12px; font-size: 13px; min-height: 36px; }
main { padding: 10px; }
/* R4-1: the arena has a FIXED height (never content-driven) and every
   in-flow row inside it has a fixed height, so the zone background —
   absolutely positioned to fill the arena — can never rescale mid-fight.
   It changes only on zone/boss change (arenaKey logic in ui.js). */
#arena { border-radius: 14px; padding: 16px 12px 12px; text-align: center; height: 515px; position: relative; overflow: hidden; transition: background 0.5s; cursor: pointer; user-select: none; display: flex; flex-direction: column; }
#arena > * { flex-shrink: 0; }
#monsterInfoBtn { height: 44px; align-self: center; }
#arena .arenahint { height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#zoneName { font-weight: 800; letter-spacing: 0.5px; text-shadow: 0 1px 3px rgba(0,0,0,0.5); height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#enemyGlyph { font-size: 92px; line-height: 1.1; margin: 10px 0 2px; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.45)); }
#enemyName { font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.bar { height: 16px; background: rgba(0,0,0,0.45); border-radius: 9px; margin: 8px 4px 2px; overflow: hidden; }
.bar > div { height: 100%; width: 100%; transform-origin: left center; transition: transform 0.15s; }
.bar.enemy > div { background: #ef5350; }
.bar.hero > div { background: #66bb6a; }
.bartext { font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,0.7); font-variant-numeric: tabular-nums; }
#enemyHpText { height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#heroHpText { height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.petblob { width: 44px; height: 44px; border-radius: 50% 50% 46% 46%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 20px; border: 2px solid rgba(255,255,255,0.5); }
.petblob.big { width: 56px; height: 56px; font-size: 26px; flex: none; }
.petlbl { font-size: 8px; color: #fff; text-shadow: 0 1px 2px #000; max-width: 42px; overflow: hidden; }
.hint { opacity: 0.85; margin-top: 8px; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.small { font-size: 12.5px; }
.btn { display: inline-block; min-height: 48px; padding: 10px 16px; margin: 6px 4px; border: none; border-radius: 10px; background: #5e35b1; color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn.ability { display: block; width: calc(100% - 8px); margin: 10px 4px; background: #c62828; font-size: 17px; }
.btn.ability:disabled { background: #6d4c41; opacity: 0.8; }
.btn.warn { background: #8d6e00; }
.btn.test { background: #37474f; border: 2px dashed #ffd54f; color: #ffe082; }
.card { background: #241647; border: 1px solid #3d2a6e; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.card h3 { margin: 2px 0 8px; }
.node { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px; margin: 5px 0; border-radius: 9px; background: #2e1d59; border: 1px solid #453073; }
.node.avail { border-color: #ffd54f; cursor: pointer; }
.node.owned { opacity: 0.75; border-color: #66bb6a; }
.node.locked { opacity: 0.55; }
.nodelabel { font-size: 12px; text-align: right; flex: none; max-width: 42%; }
.petcard .pethead { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.quest { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #3d2a6e; }
.quest:last-child { border-bottom: none; }
nav#tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; display: flex; background: #1c1033; border-top: 2px solid #3d2a6e; z-index: 10; }
nav#tabbar button { flex: 1; min-height: 62px; background: none; border: none; color: #cfc4f5; font-size: 13px; font-weight: 700; cursor: pointer; padding: 6px 0; }
nav#tabbar button.active { color: #ffd54f; background: #2a1a52; }
#offlineModal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modalcard { background: #241647; border-radius: 14px; padding: 20px; max-width: 420px; width: 100%; text-align: center; }
#toast { position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%) translateY(20px); background: #000; color: #fff; padding: 10px 16px; border-radius: 24px; font-size: 14px; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 30; max-width: 92%; text-align: center; }
#toast.show { opacity: 0.95; transform: translateX(-50%) translateY(0); }
.float { position: absolute; top: 34%; font-weight: 900; font-size: 21px; color: #fff; text-shadow: 0 2px 4px #000; animation: rise 0.9s ease-out forwards; pointer-events: none; }
.float.crit { color: #ffd54f; font-size: 27px; }
@keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-56px); opacity: 0; } }

/* ===== Fix pass v2 ===== */
/* per-screen palettes (no more all-purple) */
body[data-tab="battle"] header#hud { background: #17351c; border-bottom-color: #2e5d23; }
body[data-tab="tree"] header#hud { background: #0f2f2b; border-bottom-color: #14665a; }
body[data-tab="pets"] header#hud { background: #3d1430; border-bottom-color: #7a2a5e; }
body[data-tab="monsters"] header#hud { background: #2b1a10; border-bottom-color: #6e4520; }
body[data-tab="quests"] header#hud { background: #3a2a12; border-bottom-color: #8d6e00; }
body[data-tab="shop"] header#hud { background: #12303d; border-bottom-color: #1f5a72; }
body[data-tab="tree"] .card { background: #10261f; border-color: #1d4a3a; }
body[data-tab="pets"] .card { background: #2c1230; border-color: #5e2a6e; }
body[data-tab="monsters"] .card { background: #261a12; border-color: #54402a; }
body[data-tab="quests"] .card { background: #2a2110; border-color: #54451a; }
body[data-tab="shop"] .card { background: #122530; border-color: #1f4a5e; }

/* arena map background */
#zoneArt { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
#arenaShade { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
#arenaShade.bossShade { background: radial-gradient(ellipse at center, transparent 40%, rgba(120,0,0,0.45) 100%); }
#arena > *:not(#zoneArt):not(#arenaShade) { position: relative; z-index: 2; }
#arena .float { z-index: 6; }

/* fighters */
#fightStage { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; margin-top: 10px; height: 184px; }
#partyCol { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 118px; flex: none; }
#vsCol { font-size: 12px; font-weight: 900; letter-spacing: 1px; color: #ffd54f; align-self: center; flex: none; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.4); border-radius: 50%; text-shadow: 0 1px 2px #000; }
.fighter { position: relative; width: 104px; text-align: center; }
.fighter img { position: absolute; inset: 0; width: 100%; height: 88px; object-fit: cover; border-radius: 14px; border: 2px solid rgba(255,255,255,0.65); box-shadow: 0 6px 12px rgba(0,0,0,0.5); z-index: 1; }
/* R3-1/R3-2: the fallback glyph is absolutely positioned (never in flow), so
   showing/hiding it on image load/fail can neither paint over the portrait
   once imgOk hides it, nor shift the layout by its 88px box. */
.fighterFallback { position: absolute; top: 0; left: 0; right: 0; height: 88px; display: flex; align-items: center; justify-content: center; font-size: 52px; border-radius: 14px; background: rgba(0,0,0,0.35); border: 2px solid rgba(255,255,255,0.4); z-index: 0; }
.fighterName { margin-top: 94px; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px #000; line-height: 1.15; height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fighterSub { font-size: 10.5px; text-shadow: 0 1px 2px #000; opacity: 0.95; line-height: 1.2; height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#enemyFighter { width: 148px; cursor: pointer; }
#enemyFighter img, #enemyFighter .fighterFallback { height: 118px; }
#enemyFighter .fighterFallback { font-size: 72px; }
#enemyFighter .fighterName { margin-top: 124px; font-size: 14px; height: 19px; }
/* R4-1: ONE pet-row rule — a single no-wrap row at a fixed height; tiles
   shrink to fit all 4 active pets across the party column instead of
   wrapping to a second row and growing the arena. */
#petRow { display: flex; gap: 6px; height: 68px; flex-wrap: nowrap; justify-content: center; align-items: flex-start; margin: 0; width: 100%; overflow: hidden; }
.petfighter { width: 58px; flex: 1 1 0; min-width: 0; max-width: 58px; }
.petfighter img, .petfighter .fighterFallback { height: 48px; border-radius: 12px; }
.petfighter .fighterFallback { font-size: 26px; }
.petfighter .fighterName { margin-top: 52px; font-size: 9.5px; height: 12px; }
@keyframes lungeR { 0% { transform: translateX(0); } 40% { transform: translateX(16px) scale(1.05); } 100% { transform: translateX(0); } }
@keyframes lungeL { 0% { transform: translateX(0); } 40% { transform: translateX(-16px) scale(1.05); } 100% { transform: translateX(0); } }
@keyframes hitShake { 0% { transform: translateX(0); } 25% { transform: translateX(-5px); } 55% { transform: translateX(5px); } 100% { transform: translateX(0); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.lungeR { animation: lungeR 0.3s ease; }
.lungeL { animation: lungeL 0.3s ease; }
.hit { animation: hitShake 0.3s ease; }
.fighter img, .fighter .fighterFallback { animation: bob 2.6s ease-in-out infinite; }
.float.hurt { color: #ff8a80; }
.float.petdmg { color: #a5d6a7; font-size: 17px; }
.btn.small-btn { min-height: 40px; font-size: 13px; padding: 7px 12px; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.5); }
.btn:disabled { opacity: 0.55; }

/* battle statistics */
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; }
.statgrid > div { display: flex; flex-direction: column; background: rgba(0,0,0,0.22); border-radius: 8px; padding: 6px 8px; }
.statgrid span { font-size: 11px; opacity: 0.85; }
.statgrid b { font-size: 14.5px; }

/* screen art headers */
.screenhead { position: relative; border-radius: 12px; overflow: hidden; margin-bottom: 10px; min-height: 92px; background: #241647; }
.screenhead img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.screenheadTitle { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 12px 8px; font-weight: 800; font-size: 17px; text-shadow: 0 2px 4px #000; background: linear-gradient(180deg, transparent, rgba(0,0,0,0.72)); }

/* skill webs */
.webcard { padding: 8px; }
.webwrap { overflow: auto; max-height: 62vh; border-radius: 10px; background: radial-gradient(circle at center, #1d1440 0%, #120b28 75%); border: 1px solid #453073; -webkit-overflow-scrolling: touch; }
.websvg { display: block; margin: 0 auto; }
.webedge { stroke: #6a55a3; stroke-width: 2.5; opacity: 0.85; }
.webedge.webonly { stroke: #463a75; stroke-width: 1.2; opacity: 0.5; stroke-dasharray: 5 6; }
.webcenter { fill: #ffd54f; stroke: #8d6e00; stroke-width: 3; }
.webcentertext { fill: #3a2a12; font-size: 26px; text-anchor: middle; font-weight: 900; }
.webnode { cursor: pointer; }
.webnode circle { fill: #2e1d59; stroke: #6a55a3; stroke-width: 3.5; }
.webnode.avail circle { stroke: #ffd54f; fill: #4a3485; }
.webnode.choice circle { stroke: #ff9800; stroke-width: 3; stroke-dasharray: 6 4; }
.webnode.owned circle { fill: #2e7d32; stroke: #81c784; }
.webnode.locked { opacity: 0.62; }
.webnode.selected circle { stroke: #fff; stroke-width: 5; }
.webnodetext { fill: #fff; font-size: 15px; text-anchor: middle; font-weight: 700; pointer-events: none; }
.nodedetail { margin-top: 10px; background: rgba(0,0,0,0.25); border-radius: 10px; padding: 10px; line-height: 1.45; }

/* pets */
.petsq { position: relative; width: 56px; height: 56px; flex: none; display: inline-block; }
.petsq img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 14px; border: 2px solid rgba(255,255,255,0.5); z-index: 1; }
.petfallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; border-radius: 14px; z-index: 0; }

/* bestiary */
.bestgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bestcell { background: rgba(0,0,0,0.25); border-radius: 10px; padding: 6px; text-align: center; cursor: pointer; min-height: 112px; }
.bestcell img { width: 100%; height: 74px; object-fit: cover; border-radius: 8px; }
.bestunknown { height: 74px; display: flex; align-items: center; justify-content: center; font-size: 30px; background: rgba(0,0,0,0.4); border-radius: 8px; }
.bestcell.unknown { opacity: 0.65; }
.bestname { font-size: 11.5px; font-weight: 700; margin-top: 4px; line-height: 1.2; }

/* monster modal + offline art */
#monsterModal { position: fixed; inset: 0; background: rgba(0,0,0,0.72); display: flex; align-items: center; justify-content: center; z-index: 25; padding: 14px; }
#monsterCard { max-height: 88vh; overflow-y: auto; text-align: left; }
.monsterBig { width: 100%; height: 210px; object-fit: cover; border-radius: 10px; }
.lore { margin-top: 10px; background: rgba(0,0,0,0.3); border-left: 3px solid #ffd54f; border-radius: 6px; padding: 9px 10px; font-size: 13.5px; line-height: 1.5; }
.traitbox { margin-top: 8px; background: rgba(106,27,154,0.35); border: 1px solid #8e24aa; border-radius: 8px; padding: 7px 9px; font-size: 13px; }
#offlineArt { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; margin-bottom: 6px; }

/* ===== Round-2 pass (R2-3 / R2-4): menu art treatments + polish ===== */
/* R2-3: Daily tab — full-background art behind the content, dark overlay for readability */
#tab-quests { background: linear-gradient(180deg, rgba(16,10,4,0.64), rgba(16,10,4,0.86)), url('art/screen-daily.jpg') center top / cover no-repeat; border-radius: 14px; padding: 12px; }
#tab-quests .card { background: rgba(42,33,16,0.93); }
/* R2-3: daily login block gets its own art-backed styling (first card in the Daily tab) */
#tab-quests > .card:nth-of-type(2) { background: linear-gradient(180deg, rgba(24,17,6,0.68), rgba(24,17,6,0.88)), url('art/screen-daily.jpg') center / cover; border: 1px solid rgba(255,213,79,0.55); box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
/* R2-4: Shop tab — same full-background art treatment */
#tab-shop { background: linear-gradient(180deg, rgba(6,16,22,0.66), rgba(6,16,22,0.87)), url('art/screen-shop.jpg') center top / cover no-repeat; border-radius: 14px; padding: 12px; }
#tab-shop .card { background: rgba(18,37,48,0.93); }
/* R2-4: general menu polish — consistent cards, clearer headers, better spacing */
.card { padding: 14px; box-shadow: 0 3px 10px rgba(0,0,0,0.35); line-height: 1.45; }
.card h3 { font-size: 16.5px; letter-spacing: 0.3px; border-bottom: 1px solid rgba(255,255,255,0.14); padding-bottom: 6px; margin-bottom: 10px; }
.screenhead { box-shadow: 0 4px 14px rgba(0,0,0,0.45); }
.screenheadTitle { font-size: 18px; letter-spacing: 0.4px; }
.quest { padding: 10px 0; }
#tab-tree .card, #tab-pets .card, #tab-monsters .card { box-shadow: 0 3px 10px rgba(0,0,0,0.35); }

/* ===== Second update: toolbar, battle extras, gear/food/player UI ===== */
#toolbar { display: flex; gap: 8px; justify-content: flex-end; max-width: 520px; margin: 4px auto 0; padding: 0 10px; }
#bossTimer { margin-top: 6px; font-weight: 800; color: #ff8a65; text-shadow: 0 1px 3px #000; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#comboBar { margin-top: 4px; font-weight: 800; color: #ffd54f; text-shadow: 0 1px 3px #000; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#elemIndicator { margin-top: 6px; font-weight: 700; color: #ffe082; height: 36px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#bossPreview { display: flex; gap: 10px; align-items: center; margin-top: 10px; border: 1px solid rgba(255,138,101,0.6); height: 88px; overflow: hidden; }
#bossPreview img { width: 84px; height: 64px; object-fit: cover; border-radius: 8px; }
/* Boss gate state of the preview slot: gold border while a boss waits
   unchallenged (the slot itself stays the same fixed height). */
#bossPreview.gatecard { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,194,31,0.35); }
#bossPreview .btn { flex-shrink: 0; }
#lootPanel { position: fixed; left: 50%; transform: translateX(-50%) translateY(16px); bottom: 84px; width: min(92vw, 470px); background: rgba(24,16,44,0.97); border: 1px solid #ffd54f; border-radius: 12px; padding: 10px 12px; z-index: 30; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; box-shadow: 0 8px 28px rgba(0,0,0,0.6); }
#lootPanel.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.lootline { margin-top: 4px; font-size: 13.5px; }
.lootlore { font-size: 12px; opacity: 0.85; font-style: italic; margin: 2px 0 2px 10px; }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: 0; background: radial-gradient(circle, rgba(255,255,255,0.55), transparent 70%); }
#flash.flashshow { animation: flashanim 0.45s ease-out; }
#flash.goldflash { background: radial-gradient(circle, rgba(255,193,7,0.65), transparent 72%); }
@keyframes flashanim { 0% { opacity: 1; } 100% { opacity: 0; } }
.burst { position: absolute; font-size: 18px; pointer-events: none; animation: burstfly 0.7s ease-out forwards; z-index: 5; }
@keyframes burstfly { 0% { transform: translateY(0) scale(0.6); opacity: 1; } 100% { transform: translateY(-46px) scale(1.5); opacity: 0; } }
.float.crit { font-size: 27px; color: #ff5252; text-shadow: 0 0 8px rgba(255,82,82,0.8), 0 2px 3px #000; }
.masterybar { grid-column: 1 / -1; height: 7px; background: rgba(0,0,0,0.4); border-radius: 4px; overflow: hidden; }
.masterybar > div { height: 100%; background: linear-gradient(90deg, #ffb02e, #ffd54f); }
.slotrow { padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.streakdots { display: flex; gap: 6px; margin: 8px 0; }
.sdot { width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; opacity: 0.55; }
.sdot.on { background: #ff7043; opacity: 1; color: #fff; }
.textinput { background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.25); border-radius: 8px; color: #fff; padding: 8px 10px; font-size: 14px; max-width: 55%; }
.tintbtn.active { outline: 2px solid #ffd54f; }
.slotlabel { font-weight: 800; margin: 10px 0 4px; color: #cfc4f5; }
.gearcard { display: flex; gap: 10px; align-items: center; background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 7px; margin-bottom: 6px; cursor: pointer; text-align: left; }
.gearcard.equipped { border-color: #ffd54f; background: rgba(255,213,79,0.1); }
.gearcard.empty { cursor: default; }
.gearimg { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.gearinfo { min-width: 0; }
.gearDetail { margin-top: 10px; }
.foodrow { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.foodimg { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: none; }
.foodinfo { flex: 1; min-width: 0; }
.deltaup { color: #81c784; font-weight: 700; }
.deltadown { color: #ff8a65; font-weight: 700; }
.vaultcard { border: 1px solid rgba(255,176,46,0.65); background: linear-gradient(180deg, rgba(52,38,8,0.95), rgba(30,22,8,0.95)); }
.vaultitem { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255,213,79,0.25); }
.vaultimg { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; flex: none; border: 1px solid rgba(255,176,46,0.5); }
.vaultinfo { min-width: 0; }
.badgegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.badge { background: rgba(0,0,0,0.28); border-radius: 10px; padding: 8px; text-align: center; opacity: 0.55; }
.badge.got { opacity: 1; border: 1px solid rgba(255,213,79,0.5); }
.badgeicon { font-size: 24px; }
.setrow { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
#tab-player { background: linear-gradient(180deg, rgba(10,14,26,0.72), rgba(10,14,26,0.9)), url('art/hero-warrior.jpg') center top / cover no-repeat; border-radius: 14px; padding: 12px; }
#tab-player .card { background: rgba(16,22,38,0.93); }
body.reducedanim .fighter img, body.reducedanim .fighter .fighterFallback { animation: none !important; }
body.reducedanim .burst { display: none; }

/* ===== Round 3 (R3-3/R3-4): paper doll, icon grids, shop tiles ===== */
.paperdoll { display: grid; grid-template-columns: 68px 1fr 68px; grid-template-areas: ". helmet ." "weapon hero armor" "ring hero amulet" ". boots ."; gap: 8px; align-items: center; max-width: 340px; margin: 10px auto 4px; }
.pos-helmet { grid-area: helmet; } .pos-weapon { grid-area: weapon; } .pos-armor { grid-area: armor; }
.pos-ring { grid-area: ring; } .pos-amulet { grid-area: amulet; } .pos-boots { grid-area: boots; }
.dollcenter { grid-area: hero; position: relative; text-align: center; }
.dollcenter img { width: 100%; height: 190px; object-fit: cover; border-radius: 14px; border: 2px solid rgba(255,255,255,0.5); display: block; }
.dollcenter .petfallback { position: absolute; top: 0; left: 0; right: 0; height: 190px; display: flex; align-items: center; justify-content: center; font-size: 64px; background: rgba(0,0,0,0.35); border-radius: 14px; }
.dollname { font-weight: 800; font-size: 13px; margin-top: 6px; text-shadow: 0 1px 2px #000; }
.dollslot { position: relative; width: 100%; aspect-ratio: 1; min-height: 52px; border: 2px solid rgba(255,255,255,0.35); border-radius: 12px; background: rgba(0,0,0,0.3); cursor: pointer; overflow: hidden; }
.dollslot.empty { border-style: dashed; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.dollglyph { font-size: 22px; opacity: 0.75; }
.dollslot .dollimg { width: 100%; height: 100%; object-fit: cover; display: block; }
.dolllabel { position: absolute; left: 0; right: 0; bottom: 0; font-size: 9.5px; font-weight: 700; text-align: center; background: rgba(0,0,0,0.55); padding: 1px 0; }
.dollslot.empty .dolllabel { position: static; background: none; }
.invgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.geartile { position: relative; border: 2px solid rgba(255,255,255,0.3); border-radius: 10px; background: rgba(0,0,0,0.3); padding: 5px; cursor: pointer; text-align: center; }
.geartile.equipped { box-shadow: 0 0 0 2px #7de63a inset; }
.geartileimg { width: 100%; height: 56px; object-fit: cover; border-radius: 7px; display: block; }
.geartilelvl { position: absolute; top: 7px; left: 7px; background: rgba(0,0,0,0.7); color: #ffd54f; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 6px; z-index: 2; }
.geartileleg { position: absolute; top: 7px; right: 7px; font-size: 13px; z-index: 2; }
.geartilename { display: block; font-size: 11.5px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.geartilestats { display: block; font-size: 10.5px; opacity: 0.9; }
.pickerbox { border: 1px solid rgba(255,255,255,0.25); border-radius: 10px; padding: 10px; margin-top: 10px; background: rgba(0,0,0,0.25); }
.pickerhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.foodgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.foodtile { position: relative; border: 1px solid rgba(255,255,255,0.18); border-radius: 10px; background: rgba(0,0,0,0.25); padding: 6px; text-align: center; }
.foodtileimg { width: 100%; height: 54px; object-fit: cover; border-radius: 7px; display: block; }
.foodtimer { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.75); color: #ffd54f; font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 6px; }
.foodname { display: block; font-weight: 700; font-size: 12.5px; margin-top: 4px; }
.foodbtns { display: flex; gap: 6px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.foodbtns .btn { min-height: 40px; padding: 6px 10px; font-size: 12.5px; margin: 0; }
.loadoutrow { display: flex; gap: 8px; margin: 6px 0 4px; }
.loadouttile { flex: 1; border: 2px dashed rgba(255,255,255,0.3); border-radius: 10px; padding: 5px; text-align: center; font-size: 11.5px; font-weight: 700; }
.loadouttile.empty { display: flex; align-items: center; justify-content: center; min-height: 64px; opacity: 0.7; }
.loadoutimg { width: 100%; height: 40px; object-fit: cover; border-radius: 7px; display: block; margin-bottom: 3px; }
.shopgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.shoptile { border: 1px solid rgba(255,255,255,0.18); border-radius: 12px; background: rgba(0,0,0,0.25); padding: 10px; text-align: center; }
.shopglyph { font-size: 44px; line-height: 64px; height: 64px; }
.shopimg { width: 100%; height: 64px; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 6px; }
.shoptile .btn { width: 100%; margin: 8px 0 0; }
.vaultgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.vaulttile { position: relative; border: 2px solid rgba(255,176,46,0.45); border-radius: 10px; background: rgba(0,0,0,0.3); padding: 6px; cursor: pointer; text-align: center; }
.vaulttile.selected { outline: 2px solid #ffd54f; outline-offset: 1px; }
.vaulttile .vaultimg { width: 100%; height: 64px; }
.vaultname { display: block; font-weight: 800; font-size: 12px; margin: 4px 0 2px; line-height: 1.25; }
.vaultbuy { display: block; width: 100%; margin: 6px 0 0; padding: 6px 2px; font-size: 11.5px; min-height: 40px; }

/* ===== FINAL BUILD: design system (UI polish pass) =====
   One token set drives every screen. Deep neutral slate base; zone and
   art color do the talking; gold is reserved for rewards/Legendaries.
   The old all-purple wash is retired: surfaces below override the legacy
   purple rules by cascade order. */
:root {
  --bg: #12161d;
  --panel: #1b2230;
  --panel-2: #232c3f;
  --panel-3: #2b364e;
  --line: #33405a;
  --line-soft: rgba(255,255,255,0.09);
  --text: #eef2f8;
  --muted: #9fb0c3;
  --gold: #ffc21f;
  --gold-soft: #ffd54f;
  --green: #7de63a;
  --red: #ef5350;
  --blue: #6db9ff;
  --radius: 12px;
  --radius-sm: 8px;
  --space: 12px;
  --shadow: 0 3px 10px rgba(0,0,0,0.35);
  --font-h: 18px;
  --font-body: 14.5px;
  --font-small: 12.5px;
}
body { background: var(--bg); color: var(--text); font-size: var(--font-body); padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
header#hud { background: var(--panel); border-bottom: 2px solid var(--line); }
body[data-tab] header#hud { background: var(--panel); border-bottom-color: var(--line); }
#guideBar { background: #2b2113; color: var(--gold-soft); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
body[data-tab="tree"] .card, body[data-tab="pets"] .card, body[data-tab="monsters"] .card,
body[data-tab="quests"] .card, body[data-tab="shop"] .card, #tab-player .card { background: var(--panel); border-color: var(--line); }
#tab-player { background: linear-gradient(180deg, rgba(10,14,20,0.82), rgba(10,14,20,0.94)); }
#tab-quests, #tab-shop { background: none; padding: 0; }
#tab-quests > .card:nth-of-type(2) { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
.btn { background: var(--panel-3); border: 1px solid var(--line); color: var(--text); border-radius: var(--radius-sm); min-height: 48px; transition: transform 0.12s, opacity 0.12s, background 0.12s; }
.btn.warn { background: #6d5410; border-color: #8d6e00; }
.btn.test { background: #26313d; border: 2px dashed var(--gold); color: #ffe082; }
.btn.ability { background: #b3261e; border-color: #7a130d; }
.btn.small-btn { min-height: 44px; }
nav#tabbar { background: var(--panel); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav#tabbar button { color: var(--muted); min-height: 62px; }
nav#tabbar button.active { color: var(--gold); background: var(--panel-2); box-shadow: inset 0 3px 0 var(--gold); }
.modalcard { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.screenhead { background: var(--panel-2); border: 1px solid var(--line); }
.webwrap { background: radial-gradient(circle at center, #1d2637 0%, #12161d 78%); border-color: var(--line); }
.textinput { background: rgba(0,0,0,0.35); border-color: var(--line); }
input[type="range"] { accent-color: var(--gold); min-height: 44px; }

/* bonus-hours banner: FIXED-HEIGHT reserved slot — never shifts layout */
#bonusBanner { height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; margin-bottom: 8px; background: linear-gradient(90deg, rgba(255,194,31,0.16), rgba(255,194,31,0.05)); border: 1px solid rgba(255,194,31,0.45); border-radius: var(--radius-sm); font-size: 13px; white-space: nowrap; overflow: hidden; }
#bonusBanner .bonusclock { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

/* tutorial coach bar: absolute overlay inside the arena (no layout impact) */
#coachBar { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 9; background: rgba(16,20,28,0.96); border: 2px solid var(--gold); border-radius: var(--radius); padding: 10px 12px; text-align: left; box-shadow: 0 8px 24px rgba(0,0,0,0.55); }
.coachtext { font-size: 13.5px; line-height: 1.45; }
.coachbtns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.coachbtns .btn { min-height: 44px; margin: 0; }
@keyframes coachPulseAnim { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,194,31,0.55); } 50% { box-shadow: 0 0 0 7px rgba(255,194,31,0); } }
.coachPulse { animation: coachPulseAnim 1.5s ease-in-out infinite; }

/* hero accessory overlay + custom picture */
#heroAccessory { position: absolute; top: -8px; right: -4px; font-size: 30px; z-index: 3; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6)); pointer-events: none; }
.dollaccessory { position: absolute; top: 2px; right: 6px; font-size: 34px; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6)); z-index: 3; }
.customimgbox { margin-top: 10px; border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px; background: rgba(0,0,0,0.2); }
.customimgbox .btn { margin: 8px 4px 0 0; }

/* skill-web node icons */
.webnode { color: #b0bec5; }
.webnode.avail { color: #ffffff; }
.webnode.avail circle { animation: nodepulse 1.6s ease-in-out infinite; }
@keyframes nodepulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: 0.45; } }
.webnode.owned { color: #e8f5e9; }
.webnode.locked { color: #7d97a5; }
/* R4-2: node pictures read clearly at web size — a dark outline shadow
   behind every glyph lifts it off the node disc in all states. */
.webnode.capstone .nodeiconwrap { filter: drop-shadow(0 0 4px rgba(255,213,79,0.85)); }
.webnode.choice circle { stroke: #ff9800 !important; }
.nodeiconwrap { pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.85)) drop-shadow(0 0 1px rgba(0,0,0,0.9)); }
.nodecheck { fill: #2e7d32; stroke: #a5d6a7; stroke-width: 1.5; }
.nodechecktext { fill: #fff; font-size: 9px; font-weight: 900; text-anchor: middle; pointer-events: none; }
.nodeiconbig { float: left; margin: 2px 12px 4px 0; background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 10px; padding: 6px; line-height: 0; }
.nodedetail { overflow: hidden; }

/* intro cards (one-line, dismiss once) */
.introcard { display: flex; align-items: center; gap: 8px; background: rgba(255,194,31,0.1); border: 1px solid rgba(255,194,31,0.4); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; margin-bottom: 10px; line-height: 1.4; }
.introcard .btn { margin: 0 0 0 auto; flex: none; }

/* pets: quirks, evolution, expeditions, collection */
.quirkchip { display: inline-block; background: var(--panel-3); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin: 0 4px 4px 0; font-size: 11.5px; font-weight: 700; }
.evobadge { background: linear-gradient(90deg, #8e24aa, #3949ab); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 800; }
.petcard.evolved { border-color: #8e24aa; box-shadow: 0 0 0 1px #8e24aa, var(--shadow); }
.petcard.evolved .petsq img { filter: hue-rotate(35deg) saturate(1.5); }
.expcrew { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.expchip { display: flex; align-items: center; gap: 7px; background: var(--panel-2); border: 2px solid var(--line); color: var(--text); border-radius: var(--radius-sm); padding: 5px 9px 5px 5px; cursor: pointer; min-height: 48px; font-size: 12px; text-align: left; }
.expchip img { width: 38px; height: 38px; object-fit: cover; border-radius: 7px; }
.expchip i { font-style: normal; opacity: 0.85; font-size: 11px; }
.expchip.on { border-color: var(--gold); background: rgba(255,194,31,0.12); }
.collgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.collcell { background: rgba(0,0,0,0.25); border: 1px solid var(--line-soft); border-radius: 10px; padding: 6px; text-align: center; }
.collcell img { width: 100%; height: 56px; object-fit: cover; border-radius: 7px; }

/* bestiary: mastery + special fights */
.masterygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin: 8px 0; }
.masterycell { background: rgba(0,0,0,0.25); border: 1px solid var(--line-soft); border-radius: 10px; padding: 6px; text-align: center; }
.masterycell.current { border-color: var(--gold); }
.masterycell img { width: 100%; height: 52px; object-fit: cover; border-radius: 7px; }
.starline { color: var(--gold); font-size: 14px; letter-spacing: 1px; }
.starempty { color: rgba(255,255,255,0.3); }
.dungeonbox { position: relative; border-radius: var(--radius-sm); overflow: hidden; margin-top: 12px; border: 1px solid var(--line); }
.dungeonbox > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dungeoninfo { position: relative; background: linear-gradient(180deg, rgba(10,12,18,0.55), rgba(10,12,18,0.88)); padding: 12px; }
.setrow2 { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.setrow2:last-child { border-bottom: none; }
.setdots { color: var(--gold); letter-spacing: 2px; font-size: 13px; flex: none; padding-top: 2px; }

/* daily wheel */
.wheelprizes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.wheelchip { background: var(--panel-3); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.wheelresult { background: rgba(255,194,31,0.12); border: 1px solid rgba(255,194,31,0.5); border-radius: var(--radius-sm); padding: 8px 10px; margin: 8px 0; font-size: 14px; }

/* shop: save codes */
.savecode { width: 100%; background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); padding: 8px; font-size: 11.5px; margin: 8px 0 2px; word-break: break-all; }

/* cosmetics */
.cosgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.coscell { background: rgba(0,0,0,0.25); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px; text-align: center; }
.coscell.locked { opacity: 0.62; }
.cosicon { font-size: 34px; line-height: 1.2; }
.coscell .btn { min-height: 44px; margin: 8px 0 0; width: 100%; }

/* class select modal */
#classModal { position: fixed; inset: 0; background: rgba(0,0,0,0.78); display: flex; align-items: center; justify-content: center; z-index: 26; padding: 14px; }
#classCard { max-height: 90vh; overflow-y: auto; text-align: left; }
.classgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.classcell { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; text-align: left; }
.classimg { width: 100%; height: 104px; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 6px; }
.classcell .btn { width: 100%; margin: 8px 0 0; }

/* nursery */
.nurseryfield { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); padding: 14px 10px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 190px; }
.nurserybg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.nurseryslime { position: relative; background: rgba(10,14,20,0.55); border: 2px solid rgba(255,255,255,0.35); border-radius: 14px; padding: 6px 6px 4px; cursor: pointer; color: #fff; min-width: 76px; min-height: 44px; }
.nurseryslime.sel { border-color: var(--gold); }
.nurseryslime.evolved { border-color: #ba68c8; }
.nurseryslime .petsq.big { width: 62px; height: 62px; }
.nurseryname { display: block; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; margin-top: 3px; max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nurserygift { position: absolute; top: -8px; right: -6px; font-size: 22px; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6)); }

/* intentional empty states */
.emptyart { text-align: center; padding: 26px 16px; }
.emptyglyph { font-size: 52px; margin-bottom: 8px; }

/* ---------- Round 4: consolidated Settings + music track picker ---------- */
#settingsCard { scroll-margin-top: 84px; }
.trackgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.trackbtn { margin: 0; min-height: 56px; text-align: left; line-height: 1.25; }
.trackbtn.active { border: 2px solid var(--gold); background: #3a2c10; color: #ffe082; }

/* ---------- Content update: incubators, wheel odds, characters, unlocks ---------- */
#unlockModal { position: fixed; inset: 0; background: rgba(0,0,0,0.82); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 14px; }
.unlockart img { width: 100%; max-height: 240px; object-fit: cover; border-radius: 10px; }
.unlockname { font-size: 26px; font-weight: 800; color: var(--gold); margin: 6px 0; }
.unlockbtns { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.incgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.inccell { border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; background: var(--panel2, rgba(255,255,255,0.03)); }
.inccell.ready { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,193,7,0.35); }
.inccell .incicon { font-size: 30px; }
.inccell .btn { margin-top: 6px; }
.oddstable { margin-top: 4px; }
.oddsrow { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.chargrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 8px 0; }
.charcell { border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.charcell.active { border-color: var(--gold); }
.charcell .charimg { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; }
.newbadge { background: #e53935; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 8px; vertical-align: middle; }
.legendarytile { border: 1px solid #b8860b !important; box-shadow: 0 0 14px rgba(255,193,7,0.25); }
.legendarycard { border-color: #b8860b; }
.ultline { margin: 6px 0; padding: 6px 8px; border: 1px solid var(--gold); border-radius: 8px; background: rgba(255,193,7,0.08); font-size: 14px; }
