:root {
  --wood: #6b4528; --wood-dark: #3e2716; --wood-light: #a8713f;
  --parch: #fff6e3; --parch2: #f4e3c1; --ink: #4a2f1a; --accent: #e8743b; --accent2: #f2a63b;
  --good: #3fb64a; --gold: #ffd34d;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overscroll-behavior: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; margin: 0; height: 100%; overflow: hidden; background: #1b3a2a; font-family: Fredoka, 'Trebuchet MS', system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
#game { position: fixed; inset: 0; display: block; }

/* ------------------------------------------------ HUD */
#hud { position: fixed; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 10; gap: 8px; }
#hud > * { pointer-events: auto; }
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.hud-chip { display: flex; align-items: center; gap: 8px; padding: 5px 12px 6px 5px; border: 3px solid var(--wood-dark); border-radius: 18px; background: linear-gradient(#fff9ec, #f2dfb8); box-shadow: 0 4px 0 rgba(0,0,0,0.25); text-align: left; max-width: 62vw; }
.hud-chip canvas { width: 48px; height: 48px; background: radial-gradient(circle at 50% 40%, #fff, #ffe2a8); border-radius: 14px; border: 2px solid #e0b46a; flex: none; }
.hd-name { font-weight: 700; font-size: 15px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-name small { font-size: 11px; color: #a06a3a; margin-left: 2px; }
.hd-sub { font-size: 11px; color: #8a5a32; margin-bottom: 3px; }
.hd-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; min-width: 150px; }
.hd-bars .bar { position: relative; height: 12px; border-radius: 6px; background: rgba(74,47,26,0.18); overflow: hidden; }
.hd-bars .bar span { position: absolute; left: 1px; top: -2px; font-size: 10px; z-index: 2; }
.hd-bars .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; transition: width 0.4s; }
.bar.hunger i { background: linear-gradient(#ffb36b, #f07d2e); } .bar.fun i { background: linear-gradient(#ffe066, #f2b024); }
.bar.energy i { background: linear-gradient(#8fd8ff, #3a9ce8); } .bar.clean i { background: linear-gradient(#b9f2c8, #4fc477); }
.bar.egg { grid-column: 1 / -1; } .bar.egg i { background: linear-gradient(90deg, #ffd34d, #ff8f5a); }
.bar.low { animation: pulse 0.9s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px #ff5a3a; } }
.hud-pill { padding: 8px 14px; border-radius: 20px; background: linear-gradient(#5e3b1f, #3e2716); color: #ffe9a8; font-weight: 700; font-size: 17px; border: 3px solid #2a1a10; box-shadow: 0 4px 0 rgba(0,0,0,0.25); white-space: nowrap; }
.hud-pill.pop { animation: pop 0.4s; }
@keyframes pop { 40% { transform: scale(1.25); } }
.hud-btn { position: relative; width: 48px; height: 48px; border-radius: 16px; border: 3px solid var(--wood-dark); background: linear-gradient(#fff9ec, #f2dfb8); font-size: 22px; box-shadow: 0 4px 0 rgba(0,0,0,0.25); }
.hud-btn:active, .hud-chip:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.25); }
.hud-btn .dot { position: absolute; top: -4px; right: -4px; width: 16px; height: 16px; border-radius: 50%; background: #ff4d4d; border: 2px solid #fff; animation: pulse 1s infinite; }
body[data-scene="home"] #hud-home { display: none; }

#area-name { position: fixed; top: 32%; left: 50%; transform: translate(-50%, -50%); font-size: 30px; font-weight: 700; color: #fff; text-shadow: 0 3px 0 #3e2716, 0 0 18px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; z-index: 9; white-space: nowrap; }
#area-name.show { animation: areaname 2.6s ease-out; }
@keyframes areaname { 0% { opacity: 0; transform: translate(-50%, -30%); } 15%, 70% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; } }

/* ------------------------------------------------ controls */
#controls { position: fixed; inset: auto 0 0 0; height: 0; z-index: 8; }
#joy-zone { position: fixed; left: 0; bottom: 0; width: 50vw; height: 45vh; touch-action: none; }
.joy-base { position: absolute; left: calc(24px + env(safe-area-inset-left, 0px)); bottom: calc(24px + var(--safe-b)); width: 124px; height: 124px; border-radius: 50%; background: radial-gradient(rgba(255,255,255,0.18), rgba(255,255,255,0.08)); border: 3px solid rgba(255,255,255,0.45); display: grid; place-items: center; }
#joy-knob { width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, #e9d3a8); border: 3px solid var(--wood-dark); box-shadow: 0 4px 0 rgba(0,0,0,0.3); }
#btn-a { position: fixed; right: calc(28px + env(safe-area-inset-right, 0px)); bottom: calc(40px + var(--safe-b)); width: 84px; height: 84px; border-radius: 50%; border: 4px solid #7a2e12; background: radial-gradient(circle at 40% 35%, #ffb27a, #e8743b); color: #fff; font-size: 34px; font-weight: 700; text-shadow: 0 2px 0 #7a2e12; box-shadow: 0 6px 0 #7a2e12; touch-action: none; }
#btn-a:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a2e12; }
@media (hover: hover) and (pointer: fine) { .joy-base { opacity: 0.55; } }

/* ------------------------------------------------ home actions */
#home-actions { position: fixed; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 8px; z-index: 8; padding: 8px; border-radius: 22px; background: rgba(62,39,22,0.82); border: 3px solid #2a1a10; max-width: calc(100vw - 16px); overflow-x: auto; }
.act { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 72px; height: 76px; border-radius: 16px; border: 3px solid var(--wood-dark); background: linear-gradient(#fff9ec, #f2dfb8); box-shadow: 0 4px 0 rgba(0,0,0,0.3); padding: 2px; }
.act .ai { font-size: 26px; line-height: 1; } .act .al { font-weight: 700; font-size: 13px; margin-top: 2px; } .act .as { font-size: 10px; color: #8a5a32; }
.act:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.3); }
.act:disabled { opacity: 0.55; filter: grayscale(0.4); }
.act.go { background: linear-gradient(#ffcf8a, #f2a63b); }

/* ------------------------------------------------ speech + toast */
#speech { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translate(-50%, 20px); width: min(560px, calc(100vw - 24px)); display: flex; gap: 10px; align-items: center; padding: 10px 16px 10px 10px; background: var(--parch); border: 4px solid var(--wood); border-radius: 20px; box-shadow: 0 6px 0 rgba(0,0,0,0.3); opacity: 0; pointer-events: none; transition: 0.2s; z-index: 30; }
#speech.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#speech canvas { width: 60px; height: 60px; flex: none; background: radial-gradient(#fff, #f2dfb8); border-radius: 14px; }
.sp-name { font-weight: 700; color: var(--accent); font-size: 15px; } .sp-text { font-size: 17px; line-height: 1.3; }
#toasts { position: fixed; top: calc(74px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 60; pointer-events: none; width: min(520px, 92vw); }
.toast { background: rgba(42,26,16,0.92); color: #fff6e3; padding: 9px 16px; border-radius: 16px; font-size: 15px; font-weight: 500; text-align: center; border: 2px solid rgba(255,220,150,0.4); animation: toastin 0.3s; transition: 0.4s; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px); } }

/* ------------------------------------------------ panels */
#overlay-root { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#overlay-root > * { pointer-events: auto; }
.panel-wrap { position: fixed; inset: 0; background: rgba(20,10,5,0.5); display: grid; place-items: center; padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b)); animation: fadein 0.2s; }
@keyframes fadein { from { opacity: 0; } }
.panel { width: min(480px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--parch); border: 5px solid var(--wood); border-radius: 26px; box-shadow: 0 0 0 3px var(--wood-dark), 0 12px 0 rgba(0,0,0,0.35); animation: panelin 0.28s cubic-bezier(.2,1.4,.5,1); overflow: hidden; }
.panel.wide { width: min(760px, 100%); }
@keyframes panelin { from { transform: scale(0.85) translateY(20px); opacity: 0; } }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; background: linear-gradient(var(--wood-light), var(--wood)); color: #fff6e3; }
.panel-head h2 { margin: 0; flex: 1; font-size: 22px; text-shadow: 0 2px 0 var(--wood-dark); }
.panel-icon { font-size: 24px; }
.panel-head .x { width: 38px; height: 38px; border-radius: 12px; border: 3px solid var(--wood-dark); background: #fff6e3; color: var(--ink); font-size: 18px; font-weight: 700; }
.panel-body { padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.hint { color: #8a6a4a; font-size: 14px; } .empty { text-align: center; color: #8a6a4a; padding: 20px; grid-column: 1 / -1; }
.btn { border: 3px solid var(--wood-dark); border-radius: 14px; background: linear-gradient(#fff9ec, #eed6a6); padding: 9px 16px; font-weight: 700; font-size: 16px; box-shadow: 0 4px 0 rgba(0,0,0,0.25); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.25); }
.btn.primary { background: linear-gradient(#ffb27a, #e8743b); color: #fff; text-shadow: 0 2px 0 rgba(120,40,10,0.6); border-color: #7a2e12; }
.btn.danger { background: linear-gradient(#ff9a8a, #d9473a); color: #fff; border-color: #7a1e12; }
.btn.big { font-size: 20px; padding: 12px 26px; }
.btn.sm { font-size: 14px; padding: 6px 10px; }
.btn.wide { width: 100%; margin-top: 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { flex: 1; padding: 8px 10px; border-radius: 12px; border: 3px solid var(--wood); background: var(--parch2); font-weight: 700; font-size: 15px; white-space: nowrap; }
.tabs button.on { background: var(--wood); color: #fff6e3; }
.shop-head { display: flex; gap: 12px; align-items: center; background: var(--parch2); border-radius: 18px; padding: 8px 14px 8px 8px; margin-bottom: 12px; }
.shop-head canvas { width: 60px; height: 60px; flex: none; background: radial-gradient(#fff, #f2dfb8); border-radius: 14px; }
.shop-head b { color: var(--accent); } .shop-head p { margin: 2px 0 0; font-size: 15px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.moves { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.item, .move { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 10px 8px; border-radius: 16px; border: 3px solid #d9b98a; background: #fff; box-shadow: 0 3px 0 #d9b98a; }
button.item:active, button.move:active { transform: translateY(2px); box-shadow: 0 1px 0 #d9b98a; }
.item .ii { font-size: 34px; line-height: 1.1; } .item b, .move b { font-size: 15px; } .item small, .move small { font-size: 12px; color: #8a6a4a; }
.item .price, .move .price { margin-top: 4px; font-weight: 700; color: #b06a10; font-size: 14px; }
.item .cnt { position: absolute; top: 6px; right: 8px; font-size: 12px; font-weight: 700; background: var(--wood); color: #fff; border-radius: 10px; padding: 1px 7px; }
.item.locked, .move.locked { opacity: 0.55; filter: grayscale(0.6); }
.item.owned, .move.owned { border-color: #8fd18a; box-shadow: 0 3px 0 #8fd18a; }
.move.on { background: #f0ffe9; }
.move p { margin: 4px 0 0; font-size: 13px; }
.item.sell .row { display: flex; gap: 6px; margin-top: 6px; }
.el-fire b { color: #d9471c; } .el-water b { color: #1c7ed9; } .el-nature b { color: #2f9a33; } .el-storm b { color: #7a4ad9; }
.equipped label { font-weight: 700; } .eq-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 12px; }
.mv { padding: 5px 10px; border-radius: 12px; font-weight: 700; font-size: 14px; color: #fff; background: #9a8a7a; }
.mv.el-fire { background: #e8743b; } .mv.el-water { background: #3a9ce8; } .mv.el-nature { background: #4fae49; } .mv.el-storm { background: #8a5ce8; }

/* tailor / creator */
.tailor-main, .creator-main { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.preview { width: 130px; height: 150px; background: radial-gradient(circle at 50% 70%, #d9f0c8, #a8d48a); border-radius: 20px; border: 3px solid #d9b98a; flex: none; cursor: pointer; }
.creator .preview { width: 130px; height: 150px; }
.opts { flex: 1; min-width: 220px; }
.opt-row { margin-bottom: 10px; } .opt-row label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.swatches, .choices, .wardrobe { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #d9b98a; }
.sw.on { box-shadow: 0 0 0 3px var(--accent); transform: scale(1.12); }
.ch, .ward { padding: 6px 12px; border-radius: 12px; border: 3px solid #d9b98a; background: #fff; font-weight: 600; text-transform: capitalize; }
.ch.on, .ward.on { border-color: var(--accent); background: #fff1e6; }
.ward { display: flex; flex-direction: column; text-transform: none; } .ward small { color: #8a6a4a; font-size: 11px; } .ward.locked { opacity: 0.5; }
input { font-family: inherit; font-size: 18px; padding: 10px 14px; border-radius: 14px; border: 3px solid #d9b98a; width: 100%; color: var(--ink); background: #fff; user-select: text; -webkit-user-select: text; }

/* arena / training */
.daily-ch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: linear-gradient(#fff1d6, #ffe0b0); border: 3px solid #f2b05a; border-radius: 16px; padding: 10px 14px; margin-bottom: 12px; }
.daily-ch b { font-size: 16px; } .daily-ch small { flex: 1; min-width: 150px; color: #8a5a32; } .daily-ch.done { opacity: 0.7; }
.league { border: 3px solid #d9b98a; border-radius: 18px; padding: 10px; margin-bottom: 10px; background: #fff; }
.league.locked { opacity: 0.6; }
.lg-head { display: flex; align-items: center; gap: 8px; font-size: 18px; margin-bottom: 6px; } .lg-head em { color: var(--good); font-size: 14px; font-style: normal; font-weight: 700; }
.trainer { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-top: 1px dashed #e6cfa8; }
.trainer > div { flex: 1; } .trainer small { display: block; color: #8a6a4a; font-size: 13px; }
.trainer.beaten b::after { content: ' ✅'; }
.tr-el { font-size: 24px; }
.grid.drills { margin-bottom: 8px; }

/* bag */
.dcard { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.dcard canvas { width: 120px; height: 120px; background: radial-gradient(circle at 50% 40%, #fff, #ffe2a8); border-radius: 24px; border: 3px solid #e0b46a; flex: none; }
.dcard > div { flex: 1; min-width: 200px; } .dcard h3 { margin: 0 0 4px; font-size: 24px; } .dcard p { margin: 3px 0; }
.xpbar { position: relative; height: 18px; border-radius: 9px; background: #eadbc0; overflow: hidden; margin: 6px 0; }
.xpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #a77bff, #5ad1ff); }
.xpbar span { position: relative; font-size: 12px; font-weight: 700; padding-left: 8px; }
.hearts { letter-spacing: -2px; font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: #fff; border: 3px solid #d9b98a; border-radius: 14px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 13px; } .stat span { font-size: 24px; font-weight: 700; } .stat small { display: block; font-size: 11px; color: #8a6a4a; }
.next-unlock { display: flex; gap: 10px; align-items: center; background: #eaf7ff; border: 3px solid #9ad0f2; border-radius: 16px; padding: 10px; margin: 10px 0; }
.next-unlock span { font-size: 32px; } .next-unlock small { display: block; color: #4a6a8a; }
.gift { background: linear-gradient(#fff1d6, #ffe0b0); border: 3px solid #f2b05a; border-radius: 18px; padding: 12px; margin-bottom: 12px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 10px 0; }
.cd { background: #fff; border-radius: 12px; padding: 5px 2px; border: 2px solid #e6cfa8; display: flex; flex-direction: column; align-items: center; }
.cd small { font-size: 10px; color: #8a6a4a; } .cd span { font-size: 18px; } .cd b { font-size: 13px; }
.cd.got { opacity: 0.45; } .cd.got span::after { content: '✓'; color: var(--good); font-weight: 700; }
.cd.today { border-color: var(--accent); background: #fff1e6; animation: pop 1.2s infinite; }
.quests > b { display: block; margin-bottom: 6px; font-size: 17px; }
.quest { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid #d9b98a; border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; }
.quest > div { flex: 1; } .quest small { color: #8a6a4a; font-size: 12px; }
.qbar { height: 8px; border-radius: 4px; background: #eadbc0; overflow: hidden; margin: 4px 0 2px; } .qbar i { display: block; height: 100%; background: linear-gradient(90deg, #7ee36b, #3fb64a); }
.quest.done { border-color: #7ee36b; background: #f3ffed; } .quest.claimed { opacity: 0.55; }
.journal { margin-bottom: 14px; } .journal > b { font-size: 17px; }
.jgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; margin-top: 6px; }
.j { background: #fff; border: 2px solid #d9b98a; border-radius: 12px; padding: 6px; text-align: center; } .j span { font-size: 26px; display: block; } .j small { font-size: 11px; } .j.unk { opacity: 0.5; }
.settings .dev { margin-top: 14px; padding: 10px; border: 2px dashed #b9a477; border-radius: 12px; } .settings .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* celebrate */
.celebrate, .result { text-align: center; }
.cel-icon { font-size: 64px; animation: bounce 1s infinite; }
@keyframes bounce { 50% { transform: translateY(-8px) scale(1.05); } }
.cel-dragon { width: 180px; height: 150px; display: block; margin: 0 auto; }
.celebrate p, .result p { font-size: 17px; line-height: 1.4; }
.result .reward { font-weight: 700; color: #b06a10; font-size: 20px; }
.name-form { text-align: center; } .name-form canvas { width: 150px; height: 120px; } .name-form .chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.chip { padding: 6px 12px; border-radius: 12px; border: 2px solid #d9b98a; background: #fff; font-weight: 600; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 80; }
#fade.on { opacity: 1; }

/* ------------------------------------------------ screens */
#screen-root { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
#screen-root > * { pointer-events: auto; }
.screen { position: absolute; inset: 0; display: grid; place-items: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); overflow-y: auto; touch-action: pan-y; }
.title-screen { align-content: center; gap: 10px; text-align: center; }
.logo { display: flex; flex-direction: column; line-height: 0.9; animation: logoin 0.8s cubic-bezier(.2,1.4,.5,1); }
.logo span { font-weight: 700; color: #fff; -webkit-text-stroke: 3px #5a2a10; paint-order: stroke fill; text-shadow: 0 6px 0 #5a2a10, 0 10px 24px rgba(0,0,0,0.35); }
.logo .l1 { font-size: clamp(54px, 14vw, 110px); color: #ffd34d; } .logo .l2 { font-size: clamp(46px, 12vw, 92px); }
@keyframes logoin { from { transform: scale(0.4) rotate(-6deg); opacity: 0; } }
.tag { margin: 6px 0 12px; font-size: 20px; color: #fff; font-weight: 600; text-shadow: 0 2px 0 rgba(90,42,16,0.8); }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.menu .btn { min-width: 240px; }
.foot { color: rgba(255,255,255,0.9); text-shadow: 0 1px 0 rgba(0,0,0,0.4); margin-top: 18px; }
.screen .card { width: min(760px, 100%); background: var(--parch); border: 5px solid var(--wood); border-radius: 28px; box-shadow: 0 0 0 3px var(--wood-dark), 0 12px 0 rgba(0,0,0,0.35); padding: 18px; text-align: center; }
.screen .card h1 { margin: 0 0 8px; font-size: 30px; color: var(--wood); }
.creator .card { text-align: left; } .creator h1 { text-align: center; } .creator .go { display: block; margin: 10px auto 0; }
.egg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
@media (max-width: 600px) { .egg-grid { grid-template-columns: repeat(2, 1fr); } .stats { grid-template-columns: repeat(2, 1fr); } }
.egg-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; border-radius: 20px; border: 3px solid #d9b98a; background: #fff; box-shadow: 0 4px 0 #d9b98a; }
.egg-pick:hover { border-color: var(--accent); } .egg-pick:active { transform: translateY(3px); }
.egg-pick canvas { width: 100px; height: 110px; } .egg-pick b { font-size: 17px; } .egg-pick small { font-size: 12px; color: #8a6a4a; }

/* ------------------------------------------------ battle */
.battle-ui { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.battle-ui > * { pointer-events: auto; }
.hpcard { position: absolute; width: min(250px, 46vw); background: var(--parch); border: 4px solid var(--wood); border-radius: 16px; padding: 6px 10px; box-shadow: 0 4px 0 rgba(0,0,0,0.3); }
.hpcard.foe { top: calc(12px + var(--safe-t)); left: 12px; } .hpcard.me { right: 12px; bottom: calc(190px + var(--safe-b)); }
.hp-name { font-weight: 700; font-size: 15px; } .hp-name small { color: #8a6a4a; }
.hp-bar { height: 12px; border-radius: 6px; background: #4a3a2a; overflow: hidden; margin: 4px 0 2px; border: 2px solid #2a1a10; } .hp-bar i { display: block; height: 100%; }
.hp-num { font-size: 12px; text-align: right; font-weight: 700; }
.hp-status { display: flex; gap: 4px; flex-wrap: wrap; font-size: 11px; font-weight: 700; } .hp-status .up { color: #2f9a33; } .hp-status .down { color: #d9471c; }
.battle-bottom { position: absolute; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); background: var(--parch); border: 4px solid var(--wood); border-radius: 20px; padding: 10px; box-shadow: 0 0 0 3px var(--wood-dark); }
.battle-msg { font-size: 19px; font-weight: 600; min-height: 28px; padding: 2px 6px 6px; }
.battle-moves { display: none; grid-template-columns: 1fr 1fr; gap: 8px; }
.battle-moves.show { display: grid; }
@media (min-width: 700px) { .battle-moves { grid-template-columns: repeat(4, 1fr); } .battle-bottom { left: 50%; transform: translateX(-50%); width: min(820px, 96vw); } }
.move-btn { position: relative; display: flex; flex-direction: column; align-items: flex-start; padding: 8px 12px; border-radius: 14px; border: 3px solid #9a8a7a; background: linear-gradient(#ffffff, #efe6d6); box-shadow: 0 4px 0 #9a8a7a; text-align: left; }
.move-btn b { font-size: 16px; } .move-btn small { font-size: 12px; color: #6a5a4a; } .move-btn em { color: #d9471c; font-style: normal; font-weight: 700; }
.move-btn.el-fire { border-color: #e8743b; box-shadow: 0 4px 0 #b8501c; background: linear-gradient(#fff4ec, #ffd9c0); }
.move-btn.el-water { border-color: #3a9ce8; box-shadow: 0 4px 0 #1c6cb8; background: linear-gradient(#eef7ff, #cfe8ff); }
.move-btn.el-nature { border-color: #4fae49; box-shadow: 0 4px 0 #2f7a2a; background: linear-gradient(#f0fff0, #cdeec7); }
.move-btn.el-storm { border-color: #8a5ce8; box-shadow: 0 4px 0 #5a2ab8; background: linear-gradient(#f5f0ff, #ddd0ff); }
.move-btn:active { transform: translateY(3px); box-shadow: none; }
.move-btn:disabled { opacity: 0.5; }
.move-btn .cd { position: absolute; right: 8px; top: 6px; font-size: 11px; font-weight: 700; color: #8a5a32; }
.move-btn.flee { border-color: #9a8a7a; }

@media (max-width: 520px) {
  .hd-bars { min-width: 120px; } .hud-chip { padding-right: 8px; } .hud-chip canvas { width: 40px; height: 40px; }
  .hud-pill { font-size: 15px; padding: 6px 10px; } .hud-btn { width: 42px; height: 42px; font-size: 19px; }
  #home-actions { flex-wrap: wrap; justify-content: center; width: calc(100vw - 16px); gap: 6px; }
  .act { width: calc((100vw - 64px) / 4); max-width: 80px; height: 64px; } .act .ai { font-size: 22px; } .act .al { font-size: 12px; }
  .joy-base { width: 110px; height: 110px; } #btn-a { width: 74px; height: 74px; }
}
.loading { color: #fff; font-size: 24px; font-weight: 700; text-shadow: 0 2px 0 rgba(90,42,16,0.8); }
.egg-grid { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 700px) { .egg-grid { grid-template-columns: repeat(3, 1fr); } }

.hud-stack { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
#hud-quest { background: rgba(255,246,227,0.95); border: 3px solid var(--wood); border-radius: 14px; padding: 5px 10px; font-weight: 600; font-size: 13px; max-width: 62vw; box-shadow: 0 3px 0 rgba(0,0,0,0.2); }
.act.pulse { animation: actpulse 1.1s infinite; background: linear-gradient(#ffe9ef, #ffc2d4); border-color: #b0405f; }
@keyframes actpulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 4px rgba(255,120,160,0.5), 0 4px 0 rgba(0,0,0,0.3); } }
.poke-menu .btn { margin-top: 8px; }
.settings .fast { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 8px 0; }
.settings .fast input { width: 22px; height: 22px; }
/* joystick on the right (left-handed option) */
body.joy-right #joy-zone { left: auto; right: 0; }
body.joy-right .joy-base { left: auto; right: calc(24px + env(safe-area-inset-right, 0px)); }
body.joy-right #btn-a { right: auto; left: calc(28px + env(safe-area-inset-left, 0px)); }

#crash { z-index: 90; background: rgba(20,10,5,0.75); pointer-events: auto; }
