/* Save Bob UI. Kid-first: big readable Lexend text, chunky glowing
 * buttons, high contrast, every control reachable by keys, pad and touch.
 * Futuristic fantasy: deep night-blue panels, gold trim, cyan tech glow. */

@font-face { font-family: "Lexend"; src: url("fonts/lexend-400.woff2") format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "Lexend"; src: url("fonts/lexend-600.woff2") format("woff2"); font-weight: 600; font-display: block; }
@font-face { font-family: "Lexend"; src: url("fonts/lexend-700.woff2") format("woff2"); font-weight: 700; font-display: block; }
@font-face { font-family: "Lexend"; src: url("fonts/lexend-800.woff2") format("woff2"); font-weight: 800; font-display: block; }
@font-face { font-family: "Cinzel Decorative"; src: url("fonts/cinzel-decorative-900.woff2") format("woff2"); font-weight: 900; font-display: block; }

:root {
  --bg: #0d1630;
  --surface: rgba(13, 22, 48, 0.9);
  --surface2: rgba(24, 38, 78, 0.95);
  --edge: #3d5aa0;
  --ink: #fbf7ea;
  --muted: #b9c6db;
  --accent: #ffd23f;
  --reward: #ffd23f;
  --danger: #ff5d5d;
  --good: #57d977;
  --tech: #57f3ff;
  --font-ui: "Lexend", system-ui, sans-serif;
  --font-title: "Cinzel Decorative", serif;
  --text-s: 0.95rem;
  --text-m: 1.15rem;
  --text-l: 1.6rem;
  --text-xl: 2.6rem;
  --space: 0.5rem;
  --radius: 16px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font-ui);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none; }
button, input { font-family: inherit; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }
svg { width: 1em; height: 1em; fill: currentColor; flex: none; }

#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,10,0.32) 100%); transition: background 0.3s; }
#vignette.hurt { background: radial-gradient(ellipse at center, transparent 42%, rgba(230,30,40,0.45) 100%); transition: none; }
#vignette.cold { background: radial-gradient(ellipse at center, transparent 50%, rgba(120,200,255,0.3) 100%); }
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: #fff; }
#bars i { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 40; transition: height 0.6s ease; pointer-events: none; }
#bars i.top { top: 0; } #bars i.bot { bottom: 0; }
#bars.on i { height: 11vh; }

:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 1.8em; height: 1.8em; padding: 0 0.45em;
  border-radius: 7px; background: #f5f0e0; color: #1f2233; font-weight: 800; font-size: 0.82em; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25); margin-right: 0.35em; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  html.touch #rotate { display: flex; position: fixed; inset: 0; z-index: 200; background: var(--bg); flex-direction: column; align-items: center;
    justify-content: center; gap: 1rem; font-size: 1.3rem; font-weight: 700; text-align: center; padding: 2rem; }
  html.touch #rotate svg { width: 80px; height: 80px; animation: tilt 2s ease-in-out infinite; color: var(--accent); }
}
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

