:root {
  color-scheme: only light;   /* opt out of forced/auto dark modes (seen on a Mac): the game has its own palette */
  --orange: #f7931e;
  --orange-d: #d9740b;
  --green: #17402d;
  --green-2: #1f5038;
  --cream: #fff3dc;
  --navy: #1d2433;
  --navy-2: #283247;
  --ink: #23182b;
  --glim: #7ff0ff;
  --gold: #ffd84a;
  --font: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--orange); color: var(--cream); font-family: var(--font); overflow: hidden;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: inherit; font-size: .75em; background: var(--cream); color: var(--navy); border-radius: 5px; padding: 1px 6px; font-weight: 700; }
#app, .page { position: fixed; inset: 0; }
h1, h2, h3 { margin: 0; font-weight: 700; }

/* ── buttons ───────────────────────── */
/* default colours on .btn itself: a bare .btn used to fall back to the browser's white button with cream text */
.btn { border: 0; border-radius: 14px; padding: 12px 22px; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em;
  background: var(--orange); color: var(--navy);
  box-shadow: 0 5px 0 rgba(0,0,0,.28); transition: transform .08s, box-shadow .08s, filter .15s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.28); }
.btn:hover { filter: brightness(1.07); }
.btn-big { background: var(--orange); color: var(--navy); font-size: 1.3rem; padding: 14px 34px; }
.btn-alt { background: var(--navy); color: var(--cream); }
.btn-ghost { background: rgba(255,255,255,.12); color: var(--cream); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: .95rem; }
.btn:disabled { opacity: .45; cursor: default; }
.pill { background: #ff4d6d; color: #fff; border-radius: 99px; padding: 0 8px; font-size: .8rem; margin-left: 6px; }
.sound-toggle { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 14px; border: 0; background: rgba(0,0,0,.25);
  border-radius: 50%; width: 44px; height: 44px; font-size: 1.2rem; }
.sound-toggle.inline { position: static; margin-top: 4px; }
.home-inner .sound-toggle { position: fixed; }
#mascot { filter: drop-shadow(0 0 30px rgba(255,240,160,.6)); }

/* ── HOME ──────────────────────────── */
/* Flex + margin:auto on the column = centred when it fits, scrollable from the top when it doesn't
   (grid place-items:center clipped both ends on short phones with a browser tab bar). */
#page-home { background: radial-gradient(ellipse at 50% 30%, #2f7a4a 0%, #17402d 70%); display: flex;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.home-bg, #home-critters { position: absolute; inset: 0; width: 100%; height: 100%; }
.home-bg { position: fixed; }
.home-inner { position: relative; margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); text-align: center; max-width: 520px; }
#mascot { width: 220px; height: 160px; margin-bottom: -18px; }
.logo { font-size: clamp(2.6rem, 11vw, 4.4rem); line-height: .9; color: var(--gold); text-shadow: 0 5px 0 var(--orange-d), 0 9px 18px rgba(0,0,0,.35);
  display: flex; flex-direction: column; letter-spacing: .01em; }
.logo span { color: var(--cream); font-size: .72em; text-shadow: 0 4px 0 #b25d08, 0 8px 16px rgba(0,0,0,.35); }
.tagline { margin: 4px 0 8px; opacity: .9; font-weight: 500; }
.home-stats { font-size: .9rem; opacity: .8; margin: 4px 0 0; min-height: 1.2em; }
.how { font-size: .85rem; opacity: .7; margin: 0; }
.home-inner .btn { min-width: 240px; }
/* Short screens (phone portrait with browser chrome): tighten the column so everything fits without scrolling. */
@media (max-height: 780px) {
  .home-inner { gap: 8px; }
  #mascot { width: 150px; height: 109px; margin-bottom: -12px; }
  .logo { font-size: clamp(2.2rem, 9vw, 3.4rem); }
  .tagline { margin: 0 0 2px; font-size: .9rem; }
  .home-inner .btn { padding-top: 9px; padding-bottom: 9px; }
  .home-inner .btn-big { padding-top: 11px; padding-bottom: 11px; }
}
@media (max-height: 640px) {
  .tagline, .how { display: none; }
  #mascot { width: 110px; height: 80px; margin-bottom: -8px; }
}

.night-pick { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.25); border-radius: 99px; padding: 4px; }
.night-pick button { border: 0; background: rgba(255,255,255,.12); border-radius: 50%; width: 34px; height: 34px; }
.night-pick button:disabled { opacity: .25; cursor: default; }
.np-label { min-width: 84px; text-align: center; font-weight: 600; }