a.back { position: fixed; left: calc(14px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); color: var(--muted); font-size: 0.9rem; text-decoration: none; z-index: 60; opacity: 0.85; }
a.back:hover, a.back:focus-visible { color: var(--accent); opacity: 1; }
a.back.ingame { left: auto; right: calc(14px + var(--safe-r)); bottom: calc(6px + var(--safe-b)); font-size: 0.8rem; opacity: 0.6; }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.screen.show { display: flex; animation: fadein 0.35s ease; }
.screen.dim { background: rgba(5, 10, 25, 0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
html.rm .screen.show { animation: none; }

.logo { font-family: var(--font-title); font-weight: 900; font-size: clamp(3rem, 11vw, 7.4rem); line-height: 0.95; letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff6c8 0%, #ffd23f 45%, #ff9d2e 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #6b3a12) drop-shadow(0 0 24px rgba(87, 243, 255, 0.45)); text-align: center; }
.logo.small { font-size: 3rem; }
.by { text-align: center; font-weight: 800; letter-spacing: 0.35em; text-transform: uppercase; color: var(--tech); font-size: 1rem;
  text-shadow: 0 0 12px rgba(87,243,255,0.7); margin-bottom: 0.4rem; }
.subtitle { text-align: center; font-weight: 700; font-size: clamp(1.1rem, 2.6vw, 1.7rem); color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  letter-spacing: 0.08em; margin: 0.6rem 0 1.6rem; }
#title { background: linear-gradient(180deg, rgba(5,10,30,0.1) 0%, rgba(5,10,30,0) 40%, rgba(5,10,30,0.55) 100%); }
.title-wrap { display: flex; flex-direction: column; align-items: center; }
.title-wrap .menu { width: min(340px, 80vw); }
.hint { color: var(--muted); font-size: var(--text-s); text-align: center; margin: 0.8rem 0 0; }
.hint.small { font-size: 0.8rem; }

#loading { background: radial-gradient(ellipse at center, #1b2a5a 0%, var(--bg) 70%); flex-direction: column; gap: 1.2rem; }
.loadbar { width: min(420px, 70vw); height: 14px; border-radius: 99px; background: rgba(255,255,255,0.12); overflow: hidden; border: 2px solid var(--edge); }
.loadbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--tech), var(--accent)); transition: width 0.2s; }
#loadtext { color: var(--muted); }

.panel { background: linear-gradient(180deg, var(--surface2), var(--surface)); border: 3px solid var(--edge); border-radius: 22px; padding: 1.4rem 1.6rem;
  box-shadow: 0 0 0 2px rgba(255,210,63,0.35) inset, 0 20px 60px rgba(0,0,0,0.5), 0 0 30px rgba(87,243,255,0.15); max-height: 92vh; overflow: auto; width: min(560px, 94vw); }
.panel.narrow { width: min(420px, 94vw); }
.panel.wide { width: min(980px, 96vw); }
.panel.center { text-align: center; }
.panel h2 { margin: 0 0 1rem; text-align: center; font-size: var(--text-l); color: var(--accent); letter-spacing: 0.04em; }
.panel h3 { margin: 1rem 0 0.5rem; color: var(--tech); font-size: 1.05rem; }
.menu { display: flex; flex-direction: column; gap: 0.7rem; }
.row-btns { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }

.bbtn { appearance: none; border: 0; cursor: pointer; min-height: 52px; padding: 0.7rem 1.4rem; border-radius: 14px; font-weight: 800; font-size: 1.12rem;
  color: #1c1405; background: linear-gradient(180deg, #ffe89a, var(--accent)); box-shadow: 0 5px 0 #a8791a, 0 8px 18px rgba(0,0,0,0.35);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; transition: transform 0.08s, filter 0.15s; letter-spacing: 0.02em; }
.bbtn svg { width: 1.3em; height: 1.3em; }
.bbtn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.bbtn:active, .bbtn.down { transform: translateY(4px); box-shadow: 0 1px 0 #a8791a, 0 3px 8px rgba(0,0,0,0.35); }
.bbtn.green { background: linear-gradient(180deg, #9ff2a8, var(--good)); box-shadow: 0 5px 0 #2a8a3c, 0 8px 18px rgba(0,0,0,0.35); }
.bbtn.blue { background: linear-gradient(180deg, #a8e4ff, #4aa8ff); box-shadow: 0 5px 0 #245e9e, 0 8px 18px rgba(0,0,0,0.35); color: #06162e; }
.bbtn.ghost { background: rgba(255,255,255,0.1); color: var(--ink); box-shadow: 0 0 0 2px var(--edge) inset; }
.bbtn.big { font-size: 1.3rem; min-height: 60px; padding: 0.8rem 2rem; }
.bbtn[disabled] { opacity: 0.4; pointer-events: none; }
.iconbtn { appearance: none; border: 0; cursor: pointer; width: 48px; height: 48px; border-radius: 12px; background: rgba(255,255,255,0.12);
  color: var(--ink); font-size: 1.6rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--edge) inset; }
.iconbtn svg { width: 24px; height: 24px; }

#heroName { width: 100%; font-size: 1.6rem; font-weight: 800; padding: 0.6rem 0.9rem; border-radius: 12px; border: 3px solid var(--edge);
  background: rgba(255,255,255,0.95); color: #1a1f33; text-align: center; -webkit-user-select: text; user-select: text; }
.swatches { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.swatch { width: 54px; height: 54px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.3); cursor: pointer; position: relative; }
.swatch[aria-checked="true"] { border-color: #fff; box-shadow: 0 0 0 3px var(--accent), 0 0 16px var(--accent); }
.swatch[aria-checked="true"]::after { content: ""; position: absolute; inset: 12px; background: #fff; -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 12.5l5 5L20 6.5" fill="none" stroke="black" stroke-width="4" stroke-linecap="round"/></svg>') center/contain no-repeat; mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 12.5l5 5L20 6.5" fill="none" stroke="black" stroke-width="4" stroke-linecap="round"/></svg>') center/contain no-repeat; }

/* settings controls */
.setting { display: grid; grid-template-columns: 8.5rem 1fr 3rem; align-items: center; gap: 0.7rem; margin: 0.8rem 0; }
.setting label, .setting .lbl { font-weight: 700; }
.setting output { text-align: right; font-variant-numeric: tabular-nums; color: var(--reward); font-weight: 700; }
.setting.seg, .setting.tog { grid-template-columns: 8.5rem 1fr; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 44px; background: transparent; width: 100%; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--tech) var(--fill, 50%), rgba(255,255,255,0.18) var(--fill, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; margin-top: -9px; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 99px; background: rgba(255,255,255,0.18); }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 99px; background: var(--tech); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; }
.segmented { display: flex; background: rgba(255,255,255,0.08); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-weight: 700; cursor: pointer; font-size: 1rem; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: #1c1405; }
.toggle { width: 70px; height: 40px; border-radius: 99px; border: 0; background: rgba(255,255,255,0.18); position: relative; cursor: pointer; justify-self: start; }
.toggle i { position: absolute; top: 5px; left: 5px; width: 30px; height: 30px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.toggle[aria-checked="true"] { background: var(--good); }
.toggle[aria-checked="true"] i { left: 35px; }

.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.6rem; }
.help-grid p { line-height: 1.5; margin: 0.4rem 0; }
.keys { line-height: 2.1 !important; }

/* ---------------------------------------------------------------- HUD */
#hud.cine > :not(#toasts):not(#subtitle) { opacity: 0; transition: opacity 0.4s; }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; font-variant-numeric: tabular-nums; }
.hud-tl { position: absolute; left: calc(16px + var(--safe-l)); top: calc(12px + var(--safe-t)); display: flex; flex-direction: column; gap: 8px; }
#hearts { display: flex; flex-wrap: wrap; gap: 3px; max-width: 290px; }
.heart { width: 34px; height: 34px; position: relative; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6)); }
.heart svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.heart .empty { color: rgba(30, 20, 40, 0.75); }
.heart .full { color: #ff4d5e; }
.heart.half .full { clip-path: inset(0 50% 0 0); }
.heart.none .full { display: none; }
.heart.pop { animation: pop 0.35s ease; }
@keyframes pop { 50% { transform: scale(1.35); } }
#energy { width: 190px; height: 12px; border-radius: 99px; background: rgba(0,0,0,0.45); border: 2px solid rgba(255,255,255,0.5); overflow: hidden; }
#energy i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #6fe3ff, #b387ff); transition: width 0.1s; }
#energy.low i { background: rgba(160,170,200,0.7); }

#compass { position: absolute; top: calc(12px + var(--safe-t)); left: 50%; width: min(460px, 40vw); height: 40px; transform: translateX(-50%);
  border-radius: 12px; background: linear-gradient(90deg, transparent, rgba(8,14,34,0.55) 15%, rgba(8,14,34,0.55) 85%, transparent); overflow: hidden; }
#compass .strip { position: absolute; inset: 0; }
#compass .tick { position: absolute; left: 50%; top: 0; width: 3px; height: 9px; margin-left: -1.5px; background: var(--accent); border-radius: 2px; }
.cm { position: absolute; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; font-weight: 800; font-size: 0.8rem; color: #fff; text-shadow: 0 1px 3px #000; }
.cm svg { width: 22px; height: 22px; filter: drop-shadow(0 1px 2px #000); }
.cm.dir { color: var(--muted); font-size: 0.95rem; }
.cm.dir.n { color: var(--accent); }
.cm .dist { font-size: 0.62rem; opacity: 0.9; margin-top: -2px; }

.hud-tr { position: absolute; right: calc(16px + var(--safe-r)); top: calc(12px + var(--safe-t)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#minimap { width: 150px; height: 150px; border-radius: 50%; border: 3px solid rgba(255,210,63,0.85); box-shadow: 0 0 0 2px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.4); background: #1d3a5e; pointer-events: auto; cursor: pointer; }
.counters { display: flex; gap: 12px; }
.count { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 1.15rem; text-shadow: 0 2px 3px rgba(0,0,0,0.8); }
.count svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 2px #000); }
.count.gears svg { color: var(--accent); }
.count.shards svg { color: #fff3b0; }
.count.bump { animation: pop 0.3s ease; }

#weapons { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; }
.wslot { width: 56px; height: 56px; border-radius: 14px; background: rgba(8,14,34,0.7); border: 3px solid rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center;
  position: relative; color: rgba(255,255,255,0.25); cursor: pointer; }
.wslot svg { width: 32px; height: 32px; }
.wslot .num { position: absolute; left: 4px; top: 1px; font-size: 0.7rem; font-weight: 800; color: rgba(255,255,255,0.6); }
.wslot.owned { color: var(--wc); border-color: color-mix(in srgb, var(--wc) 60%, transparent); }
.wslot.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--wc), 0 0 16px var(--wc); transform: translateY(-4px); }
.wslot .lock { position: absolute; right: 3px; bottom: 3px; width: 14px; height: 14px; color: rgba(255,255,255,0.4); }
.wslot.owned .lock { display: none; }

#goal { position: absolute; left: calc(16px + var(--safe-l)); top: calc(96px + var(--safe-t)); max-width: 300px; font-weight: 700; font-size: 0.95rem;
  background: rgba(8,14,34,0.55); padding: 6px 12px; border-radius: 10px; border-left: 4px solid var(--accent); text-shadow: 0 1px 2px #000; }
#goal:empty { display: none; }

#prompt { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: rgba(8,14,34,0.85); border: 2px solid var(--accent);
  border-radius: 99px; padding: 8px 18px 8px 10px; font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 6px; pointer-events: auto; cursor: pointer; animation: fadein 0.2s; }
html.touch #prompt .kbd { display: none; }

#stamina { position: absolute; width: 56px; height: 56px; left: 0; top: 0; transform: translate(-50%, -50%); }
#stamina circle { fill: none; stroke-width: 6; }
#stamina .bg { stroke: rgba(0,0,0,0.45); }
#stamina .fg { stroke: #57d977; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; stroke-dasharray: 94.25; transition: stroke 0.2s; }
#stamina.low .fg { stroke: #ffb13b; }
#stamina.empty .fg { stroke: #ff5d5d; animation: blink 0.4s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

#bossbar { position: absolute; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); width: min(620px, 70vw); text-align: center; }
#bossbar .name { font-family: var(--font-title); font-weight: 900; font-size: 1.3rem; color: #fff; text-shadow: 0 2px 4px #000, 0 0 12px rgba(255,80,80,0.6); margin-bottom: 4px; }
#bossbar .bar { position: relative; height: 18px; border-radius: 99px; background: rgba(0,0,0,0.6); border: 3px solid #f4e3b0; overflow: hidden; }
#bossbar .bar i { position: absolute; left: 0; top: 0; bottom: 0; }
#bossFill { background: linear-gradient(180deg, #ff8a8a, #e0283b); z-index: 2; }
#bossGhost { background: #fff3b0; z-index: 1; transition: width 0.6s ease 0.3s; }

#toasts { position: absolute; left: 50%; top: calc(66px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: rgba(8,14,34,0.88); border: 2px solid var(--tech); border-radius: 14px; padding: 8px 18px; font-weight: 700; font-size: 1.05rem;
  display: flex; align-items: center; gap: 8px; animation: toastin 0.3s ease; box-shadow: 0 6px 18px rgba(0,0,0,0.4); max-width: 80vw; text-align: center; }
.toast svg { width: 24px; height: 24px; color: var(--accent); }
.toast.gold { border-color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all 0.35s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px) scale(0.95); } }

#subtitle { position: absolute; left: 50%; bottom: 16vh; transform: translateX(-50%); font-family: var(--font-title); font-weight: 900; font-size: clamp(1.6rem, 4vw, 3rem);
  text-align: center; color: #fff; text-shadow: 0 3px 0 #000, 0 0 20px rgba(0,0,0,0.8); z-index: 45; white-space: nowrap; }
#subtitle small { display: block; font-family: var(--font-ui); font-size: 0.45em; letter-spacing: 0.3em; color: var(--accent); text-transform: uppercase; }
#subtitle.big { animation: slam 0.5s cubic-bezier(.2,1.6,.4,1); }
@keyframes slam { from { transform: translateX(-50%) scale(2.2); opacity: 0; } }

/* ---------------------------------------------------------------- dialog */
#dialog { position: fixed; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); display: flex; justify-content: center; z-index: 45; cursor: pointer; }
.dlg { width: min(760px, 92vw); background: linear-gradient(180deg, rgba(248,240,214,0.98), rgba(236,222,186,0.98)); color: #2a1e10; border-radius: 18px; padding: 1.1rem 1.4rem 1.3rem;
  border: 4px solid #6b4a24; box-shadow: 0 0 0 3px #f4d27a inset, 0 12px 30px rgba(0,0,0,0.5); position: relative; min-height: 110px; }
.dlg .who { position: absolute; top: -18px; left: 22px; background: #6b4a24; color: #ffe89a; font-weight: 800; padding: 3px 14px; border-radius: 10px; font-size: 1rem; }
.dlg .txt { font-size: clamp(1.1rem, 2.3vw, 1.35rem); line-height: 1.45; font-weight: 600; }
.dlg .next { position: absolute; right: 16px; bottom: 6px; color: #6b4a24; animation: bob 0.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }

#dialog.asking { cursor: default; }
#dialog.asking .next { display: none; }
.choices { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }
.choices .bbtn { min-height: 48px; font-size: 1rem; padding: 0.5rem 1rem; }
.choices .price { display: inline-flex; align-items: center; gap: 3px; background: rgba(0,0,0,0.18); border-radius: 8px; padding: 1px 7px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- weapon reveal */
.reveal { background: radial-gradient(ellipse at center, rgba(40,20,80,0.55), rgba(0,0,10,0.8)); }
.reveal-wrap { text-align: center; position: relative; max-width: 640px; }
.rays { position: absolute; left: 50%; top: 50%; width: 900px; height: 900px; margin: -450px 0 0 -450px; z-index: -1; opacity: 0.5;
  background: repeating-conic-gradient(from 0deg, rgba(255,230,140,0.35) 0 8deg, transparent 8deg 22deg); border-radius: 50%;
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 60%); mask: radial-gradient(circle, #000 0%, transparent 60%); animation: spin 18s linear infinite; }
html.rm .rays { animation: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.got { font-weight: 800; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.rname { font-family: var(--font-title); font-weight: 900; font-size: clamp(2.2rem, 7vw, 4.4rem); color: var(--rc, var(--accent)); text-shadow: 0 4px 0 #000, 0 0 30px var(--rc, var(--accent)); margin: 0.2rem 0 0.8rem; }
.rdesc { font-size: 1.3rem; font-weight: 600; line-height: 1.45; margin-bottom: 0.8rem; text-shadow: 0 2px 4px #000; }
.rhow { font-size: 1.05rem; color: var(--tech); font-weight: 700; margin-bottom: 1.4rem; }

/* ---------------------------------------------------------------- map */
.screen.map { padding: 0; background: #0a1226; }
#mapCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.map-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 1rem; padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  background: linear-gradient(180deg, rgba(8,14,34,0.9), rgba(8,14,34,0)); }
.map-top h2 { margin: 0; color: var(--accent); font-size: 1.6rem; }
.legend { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; font-size: 0.85rem; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend svg { width: 18px; height: 18px; }
.map-side { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: min(300px, 44vw); background: rgba(8,14,34,0.88); border: 2px solid var(--edge);
  border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.map-side h3 { margin: 0; color: var(--accent); }
#mapSel { display: flex; flex-direction: column; gap: 8px; }
.zoom { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------------------------------------------------------- ending */
.ending { background: linear-gradient(180deg, rgba(10,16,40,0.2), rgba(10,16,40,0.85)); flex-direction: column; justify-content: flex-end; padding-bottom: 8vh; gap: 1.5rem; }
.credits { text-align: center; font-size: 1.3rem; line-height: 1.8; font-weight: 700; text-shadow: 0 2px 6px #000; }
.credits .big { font-family: var(--font-title); font-weight: 900; font-size: clamp(2rem, 6vw, 3.6rem); color: var(--accent); display: block; }

/* ---------------------------------------------------------------- touch */
#touch { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#touch .tzone { position: absolute; top: 0; bottom: 0; pointer-events: auto; touch-action: none; }
#touch .tleft { left: 0; width: 45%; }
#touch .tright { right: 0; width: 55%; }
#touch .stick { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: rgba(255,255,255,0.12); border: 3px solid rgba(255,255,255,0.35); pointer-events: none; }
#touch .stick.idle { opacity: 0.45; }
#touch .knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,0.75); transform: translate(-50%, -50%); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.tbtn { position: absolute; pointer-events: auto; touch-action: none; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-direction: column;
  color: #fff; background: rgba(15,25,55,0.55); box-shadow: 0 0 0 3px rgba(255,255,255,0.55) inset, 0 4px 12px rgba(0,0,0,0.3); font-weight: 800; font-size: 0.7rem; gap: 1px; }
.tbtn svg { width: 46%; height: 46%; }
.tbtn.down { background: rgba(255,210,63,0.75); color: #1c1405; transform: scale(0.94); }
.tbtn.jump { width: 92px; height: 92px; right: calc(26px + var(--safe-r)); bottom: calc(34px + var(--safe-b)); }
.tbtn.sword { width: 80px; height: 80px; right: calc(128px + var(--safe-r)); bottom: calc(24px + var(--safe-b)); }
.tbtn.power { width: 70px; height: 70px; right: calc(118px + var(--safe-r)); bottom: calc(118px + var(--safe-b)); color: var(--pc, #fff); }
.tbtn.power.off { opacity: 0.35; }
.tbtn.use { width: 70px; height: 70px; right: calc(34px + var(--safe-r)); bottom: calc(140px + var(--safe-b)); display: none; }
.tbtn.use.ready { display: flex; background: rgba(255,210,63,0.8); color: #1c1405; animation: pulse 1s infinite; }
.tbtn.run { width: 62px; height: 62px; right: calc(206px + var(--safe-r)); bottom: calc(40px + var(--safe-b)); }
.tbtn.run.on { background: rgba(87,217,119,0.75); }
.tbtn.mini { width: 52px; height: 52px; border-radius: 14px; }
.tbtn.pausebtn { right: calc(180px + var(--safe-r)); top: calc(14px + var(--safe-t)); }
.tbtn.mapbtn { right: calc(180px + var(--safe-r)); top: calc(74px + var(--safe-t)); }
.tbtn.viewbtn { right: calc(20px + var(--safe-r)); top: calc(196px + var(--safe-t)); }
.tbtn.viewbtn.on { background: rgba(255, 210, 63, 0.9); color: #2a2140; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px #fff inset, 0 0 20px rgba(255,210,63,0.9); } }
html.touch #weapons { bottom: auto; top: calc(62px + var(--safe-t)); transform: translateX(-50%) scale(0.85); }
html.touch #weapons .num { display: none; }
html.touch #goal { top: calc(92px + var(--safe-t)); }
html.touch #bossbar { bottom: auto; top: calc(128px + var(--safe-t)); }
html.touch #prompt { bottom: calc(150px + var(--safe-b)); }
html.touch #minimap { width: 120px; height: 120px; }
html.touch .hud-tr { right: calc(12px + var(--safe-r)); }
@media (max-height: 500px) {
  .heart { width: 26px; height: 26px; }
  #minimap { width: 100px !important; height: 100px !important; }
  #compass { height: 34px; }
  .tbtn.jump { width: 78px; height: 78px; }
  .tbtn.sword { width: 68px; height: 68px; right: calc(112px + var(--safe-r)); }
  .tbtn.power { width: 60px; height: 60px; right: calc(104px + var(--safe-r)); bottom: calc(100px + var(--safe-b)); }
  .tbtn.use { width: 60px; height: 60px; bottom: calc(118px + var(--safe-b)); }
  .tbtn.run { width: 54px; height: 54px; right: calc(184px + var(--safe-r)); }
  .tbtn.pausebtn { right: calc(130px + var(--safe-r)); }
  .tbtn.mapbtn { right: calc(130px + var(--safe-r)); top: calc(70px + var(--safe-t)); }
  .tbtn.viewbtn { right: calc(14px + var(--safe-r)); top: calc(160px + var(--safe-t)); }
  .panel { padding: 1rem 1.2rem; }
  .logo { font-size: 3.6rem; }
  .subtitle { margin: 0.3rem 0 0.8rem; }
  .bbtn { min-height: 46px; padding: 0.5rem 1.2rem; }
  #goal { font-size: 0.8rem; max-width: 220px; }
}

/* ---------------------------------------------------------------- power cells + star map */
.count.cells svg { color: #7ff6ff; }
#cellGet { position: fixed; left: 50%; bottom: 13vh; transform: translateX(-50%); z-index: 46; text-align: center; pointer-events: none; }
#cellGet .cg-title { font-family: var(--font-title); font-weight: 900; font-size: clamp(2.4rem, 7vw, 4.6rem); color: #bffcff;
  text-shadow: 0 4px 0 #0a2a4a, 0 0 30px #57f3ff; display: flex; align-items: center; gap: 0.3em; justify-content: center; animation: slamC 0.5s cubic-bezier(.2,1.6,.4,1); }
#cellGet .cg-title svg { width: 0.9em; height: 0.9em; color: #ffd23f; filter: drop-shadow(0 0 10px #ffd23f); }
#cellGet .cg-name { font-weight: 800; font-size: 1.5rem; color: #fff; text-shadow: 0 2px 6px #000; margin-top: 0.2rem; }
#cellGet .cg-count { font-weight: 700; color: var(--accent); text-shadow: 0 2px 4px #000; margin-top: 0.2rem; }
@keyframes slamC { from { transform: scale(2.4); opacity: 0; } }
html.rm #cellGet .cg-title { animation: none; }

.screen.starmap { padding: 0; background: radial-gradient(ellipse at 30% 30%, #1a1450 0%, #070a1c 70%); flex-direction: column; }
#starsBg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sm-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 1rem; padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l)); }
.sm-top h2 { margin: 0; color: var(--accent); font-size: 1.7rem; display: flex; align-items: center; gap: 0.4rem; flex: 1; }
.sm-top h2 svg { width: 1.2em; height: 1.2em; }
.sm-cells { font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: 6px; background: rgba(8,14,34,0.7); border: 2px solid #57f3ff; border-radius: 99px; padding: 6px 14px; }
.sm-cells svg { color: #ffd23f; width: 22px; height: 22px; }
.planets { position: absolute; left: 50%; top: 11vh; transform: translateX(-50%); width: min(1100px, 96vw); height: calc(100vh - 11vh - 230px); max-height: 440px; }
.planet { position: absolute; transform: translate(-50%, -50%); border: 0; background: none; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px; border-radius: 16px; }
.planet .ball { width: var(--sz, 90px); height: var(--sz, 90px); border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--c3) 0%, var(--c2) 25%, var(--c1) 70%, #000 115%);
  box-shadow: 0 0 24px var(--c2), inset -10px -10px 24px rgba(0,0,0,0.5); position: relative; transition: transform 0.2s; }
.planet .ring { position: absolute; left: -22%; right: -22%; top: 42%; height: 16%; border: 3px solid rgba(255,255,255,0.5); border-radius: 50%; transform: rotate(-18deg); }
.planet .pname { font-weight: 800; font-size: 1rem; text-shadow: 0 2px 4px #000; white-space: nowrap; }
.planet .pstat { font-size: 0.8rem; font-weight: 700; display: flex; gap: 6px; align-items: center; color: #bffcff; }
.planet .pstat svg { width: 14px; height: 14px; }
.planet.locked .ball { filter: grayscale(0.7) brightness(0.6); }
.planet .lockbadge { position: absolute; right: -4px; top: -4px; width: 30px; height: 30px; border-radius: 50%; background: #1a2040; border: 2px solid #fff; display: flex; align-items: center; justify-content: center; }
.planet .lockbadge svg { width: 16px; height: 16px; }
.planet .here { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); background: var(--accent); color: #1c1405; font-weight: 800; font-size: 0.72rem; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.planet.sel .ball { transform: scale(1.15); box-shadow: 0 0 0 4px #fff, 0 0 40px var(--c2); }
.planet:focus-visible { outline: none; }
.planet:focus-visible .ball { box-shadow: 0 0 0 4px var(--accent), 0 0 40px var(--c2); }
.sm-info { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); width: min(620px, 94vw); background: rgba(8,14,34,0.9); border: 2px solid var(--edge);
  border-radius: 18px; padding: 12px 18px; text-align: center; }
.sm-info h3 { margin: 0 0 4px; color: var(--accent); font-size: 1.4rem; }
.sm-info p { margin: 0 0 6px; line-height: 1.4; }
#smStatus { font-weight: 700; color: #bffcff; margin-bottom: 10px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
#smStatus span { display: inline-flex; align-items: center; gap: 5px; }
#smStatus svg { width: 18px; height: 18px; }
@media (max-height: 500px) {
  .planets { top: 76px; height: calc(100vh - 76px - 150px); }
  .planet .ball { width: calc(var(--sz, 90px) * 0.6); height: calc(var(--sz, 90px) * 0.6); }
  .planet .pname { font-size: 0.85rem; }
  .sm-top h2 { font-size: 1.3rem; }
  .sm-info { padding: 6px 12px; bottom: calc(8px + var(--safe-b)); }
  .sm-info h3 { font-size: 1.1rem; }
  .sm-info p { display: none; }
  #smStatus { margin-bottom: 6px; font-size: 0.85rem; }
  .sm-info .bbtn.big { min-height: 44px; font-size: 1.05rem; padding: 0.4rem 1.4rem; }
}