/* ── PLAY ──────────────────────────── */
#page-play { background: #3a8249; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); }
.xpbar { position: relative; height: 14px; background: rgba(20,15,35,.55); border-radius: 99px; overflow: hidden; border: 2px solid rgba(255,243,220,.5); }
.xpfill { height: 100%; width: 0; background: linear-gradient(90deg, #6fe0ff, #b98aff); transition: width .15s; }
/* Umbra's Madness (umbra.js, under the HP bar on its summit): violet, cracked at 25/50/75, beating from 50 */
.madbar { position: relative; width: min(200px, 100%); margin-top: 6px; height: 11px; background: rgba(20,10,35,.65); border-radius: 99px; overflow: hidden; border: 2px solid rgba(200,160,255,.55); }
.madbar::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent calc(25% - 1px), rgba(10,0,20,.9) 25%, transparent calc(25% + 1px), transparent calc(50% - 1px), rgba(10,0,20,.9) 50%, transparent calc(50% + 1px), transparent calc(75% - 1px), rgba(10,0,20,.9) 75%, transparent calc(75% + 1px)); pointer-events: none; }
.madfill { height: 100%; width: 0; background: linear-gradient(90deg, #5b2a9e, #b46bff, #ff6bd8); transition: width .12s; }
.madbar.hot .madfill { animation: madbeat .6s ease-out infinite; }
.madbar.lost { border-color: #fff; }
@keyframes madbeat { 0% { filter: brightness(1.6); } 30% { filter: brightness(1); } 45% { filter: brightness(1.3); } 100% { filter: brightness(1); } }
.madbar span { position: absolute; inset: 0; font-size: 9px; font-weight: 700; line-height: 7px; text-align: center; text-shadow: 0 1px 2px #000; color: #f3e6ff; }
.xpbar span { position: absolute; inset: 0; font-size: 10px; font-weight: 700; line-height: 10px; text-align: center; text-shadow: 0 1px 2px #000; }
/* HUD (to-do 2026-11-11, VS-style): held weapons + perks top-left, clock + pops in the middle, glim + pause top-right; the health bar is drawn under the hero (render.js drawHeroHp) */
.hud-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; margin-top: 8px; }
.hud-left { min-width: 0; }
.hud-mid { display: flex; flex-direction: column; align-items: center; }
.hud-kills { display: flex; gap: 5px; align-items: center; font-size: 1rem; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.4); margin-top: -2px; }
.hud-kills span { font-size: .9rem; }
.hud-held { display: flex; gap: 4px; flex-wrap: wrap; }
.hud-held + .hud-held { margin-top: 4px; }
.hud-held span { width: 36px; height: 36px; display: grid; place-items: center; font-size: 1.35rem; background: rgba(20,15,35,.6); border: 2px solid rgba(255,243,220,.45); border-radius: 8px; }
.hud-held span.evo { border-color: #ffd34a; box-shadow: 0 0 6px rgba(255,211,74,.6); }
.hud-held.perks span { width: 28px; height: 28px; font-size: 1rem; border-color: rgba(190,210,255,.4); }
@media (max-width: 520px) { .hud-glim { font-size: 1rem; padding: 3px 8px; } .hud-right { gap: 5px; } }
@media (max-width: 520px) { .hud-held span { width: 30px; height: 30px; font-size: 1.1rem; } .hud-held.perks span { width: 24px; height: 24px; font-size: .85rem; } }
.hud-glim { background: var(--navy); border-radius: 12px; padding: 4px 12px; font-size: 1.25rem; display: flex; gap: 6px; align-items: center; border: 2px solid var(--orange); }
.glim-ico { color: var(--glim); }
.hud-timer { font-size: 1.8rem; font-weight: 700; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.hud-timer.boss { color: #ff9ec2; animation: throb .8s infinite; }
.hud-timer.ot { color: #ffb84a; }
.hud-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.hud-pause { pointer-events: auto; border: 0; background: var(--navy); border-radius: 12px; width: 44px; height: 40px; font-size: .9rem; border: 2px solid var(--orange); }
.banner { position: absolute; left: 50%; top: 26%; transform: translate(-50%, -50%); font-size: clamp(1.3rem, 6vw, 2.6rem); font-weight: 700;
  color: var(--gold); text-shadow: 0 4px 0 var(--orange-d), 0 8px 20px rgba(0,0,0,.5); animation: pop-in .35s ease-out;
  width: max-content; max-width: calc(100vw - 24px); text-align: center; line-height: 1.15; overflow-wrap: break-word; pointer-events: none; }   /* wraps on a phone, never wider than the screen */
.banner small { display: block; font-size: .5em; margin-top: .35em; text-shadow: 0 2px 0 var(--orange-d), 0 4px 12px rgba(0,0,0,.6); }
@keyframes throb { 50% { transform: scale(1.08); } }
/* the moonbeast button (beast.js): a ring that fills with the moon meter, then counts the form down */
.hud-beast { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 68px; height: 68px;
  border-radius: 50%; border: 0; padding: 0; pointer-events: auto; display: grid; place-items: center; opacity: .75;
  background: conic-gradient(#d9d0ff calc(var(--m, 0) * 1turn), rgba(20, 18, 50, .55) 0); }
.hud-beast[hidden] { display: none; }
.hud-beast::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: #1d1a3f; }
.hud-beast span { position: relative; font-size: 1.9rem; filter: grayscale(.7); }
.hud-beast small { position: absolute; right: 2px; bottom: 0; font-size: .7rem; font-weight: 700; background: #1d1a3f; color: #d9d0ff;
  border-radius: 6px; padding: 0 4px; border: 1px solid #d9d0ff; }
.hud-beast.ready { opacity: 1; animation: throb .8s infinite; box-shadow: 0 0 20px rgba(220,210,255,.9); }
.hud-beast.ready span, .hud-beast.on span { filter: none; }
.hud-beast.on { opacity: 1; background: conic-gradient(#fff3b0 calc(var(--m, 0) * 1turn), rgba(20, 18, 50, .55) 0); }
@media (hover: none) { .hud-beast small { display: none; } }
@keyframes pop-in { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15,10,30,.55); padding: 16px; z-index: 10; }
.modal { position: fixed; z-index: 30; }
.panel[tabindex="-1"]:focus { outline: none; }   /* dialog.js focuses the panel itself; its controls keep their rings */
.panel { background: var(--green); border: 5px solid var(--orange); border-radius: 24px; padding: 22px; display: flex; flex-direction: column;
  align-items: center; gap: 12px; box-shadow: 0 12px 0 rgba(0,0,0,.25); max-width: 100%; max-height: 100%; overflow: auto; position: relative; }
.panel h2 { font-size: 1.8rem; color: var(--gold); text-shadow: 0 3px 0 var(--orange-d); }

/* the boss is down on a garden night: LEVEL CLEARED, then end the run or keep going */
#ov-clear { background: rgba(40,25,10,.35); }
.clear-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 460px; width: 100%; }
.clear-title { font-size: clamp(2.2rem, 11vw, 4.6rem); font-weight: 900; line-height: 1; text-align: center; color: #fff3b0; letter-spacing: .04em;
  -webkit-text-stroke: 3px var(--orange-d); paint-order: stroke fill; text-shadow: 0 6px 0 var(--orange-d), 0 0 28px rgba(255,220,120,.9); }
.clear-title span { display: inline-block; animation: clear-slam .55s cubic-bezier(.2,1.6,.4,1) both, clear-glow 1.6s ease-in-out .7s infinite; }
.clear-title span + span { animation-delay: .22s, .9s; }
@keyframes clear-slam { 0% { transform: scale(3) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes clear-glow { 50% { transform: scale(1.06) translateY(-3px); } }
.clear-panel { width: 100%; animation: clear-rise .4s ease-out .5s both; }
/* no orange shadow here: gold on orange-d read as blurry (user 2026-11-06); crisp light text on the green */
.clear-panel h2 { font-size: 1.4rem; text-align: center; color: #fff; text-shadow: none; }
.clear-panel h2 #clear-boss { color: var(--gold); }
.clear-text { text-align: center; color: var(--cream); font-size: .95rem; }
.clear-panel .btn { width: 100%; }
@keyframes clear-rise { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .clear-title span, .clear-panel { animation: none; } }
/* the last night's finale (main.js showFinale): THE NIGHTMARE IS OVER over the First Dawn */
.ov-finale { background: radial-gradient(ellipse at 50% 0%, rgba(255,214,130,.55), rgba(40,30,80,.85) 70%); overflow-y: auto; }
.finale-wrap { max-width: 560px; }
.finale-title { font-size: clamp(1.8rem, 9vw, 3.6rem); color: #fff6d0; }
.finale-stamp { margin: 4px auto 10px; width: max-content; padding: 4px 14px; border: 3px solid var(--gold); border-radius: 10px; color: var(--gold); font-weight: 900; letter-spacing: .08em; transform: rotate(-4deg); animation: clear-slam .5s cubic-bezier(.2,1.6,.4,1) 1s both; }
.finale-roll { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 8px 0; }
.finale-boss { width: 48px; height: 48px; border-radius: 10px; background: rgba(255,255,255,.08); }
.finale-unmet { filter: grayscale(1) brightness(.4); }
.finale-career { font-size: .85rem; opacity: .85; }
@media (prefers-reduced-motion: reduce) { .finale-stamp { animation: none; } }

/* level-up choices, VS style: a stack of rows, icon + name + level on top, the description under it */
.cards { display: flex; flex-direction: column; gap: 8px; width: min(520px, 100%); }
.lvl-card { width: 100%; border: 3px solid var(--navy); border-radius: 14px; background: var(--cream); color: var(--navy); padding: 8px 12px 10px;
  display: grid; grid-template-columns: 44px 1fr auto auto; grid-template-rows: auto auto; align-items: center; column-gap: 10px; row-gap: 4px;
  text-align: left; box-shadow: 0 4px 0 rgba(0,0,0,.3); transition: transform .1s; animation: deal .3s ease-out backwards; }
.lvl-card:hover, .lvl-card:focus-visible { transform: translateX(4px); outline: 3px solid var(--gold); }
.lvl-card .lc-ico { font-size: 2rem; line-height: 1; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: rgba(28,30,60,.1); }
.lvl-card h3 { font-size: 1.1rem; margin: 0; min-width: 0; }
.lvl-card .lc-top { justify-self: end; background: var(--navy); color: var(--cream); border-radius: 8px; padding: 3px 8px; font-size: .78rem; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.lvl-card .lc-top.new { background: #ff4d6d; color: #fff; }
.lvl-card p { grid-column: 1 / -1; margin: 0; font-size: .92rem; line-height: 1.3; }
/* a found evolution's recipe: deep purple text on the card itself (gold on cream was unreadable, a navy strip too
   heavy; user 2026-11-11) */
.lvl-card .lc-evo img.gi { width: 1.5em; height: 1.5em; vertical-align: -0.4em; }
.lvl-card .lc-evo { font-size: 1rem; font-weight: 700; color: #5b2fb0; }
.lvl-card kbd { background: var(--navy); color: var(--cream); }
@keyframes deal { from { transform: translateY(40px) scale(.8); opacity: 0; } }

/* reroll / banish / skip under the cards; in banish mode the cards turn red and a tap banishes */
.lvl-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.lvl-tools .btn[aria-pressed="true"] { background: #ff4d6d; color: #fff; }
.skip-glim { opacity: .8; font-size: .85em; }
.banishing .lvl-card { outline: 3px dashed #ff4d6d; }
.banishing .lvl-card .lc-top { background: #ff4d6d; color: #fff; }
.banishing .lvl-card[data-fixed] { opacity: .45; outline: 0; }

/* shrine blessings reuse the level-up cards, coloured by rarity */
.lvl-sub { margin: -6px 0 0; opacity: .85; }
.lvl-card[data-rarity] .lc-top { background: var(--rc); color: var(--navy); }
.lvl-card[data-rarity] { border-color: var(--rc); }
.lvl-card[data-rarity="common"] { --rc: #cfd8dc; }
.lvl-card[data-rarity="rare"] { --rc: #6fc3ff; }
.lvl-card[data-rarity="epic"] { --rc: #c99bff; }
.lvl-card[data-rarity="legendary"] { --rc: #ffd84a; box-shadow: 0 0 0 3px #ffd84a, 0 0 24px #ffd84a, 0 6px 0 rgba(0,0,0,.3); }
.lvl-card[data-rarity="epic"] { box-shadow: 0 0 0 3px #c99bff, 0 6px 0 rgba(0,0,0,.3); }

/* XP orbs raining behind the level-up panel (main.js fillLevelRain), fading out before the bottom */
.lvl-rain { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.lvl-rain i { position: absolute; top: 0; width: var(--s); height: var(--s); transform: translateY(-30px) rotate(45deg); border-radius: 2px; will-change: transform, opacity;
  background: linear-gradient(135deg, #fff 0 18%, var(--c) 40%); box-shadow: 0 0 10px var(--c); animation: orbfall 3s linear infinite; }
.lvl-rain i.b { animation-name: orbburst; animation-iteration-count: 1; animation-fill-mode: both; animation-timing-function: cubic-bezier(.3,.1,.7,1); }
@keyframes orbfall { 0% { transform: translateY(-30px) rotate(45deg); opacity: 0; } 6% { opacity: 1; } 55% { opacity: .85; }
  82% { opacity: 0; } 100% { transform: translateY(85vh) rotate(45deg); opacity: 0; } }
@keyframes orbburst { 0% { transform: translateY(-40px) rotate(0) scale(1.3); opacity: 0; } 5% { opacity: 1; }
  60% { opacity: .9; } 100% { transform: translateY(90vh) rotate(270deg) scale(.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .lvl-rain { display: none; } }

/* ── treasure chest: a slot machine ─────────────── */
.chest-ov { background: rgba(10,5,25,.72); overflow: hidden; z-index: 12; }
.chest-rays { position: absolute; left: 50%; top: 50%; width: 220vmax; height: 220vmax; transform: translate(-50%, -50%); pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(rgba(255,216,74,.2) 0 9deg, transparent 9deg 22deg); animation: rays 9s linear infinite; transition: opacity .4s;
  -webkit-mask-image: radial-gradient(circle, #000 4%, transparent 32%); mask-image: radial-gradient(circle, #000 4%, transparent 32%); }
.chest-ov.open .chest-rays { opacity: 1; }
.chest-ov.jackpot .chest-rays { background: repeating-conic-gradient(rgba(255,140,210,.24) 0 8deg, transparent 8deg 14deg, rgba(130,220,255,.2) 14deg 22deg, transparent 22deg 30deg); animation-duration: 4s; }
@keyframes rays { to { transform: translate(-50%, -50%) rotate(360deg); } }
.chest-panel { min-width: min(460px, 100%); padding: 30px 22px 22px; border-color: var(--gold); background: radial-gradient(ellipse at 50% 0%, #2a6a48, var(--green) 70%); }
.chest-ov.jackpot .chest-panel { animation: wobble .5s ease-in-out 3; }
@keyframes wobble { 25% { transform: rotate(-1.5deg) scale(1.02); } 75% { transform: rotate(1.5deg) scale(1.02); } }
.chest-box { font-size: 4.5rem; line-height: 1; animation: shake .12s linear infinite; filter: drop-shadow(0 0 18px rgba(255,216,74,.8)); }
.chest-ov.open .chest-box { animation: lid .5s ease-out forwards; }
@keyframes shake { 25% { transform: rotate(-8deg) translateY(-2px); } 75% { transform: rotate(8deg) translateY(-2px); } }
@keyframes lid { 0% { transform: scale(1); } 40% { transform: scale(1.5) translateY(-10px); } 100% { transform: scale(0); height: 0; opacity: 0; } }
.chest-panel h2 { font-size: 2.2rem; }
.chest-ov.jackpot .chest-panel h2 { background: linear-gradient(90deg, #ff6b9a, #ffd84a, #6fe0ff, #b98aff, #ff6b9a); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; animation: rainbow 1s linear infinite, throb .5s infinite; }
@keyframes rainbow { to { background-position: 200% 0; } }
.reels { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.reel { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 84px; }
.reel-win { width: 78px; height: 78px; border-radius: 16px; background: var(--cream); border: 4px solid var(--navy); overflow: hidden; position: relative;
  box-shadow: inset 0 8px 10px rgba(0,0,0,.25), inset 0 -8px 10px rgba(0,0,0,.25), 0 4px 0 rgba(0,0,0,.3); }
.reel-strip { position: absolute; left: 0; right: 0; top: 0; }
.reel-strip div { height: 70px; display: grid; place-items: center; font-size: 2.6rem; color: #1aa7b8; }
.reel.stopped .reel-win { border-color: var(--rc, var(--gold)); animation: ding .35s ease-out; box-shadow: 0 0 0 3px var(--rc, var(--gold)), 0 0 22px var(--rc, var(--gold)); }
.reel[data-rarity="rare"] { --rc: #6fc3ff; }
.reel[data-rarity="legendary"] { --rc: #ffd84a; }
.reel[data-rarity="evo"] { --rc: #ff6bd6; }
@keyframes ding { 40% { transform: scale(1.18); } }
.reel-cap { font-size: .78rem; text-align: center; line-height: 1.15; min-height: 2.4em; opacity: 0; transition: opacity .2s; }
.reel-cap b { display: block; font-size: .85rem; }
.reel.stopped .reel-cap { opacity: 1; }
.chest-glim { font-size: 1.6rem; font-weight: 700; color: var(--glim); background: var(--navy); border-radius: 14px; padding: 4px 18px; border: 3px solid var(--orange); }
.bulbs { position: absolute; inset: 7px; pointer-events: none; }
.bulbs i { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #ffe9a8; box-shadow: 0 0 8px #ffd84a; transform: translate(-50%, -50%);
  animation: bulb .5s steps(1) infinite; }
.bulbs i:nth-child(odd) { animation-delay: .25s; }
.chest-ov.spinning .bulbs i { animation-duration: .16s; }
.chest-ov.spinning .bulbs i:nth-child(odd) { animation-delay: .08s; }
@keyframes bulb { 50% { background: #7a5a1a; box-shadow: none; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti span { position: absolute; left: 50%; top: 45%; font-size: 1.3rem; animation: coin 1.4s cubic-bezier(.2,.6,.4,1) forwards; }
@keyframes coin { 0% { transform: translate(0, 0) scale(.4) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; } }

.results { min-width: min(420px, 100%); }
.res-sub { margin: -6px 0 0; opacity: .85; text-align: center; }
.res-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; width: 100%; background: var(--navy); border-radius: 14px; padding: 12px 16px; }
.res-grid span { opacity: .8; }
.res-grid b { text-align: right; }
.res-grid .hl { color: var(--gold); }
.res-dmg { width: 100%; background: var(--navy); border-radius: 14px; padding: 10px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; font-size: .92rem; }
.res-dmg h3 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 1rem; color: var(--gold); }
.res-dmg .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 11em; }
.res-dmg .bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; min-width: 40px; }
.res-dmg .bar div { height: 100%; background: linear-gradient(90deg, var(--glim), #b98aff); }
.res-dmg b { text-align: right; white-space: nowrap; }
.res-build { width: 100%; background: var(--navy); border-radius: 14px; padding: 10px 16px; display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 3px 12px; font-size: .9rem; }
.res-build h3 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 1rem; color: var(--gold); }
.res-build span { opacity: .8; white-space: nowrap; }
.res-build b { text-align: right; white-space: nowrap; }
@media (max-width: 380px) { .res-build { grid-template-columns: 1fr auto; } }
.res-dmg b small { opacity: .65; font-weight: 400; margin-left: 6px; }
.res-total { display: flex; justify-content: space-between; align-items: center; width: 100%; background: var(--cream); color: var(--navy); border-radius: 14px; padding: 8px 16px; font-size: 1.2rem; }
.res-total b { font-size: 1.6rem; }
.res-goal { width: 100%; text-align: center; font-size: .95rem; }
.res-goal .goal-bar { height: 10px; border-radius: 99px; background: rgba(0,0,0,.35); overflow: hidden; margin-top: 6px; }
.res-goal .goal-bar div { height: 100%; background: linear-gradient(90deg, var(--glim), #b98aff); }
.res-goal .can { color: var(--gold); font-weight: 700; font-size: 1.1rem; animation: throb 1s infinite; display: inline-block; }
.res-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── TREE ──────────────────────────── */
#page-tree { background: var(--orange); padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.frame { position: relative; height: 100%; background: var(--green); border-radius: 28px; border: 6px solid var(--cream); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: inset 0 0 0 4px #0f2c1f; }
.frame::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: radial-gradient(#0a2016 1.5px, transparent 1.6px); background-size: 14px 14px; }
.tree-top { position: relative; z-index: 3; display: flex; align-items: center; gap: 12px; padding: 12px; flex-wrap: wrap; }
.money { display: flex; align-items: center; background: var(--navy); border: 3px solid var(--cream); border-radius: 16px 40px 16px 16px; padding: 6px 16px 6px 6px; gap: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,.3); }
.money-can { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(160deg, #2fd1c8, #146e78); display: grid; place-items: center;
  font-size: 1.8rem; color: #fff; border: 3px solid var(--cream); transform: rotate(-8deg); }
.money-text { display: flex; flex-direction: column; line-height: 1; }
.money-text small { font-size: .7rem; letter-spacing: .1em; opacity: .8; }
.money-text strong { font-size: 2rem; color: var(--orange); }
.money-text em { font-size: .6rem; opacity: .55; font-style: normal; letter-spacing: .05em; text-transform: uppercase; }
.money-shards { margin-left: 8px; padding-left: 12px; border-left: 2px dashed rgba(255,243,220,.3); font-size: 1.3rem; }
.bloom { display: flex; align-items: center; gap: 8px; font-size: .85rem; background: rgba(0,0,0,.22); padding: 6px 12px; border-radius: 99px; }
.bloom-bar { width: 110px; height: 10px; border-radius: 99px; background: rgba(0,0,0,.35); overflow: hidden; }
.bloom-bar div { height: 100%; width: 0; background: linear-gradient(90deg, #58d36b, var(--gold)); transition: width .4s; }
.tabs { margin-left: auto; display: flex; background: var(--navy); border: 3px solid var(--cream); border-radius: 16px; padding: 4px; gap: 4px; }
.tab { border: 0; background: transparent; padding: 8px 16px; border-radius: 11px; font-weight: 700; letter-spacing: .03em; display: flex; align-items: center; gap: 6px; position: relative; text-transform: uppercase; font-size: .95rem; }
.tab.active { background: var(--orange); color: var(--navy); }
.badge { position: absolute; top: -8px; right: -6px; background: #ff4d6d; color: #fff; border-radius: 99px; min-width: 22px; height: 22px; font-size: .8rem;
  display: grid; place-items: center; border: 2px solid var(--cream); animation: throb 1s infinite; }

.tree-viewport { position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: grab; }
.tree-viewport:active { cursor: grabbing; }
.tree-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tree-lines { position: absolute; left: 0; top: 0; overflow: visible; }
.tree-lines line { stroke-width: 5; stroke-linecap: round; }
.tree-lines line.dim { stroke: #0d2a1d; stroke-dasharray: 2 9; stroke-width: 4; stroke: #5c7d6a; opacity: .5; }

.node { position: absolute; width: 66px; height: 66px; transform: translate(-50%, -50%); border-radius: 50%; border: 4px solid #0e2419;
  background: #3a4a44; display: grid; place-items: center; padding: 0; box-shadow: 0 5px 0 rgba(0,0,0,.35); transition: transform .12s, filter .2s; }
.node .ico { width: 2.05rem; height: 2.05rem; display: block; pointer-events: none; }   /* an <img> of the emoji (treeView.js icoSrc): live emoji text re-rasterized on every zoom step */
.node .pips { position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%); background: var(--navy); border: 2px solid var(--cream); border-radius: 99px;
  font-size: .68rem; padding: 0 6px; font-weight: 700; white-space: nowrap; z-index: 1; }   /* above the can-buy ring (::after paints last) */
.node.sh-diamond { border-radius: 14px; transform: translate(-50%, -50%) rotate(45deg); }
.node.sh-diamond .ico { transform: rotate(-45deg); }
.node.sh-diamond .pips { transform: translateX(-50%) rotate(-45deg); bottom: -14px; left: 80%; }
.node.sh-big { width: 84px; height: 84px; }
.node.st-owned, .node.st-maxed { background: var(--c); border-color: #fff8e7; }
.node.st-maxed { box-shadow: 0 0 0 4px var(--gold), 0 5px 0 rgba(0,0,0,.35), 0 0 24px var(--gold); }
.node.st-available { background: #2c3b36; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 55%, transparent), 0 5px 0 rgba(0,0,0,.35); }
.node.st-available .ico { opacity: .75; }
.node.st-teaser { background: #22302b; border-color: #0e2419; opacity: .7; }
.node.st-teaser .ico { width: 1.45rem; height: 1.45rem; opacity: .6; }
/* the can-buy glow pulses OPACITY only (compositor-only; measured no zoom cost with 63 pulsing nodes, now that icons are
   images). Never animate the box-shadow itself: that repaints every node every frame. */
.node.can-buy::after { content: ''; position: absolute; inset: -4px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 5px var(--c), 0 0 18px var(--c); opacity: .85; animation: canbuy 1.4s ease-in-out infinite alternate; }
@keyframes canbuy { to { opacity: .3; } }
.node.can-buy .ico { opacity: 1; }
.node.selected { outline: 4px solid var(--cream); outline-offset: 4px; z-index: 2; }
.node:hover { filter: brightness(1.15); }
.node.sh-circle:hover, .node.sh-big:hover { transform: translate(-50%, -50%) scale(1.07); }
.node.just-bought { animation: bought .5s ease-out; }
.node.sh-diamond.just-bought { animation: bought-d .5s ease-out; }
.node.fresh { animation: fresh .6s ease-out backwards; }
@keyframes bought { 0% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.35); } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes bought-d { 0% { transform: translate(-50%, -50%) rotate(45deg) scale(1); } 40% { transform: translate(-50%, -50%) rotate(45deg) scale(1.35); } 100% { transform: translate(-50%, -50%) rotate(45deg) scale(1); } }
@keyframes fresh { from { opacity: 0; transform: translate(-50%, -50%) scale(.2); } }

.burst { position: absolute; pointer-events: none; font-size: 1.1rem; animation: fly .7s ease-out forwards; z-index: 5; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) scale(.5); opacity: 0; } }

.node-card { position: absolute; z-index: 4; right: 16px; top: 12px; width: 300px; background: var(--cream); color: var(--navy); border-radius: 18px;
  padding: 0 0 12px; box-shadow: 0 8px 0 rgba(0,0,0,.3); overflow: hidden; border: 4px solid var(--orange); animation: card-in .18s ease-out; }
@keyframes card-in { from { transform: translateY(10px); opacity: 0; } }
.node-card h3 { font-size: 1.35rem; text-align: center; padding: 12px 34px 6px; }
.card-head { display: flex; align-items: center; justify-content: center; gap: 8px; padding-top: 6px; }
.card-head h3 { padding: 8px 0 4px; }
.card-ico { font-size: 1.5rem; }
.card-close { position: absolute; right: 8px; top: 6px; border: 0; background: transparent; font-size: 1.1rem; color: inherit; opacity: .6; z-index: 2; width: 36px; height: 36px; }
.card-body { background: var(--navy); color: var(--cream); margin: 0 12px; border-radius: 12px; padding: 12px; text-align: center; }
.card-body p { margin: 0 0 8px; font-weight: 500; }
.stat { display: flex; justify-content: center; gap: 14px; align-items: baseline; }
.stat span { opacity: .7; font-size: .9rem; }
.stat b { font-size: 1.2rem; }
.stat i { color: var(--orange); font-style: normal; font-size: .9rem; }
.rank { font-size: .8rem; opacity: .7; margin-top: 6px; }
.card-foot { display: flex; align-items: center; gap: 10px; margin: 10px 12px 0; flex-wrap: wrap; }
.hazard { flex: 1; height: 26px; border-radius: 6px; min-width: 60px;
  background: repeating-linear-gradient(-45deg, var(--orange) 0 10px, var(--navy) 10px 20px); }
.buy { border: 0; background: var(--navy); color: var(--cream); font-weight: 700; font-size: 1.25rem; border-radius: 10px; padding: 6px 18px; box-shadow: 0 4px 0 rgba(0,0,0,.3); }
.buy:not(:disabled) { background: var(--orange); color: var(--navy); animation: throb 1.2s infinite; }
.buy:disabled { opacity: .6; cursor: default; }
.need { width: 100%; text-align: right; font-weight: 600; opacity: .7; }
.maxed { font-weight: 700; color: #b07d00; font-size: 1.2rem; }

.zoom-btns { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.zoom-btns button { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--cream); background: var(--navy); font-size: 1.1rem; }

.start-btn { border: 3px solid var(--navy); background: var(--cream); color: var(--navy); font-weight: 700; font-size: 1.35rem; letter-spacing: .04em;
  border-radius: 14px 14px 30px 14px; padding: 10px 20px; box-shadow: 0 5px 0 rgba(0,0,0,.3); display: flex; align-items: center; gap: 10px; }
.start-btn kbd { background: var(--navy); color: var(--cream); }
.start-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.3); }

/* ── MAIL ──────────────────────────── */
.mail { width: min(520px, 100%); align-items: stretch; }
.mail h2 { text-align: center; }
.mail-sub { margin: -4px 0 4px; text-align: center; opacity: .8; font-size: .9rem; }
.letter { display: grid; grid-template-columns: 52px 1fr; gap: 4px 12px; background: var(--cream); color: var(--navy); border-radius: 16px; padding: 12px; margin-bottom: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.letter .av { font-size: 2.2rem; grid-row: span 3; display: grid; place-items: center; background: var(--navy); border-radius: 12px; height: 52px; }
.letter .from { font-weight: 700; }
.letter p { margin: 0; font-size: .95rem; }
.letter .prog { display: flex; align-items: center; gap: 8px; }
.letter .prog .bar { flex: 1; height: 10px; background: rgba(29,36,51,.2); border-radius: 99px; overflow: hidden; }
.letter .prog .bar div { height: 100%; background: linear-gradient(90deg, #58d36b, #2fd1c8); }
.letter .prog small { font-weight: 600; white-space: nowrap; }
.letter .claim { border: 0; border-radius: 10px; padding: 4px 12px; background: var(--navy); color: var(--cream); font-weight: 700; }
.letter.done { outline: 3px solid var(--gold); }
.letter.done .claim { background: var(--orange); color: var(--navy); animation: throb 1s infinite; }
.letter .claim:disabled { opacity: .5; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--navy); border: 3px solid var(--orange); border-radius: 14px; padding: 8px 18px;
  font-weight: 600; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .25s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }

/* ── phone / narrow ────────────────── */
@media (max-width: 700px) {
  #page-tree { padding: 6px; }
  .frame { border-width: 4px; border-radius: 20px; }
  .tree-top { padding: 8px; gap: 8px; }
  .money { padding: 4px 10px 4px 4px; gap: 8px; }
  .money-can { width: 40px; height: 40px; font-size: 1.3rem; }
  .money-text strong { font-size: 1.5rem; }
  .money-text em { display: none; }
  .bloom { order: 3; width: 100%; justify-content: center; }
  .bloom-bar { flex: 1; }
  .tabs { margin-left: auto; }
  .tab { padding: 6px 10px; font-size: .8rem; }
  .tab.active .tab-ico ~ * { display: none; }
  .node-card { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; }
  .start-btn { font-size: 1.1rem; padding: 10px 14px; }
  .start-btn kbd { display: none; }
  .lvl-card { grid-template-columns: 40px 1fr auto; padding: 7px 10px 9px; }
  .lvl-card .lc-ico { width: 40px; height: 40px; font-size: 1.7rem; }
  .lvl-card h3 { font-size: 1rem; }
  .lvl-card kbd { display: none; }
  .lvl-panel { width: 100%; }
  .reel { width: 60px; }
  .reel-win { width: 58px; height: 58px; border-width: 3px; }
  .reel-strip div { height: 52px; font-size: 1.9rem; }
  .reel-cap { font-size: .68rem; }
  .chest-box { font-size: 3.4rem; }
}
@media (max-width: 420px) {
  .money-shards { font-size: 1rem; margin-left: 2px; padding-left: 8px; }
}

/* ── audio toggles, stage label ───────── */
.audio-toggles { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 14px; display: flex; gap: 8px; }
.audio-toggles .sound-toggle { position: static; }
.audio-toggles.inline { position: static; justify-content: center; margin-top: 4px; }
.sound-toggle.off { opacity: .45; }
.np-label small { display: block; font-size: .72rem; font-weight: 500; opacity: .85; line-height: 1.1; }

/* ── CHARACTERS ( /characters ) ───────── */
#page-characters { background: radial-gradient(ellipse at 50% 20%, #2f7a4a 0%, #17402d 75%); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
.heroes-frame { height: 100%; max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.heroes-top { display: flex; align-items: center; gap: 12px; }
.heroes-top h2 { flex: 1; text-align: center; font-size: clamp(1.3rem, 4vw, 2rem); color: var(--gold); text-shadow: 0 3px 0 var(--orange-d); }
.heroes-count { font-size: .9rem; opacity: .8; min-width: 70px; text-align: right; }
.hero-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 4px 4px 12px; align-content: start; }
.hero-card { position: relative; border: 0; border-radius: 18px; background: var(--cream); color: var(--navy); padding: 10px 12px 12px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 5px 0 rgba(0,0,0,.25); transition: transform .12s; }
.hero-card:hover { transform: translateY(-3px); }
.hero-card.selected { outline: 4px solid var(--gold); box-shadow: 0 0 0 4px var(--orange), 0 0 26px rgba(255,216,74,.7), 0 5px 0 rgba(0,0,0,.25); }
.hero-card canvas { width: 96px; height: 96px; }
.hero-card h3 { font-size: 1.2rem; }
.hero-card .animal { font-size: .8rem; opacity: .7; margin-top: -2px; }
.hero-card .weapon { font-size: .85rem; font-weight: 600; background: var(--navy); color: var(--cream); border-radius: 99px; padding: 2px 10px; margin: 4px 0 2px; }
.hero-card ul { list-style: none; margin: 2px 0 0; padding: 0; font-size: .85rem; line-height: 1.35; }
.hero-card .new { position: absolute; top: 8px; right: 8px; background: #ff4d6d; color: #fff; border-radius: 99px; padding: 0 8px; font-size: .75rem; font-weight: 700;
  animation: newpulse 1s ease-in-out infinite alternate; }
@keyframes newpulse { to { transform: scale(1.15); } }
.hero-card.locked { background: #44505f; color: #c7cdd6; cursor: default; }
.hero-card.locked:hover { transform: none; }
.hero-card.locked canvas { filter: brightness(0) opacity(.55); }
.hero-card .lock { font-size: .85rem; margin-top: 6px; }
.hero-card .lock-bar { width: 80%; height: 7px; border-radius: 9px; background: rgba(0,0,0,.35); overflow: hidden; margin-top: 4px; }
.hero-card .lock-bar div { height: 100%; background: var(--gold); }
/* /characters: the picked hero's stats on the left, Talents under them, the grid on the right; on a phone below the grid,
   Talents first and the stats folded until opened */
.hero-wrap { flex: 1; min-height: 0; display: flex; gap: 12px; }
.hero-wrap .hero-grid { min-width: 0; }
.hero-side { flex: none; width: 270px; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.hero-side .hero-prep { width: 100%; }
.hero-stats { min-height: 0; overflow-y: auto; background: var(--navy); border-radius: 18px; padding: 10px 12px; font-size: .85rem; }
.hero-stats > summary { font-size: 1rem; font-weight: 700; color: var(--cream); list-style: none; }
.hero-stats > summary::-webkit-details-marker { display: none; }
.hero-stats.wide > summary { pointer-events: none; }   /* wide: always open, the title is just a title */
.hero-stats:not(.wide) > summary { cursor: pointer; }
.hero-stats:not(.wide) > summary::after { content: ' ▾'; opacity: .7; }
.hero-stats:not(.wide):not([open]) > summary::after { content: ' ▸'; }
.hs-list b.own, .hero-stats em.own { color: var(--gold); }
.hero-stats h4 { margin: 10px 0 4px; font-size: .9rem; color: var(--gold); }
.hs-note { margin: 4px 0; font-size: .75rem; opacity: .8; }
.hs-note i { font-style: normal; }
.hero-stats em { font-style: normal; font-weight: 700; }
.hero-stats em.up { color: #7dff9a; }
.hero-stats em.down { color: #ff8a8a; }
.hs-list { list-style: none; margin: 0; padding: 0; }
.hs-list li { display: grid; grid-template-columns: 1fr auto 3.6em; gap: 6px; padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.hs-list b { text-align: right; font-weight: 600; }
.hs-list em { text-align: right; }
.hs-tal { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hs-tal li { display: flex; flex-direction: column; }
.hs-tal small { opacity: .75; }
.heroes-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.heroes-bottom .start-btn { margin-left: auto; }
@media (max-width: 700px) {
  .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hero-wrap { flex-direction: column; gap: 8px; }
  .hero-side { width: auto; order: 1; gap: 6px; }   /* phone: below the heroes */
  .hero-side .hero-prep { order: -1; }   /* phone: Talents first, always in sight */
  .hero-stats { max-height: 45vh; padding: 8px 12px; }
  .hero-card { padding: 8px; }
  .hero-card canvas { width: 72px; height: 72px; }
  .hero-card ul { font-size: .78rem; }
  .heroes-top h2 { font-size: 1.2rem; }
  .heroes-bottom { justify-content: center; }
  .heroes-bottom .start-btn { margin-left: 0; flex: 1; }
}

/* ── evolutions ───────────────────────── */
.reel[data-rarity="evolve"] { --rc: #ff6bd6; }
.reel[data-rarity="evolve"].stopped .reel-win { animation: evoglow .5s ease-in-out infinite alternate; }
@keyframes evoglow { from { box-shadow: 0 0 10px #ff6bd6, inset 0 0 8px #fff; } to { box-shadow: 0 0 28px #ffd84a, 0 0 48px #ff6bd6, inset 0 0 14px #fff; } }
.night-pick.single button { visibility: hidden; width: 8px; }

/* ── Journal ( /journal ) + Evolutions ( /evolutions ) ── */
.btn-journal small { opacity: .7; font-size: .8em; }
.journal-tabs { display: flex; gap: 8px; justify-content: center; }
.journal-tabs button { font: inherit; font-weight: 700; border: 0; border-radius: 99px; padding: 6px 16px; cursor: pointer;
  background: rgba(255,255,255,.12); color: var(--cream); }
.journal-tabs button[aria-current] { background: var(--gold); color: var(--navy); box-shadow: 0 3px 0 var(--orange-d); }
.journal-body { flex: 1; overflow-y: auto; padding: 4px 4px 16px; }
.journal-body h3 { color: var(--gold); margin: 14px 4px 8px; font-size: 1.1rem; }
.journal-body h3 small { color: var(--cream); opacity: .7; font-weight: 500; margin-left: 6px; }
.j-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.j-grid.evo { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.jcard { position: relative; border-radius: 16px; background: var(--cream); color: var(--navy); padding: 10px 12px 12px; text-align: center;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.jcard .j-icon { font-size: 2.4rem; line-height: 1.2; width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 50%;
  display: grid; place-items: center; background: radial-gradient(circle, #fff6d6 0 55%, #ffd84a 56% 100%); }
.jcard.kind-perks .j-icon { background: radial-gradient(circle, #eaf7ff 0 55%, #8fd0ff 56% 100%); }
.jcard.kind-evos .j-icon { background: radial-gradient(circle, #f6ecff 0 50%, #c59bff 51% 70%, #ffd84a 71% 100%); width: 76px; height: 76px; font-size: 2.8rem; }
.jcard h4 { font-size: 1.05rem; }
.jcard p { font-size: .82rem; line-height: 1.3; margin: 3px 0 0; }
.jcard .j-tag { display: inline-block; margin-top: 6px; font-size: .75rem; font-weight: 600; background: var(--navy); color: var(--cream);
  border-radius: 99px; padding: 2px 9px; }
.jcard .j-recipe { margin-top: 6px; font-size: .85rem; font-weight: 600; }
.jcard .new { position: absolute; top: 6px; right: 6px; background: #ff4d6d; color: #fff; border-radius: 99px; padding: 0 7px; font-size: .7rem; font-weight: 700; }
.jcard.blank { background: rgba(255,255,255,.06); color: #c7cdd6; border: 2px dashed rgba(255,255,255,.28); box-shadow: none; }
.jcard.blank .j-icon { background: rgba(0,0,0,.25); color: rgba(255,255,255,.45); font-weight: 700; font-size: 2rem; }
.jcard.blank .j-hint { opacity: .85; font-style: italic; }
@media (max-width: 700px) {
  .j-grid, .j-grid.evo { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .jcard { padding: 8px; }
  .jcard .j-icon { width: 52px; height: 52px; font-size: 2rem; }
  .jcard.kind-evos .j-icon { width: 60px; height: 60px; font-size: 2.2rem; }
  .jcard p { font-size: .76rem; }
}
/* Journal: calm backdrop (it inherited the full orange body) + softer accents */
#page-journal, #page-evolutions, #page-creatures { background: radial-gradient(ellipse at 50% 15%, #2c4d63 0%, #1d2433 80%);
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
#page-journal .heroes-top h2, #page-evolutions .heroes-top h2, #page-creatures .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.journal-tabs button[aria-current] { background: #ffe9a8; color: var(--navy); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.journal-body h3 { color: #ffe9a8; }
.jcard { background: #f6efe2; }
.jcard .j-icon { background: radial-gradient(circle, #fffaf0 0 55%, #f3dc9a 56% 100%); }

/* ── settings ( /settings ) ── */
#page-settings { background: radial-gradient(ellipse at 50% 15%, #2c4d63 0%, #1d2433 80%); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
#page-settings .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.settings-frame { max-width: 860px; }
/* categories (user 2026-11-11): a side menu beside the open one; on phone the bare /settings is the menu and a category
   opens full width (.tab-open), with ◀ Settings back to the menu */
.settings-body { flex: 1; min-height: 0; display: flex; gap: 16px; }
.set-menu { flex: 0 0 210px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 4px 2px 20px; }
.set-menu .set-tab b { opacity: 0; }
.set-menu .set-tab[aria-current] { outline: 2px solid var(--gold); background: rgba(255,233,168,.14) !important; }
.set-menu .set-tab[aria-current] b { opacity: .9; color: var(--gold); }
.settings-body .settings-list { flex: 1; min-width: 0; }
.set-cat { display: flex; flex-direction: column; gap: 10px; }
.set-cat h3:first-child { margin-top: 0; }
.set-crumb, .set-back-menu { display: none; }
@media (max-width: 700px) {
  .settings-body { flex-direction: column; }
  .set-menu { flex: 1; }
  .set-menu .set-tab b { opacity: .6; }
  .set-menu .set-tab[aria-current]:not(:focus-visible) { outline: 0; background: rgba(255,255,255,.07) !important; }
  .set-menu .set-tab[aria-current] b { color: inherit; }
  .settings-frame:not(.tab-open) .settings-list { display: none; }
  .settings-frame.tab-open .set-menu { display: none; }
  .settings-frame.tab-open .set-back-home { display: none; }
  .settings-frame.tab-open .set-back-menu { display: inline-block; }
  .settings-frame.tab-open .set-crumb { display: inline; }
  .settings-frame.tab-open .set-cat h3:first-child { display: none; }
}
.set-row { background: rgba(255,255,255,.07) !important; }
.lv-turbo { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.25); border-radius: 14px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.lv-turbo small { display: block; font-weight: 400; opacity: .75; font-size: .75rem; }
.settings-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 4px 2px 20px; }
.settings-list h3 { margin: 10px 0 0; color: var(--gold); font-size: 1.1rem; }
.set-row { display: flex; align-items: center; gap: 12px; background: var(--navy); border-radius: 14px; padding: 12px 16px; min-height: 52px; }
.set-row > span { flex: 1; font-weight: 600; }
.set-row small { display: block; font-weight: 400; opacity: .75; font-size: .8rem; }
.set-row input[type=range] { flex: 1.2; accent-color: var(--orange); min-width: 0; height: 28px; }
.set-row output { width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.set-row:has(.switch:not(:checked)) :is(input[type=range], output) { opacity: .4; }
.set-note { margin: -2px 4px 4px; font-size: .8rem; opacity: .75; }
.switch { appearance: none; width: 52px; height: 30px; border-radius: 15px; background: var(--navy-2); position: relative; cursor: pointer; border: 2px solid rgba(255,255,255,.2); transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--cream); transition: transform .15s; }
.switch:checked { background: var(--orange); }
.switch:checked::after { transform: translateX(22px); }
.switch:disabled { opacity: .4; cursor: not-allowed; }
/* save slots + /admin */
#page-admin { background: radial-gradient(ellipse at 50% 15%, #4d2c3a 0%, #1d2433 80%); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
#page-admin .heroes-top h2 { color: #ffb8a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.slot-list { display: flex; flex-direction: column; gap: 10px; }
.slot-row.on { outline: 2px solid var(--gold); }
.slot-btns { display: flex; gap: 8px; align-items: center; flex: none; }
.slot-btns .slot-on { color: var(--gold); font-size: .9rem; padding: 0 6px; }
.slot-btns .btn:disabled { opacity: .4; cursor: not-allowed; }
.set-num { width: 9em; max-width: 45%; font: inherit; font-weight: 700; text-align: right; padding: 8px 10px; border-radius: 10px; border: 2px solid rgba(255,255,255,.2); background: var(--navy-2); color: var(--cream); }
.btn-danger { background: #d9443a; color: #fff; }
.slot-btns [data-slot-use] { background: var(--orange); color: var(--navy); }
.slot-confirm { max-width: 420px; gap: 12px; }
.slot-confirm p { margin: 0; line-height: 1.45; }
.slot-confirm-btns { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 420px) { .slot-row { flex-wrap: wrap; } .slot-btns { width: 100%; justify-content: flex-end; } }
.hud-turbo { font-size: .8rem; background: var(--orange); color: var(--navy); border-radius: 8px; padding: 1px 6px; margin-left: 4px; font-weight: 700; }

/* ── the Village ( /village, /forge, /fortune ): reuses the Journal frame + cards ── */
.village-page { background: radial-gradient(ellipse at 50% 15%, #4a3a52 0%, #1d2433 80%);
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
.village-page .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.v-money { white-space: nowrap; }
.v-intro { margin: 6px 4px 4px; opacity: .85; font-size: .92rem; }
.v-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
button.jcard { font: inherit; border: 0; cursor: pointer; width: 100%; }
button.jcard:hover { transform: translateY(-2px); }
.v-house .j-icon { width: 76px; height: 76px; font-size: 2.8rem; }
.v-locked { text-align: center; margin: 40px auto; max-width: 420px; }
.v-locked .j-icon { font-size: 3.4rem; opacity: .6; filter: grayscale(.7); }
.v-locked h3 { margin: 10px 0 6px; }
.v-buy { margin-top: 8px; border: 0; border-radius: 10px; padding: 7px 12px; min-height: 36px; font: inherit; font-weight: 700;
  background: var(--orange); color: var(--navy); box-shadow: 0 3px 0 rgba(0,0,0,.3); cursor: pointer; }
.v-buy:disabled { background: #b9b2a4; color: #5c5a55; box-shadow: none; cursor: not-allowed; }
.v-buy.on { background: #7fd68a; }
.v-pips { display: flex; justify-content: center; gap: 4px; margin: 2px 0 4px; }
.v-pips i { width: 12px; height: 12px; border-radius: 3px; background: rgba(0,0,0,.15); transform: rotate(45deg); }
.v-pips i.on { background: #e0a36a; box-shadow: 0 0 0 2px #8a5a3a inset; }
.jcard.v-worn { box-shadow: 0 0 0 3px #7fd68a, 0 4px 0 rgba(0,0,0,.25); }
/* the Fortune Teller: worn-sign slots, then the 12 zodiac cards (art = zodiacArt.js <img>s) */
.v-slots { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 4px 10px; }
.v-slot { width: 78px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0; border: 2px dashed rgba(255,255,255,.3);
  border-radius: 12px; background: rgba(0,0,0,.15); color: inherit; font: inherit; min-height: 117px; justify-content: center; }
.v-slot span { font-size: .72rem; opacity: .8; }
.v-slot.on { border: 0; background: none; cursor: pointer; justify-content: flex-start; }
.v-slot.on img { width: 78px; height: 117px; border-radius: 8px; box-shadow: 0 0 0 3px #e8c66a, 0 4px 0 rgba(0,0,0,.3); }
.v-signs { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.v-sign img { display: block; width: 110px; height: 165px; margin: 0 auto 6px; border-radius: 10px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.v-sign h4 small { display: block; font-size: .75rem; font-weight: 500; opacity: .7; }
.v-sign .v-good { color: #2f7d3a; font-weight: 600; margin: 4px 0 0; }
.v-sign .v-bad { color: #a8423a; margin: 2px 0 0; }
.v-sign.locked { background: #e4ddd0; }
.v-sign.hidden { background: rgba(255,255,255,.06); color: #c7cdd6; border: 2px dashed rgba(255,255,255,.28); box-shadow: none; }
.v-sign.picked { box-shadow: 0 0 0 4px #e8c66a, 0 6px 0 rgba(0,0,0,.3); }
@media (max-width: 480px) {
  .v-signs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .v-sign { padding: 8px 6px 10px; }
  .v-sign img { width: 88px; height: 132px; }
  .v-slot, .v-slot.on img { width: 64px; } .v-slot { min-height: 96px; } .v-slot.on img { height: 96px; }
}
.v-heat { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: rgba(0,0,0,.2); border-radius: 14px; padding: 10px 14px; }
.v-heat > b { font-size: 1.8rem; min-width: 1.5em; text-align: center; color: #ffb36b; }
.v-heat .v-buy { margin: 0; width: 44px; }
.v-heat p { flex: 1 1 220px; margin: 0; font-size: .9rem; }
.node.needs .ico { opacity: .45; }
/* the Blacksmith: weapon tiles + the anvil (the picked weapon's upgrades). Phone: tiles become a swipe strip on top */
.v-forge { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 12px; align-items: start; }
.v-wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.v-wtile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 0; border-radius: 14px;
  font: inherit; color: var(--navy); background: var(--cream); box-shadow: 0 3px 0 rgba(0,0,0,.25); cursor: pointer; min-height: 44px; }
.v-wtile b { font-size: .8rem; line-height: 1.1; text-align: center; }
.v-wtile small { font-size: .72rem; opacity: .75; }
.v-wtile-ico { font-size: 1.8rem; line-height: 1.2; }
.v-wtile.locked { background: #cfc8bb; }
.v-wtile.locked .v-wtile-ico { filter: grayscale(.9); opacity: .6; }
.v-wtile.on { box-shadow: 0 0 0 3px #ffb36b, 0 3px 0 rgba(0,0,0,.25); transform: translateY(-2px); }
.v-dot { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: #ff6b6b; box-shadow: 0 0 0 2px var(--cream); }
.v-anvil { position: sticky; top: 0; background: var(--cream); color: var(--navy); border-radius: 18px; padding: 12px; box-shadow: 0 4px 0 rgba(0,0,0,.3); }
.v-anvil-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.v-anvil-head .j-icon { flex: none; width: 64px; height: 64px; font-size: 2.4rem; }
.v-anvil-head h4 { margin: 0; font-size: 1.15rem; }
.v-anvil-head p { margin: 2px 0 4px; font-size: .85rem; }
.v-anvil.locked .v-anvil-head .j-icon { filter: grayscale(.8); }
.v-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid rgba(0,0,0,.1); }
.v-row-ico { font-size: 1.4rem; width: 1.6em; text-align: center; flex: none; }
.v-row-main { flex: 1; min-width: 0; }
.v-row-main h5 { margin: 0; font-size: .95rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.v-row-main h5 .v-pips { margin: 0; }
.v-row-main p { margin: 2px 0 0; font-size: .82rem; }
.v-row-main small { font-size: .78rem; opacity: .8; }
.v-row .v-buy { margin: 0; flex: none; }
.v-row .j-tag { flex: none; max-width: 40%; text-align: center; }
@media (max-width: 720px) {
  .v-forge { grid-template-columns: minmax(0, 1fr); }
  .v-wgrid { display: flex; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x proximity; }
  .v-wtile { flex: 0 0 92px; scroll-snap-align: start; }
  .v-anvil { position: static; }
}
@media (max-width: 520px) { .v-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .v-house .j-icon { width: 56px; height: 56px; font-size: 2rem; } }

/* ── LEVELS ( /levels ): night list + garden preview + secret riddles ── */
.lv-wrap { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr); gap: 12px; }
.lv-preview { min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
#lv-canvas { width: 100%; aspect-ratio: 16 / 9; flex: none; border-radius: 18px; border: 4px solid var(--navy); background: var(--green); box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.lv-info { background: var(--navy); border-radius: 18px; padding: 12px 16px; }
.lv-info h3 { margin: 0 0 4px; color: var(--gold); font-size: 1.35rem; }
.lv-info h3 span { color: var(--cream); font-size: .8em; margin-left: 6px; }
.lv-info p { margin: 4px 0; font-size: .95rem; }
.lv-info h4 { margin: 12px 0 6px; color: var(--gold); }
.lv-moon small { opacity: .7; margin-left: 4px; }
.lv-stats { list-style: none; margin: 8px 0 2px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.lv-stats li { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.07); border-radius: 10px; padding: 5px 9px; font-size: .9rem; }
.lv-stats b { margin-left: auto; font-variant-numeric: tabular-nums; }
.lv-stats .good b { color: #9be89b; }
.lv-stats .bad b { color: #ffab91; }
.lv-stats-note { opacity: .6; font-size: .78rem !important; }
.lv-secrets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lv-secrets li { display: flex; gap: 10px; align-items: flex-start; background: rgba(255,255,255,.07); border-radius: 12px; padding: 8px 10px; }
.lv-secrets em { display: block; font-style: italic; }
.lv-secrets small { display: block; opacity: .7; margin-top: 2px; }
.lv-secrets li.found { background: rgba(127,214,138,.18); }
.lv-secrets li.found small { opacity: 1; color: #a6f0b0; }
.lv-q { font-size: 1.3rem; line-height: 1.2; }
.lv-list { min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; align-content: start; padding: 4px; }
.lv-card { --bg: #3f8a4f; border: 0; border-radius: 14px; padding: 8px 6px; min-height: 96px; font: inherit; color: var(--cream); cursor: pointer;
  background: linear-gradient(160deg, var(--bg), rgba(0,0,0,.25) 140%), var(--bg); box-shadow: 0 4px 0 rgba(0,0,0,.3);
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.lv-card small { font-size: .75rem; opacity: .9; }
.lv-card .lv-icon { font-size: 1.5rem; }
.lv-card.selected { outline: 4px solid var(--gold); transform: translateY(-2px); }
.lv-card:focus-visible { outline: 4px solid var(--cream); }
.lv-card.locked { filter: grayscale(.8) brightness(.7); cursor: not-allowed; }
.lv-meadow { --bg: #3f8a4f; } .lv-hollow { --bg: #2f5246; } .lv-frost { --bg: #6e9fb8; } .lv-ember { --bg: #7a4a3b; }
.lv-bog { --bg: #35523a; } .lv-cave { --bg: #4a4266; } .lv-sky { --bg: #5f6fa8; } .lv-spire { --bg: #3a3566; } .lv-bridge { --bg: #4a5068; } .lv-comet { --bg: #4a3a6e; } .lv-cradle { --bg: #2e2a5e; } .lv-mare { --bg: #1d1830; }
/* the next Spire, shown ahead of time: a dark, starry card that looks like it is waiting, not just greyed out */
.lv-card.teaser { filter: none; opacity: .8; background: radial-gradient(circle at 50% 20%, rgba(201,211,255,.35), transparent 60%), linear-gradient(170deg, #2a2550, #0f0d24); }
/* the list = each garden once, then the Spires: section labels span the grid (a thin vertical tag in the phone strip) */
.lv-head { grid-column: 1 / -1; margin: 6px 2px 0; font-size: .9rem; color: var(--cream); opacity: .8; font-weight: 700; }
.lv-head:first-child { margin-top: 0; }
.lv-card b { text-align: center; line-height: 1.15; font-size: .9rem; }
.lv-card small { text-align: center; line-height: 1.2; }
/* a Spire card names the climb up to it (data/climbs.js) under its night */
.lv-card small.lv-climb { font-size: .68rem; opacity: .75; }
/* difficulty chips under the place's name: one per night it comes back on; locked ones say how to open them */
.lv-diffs { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; margin: 8px 0 6px; }
.lv-diff { border: 0; border-radius: 12px; padding: 6px 8px; font: inherit; color: var(--cream); cursor: pointer; background: rgba(255,255,255,.08);
  display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; }
.lv-diff b { color: var(--gold); letter-spacing: 1px; font-size: .95rem; }
.lv-diff span { font-weight: 700; font-size: .9rem; }
.lv-diff small { font-size: .72rem; opacity: .8; line-height: 1.2; }
.lv-diff.selected { background: rgba(255,214,102,.2); outline: 3px solid var(--gold); }
.lv-diff:focus-visible { outline: 3px solid var(--cream); }
.lv-diff.locked { opacity: .6; cursor: not-allowed; }
.lv-diff.locked b { color: var(--cream); }
.lv-pips { display: flex; gap: 4px; margin-top: 2px; }
.lv-pips i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--cream); }
.lv-pips i.on { background: var(--gold); border-color: var(--gold); }
/* phone: one scrolling column. The nights are a sideways strip on top (a grid row here got squeezed to ~55 px and
   the cards spilled over the secrets), then the preview, then the night's info + secrets */
@media (max-width: 760px) {
  .lv-wrap { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
  .lv-list { order: -1; flex: none; display: flex; overflow-x: auto; overflow-y: hidden; padding: 4px 4px 8px; position: relative; }
  .lv-card { flex: none; width: 96px; min-height: 84px; }
  .lv-head { flex: none; writing-mode: vertical-rl; transform: rotate(180deg); margin: 0; font-size: .75rem; align-self: stretch; text-align: center; }
  .lv-preview { flex: none; overflow: visible; }
  #lv-canvas { aspect-ratio: 2 / 1; }
}

/* ── Journal: Creatures ( /creatures ) ── */
.jcard canvas.j-foe { width: 96px; height: 96px; display: block; margin: 0 auto 2px; border-radius: 50%; background: radial-gradient(circle, rgba(63,138,79,.35) 0 60%, transparent 61%); }
.j-traits { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 4px 0; }
.j-traits span { font-size: .72rem; background: rgba(0,0,0,.08); border-radius: 8px; padding: 1px 6px; }
.j-foestat { font-size: .8rem; opacity: .8; margin: 2px 0; }

/* ── hero levels (/characters): level badge on the card, talents of the picked hero under the grid ── */
.hero-lv { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: .8rem; }
.hero-lv .pill { margin: 0; }
.hero-xp { flex: 1; height: 7px; border-radius: 99px; background: rgba(29,36,51,.18); overflow: hidden; }
.hero-xp span { display: block; height: 100%; background: linear-gradient(90deg, #7fd36b, #ffd84a); }
.hero-talents { flex: none; max-height: 38vh; overflow-y: auto; background: rgba(0,0,0,.22); border-radius: 16px; padding: 10px 12px; }
.hero-talents h3 { font-size: 1.05rem; margin: 0; }
.hero-talents h3 small { font-weight: 400; opacity: .75; font-size: .8rem; }
.ht-note { margin: 2px 0 8px; font-size: .8rem; opacity: .8; }
.ht-tiers { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 12px; }
.ht-tier { display: grid; grid-template-columns: 44px 1fr 1fr; gap: 6px; align-items: stretch; }
.ht-at { align-self: center; font-weight: 700; font-size: .8rem; text-align: center; }
.ht-opt { border: 0; border-radius: 12px; background: rgba(255,255,255,.14); color: inherit; padding: 5px 6px; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; column-gap: 6px; font: inherit; line-height: 1.15; }
.ht-opt .ht-icon { grid-row: span 2; font-size: 1.3rem; align-self: center; }
.ht-opt b { font-size: .85rem; }
.ht-opt small { font-size: .72rem; opacity: .85; }
.ht-opt:hover:not(:disabled) { background: rgba(255,255,255,.24); }
.ht-opt.on { background: var(--gold); color: var(--navy); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.ht-tier.locked .ht-opt { opacity: .45; cursor: default; }
@media (max-width: 760px) {
  .ht-tiers { grid-template-columns: 1fr; }
  .hero-talents { max-height: 34vh; padding: 8px; }
}

/* ── moon pet strip (/characters, pets.js): pick the pet taken along. No `display` on .pet-pick, so [hidden] works ── */
.pet-pick { flex: none; background: rgba(20,24,60,.35); border-radius: 16px; padding: 8px 12px; }
.pet-pick h3 { font-size: 1rem; margin: 0; }
.pet-pick h3 small { font-weight: 400; opacity: .8; font-size: .78rem; margin-left: 4px; }
/* a scroller clips what pokes out of it, so the padding is room for the NEW! badge (top/right -4px) and the .on shadow */
.pet-row { display: flex; gap: 8px; overflow-x: auto; padding: 6px 6px 4px 0; }
.pet-chip { position: relative; flex: none; width: 92px; border: 0; border-radius: 14px; background: rgba(255,255,255,.14); color: inherit;
  font: inherit; padding: 4px 4px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.1; }
.pet-chip canvas { width: 56px; height: 56px; }
.pet-chip b { font-size: .74rem; }
.pet-chip small { font-size: .66rem; opacity: .8; }
.pet-chip .pet-q { font-size: 1.7rem; height: 56px; line-height: 56px; opacity: .7; }
.pet-chip:hover:not(.locked) { background: rgba(255,255,255,.24); }
.pet-chip.on { background: #cfe6ff; color: var(--navy); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.pet-chip.locked { cursor: default; opacity: .6; }
.pet-chip .new { position: absolute; top: -4px; right: -4px; background: #ff4d6d; color: #fff; border-radius: 99px; padding: 0 6px; font-size: .65rem; font-weight: 700; }

/* ── achievements ( /achievements ): navy like the Journal ── */
#page-achievements { background: radial-gradient(ellipse at 50% 15%, #2c4d63 0%, #1d2433 80%);
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
#page-achievements .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.ach-bar { display: flex; justify-content: flex-end; min-height: 0; }
.ach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; align-content: start; }
.ach { display: flex; align-items: center; gap: 10px; background: #f6efe2; color: var(--navy); border-radius: 16px; padding: 10px 12px; }
.ach.ready { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255,216,74,.5); }
.ach.done { opacity: .75; }
.ach-icon { font-size: 2rem; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle, #fffaf0 0 55%, #f3dc9a 56% 100%); flex: none; }
.ach-main { flex: 1; min-width: 0; }
.ach-main h4 { font-size: 1rem; margin: 0; }
.ach-main p { margin: 0; font-size: .82rem; }
.ach-main small { font-size: .72rem; opacity: .7; }
.ach-stars span { color: rgba(29,36,51,.2); font-size: .85rem; }
.ach-stars span.on { color: #e0a53a; }
.ach-stars span.ready { color: #ffd84a; text-shadow: 0 0 6px #ffd84a; }
.ach-prog { height: 7px; border-radius: 99px; background: rgba(29,36,51,.15); overflow: hidden; margin-top: 4px; }
.ach-prog span { display: block; height: 100%; background: linear-gradient(90deg, #7fd36b, #ffd84a); }
.ach-reward { font-weight: 700; font-size: .85rem; white-space: nowrap; }
.ach-claim { white-space: nowrap; }
#ach-all, .ach-claim { background: var(--orange); color: var(--navy); }
@media (max-width: 760px) { .ach-list { grid-template-columns: 1fr; } }

/* ── auto-pick (everything maxed) ── */
.lvl-auto { text-align: center; background: rgba(0,0,0,.18); border-radius: 14px; padding: 10px 12px; max-width: 560px; }
.lvl-auto p { margin: 0 0 8px; font-weight: 600; }
.lvl-auto .lvl-auto-note { margin: 8px 0 0; font-size: .78rem; font-weight: 400; opacity: .75; }
.lvl-auto-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.set-select { font: inherit; font-size: .9rem; background: var(--cream); color: var(--navy); border: 3px solid var(--orange); border-radius: 10px; padding: 6px 8px; max-width: 55%; }
/* ── pause screen: your build + every stat, and the in-run settings ── */
.pause-panel { width: min(860px, 100%); }
.pause-main, .pause-set { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pause-main[hidden], .pause-set[hidden] { display: none; }
.pause-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pause-cols { width: 100%; display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 700px) { .pause-cols { grid-template-columns: 1fr; } }
.pause-held { background: var(--navy); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.pause-held h3 { margin: 4px 0 2px; font-size: 1rem; color: var(--gold); }
.pause-held h3 small { color: var(--cream); opacity: .7; font-weight: 400; }
.held-row { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.held-row .nm { flex: 1; min-width: 0; font-weight: 600; }
.held-row .nm small { font-weight: 400; opacity: .75; }
.held-row b { width: 3.2em; text-align: right; font-size: .8rem; }
.held-row.empty .nm { opacity: .45; font-weight: 400; }
.lvpips { display: flex; gap: 3px; flex: none; }
.lvpips i { width: 12px; height: 12px; border-radius: 3px; border: 2px solid rgba(255,255,255,.35); }
.lvpips i.on { background: var(--orange); border-color: var(--orange); }
.lvpips.evo i.on { background: var(--gold); border-color: var(--gold); }
.res-build.pause-stats { grid-template-columns: 1fr auto; }
.pause-stats b { white-space: normal; }
.pause-set-top { width: 100%; display: flex; align-items: center; gap: 12px; }
.pause-set-top h2 { margin: 0; }
.pause-set-list { width: 100%; max-width: 560px; overflow: visible; }
.auto-toast { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); pointer-events: none; z-index: 5;
  background: rgba(20,16,50,.8); color: var(--glim); font-weight: 700; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--gold);
  animation: autotoast 1.3s ease-out forwards; width: max-content; max-width: calc(100vw - 24px); text-align: center; }
@keyframes autotoast { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  25% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -14px); } }

/* ── chest: the extra juice (tease, hits, combos, finale) ── */
.chest-panel { position: relative; }
.chest-flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 45%, var(--fc, #fff), transparent 70%); opacity: 0; z-index: 1; }
.chest-flash.go { animation: cflash .45s ease-out; }
@keyframes cflash { 0% { opacity: var(--fo, .4); } 100% { opacity: 0; } }
/* tease: the reel about to land a big prize glows and rattles, the rays spin up, the room darkens */
.reel.tease .reel-win { border-color: #ffd84a; animation: teaseglow .18s ease-in-out infinite alternate, teaserattle .09s linear infinite; }
@keyframes teaseglow { from { box-shadow: 0 0 6px #ffd84a, 0 0 0 2px #ff6bd6; } to { box-shadow: 0 0 30px #ffd84a, 0 0 0 4px #ff6bd6; } }
@keyframes teaserattle { 25% { transform: translate(-1px, 1px) rotate(-1deg); } 75% { transform: translate(1px, -1px) rotate(1deg); } }
.chest-ov { transition: background .3s; }
.chest-ov.teasing { background: rgba(30,5,40,.85); }
.chest-ov.teasing .chest-rays { animation-duration: 1.4s; }
.chest-ov.teasing .bulbs i { animation-duration: .08s; background: #ffb0ec; box-shadow: 0 0 10px #ff6bd6; }
/* chase lights while spinning, rainbow once it's won */
.chest-ov.spinning:not(.teasing) .bulbs i { animation: chase .6s linear infinite; animation-delay: calc(var(--i) * -.02s); }
@keyframes chase { 0%, 70% { background: #7a5a1a; box-shadow: none; } 80% { background: #fff6c8; box-shadow: 0 0 12px #ffd84a; } }
.chest-ov.won .bulbs i { animation: rainbowbulb .5s linear infinite; animation-delay: calc(var(--i) * -.05s); }
@keyframes rainbowbulb { 0% { background: #ff6b9a; box-shadow: 0 0 10px #ff6b9a; } 33% { background: #ffd84a; box-shadow: 0 0 10px #ffd84a; } 66% { background: #6fe0ff; box-shadow: 0 0 10px #6fe0ff; } }
.chest-ov.won .chest-rays { animation-duration: 3s; }
/* hits */
.reel { position: relative; }
.reel.stopped .reel-strip div:nth-last-child(2) { animation: prizepop .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes prizepop { 0% { transform: scale(1.7); } 100% { transform: scale(1); } }
.reel-pop { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); font-weight: 800; font-size: 1rem; white-space: nowrap; pointer-events: none;
  color: var(--rc, #fff); text-shadow: 0 2px 0 var(--navy), 0 0 10px var(--rc, #fff); animation: reelpop 1.2s ease-out forwards; z-index: 3; }
@keyframes reelpop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -8px) scale(1.35); }
  35% { transform: translate(-50%, -10px) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -34px); } }
.chest-combo { font-size: 1.5rem; font-weight: 800; color: #ffd84a; text-shadow: 0 3px 0 #b8327a, 0 0 16px #ff6bd6; letter-spacing: .04em; margin: -4px 0; transform: rotate(-3deg); }
.chest-combo.go { animation: combo .5s cubic-bezier(.3,1.7,.5,1); }
@keyframes combo { 0% { transform: scale(2.4) rotate(-8deg); opacity: 0; } 100% { transform: scale(1) rotate(-3deg); opacity: 1; } }
.chest-glim { position: relative; }
.chest-glim.bump { animation: gbump .35s cubic-bezier(.3,1.8,.5,1); }
@keyframes gbump { 0% { transform: scale(1.35); box-shadow: 0 0 26px var(--gold); } 100% { transform: scale(1); } }
.glim-pop { position: absolute; left: 100%; top: -8px; font-size: 1.1rem; color: var(--gold); text-shadow: 0 2px 0 var(--navy); pointer-events: none; white-space: nowrap; animation: reelpop 1.2s ease-out forwards; }
/* finale */
.chest-ov.won .chest-panel h2 { animation: titleslam .5s cubic-bezier(.3,1.6,.5,1); }
.chest-ov.won.jackpot .chest-panel h2 { animation: titleslam .5s cubic-bezier(.3,1.6,.5,1), rainbow 1s linear infinite, throb .5s .5s infinite; }
@keyframes titleslam { 0% { transform: scale(1.8); } 100% { transform: scale(1); } }
.chest-stamp { position: absolute; right: 8px; top: 34px; z-index: 4; pointer-events: none; font-weight: 900; font-size: 1.5rem; padding: 4px 12px; border-radius: 12px;
  color: #fff; background: #ff6b9a; border: 3px solid #fff; box-shadow: 0 4px 0 rgba(0,0,0,.3), 0 0 20px rgba(255,107,154,.7); transform: rotate(12deg); }
.chest-stamp[data-tier="1"] { background: #3fae6a; box-shadow: 0 4px 0 rgba(0,0,0,.3); font-size: 1.2rem; }
.chest-stamp[data-tier="2"] { background: #3d8ee0; }
.chest-stamp[data-tier="3"] { background: #b56cff; }
.chest-stamp[data-tier="4"] { background: linear-gradient(90deg, #ff6b9a, #ffb84a, #b56cff); font-size: 1.8rem; }
.chest-stamp.go { animation: stamp .45s cubic-bezier(.3,1.5,.5,1); }
@keyframes stamp { 0% { transform: scale(3) rotate(-20deg); opacity: 0; } 100% { transform: scale(1) rotate(12deg); opacity: 1; } }
.confetti span.rain { top: -40px; animation-name: rain; animation-timing-function: cubic-bezier(.4,0,.8,.6); animation-fill-mode: both; }
@keyframes rain { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--sway), 105vh) rotate(var(--rot)); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .reel.tease .reel-win, .chest-stamp.go, .chest-combo.go { animation: none; } .chest-flash.go { animation-duration: .01s; } }
@media (max-width: 700px) { .chest-stamp { top: 8px; right: 4px; font-size: 1.1rem; } .chest-combo { font-size: 1.2rem; } }

/* ── MOON TREE (/moon): the Garden Tree's layout under a night sky ── */
#page-moon { background: #2b2160; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.moon-frame { background: radial-gradient(ellipse at 50% 45%, #2e3a7a 0%, #161a44 55%, #0b0d26 100%); border-color: #e9e4ff; box-shadow: inset 0 0 0 4px #0a0b22; }
.moon-frame::before { opacity: .55; background-image:
  radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 33% 72%, #fff 50%, transparent 51%),
  radial-gradient(1.2px 1.2px at 58% 12%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 81% 44%, #fff 50%, transparent 51%),
  radial-gradient(1.6px 1.6px at 90% 86%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 22% 92%, #fff 50%, transparent 51%),
  radial-gradient(1.2px 1.2px at 70% 64%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 45% 38%, #fff 50%, transparent 51%);
  background-size: 260px 260px; animation: twinkle 6s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .35; } to { opacity: .7; } }
.moon-money .money-can { background: linear-gradient(160deg, #a9a2ff, #3b3592); }
.moon-money .money-text strong { color: #cfe6ff; }
.moon-frame .bloom-bar div { background: linear-gradient(90deg, #8fd3ff, #e9e4ff); }
.moon-frame .tab.active { background: #cfe6ff; }
.moon-frame .node { border-color: #1b1740; }
.moon-frame .node.st-available { background: #2a2950; }
.moon-frame .node.st-teaser { background: #1e1d3a; border-color: #14122c; }
.moon-frame .node.st-owned, .moon-frame .node.st-maxed { box-shadow: 0 0 18px color-mix(in srgb, var(--c) 70%, transparent), 0 5px 0 rgba(0,0,0,.35); }
.moon-frame .node.st-maxed { box-shadow: 0 0 0 4px #e9e4ff, 0 0 28px var(--c); }
.moon-frame .tree-lines line.dim { stroke: #7d7ab8; opacity: .35; }
.moon-frame .tree-lines line.lit { filter: drop-shadow(0 0 6px currentColor); }
.tree-lines line.link { stroke-width: 3; }
.tree-lines line.link.dim { stroke-dasharray: 1 8; opacity: .25; }
.moon-locked { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; max-width: 460px; margin: auto; }
.moon-locked[hidden] { display: none; }
.moon-locked .j-icon { font-size: 3.6rem; }
.moon-locked p { opacity: .85; line-height: 1.4; }
.moon-pets { position: relative; z-index: 3; margin: 0 12px; background: rgba(10,12,40,.55); }
.moon-pets .pet-chip { width: 78px; padding-top: 2px; }
.moon-pets .pet-chip canvas, .moon-pets .pet-chip .pet-q { width: 44px; height: 44px; line-height: 44px; }
.moon-pets .pet-chip small { display: none; }
.pet-pick h3 i { font-style: normal; opacity: .7; font-size: .85rem; }
@media (max-width: 700px) {
  #page-moon { padding: 6px; }
  .moon-pets { margin: 0 6px; padding: 6px 8px; }
  .moon-pets h3 small { display: none; }
}

/* ── Moon Tree chunk 5: complete constellations, the Moon Altar, hybrids, the Pets Journal ── */
.moon-frame .node.set-done { box-shadow: 0 0 0 3px #ffe9a8, 0 0 30px var(--c), 0 0 60px color-mix(in srgb, var(--c) 50%, transparent); }
.moon-frame .tree-lines line.set-done { stroke-width: 7; filter: drop-shadow(0 0 10px #ffe9a8); }
.moon-frame .tree-lines line.celebrate { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: set-draw 1.4s ease-out .15s forwards; }
.moon-frame .node.celebrate { animation: set-flare .9s ease-out var(--d, 0ms) both; }
@keyframes set-draw { to { stroke-dashoffset: 0; } }
@keyframes set-flare { 0% { transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
  40% { transform: translate(-50%, -50%) scale(1.45); filter: brightness(2.2); } 100% { transform: translate(-50%, -50%) scale(1); filter: brightness(1); } }
.altar-btn { position: absolute; top: 10px; right: 10px; z-index: 3; font: inherit; font-weight: 700; border: 2px solid #e9e4ff; border-radius: 99px;
  background: #2a2950; color: #e9e4ff; padding: 6px 14px; cursor: pointer; box-shadow: 0 0 16px rgba(185,166,255,.5); }
.altar-btn:hover { background: #3a3870; }
.altar-btn .badge { position: static; display: inline-block; margin-left: 4px; }
.altar { background: radial-gradient(ellipse at 50% 0%, #2e3a7a 0%, #161a44 70%); border-color: #e9e4ff; width: min(600px, 100%); }
.altar h2 { color: #e9e4ff; text-shadow: 0 3px 0 #0b0d26; }
.altar h3 { color: #ffe9a8; margin: 4px 0 0; font-size: 1.1rem; }
.altar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.altar-list li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; background: rgba(255,255,255,.08); border-radius: 14px;
  padding: 8px 10px; border: 2px solid transparent; }
.altar-list li .av { font-size: 1.8rem; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.3); }
.altar-list li .av canvas { width: 52px; height: 52px; }
.altar-list li b { color: #fff; }
.altar-list li small { opacity: .75; }
.altar-list li p { margin: 2px 0 4px; font-size: .86rem; }
.altar-list li p i { opacity: .7; }
.altar-list li.done { border-color: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 60%, transparent); }
.altar-list li.ready { border-color: #ffe9a8; }
.altar-list .prog { display: flex; align-items: center; gap: 8px; }
.altar-list .prog .bar { flex: 1; height: 8px; background: rgba(0,0,0,.35); border-radius: 99px; overflow: hidden; }
.altar-list .prog .bar div { height: 100%; background: linear-gradient(90deg, #8fd3ff, #e9e4ff); }
.altar-list .claim { border: 0; border-radius: 10px; padding: 4px 12px; background: #e9e4ff; color: var(--navy); font-weight: 700; cursor: pointer; }
.altar-list li.ready .claim { background: #ffe9a8; animation: throb 1s infinite; }
.altar-list .claim:disabled { opacity: .5; cursor: default; }
.altar-list .maxed { color: #ffe9a8; font-weight: 700; font-size: .85rem; }
.pet-chip.hybrid { background: linear-gradient(135deg, rgba(255,233,168,.25), rgba(185,166,255,.3)); }
.pet-chip.hybrid.on { background: linear-gradient(135deg, #ffe9a8, #cfe6ff); }
.journal-tabs { flex-wrap: wrap; }
#page-pets { background: radial-gradient(ellipse at 50% 15%, #2e3a7a 0%, #161a44 80%);
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
#page-pets .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.jcard.kind-pets { border-top: 5px solid var(--c, #e9e4ff); }
.jcard .j-tricks { list-style: none; margin: 6px 0 0; padding: 0; text-align: left; font-size: .76rem; line-height: 1.3; }
.jcard .j-tricks li { opacity: .5; }
.jcard .j-tricks li.on { opacity: 1; font-weight: 600; }
@media (max-width: 700px) {
  .altar-btn { top: 6px; right: 6px; padding: 6px 10px; }
  .altar-btn > span:not(.badge) { display: none; }
  .journal-tabs { gap: 6px; }
  .journal-tabs button { padding: 5px 11px; font-size: .9rem; }
  .altar-list li { grid-template-columns: 42px 1fr; gap: 8px; }
  .altar-list li .av, .altar-list li .av canvas { width: 42px; height: 42px; font-size: 1.4rem; }
}
.moon-frame .node.sh-diamond.celebrate { animation-name: set-flare-d; }
@keyframes set-flare-d { 0% { transform: translate(-50%, -50%) rotate(45deg) scale(1); filter: brightness(1); }
  40% { transform: translate(-50%, -50%) rotate(45deg) scale(1.45); filter: brightness(2.2); } 100% { transform: translate(-50%, -50%) rotate(45deg) scale(1); filter: brightness(1); } }

/* ── sound test ( /soundtest ), reached from /settings ── */
.set-link { color: inherit; font: inherit; text-align: left; cursor: pointer; border: 0; width: 100%; }
.set-link:hover { background: rgba(255,255,255,.12) !important; }
#page-soundtest { background: radial-gradient(ellipse at 50% 15%, #2c4d63 0%, #1d2433 80%); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); color: var(--cream); }
#page-soundtest .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.soundtest-frame { max-width: 1200px; }
.st-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px 2px 20px; }
.st-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.st-box { background: rgba(255,255,255,.06); border-radius: 16px; padding: 12px; }
.st-box h3 { margin: 0 0 8px; color: var(--gold); font-size: 1.1rem; }
.st-box h4 { margin: 12px 0 6px; font-size: .95rem; opacity: .85; }
.st-box h4:first-child { margin-top: 0; }
.st-note { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; opacity: .9; }
.st-songs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.st-song, .st-snd, .st-wpn, .st-lv { font: inherit; color: inherit; border: 2px solid transparent; background: var(--navy-2); border-radius: 12px; cursor: pointer; }
.st-song { display: flex; align-items: center; gap: 8px; padding: 8px 10px; text-align: left; min-height: 44px; }
.st-song > span:nth-child(2) { flex: 1; }
.st-play { opacity: .6; font-size: .85rem; }
.st-song.on, .st-wpn.on, .st-lv.on { border-color: var(--orange); background: #3a3348; }
.st-song.on .st-play { opacity: 1; color: var(--orange); }
.st-snd-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.st-snd { padding: 6px 12px; min-height: 40px; font-size: .9rem; }
.st-snd:active, .st-song:active, .st-wpn:active { transform: scale(.96); }
.st-song:hover, .st-snd:hover, .st-wpn:hover, .st-lv:hover { background: #343f57; }
.st-ico { font-size: 1.2rem; width: 1.4em; text-align: center; flex: none; }
#st-canvas { display: block; width: 100%; height: min(46vh, 420px); border-radius: 12px; background: #17402d; touch-action: pan-y; }
.st-wpn-info { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; min-height: 3em; }
.st-wpn-info small { opacity: .7; }
.st-wpn-info span { flex-basis: 100%; font-size: .9rem; opacity: .9; }
.st-wpn-info .st-evo-hint { opacity: .6; font-size: .8rem; }
.st-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.st-controls label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }
.st-lvs { display: flex; align-items: center; gap: 6px; }
.st-lvs small { opacity: .75; }
.st-lvs > span { display: flex; gap: 4px; }
.st-lv { width: 36px; height: 36px; font-weight: 700; }
.st-weapons { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.st-wpn { display: flex; align-items: center; gap: 6px; padding: 6px 8px; text-align: left; min-height: 42px; font-size: .9rem; }
@media (min-width: 900px) {
  .st-body { flex-direction: row; align-items: flex-start; }
  .st-col { flex: 1; }
  .st-stage { flex: 1.15; position: sticky; top: 0; }
  #st-canvas { height: min(52vh, 480px); }
}
/* ── /bossdefeat (Settings → Demos): the real defeat show on a stage ── */
#page-bossdefeat, #page-bossfight { background: radial-gradient(ellipse at 50% 15%, #2c4d63 0%, #1d2433 80%); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); color: var(--cream); }
#page-bossdefeat .heroes-top h2, #page-bossfight .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.bd-body .st-stage { flex: 1; position: static; }
.bd-stage { position: relative; }
#bd-canvas, #bf-canvas { display: block; width: 100%; height: min(62vh, 620px); border-radius: 12px; background: #000; }
/* centred with translate, not transform: .btn:active's transform would replace it and the button jumped off the cursor, eating the click */
.bd-again { position: absolute; left: 50%; bottom: 16px; translate: -50% 0; opacity: 0; pointer-events: none; transition: opacity .3s; }
.bd-again.on { opacity: 1; pointer-events: auto; }
.bd-status { margin: 8px 0 12px; min-height: 1.4em; opacity: .9; }
/* /bossfight: an attack's name as it's telegraphed (top), a phase beat (middle); popup text wraps, never nowrap */
.bf-caption { position: absolute; left: 50%; top: 12px; transform: translate(-50%, -6px); max-width: calc(100% - 24px); margin: 0; text-align: center;
  background: rgba(10, 14, 28, .72); color: var(--cream); border-radius: 99px; padding: 5px 16px; font-weight: 700; font-size: clamp(.9rem, 3.6vw, 1.1rem);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.bf-caption.on { opacity: 1; transform: translate(-50%, 0); }
.bf-beat { position: absolute; left: 0; right: 0; top: 38%; margin: 0; text-align: center; pointer-events: none; opacity: 0; color: #fff; }
.bf-beat b { display: block; font-size: clamp(2rem, 11vw, 3.6rem); letter-spacing: .06em; color: #ffe9a8; -webkit-text-stroke: 2px #6b2a12; paint-order: stroke fill; }
.bf-beat small { display: block; font-size: clamp(.95rem, 4vw, 1.2rem); opacity: .95; padding: 0 12px; }
.bf-beat.on { animation: bf-beat 2.4s ease-out forwards; }
@keyframes bf-beat { 0% { opacity: 0; transform: scale(1.5); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.96); } }
@media (prefers-reduced-motion: reduce) { .bf-beat.on { animation: none; opacity: 1; } }
.bd-bosses .st-wpn small { display: block; opacity: .65; font-size: .78rem; }
/* ── /trailer (Settings → Demos): the ad. The canvas fills the stage; the card pops over it (trailer.js cardLook) ── */
#page-trailer { background: #07081a; padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); color: var(--cream); }
#page-trailer .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.tr-stage { position: relative; flex: 1; min-height: 0; display: flex; }
#tr-canvas { display: block; width: 100%; height: min(78vh, 760px); border-radius: 12px; background: #000; }
.tr-card { position: absolute; left: 0; right: 0; top: 26%; margin: 0; padding: 0 16px; text-align: center; pointer-events: none; opacity: 0; color: #fff; }
.tr-card b { display: block; font-size: clamp(1.8rem, 9vw, 3.4rem); line-height: 1.1; letter-spacing: .02em; color: #fff; -webkit-text-stroke: 2px #1d2433; paint-order: stroke fill; }
.tr-card small { display: block; margin-top: 8px; font-size: clamp(1rem, 4.2vw, 1.35rem); font-weight: 700; color: #fff; opacity: .95; }
.tr-card.title b { font-size: clamp(2.6rem, 14vw, 5.4rem); color: #ffe9a8; -webkit-text-stroke: 3px #6b2a12; text-shadow: 0 0 24px rgba(255, 200, 90, .7); }
.tr-card.end { top: 18%; }
#tr-card:not(.end) { top: 5%; }   /* the trailer: inside trailerLive.js CARD_BAND, the action is framed under it (user 2026-11-12) */
.tr-start, .tr-end { position: absolute; left: 50%; translate: -50% 0; opacity: 0; pointer-events: none; transition: opacity .3s; }
.tr-start { top: 50%; font-size: 1.2rem; }
.tr-end { bottom: 18%; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100% - 24px); }
.tr-skip { position: absolute; top: 10px; right: 10px; opacity: 0; pointer-events: none; transition: opacity .3s; background: rgba(7,8,26,.55); }
.tr-start.on, .tr-end.on, .tr-skip.on { opacity: 1; pointer-events: auto; }
/* ── /intro (docs/story.md): a full-screen film, the canvas fills the page; captions over the bottom letterbox bar ── */
#page-intro { background: #000; padding: 0; color: #fff; }
.in-stage { position: absolute; inset: 0; }
#in-canvas { display: block; width: 100%; height: 100%; }
.in-cap { position: absolute; left: 0; right: 0; bottom: max(9%, calc(env(safe-area-inset-bottom) + 12px)); margin: 0; padding: 0 18px; text-align: center;
  pointer-events: none; opacity: 0; font-size: clamp(1.05rem, 4.6vw, 1.6rem); font-weight: 700; line-height: 1.3; color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.9), 0 0 2px rgba(0,0,0,.9); }
.in-card { top: 16%; }
#page-intro .tr-skip { top: max(10px, env(safe-area-inset-top)); }
#page-intro .tr-end { bottom: 24%; }
/* ── /ending: the same film frame as /intro (filmPage.js), its card a little smaller (a longer line) ── */
#page-ending { background: #000; padding: 0; color: #fff; }
#en-canvas { display: block; width: 100%; height: 100%; }
#page-ending .tr-skip { top: max(10px, env(safe-area-inset-top)); }
#page-ending .tr-end { bottom: auto; top: 40%; }   /* under the card, clear of the cast at the bottom */
.tr-card.title.en-card b { font-size: clamp(2.2rem, 11vw, 4.6rem); color: #f2f4ff; -webkit-text-stroke: 3px #2a2c6b; text-shadow: 0 0 24px rgba(200, 210, 255, .75); }
/* ── /characters strip + /hero page: the picked hero's level, talents, pet and moon, off the grid page ── */
.hero-prep { flex: none; display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; border: 0; border-radius: 14px; background: rgba(0,0,0,.25);
  color: inherit; font: inherit; font-size: .95rem; padding: 8px 14px; cursor: pointer; text-align: left; }
.hero-prep:hover { background: rgba(0,0,0,.35); }
.hero-prep i { font-style: normal; }
.hero-prep b { margin-left: auto; background: var(--gold); color: var(--navy); border-radius: 99px; padding: 3px 12px; white-space: nowrap; }
#page-hero { background: radial-gradient(ellipse at 50% 20%, #2f7a4a 0%, #17402d 75%); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
.hp-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }
.hp-who { display: flex; align-items: center; gap: 14px; background: rgba(0,0,0,.18); border-radius: 16px; padding: 8px 14px; }
.hp-who canvas { width: 110px; height: 110px; flex: none; }
.hp-who .animal { font-size: .85rem; opacity: .75; }
.hp-who .weapon { display: inline-block; font-size: .85rem; font-weight: 600; background: var(--navy); color: var(--cream); border-radius: 99px; padding: 2px 10px; margin: 4px 0; }
.hp-who ul { list-style: none; margin: 0; padding: 0; font-size: .88rem; line-height: 1.35; }
#page-hero .hero-talents { max-height: none; overflow: visible; }
@media (max-width: 700px) {
  .hero-prep { font-size: .85rem; padding: 7px 10px; }
  .hp-who canvas { width: 84px; height: 84px; }
}
/* phone: the count (e.g. "🔍 0 / 18 secrets") wraps instead of pushing past the right edge; the title shrinks first */
@media (max-width: 700px) {
  .heroes-top { gap: 8px; }
  .heroes-top h2 { min-width: 0; }
  .heroes-count { min-width: 0; max-width: 34%; font-size: .75rem; line-height: 1.15; }
}
/* /levels sat flush to the screen edge (no padding), so its header count touched the right edge on a phone */
#page-levels { padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
/* /levels sat on the bare orange body: the ghost ◀ Heroes button, the gold-on-orange title, the count and the section
   labels all blended in (user 2026-11-11). A night-sky backdrop like /characters' dark green, plus solid controls */
#page-levels { background: radial-gradient(ellipse at 50% 15%, #34407a 0%, #1a1f3d 60%, #10132a 100%); }
#page-levels .heroes-top h2 { color: #ffe9a8; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
#page-levels .heroes-top .btn-ghost { background: var(--cream); color: var(--navy); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
#page-levels .heroes-count { opacity: 1; }
#page-levels .lv-head { opacity: 1; color: #ffe9a8; }
#page-characters .lv-turbo { background: var(--navy-2); border: 2px solid rgba(255,255,255,.18); }
.lv-turbo[hidden] { display: none; }   /* (display:flex above would beat [hidden]) */
.lv-turbo .turbo-xp { color: var(--gold, #ffd75e); margin-left: 4px; }
#page-levels .lv-turbo { background: var(--navy-2); border: 2px solid rgba(255,255,255,.18); }
#page-levels #lv-canvas { border-color: #0b0e1f; }
#page-levels .lv-info { border: 2px solid rgba(255,255,255,.12); }
#page-levels .lv-card { box-shadow: inset 0 0 0 2px rgba(255,255,255,.16), 0 4px 0 rgba(0,0,0,.4); }

/* icons.js: the glyph that stands in for an emoji in page text (alt = the emoji) */
img.gi { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -0.25em; margin: 0 .04em; pointer-events: none; user-select: none; }

/* Refund all (refund.js): the row at the foot of the Blacksmith / Fortune Teller */
.v-refund { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 6px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.v-refund p { margin: 0; opacity: 0.75; font-size: 0.9em; }
.tabs .tab:disabled { opacity: 0.45; cursor: default; }
