@font-face { font-family: "PS2P"; src: url(../assets/fonts/ps2p-lat.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF; }
@font-face { font-family: "PS2P"; src: url(../assets/fonts/ps2p-cyr.woff2) format("woff2"); unicode-range: U+0400-045F, U+2116; }

:root {
  --bg: #120c1f; --bg2: #1c1330; --panel: #261a40; --panel2: #34265a; --panel3: #4a3a78;
  --ink: #f4f0ff; --dim: #a99cc9; --hl: #ffd23f; --good: #2bd96b; --bad: #ff3864;
  --c1: #ff8c1a; --c2: #4df0ff; --c3: #ffd23f; --c4: #b14dff; --c5: #2bd96b;
  --accent: #2bd96b;
  --px: "PS2P", system-ui, "Apple Color Emoji", sans-serif;
  --body: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --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%; background: var(--bg); color: var(--ink); font-family: var(--body); overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
body { background: radial-gradient(ellipse at top, #2a1850 0%, var(--bg) 60%) fixed; }
body::after { /* CRT scanlines */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.12) 0 1px, transparent 1px 3px);
}
#field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; image-rendering: pixelated; }
#app { position: relative; z-index: 1; min-height: 100%; max-width: 820px; margin: 0 auto; padding: calc(var(--safe-t) + 8px) 14px calc(var(--safe-b) + 20px); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.dim { color: var(--dim); } .small { font-size: 13px; } .center { text-align: center; }
.px { image-rendering: pixelated; display: block; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--px); font-size: 12px; letter-spacing: .5px; padding: 14px 16px; background: var(--panel2);
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.12), 0 4px 0 #000;
  transition: transform .06s; position: relative; line-height: 1.5;
}
.btn:active { transform: translateY(3px); box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.12), 0 1px 0 #000; }
.btn:disabled { opacity: .4; }
.btn.big { font-size: 16px; padding: 18px 20px; width: 100%; }
.btn.go { background: var(--accent); color: #000; }
.btn.alt { background: var(--panel3); }
.btn.danger { background: var(--bad); }
.btn.icon { width: 44px; height: 44px; padding: 0; font-size: 16px; }
.btn.small { font-size: 10px; padding: 10px; }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.top .title { flex: 1; font-family: var(--px); font-size: 13px; text-align: center; color: var(--hl); text-shadow: 2px 2px 0 #000; }
.spacer { width: 44px; }
.aura { font-family: var(--px); font-size: 12px; background: #000; padding: 8px 10px; border: 2px solid var(--hl); color: var(--hl); display: flex; gap: 6px; align-items: center; }
.aura-ico { animation: spin 3s linear infinite; display: inline-block; }

/* ---------- Title ---------- */
.title-screen { min-height: calc(100vh - 40px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; position: relative; overflow: hidden; }
.logo { font-family: var(--px); line-height: 1.1; transform: rotate(-3deg); }
.logo-small { font-size: clamp(14px, 4vw, 22px); color: var(--c2); text-shadow: 3px 3px 0 #000; }
.logo-big { font-size: clamp(34px, 11vw, 72px); color: var(--hl); text-shadow: 4px 4px 0 var(--c1), 8px 8px 0 #000; animation: wobble 2.5s ease-in-out infinite; }
.logo-math { font-size: clamp(30px, 10vw, 64px); color: var(--c4); text-shadow: 4px 4px 0 var(--c2), 8px 8px 0 #000; letter-spacing: 6px; }
.ground { display: flex; overflow: hidden; width: 100%; justify-content: center; margin-top: -10px; }
.ground .px { width: 48px; height: 48px; }
.start { font-size: 16px; padding: 18px 26px; background: var(--hl); color: #000; }
.blink { animation: blink 1.1s steps(2) infinite; }
.sub { font-family: var(--px); font-size: 10px; color: var(--dim); }
.stars-bg { position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(2px 2px at 20% 30%, #fff, transparent), radial-gradient(2px 2px at 70% 20%, #fff, transparent), radial-gradient(2px 2px at 40% 70%, #fff8, transparent), radial-gradient(2px 2px at 85% 60%, #fff, transparent), radial-gradient(2px 2px at 10% 85%, #fff8, transparent); animation: twinkle 3s steps(3) infinite; }

/* ---------- Mascot ---------- */
.digga { position: relative; display: inline-block; }
.digga .pick { position: absolute; right: -30%; top: 30%; transform-origin: 50% 90%; animation: swing 1.2s ease-in-out infinite; }
.digga.bounce { animation: bounce .8s steps(4) infinite alternate; }
.digga.talk .px { animation: talk .25s steps(2) infinite; }
.mascot-corner { position: fixed; right: 8px; bottom: calc(var(--safe-b) + 4px); opacity: .9; pointer-events: none; z-index: 2; }
@media (max-width: 600px) { .mascot-corner { display: none; } }
/* the corner Digga chops on the beat, cheers at a right answer, shakes his head at a wrong one */
.mascot-corner .digga .pick { animation: none; transform: rotate(-30deg); }
.mascot-corner.idle .digga .pick { animation: swing 1.2s ease-in-out infinite; }
.mascot-corner.hit .digga .pick { animation: chop .3s steps(3, jump-none); }
.mascot-corner.hit .digga { animation: nod .3s steps(2, jump-none); }
.mascot-corner.cheer .digga { animation: cheer .6s steps(6, jump-none); }
.mascot-corner.oops .digga { animation: oops .5s steps(5, jump-none); }
@keyframes chop { 0% { transform: rotate(-30deg); } 40% { transform: rotate(45deg); } 100% { transform: rotate(-30deg); } }
@keyframes nod { 0%,100% { transform: none; } 40% { transform: translateY(3px); } }
@keyframes cheer { 0%,100% { transform: none; } 30% { transform: translateY(-18px); } 60% { transform: translateY(-6px); } }
@keyframes oops { 0%,100% { transform: none; } 20%,60% { transform: translateX(-4px); } 40%,80% { transform: translateX(4px); } }

/* ---------- Map ---------- */
.profile { display: flex; gap: 14px; align-items: center; background: var(--panel); padding: 12px; margin-bottom: 14px; box-shadow: 0 4px 0 #000; }
.prof-info { flex: 1; }
.rank { font-family: var(--px); font-size: 14px; color: var(--hl); margin-bottom: 8px; }
.xpbar { height: 12px; background: #000; border: 2px solid var(--panel3); margin-bottom: 6px; }
.xpbar div { height: 100%; background: repeating-linear-gradient(90deg, var(--hl) 0 8px, var(--c1) 8px 16px); }
.shaft { display: flex; flex-direction: column; gap: 0; border: 4px solid #000; }
.layer { display: flex; align-items: center; gap: 14px; padding: 16px; text-align: left; position: relative;
  background: linear-gradient(var(--lb), var(--lb2)); border-bottom: 4px solid #000;
  /* one continuous strip of the matching mine layer's rock (js/pixelart.js layerTexture), pixels at 3×, dimmed for the text */
  background-image: linear-gradient(90deg, rgba(0,0,0,.2), rgba(0,0,0,.5)), var(--rock, linear-gradient(var(--lb), var(--lb2)));
  background-size: 100% 100%, 768px 96px; background-position: 0 0, left center; image-rendering: pixelated; }
.layer.surface { padding-top: 28px; }
.layer.surface::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 18px; background: var(--grass) 0 0 / 48px 48px repeat-x; image-rendering: pixelated; }
.layer:active { filter: brightness(1.2); }
.layer-depth { position: absolute; right: 10px; top: 8px; font-family: var(--px); font-size: 9px; color: rgba(255,255,255,.6); }
.layer-logo { font-family: var(--px); font-size: 15px; min-width: 76px; height: 64px; display: grid; place-items: center; background: #000; color: var(--la); border: 3px solid var(--la); box-shadow: 4px 4px 0 rgba(0,0,0,.5); white-space: nowrap; padding: 0 6px; }
.layer-info { flex: 1; min-width: 0; }
.layer-name { font-family: var(--px); font-size: 9px; color: var(--la); margin-bottom: 6px; text-shadow: 1px 1px 0 #000; }
.layer-title { font-size: 18px; font-weight: 800; text-shadow: 2px 2px 0 rgba(0,0,0,.6); margin-bottom: 8px; }
.layer-prog { display: flex; align-items: center; gap: 8px; font-family: var(--px); font-size: 9px; }
.layer-prog .bar { flex: 1; height: 10px; background: rgba(0,0,0,.75); box-shadow: 0 0 0 2px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.18); }
.layer-prog .bar div { height: 100%; background: var(--la); }
.parent-link { display: block; margin: 24px auto 0; font-size: 13px; color: var(--dim); padding: 10px; }

/* ---------- World ---------- */
/* header: the world's own pixel rock (same as its row on the map), logo + title, progress bar, badges */
.world-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 12px; padding: 14px; margin-bottom: 12px; border: 3px solid var(--accent); box-shadow: 0 6px 0 #000; }
.world-rock { position: absolute; inset: 0; z-index: 0; background-size: 100% 100%, 768px 100%; image-rendering: pixelated; }
.world-hero > :not(.world-rock) { position: relative; z-index: 1; }
.world-row { display: flex; gap: 14px; align-items: center; }
.world-logo { font-family: var(--px); font-size: 20px; color: var(--accent); background: #000; padding: 14px 10px; white-space: nowrap; border: 3px solid var(--accent); box-shadow: 4px 4px 0 rgba(0, 0, 0, .5); }
.world-info { min-width: 0; }
.world-sub { font-family: var(--px); font-size: 9px; color: var(--accent); text-shadow: 1px 1px 0 #000; margin-bottom: 6px; }
.world-title { font-size: 22px; font-weight: 800; line-height: 1.15; color: #fff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .7); }
.world-prog { height: 12px; background: rgba(0, 0, 0, .75); box-shadow: 0 0 0 2px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .18); }
.world-prog div { height: 100%; background: var(--accent); }
.world-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.world-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; font-family: var(--px); font-size: 10px; color: #fff; background: rgba(0, 0, 0, .55); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15); }
.world-badge .pxi-svg { height: 14px; }
/* actions: one line each; the arcade record is a tag on the button's corner */
.world-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 12px; }
.world-actions .btn { position: relative; height: 56px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 6px; font-size: 11px; white-space: nowrap; }
.world-actions .btn .pxi-svg { height: 20px; }
.world-best { position: absolute; top: -10px; right: -6px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px; font-style: normal; font-family: var(--px); font-size: 9px; color: #000; background: var(--hl); box-shadow: 0 2px 0 #000; }
.world-best .pxi-svg { height: 12px; }
.world-note { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 26px; font-size: 14px; line-height: 1.35; background: var(--panel); box-shadow: inset 3px 0 0 var(--good), 0 4px 0 #000; }
.world-note .pxi-svg { height: 18px; flex: none; }
.note { background: var(--panel); padding: 12px; font-size: 14px; line-height: 1.4; margin-bottom: 14px; border-left: 4px solid var(--hl); }
.path { display: flex; flex-direction: column; gap: 4px; padding: 10px 0 40px; position: relative; }
.node-row { display: flex; align-items: center; gap: 12px; }
.node-row.col1 { padding-left: 4%; } .node-row.col2 { padding-left: 24%; } .node-row.col3 { padding-left: 44%; }
.node { width: 64px; height: 64px; flex: none; font-family: var(--px); font-size: 16px; position: relative; display: grid; place-items: center;
  background: var(--lb); box-shadow: inset -5px -5px 0 rgba(0,0,0,.4), inset 5px 5px 0 rgba(255,255,255,.15), 0 5px 0 #000; }
.node.open { background: var(--accent); color: #000; }
.node.done { background: var(--hl); color: #000; }
.node.locked { background: var(--lb2); color: rgba(255,255,255,.3); }
.node.boss { width: 76px; height: 76px; font-size: 26px; background: var(--bad); color: #fff; }
.node.boss.locked { background: #4a1020; }
.node.next { animation: pulse 1s ease-in-out infinite; }
.node .here { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); }
.node-label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; max-width: 50%; }
.node-label b { font-weight: 700; }
.node-stars { color: var(--hl); font-size: 13px; letter-spacing: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--panel); padding: 18px; box-shadow: 0 6px 0 #000; display: flex; flex-direction: column; gap: 14px; }
.step-title { font-size: 26px; margin: 0; text-align: center; line-height: 1.15; }
.tag { align-self: center; background: #1e3a8a; color: #cfe0ff; font-size: 13px; padding: 6px 10px; }
.visual-wrap { display: flex; justify-content: center; background: var(--bg2); padding: 14px; min-height: 120px; align-items: center; }
.visual-wrap.small { min-height: 0; padding: 8px; }
.vis { width: 100%; max-width: 420px; max-height: 260px; height: auto; }
.visual-wrap.small .vis { max-height: 190px; }
.vt { font-family: var(--px); }
.idea, .important { font-size: 19px; line-height: 1.45; }
.important { background: rgba(255,56,100,.12); border-left: 4px solid var(--bad); padding: 10px 12px; font-size: 17px; }
.lbl { display: block; font-family: var(--px); font-size: 10px; color: var(--hl); margin-bottom: 6px; }
.important .lbl { color: var(--bad); }
.mission { font-family: var(--px); font-size: 10px; color: var(--dim); text-align: center; line-height: 1.7; }
.boss-face { font-size: 80px; animation: bounce .6s steps(3) infinite alternate; }

/* ---------- Task ---------- */
.dig-strip { display: flex; gap: 3px; margin-bottom: 10px; padding: 6px; background: #000; }
.blk { flex: 1; height: 30px; background: var(--lb); box-shadow: inset -3px -3px 0 var(--lb2), inset 3px 3px 0 var(--lb3); display: grid; place-items: center; }
.blk.broken { background: #000; box-shadow: none; }
.blk.breaking { animation: breakblk .5s steps(4) forwards; }
.combo { font-family: var(--px); font-size: 14px; color: var(--c1); text-align: center; height: 20px; opacity: 0; transition: opacity .2s; text-shadow: 2px 2px 0 #000; }
.combo.show { opacity: 1; animation: pulse .5s ease-in-out infinite; }
.task-card { background: var(--panel); padding: 16px; box-shadow: 0 6px 0 #000; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; transition: background .2s; }
.task-card.good { background: #1d4a33; }
.q { font-size: clamp(26px, 7vw, 40px); font-weight: 800; text-align: center; line-height: 1.25; padding: 8px 0; }
.q.long { font-size: clamp(18px, 4.6vw, 24px); font-weight: 600; text-align: left; }
.hint { text-align: center; color: var(--hl); font-size: 17px; min-height: 22px; line-height: 1.4; }
.fields { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.field { min-width: 120px; min-height: 64px; padding: 6px 14px; background: #000; border: 4px solid var(--panel3); font-family: var(--px); font-size: 26px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.field.single { min-width: 200px; }
.field.focus { border-color: var(--hl); }
.flabel { font-family: var(--px); font-size: 14px; color: var(--dim); }
.caret { width: 4px; height: 30px; background: var(--hl); animation: blink 1s steps(2) infinite; }
.frac { display: inline-flex; flex-direction: column; align-items: center; font-size: 18px; line-height: 1.2; }
.frac span:first-child { border-bottom: 3px solid currentColor; padding: 0 4px 2px; }
.frac span:last-child { padding-top: 2px; }
.whole { margin-right: 6px; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 460px; margin: 0 auto; }
.key { font-family: var(--px); font-size: 22px; height: 62px; background: var(--panel2); box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), inset 4px 4px 0 rgba(255,255,255,.12), 0 4px 0 #000; }
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; background: var(--panel3); }
.key.fn { background: var(--panel3); font-size: 16px; }
.key[data-k="␣"] { font-size: 10px; }
.key.ok { background: var(--accent); color: #000; font-size: 16px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.choice { font-family: var(--body); font-size: 22px; font-weight: 800; padding: 20px 12px; }
.choice.right, .why-opt.right { background: var(--good); color: #000; }
.choice.wrong, .why-opt.wrong { background: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.chip { font-family: var(--px); font-size: 15px; min-width: 56px; height: 52px; padding: 0 10px; background: var(--panel2); box-shadow: 0 4px 0 #000; }
.chip.on { background: var(--hl); color: #000; transform: translateY(2px); box-shadow: 0 2px 0 #000; }
.ok { margin-top: 4px; }
.arcade-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.timer { flex: 1; height: 16px; background: #000; border: 2px solid var(--panel3); }
#timebar { height: 100%; background: linear-gradient(90deg, var(--bad), var(--hl), var(--good)); transition: width .1s linear; width: 100%; }
.score { font-family: var(--px); font-size: 12px; } .score b { color: var(--hl); font-size: 16px; }

/* ---------- Why / Say ---------- */
.why-q { display: flex; gap: 12px; align-items: center; }
.bubble { flex: 1; background: #fff; color: #000; padding: 14px; font-size: 20px; font-weight: 800; position: relative; box-shadow: 4px 4px 0 #000; }
.bubble::before { content: ""; position: absolute; left: -12px; top: 50%; border: 8px solid transparent; border-right: 12px solid #fff; transform: translateY(-50%); }
.why-opts { display: flex; flex-direction: column; gap: 10px; }
.why-opt { font-family: var(--body); font-size: 18px; text-align: left; padding: 16px; line-height: 1.35; font-weight: 600; }
.say-bubble { background: #fff; color: #000; font-size: 22px; line-height: 1.4; padding: 18px; font-weight: 700; box-shadow: 6px 6px 0 var(--accent); }
.say-mascot { display: flex; justify-content: center; }

/* ---------- Result ---------- */
.result { min-height: calc(100vh - 60px); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 16px; text-align: center; padding-top: clamp(16px, 5vh, 48px); }
.res-title { font-family: var(--px); font-size: clamp(20px, 6vw, 32px); color: var(--hl); text-shadow: 4px 4px 0 #000; animation: popin .5s steps(6, jump-none); }
.chest { animation: chest 1s steps(7, jump-none) both; }
.res-stars { display: flex; gap: 10px; }
.rs { opacity: .15; filter: grayscale(1); }
.rs.on { opacity: 1; filter: none; animation: starpop .45s steps(6, jump-none) both; animation-delay: calc(.6s + var(--i) * .3s); }
.res-aura { font-family: var(--px); font-size: 20px; color: var(--hl); }
.rankup { font-family: var(--px); font-size: 14px; background: var(--c4); padding: 12px; animation: pulse .6s infinite; }
.res-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; }
.big-score { font-family: var(--px); font-size: 56px; color: var(--c2); text-shadow: 5px 5px 0 #000; }
.qgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; width: 100%; max-width: 460px; }
.qcell { font-family: var(--px); font-size: 14px; padding: 9px 2px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 3px 0 #000; }
.qcell small { font-size: 7px; opacity: .85; white-space: nowrap; }
.qcell.ok { background: var(--good); color: #000; } .qcell.no { background: var(--bad); }

/* ---------- Settings / parent ---------- */
.vol { display: flex; align-items: center; gap: 8px; }
.vol-bar { flex: 1; display: flex; align-items: flex-end; gap: 4px; height: 40px; }
.vol-bar button { flex: 1; min-width: 0; background: var(--panel3); box-shadow: 0 3px 0 #000; }
.vol-bar button:nth-child(1) { height: 30%; } .vol-bar button:nth-child(2) { height: 37%; } .vol-bar button:nth-child(3) { height: 44%; }
.vol-bar button:nth-child(4) { height: 51%; } .vol-bar button:nth-child(5) { height: 58%; } .vol-bar button:nth-child(6) { height: 65%; }
.vol-bar button:nth-child(7) { height: 72%; } .vol-bar button:nth-child(8) { height: 79%; } .vol-bar button:nth-child(9) { height: 86%; }
.vol-bar button:nth-child(10) { height: 100%; }
.vol-bar button.on { background: var(--good); }
.vol-bar button.on:nth-child(n+8) { background: var(--hl); }
.vol-n { min-width: 44px; height: 28px; padding: 0 8px; display: inline-grid; place-items: center; font-family: var(--px); font-size: 12px; color: var(--hl);
  background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 2px var(--panel3); }
.vol-n .pxi-svg { height: 16px; }
.vol .btn.icon { width: 40px; height: 40px; flex: none; }
/* ---------- options screen: grouped panels, label rows with right-aligned values, segmented controls ---------- */
.opts { display: flex; flex-direction: column; gap: 16px; }
.opt-group { background: var(--panel); box-shadow: 0 6px 0 #000; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.opt-head { margin: 0; padding-bottom: 10px; font-family: var(--px); font-size: 10px; letter-spacing: 2px; color: var(--dim); border-bottom: 2px solid rgba(255, 255, 255, .08); }
.opt-vol { display: flex; flex-direction: column; gap: 10px; }
.opt-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.opt-label { display: inline-flex; align-items: center; gap: 10px; font-family: var(--px); font-size: 12px; color: var(--ink); }
.opt-label .pxi-svg { height: 18px; }
.seg { display: flex; gap: 4px; padding: 4px; background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 2px var(--panel3); }
.seg button { flex: 1 1 0; min-width: 0; height: 46px; padding: 0 6px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--px); font-size: 11px; line-height: 1.35; color: var(--ink); text-align: center; overflow-wrap: anywhere; }
.seg button.on { background: var(--hl); color: #000; box-shadow: 0 3px 0 #000; }
.seg button:not(.on):active { background: rgba(255, 255, 255, .08); }
.sw { flex: none; width: 14px; height: 14px; background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%); box-shadow: 0 0 0 2px #000; }
.opt-tip { font-size: 12px; color: var(--dim); text-align: center; padding: 0 12px 8px; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: grid; place-items: center; z-index: 50; padding: 20px; }
.gate { max-width: 360px; text-align: center; font-size: 16px; }
.hold { overflow: hidden; } .hold i { position: absolute; left: 0; bottom: 0; height: 6px; width: 0; background: #000; }
.hold.holding i { width: 100%; transition: width 2s linear; }
.parent { background: #f6f3ff; color: #1c1330; padding: 16px; font-size: 15px; line-height: 1.5; -webkit-user-select: text; user-select: text; }
.parent h2 { margin: 8px 0; } .parent h3 { margin: 20px 0 8px; }
.parent .tag { background: #dbe6ff; color: #1e3a8a; }
.parent .btn { margin: 6px 0; display: block; width: 100%; color: #fff; }
.tabs { display: flex; gap: 6px; }
.tab { font-family: var(--px); width: 44px; height: 40px; background: #ddd5f5; } .tab.on { background: #1c1330; color: #fff; }
.pstats { font-size: 13px; color: #5a4a80; }
.pstep { border-top: 1px solid #d8d0ee; padding: 8px 0; }
.pstep summary { cursor: pointer; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.pn { font-family: var(--px); font-size: 10px; background: #1c1330; color: #fff; padding: 4px 6px; }
.ps { margin-left: auto; color: #b08000; font-size: 13px; }
.pans { font-size: 14px; } .porder { font-size: 14px; }

/* ---------- FX ---------- */
.float { position: fixed; transform: translate(-50%, -50%); font-family: var(--px); font-size: 26px; color: var(--hl); text-shadow: 3px 3px 0 #000, -2px -2px 0 #000; pointer-events: none; z-index: 60; animation: floatup 1.2s ease-out forwards; white-space: nowrap; }
.float.bad { color: var(--bad); font-size: 18px; }
.float.combo-txt { color: var(--c1); font-size: 30px; }
.particle { position: fixed; width: 8px; height: 8px; pointer-events: none; z-index: 60; animation: particle .8s ease-out forwards; }
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 55; animation: fade .35s forwards; }
.shake { animation: shake .35s steps(6); }
/* One-shot entrance animations use steps(n, jump-none): the last frame IS the finished state, so nothing waits on a
   post-animation repaint (iOS Safari often skipped it and left cells/stars frozen mid-step). main.js also clears them on end. */
.pop { animation: popin .35s steps(5, jump-none) both; animation-delay: calc(var(--i, 0) * 45ms); transform-box: fill-box; transform-origin: center; }
.slide { animation: slide .9s steps(7, jump-none) both; animation-delay: .8s; }
.draw { stroke-dasharray: 400; animation: draw 1s steps(11, jump-none) both; }
.wobble { animation: wob 2s ease-in-out infinite; transform-origin: 160px 58px; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-10px); } }
@keyframes swing { 0%,100% { transform: rotate(-20deg); } 50% { transform: rotate(25deg); } }
@keyframes talk { 50% { transform: translateY(-2px); } }
@keyframes wobble { 0%,100% { transform: rotate(0); } 50% { transform: rotate(2deg) scale(1.03); } }
@keyframes twinkle { 50% { opacity: .5; } }
@keyframes pulse { 50% { transform: scale(1.07); } }
@keyframes popin { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes breakblk { 0% { transform: scale(1); } 50% { transform: scale(1.2) rotate(8deg); filter: brightness(2); } 100% { transform: scale(0); opacity: 0; } }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -180%) scale(1); } }
@keyframes particle { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
@keyframes fade { to { opacity: 0; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes slide { from { transform: translateX(calc(var(--dx) * -1)); opacity: .2; } to { transform: translateX(0); opacity: 1; } }
@keyframes draw { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
@keyframes wob { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes chest { 0% { transform: scale(0) rotate(-20deg); } 60% { transform: scale(1.2) rotate(5deg); } 100% { transform: scale(1); } }
@keyframes starpop { from { transform: scale(0) rotate(-90deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (min-width: 700px) {
  .q { font-size: 44px; } .key { height: 72px; } .idea { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
.vis .plate { fill: var(--panel2); stroke: var(--panel3); stroke-width: 2; }

/* ---------- Mine / shop / base ---------- */
.play-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.btn.dig { background: var(--hl); color: #000; }
.pick-status { margin-bottom: 14px; }
.section-title { font-family: var(--px); font-size: 10px; color: var(--dim); margin: 6px 0 8px; }
.hud { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.hud-i { display: flex; align-items: center; gap: 6px; background: var(--panel); padding: 6px; font-family: var(--px); font-size: 8px; }
.hud-i .mbar { flex: 1; }
.mbar { height: 10px; background: #000; border: 2px solid var(--panel3); min-width: 40px; }
.mbar div { height: 100%; }
.mine-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 0; border: 4px solid #000; max-width: 560px; margin: 0 auto; touch-action: manipulation; }
.mc { aspect-ratio: 1; position: relative; display: grid; place-items: center; background: #0a0612; }
.mc.sky { background: linear-gradient(#3a2a6a, #6b4aa8); }
.mc.air { background: color-mix(in srgb, var(--a) 35%, #000); box-shadow: inset 0 0 0 1px rgba(0,0,0,.4); }
.mc.solid { background:
  radial-gradient(circle at 25% 30%, rgba(0,0,0,.35) 12%, transparent 13%),
  radial-gradient(circle at 70% 70%, rgba(255,255,255,.12) 10%, transparent 11%),
  var(--a);
  box-shadow: inset -4px -4px 0 var(--b), inset 4px 4px 0 rgba(255,255,255,.12); }
.mc.grass { box-shadow: inset 0 8px 0 #2bd96b, inset -4px -4px 0 var(--b); }
.mc.hard { filter: brightness(.8) contrast(1.2); }
.mc.ore { background:
  radial-gradient(circle at 30% 30%, var(--ore) 14%, transparent 15%),
  radial-gradient(circle at 68% 45%, var(--ore) 12%, transparent 13%),
  radial-gradient(circle at 40% 72%, var(--ore) 13%, transparent 14%),
  var(--a); }
.mc.dark { background: #0a0612 !important; box-shadow: none; filter: none; }
.mc.sensed { box-shadow: inset 0 0 0 2px var(--c2); }
.mc.adj.solid:not(.dark) { outline: 2px dashed rgba(255,210,63,.6); outline-offset: -4px; }
.mc.adj.dark { outline: 2px dashed rgba(255,210,63,.35); outline-offset: -4px; }
.mc .px { width: 70%; height: auto; }
.mc.crack1::after, .mc.crack2::after, .mc.crack3::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(45deg, transparent 45%, #000 46% 52%, transparent 53%), linear-gradient(-30deg, transparent 60%, #000 61% 66%, transparent 67%); opacity: .4; }
.mc.crack2::after { opacity: .7; } .mc.crack3::after { opacity: 1; background: linear-gradient(45deg, transparent 45%, #000 46% 52%, transparent 53%), linear-gradient(-30deg, transparent 60%, #000 61% 66%, transparent 67%), linear-gradient(80deg, transparent 30%, #000 31% 36%, transparent 37%); }
.mc.corecell { background: repeating-linear-gradient(45deg, #ff4df0 0 6px, #ffd23f 6px 12px); }
.me { width: 100%; display: grid; place-items: center; animation: bounce .5s steps(2) infinite alternate; z-index: 2; }
.me .px { width: 80%; }
.art-ico { font-family: var(--px); color: var(--hl); font-size: 16px; text-shadow: 0 0 8px var(--hl); animation: pulse .8s infinite; }
.sign { font-family: var(--px); font-size: 7px; background: #6b4320; padding: 3px; color: var(--hl); }
.mine-msg { min-height: 34px; text-align: center; font-size: 16px; font-weight: 700; color: var(--hl); padding: 8px; opacity: 0; transition: opacity .2s; }
.mine-msg.show { opacity: 1; } .mine-msg.bad { color: var(--bad); }
.mine-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.pop-card { max-width: 440px; width: 100%; max-height: 92vh; overflow: auto; animation: popin .3s steps(5, jump-none); }
.art-big { font-size: 80px; text-align: center; animation: chest 1s steps(7, jump-none) both; }
.shop { display: flex; flex-direction: column; gap: 12px; }
.gear { display: flex; gap: 14px; background: var(--panel); padding: 14px; box-shadow: 0 5px 0 #000; }
.gear-ico { width: 72px; display: grid; place-items: center; background: var(--bg2); }
.gear-info { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 16px; }
.gear-info .btn { font-size: 11px; }
.next { font-size: 14px; color: var(--dim); border-top: 1px dashed var(--panel3); padding-top: 8px; }
.need { font-size: 12px; color: var(--bad); }
.good { color: var(--good); }
.ores { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ore-row { display: flex; align-items: center; gap: 8px; background: var(--panel); padding: 8px; font-size: 14px; }
.ore-row b { margin-left: auto; color: var(--hl); font-family: var(--px); font-size: 10px; }
.ore-dot { width: 14px; height: 14px; box-shadow: 0 0 0 2px #000; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.base-wrap { border: 4px solid #000; margin-bottom: 12px; }
.base-scene { width: 100%; display: block; }
.neonblink { animation: blink 1.4s steps(2) infinite; filter: drop-shadow(0 0 4px #ff4df0); }
.blinkdot { animation: blink .8s steps(2) infinite; }
.builds { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.build { background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 4px 0 #000; font-size: 15px; }
.build.built { border-left: 4px solid var(--good); }
.build-head { display: flex; justify-content: space-between; align-items: center; }
.lv { color: var(--hl); letter-spacing: 2px; }
.build .btn { font-size: 10px; }
.arts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.art { background: var(--panel); aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 30px; gap: 4px; text-align: center; }
.art span { font-family: var(--px); color: var(--panel3); font-size: 20px; }
.art small { font-size: 9px; color: var(--dim); line-height: 1.1; padding: 0 2px; }
.art.found { background: #2a2050; box-shadow: inset 0 0 0 2px var(--hl); }
.art .pxi-svg { height: 48px; }
.node.boss .pxi-svg { height: 40px; }
.center > .px { margin: 0 auto; }

/* ---------- Pixel-art mine & base ---------- */
.mine-grid { border: 4px solid #000; box-shadow: 0 0 0 4px #2a1d55, 0 8px 0 4px #000; }
.mc { background-color: #07040d; background-size: 100% 100%; background-repeat: no-repeat; image-rendering: pixelated; }
.mc.dark { background: #07040d !important; }
.mc::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: #07040d; opacity: 0; z-index: 1; }
.mc.l1::before { opacity: .38; } .mc.l2::before { opacity: .68; } .mc.mem::before { opacity: .82; }
.mc.sensed::before { opacity: .55; } .mc.sensed { box-shadow: inset 0 0 0 2px var(--c2); animation: pulse 1.2s steps(3) infinite; }
.mc.adj { cursor: pointer; }
.mc.adj::after { content: ""; position: absolute; inset: 3px; border: 2px dashed rgba(255,210,63,.55); z-index: 2; pointer-events: none; animation: blink 1.2s steps(2) infinite; }
.mc .art-ico { position: absolute; right: 4px; top: 2px; font-size: 12px; z-index: 2; }
.me { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; animation: none; }
.me > .px { width: 78%; height: auto; animation: bounce .5s steps(2) infinite alternate; }
.me.left > .px { transform: scaleX(-1); }
.mpick { position: absolute; right: 2%; top: 22%; width: 42%; transform-origin: 30% 90%; transform: rotate(20deg); }
.mpick .px { width: 100%; height: auto; }
.me.left .mpick { right: auto; left: 2%; transform: scaleX(-1) rotate(20deg); }
.me.hit .mpick { animation: hitswing .22s steps(3) 1; }
.me.left.hit .mpick { animation: hitswingL .22s steps(3) 1; }
@keyframes hitswing { 0% { transform: rotate(-50deg); } 100% { transform: rotate(40deg); } }
@keyframes hitswingL { 0% { transform: scaleX(-1) rotate(-50deg); } 100% { transform: scaleX(-1) rotate(40deg); } }
.sign { position: absolute; left: 4px; bottom: 4px; z-index: 2; }
.base-banner { display: block; width: 100%; max-width: 560px; margin: 0 auto -4px; image-rendering: pixelated; border: 4px solid #000; border-bottom: 0; }
.base-canvas { display: block; width: 100%; image-rendering: pixelated; }
.title-ground { width: 100%; height: 144px; margin-top: -44px; background-size: 768px 144px; background-position: center top; background-repeat: repeat-x; image-rendering: pixelated; }
.ground i { width: 48px; height: 48px; background-size: 100% 100%; image-rendering: pixelated; }
.shopfront { position: relative; border: 4px solid #000; margin-bottom: 12px; box-shadow: 0 6px 0 #000; }
.shopfront canvas { display: block; width: 100%; image-rendering: pixelated; cursor: pointer; }
.bro-bubble { position: absolute; left: 50%; top: 6%; transform: translateX(-50%); max-width: 46%; background: #fff; color: #000;
  font-family: var(--px); font-size: clamp(8px, 1.8vw, 12px); line-height: 1.6; padding: 8px 10px; box-shadow: 3px 3px 0 #000, 0 0 0 3px #000;
  opacity: 0; transition: opacity .15s; pointer-events: none; min-height: 2.2em; }
.bro-bubble.show { opacity: 1; }
.bro-bubble::after { content: ""; position: absolute; left: 50%; bottom: -10px; border: 6px solid transparent; border-top: 8px solid #fff; transform: translateX(-50%); }
.btn.poor { opacity: .55; }

/* pixel-art UI icons (js/icons.js): sized to the text they sit in */
.pxi { display: inline-flex; vertical-align: -0.22em; line-height: 0; }
.pxi-svg { height: 1.25em; width: auto; }
.btn.icon .pxi-svg { height: 22px; }
.btn.big .pxi-svg, .btn.dig .pxi-svg { height: 1.45em; }

/* ---------- "Artifact found" popup (mine.js findArtifact): ribbon, lit stage with pedestal, reward chip, collection strip ---------- */
.art-pop { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.art-ribbon, .ribbon { position: relative; margin-top: 4px; padding: 10px 26px; background: var(--hl); color: #000; font-family: var(--px); font-size: clamp(16px, 5vw, 22px);
  box-shadow: 0 4px 0 #000; clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 50%, 100% 100%, 0 100%, 10px 50%); animation: popin .4s steps(5, jump-none) both; }
.art-stage { position: relative; width: 220px; height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; overflow: hidden; }
.art-stage::before { content: ""; position: absolute; left: 50%; top: 42%; width: 360px; height: 360px; margin: -180px 0 0 -180px;
  background: repeating-conic-gradient(from 0deg, rgba(255, 220, 110, .26) 0deg 11deg, transparent 11deg 30deg);
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 52%); mask-image: radial-gradient(circle, #000 18%, transparent 52%);
  animation: spin 16s steps(64) infinite; }
.art-hero { position: relative; z-index: 1; margin-bottom: -4px; animation: chest 1s steps(7, jump-none) both; }
.art-hero .pxi { animation: bounce .7s steps(2) infinite alternate; }
.art-hero .pxi-svg { height: 108px; filter: drop-shadow(0 0 10px rgba(255, 220, 110, .55)); }
.art-plinth { position: relative; z-index: 1; line-height: 0; }
.art-plinth .px { width: 140px; height: auto; }
.art-spark { position: absolute; z-index: 1; animation: twinkle-px 1.4s steps(2) infinite; animation-delay: calc(var(--i) * .35s); }
.art-spark .pxi-svg { height: 18px; }
@keyframes twinkle-px { 50% { opacity: .15; transform: scale(.6); } }
.art-name { font-size: 22px; font-weight: 800; color: var(--ink); }
.art-depth { font-family: var(--px); font-size: 10px; color: var(--dim); margin-top: -6px; }
.art-reward { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; font-family: var(--px); font-size: 20px; color: var(--hl);
  background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 3px var(--hl); }
.art-reward .pxi-svg { height: 22px; }
.art-coll { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.art-coll-head { font-family: var(--px); font-size: 10px; color: var(--dim); }
.slots { display: grid; grid-template-columns: repeat(6, 34px); gap: 5px; }
.slot { width: 34px; height: 34px; display: grid; place-items: center; background: rgba(0, 0, 0, .4); font: normal 14px var(--px); color: var(--panel3); }
.slot .pxi-svg { height: 24px; }
.slot.got { background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 2px var(--panel3); }
.slot.new { background: rgba(255, 220, 110, .2); box-shadow: inset 0 0 0 2px var(--hl); animation: blink .6s steps(2) 4; }
.art-pop .btn { width: 100%; }

/* ---------- shared result layout (main.js resultScreen) ---------- */
.res-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.score-panel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 34px 16px; background: rgba(0, 0, 0, .4); box-shadow: inset 0 0 0 3px var(--c2), 0 5px 0 #000; }
.score-panel small { font-family: var(--px); font-size: 10px; letter-spacing: 2px; color: var(--dim); }
.score-panel b { font-family: var(--px); font-size: clamp(40px, 13vw, 64px); line-height: 1; color: var(--c2); text-shadow: 4px 4px 0 #000; }
.res-highlight { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; font-family: var(--px); font-size: 12px; color: #fff; background: var(--c4); box-shadow: 0 4px 0 #000; animation: popin .4s steps(5, jump-none) both; animation-delay: .5s; }
.res-best { display: inline-flex; align-items: center; gap: 8px; font-family: var(--px); font-size: 11px; color: var(--dim); }
.res-highlight .pxi-svg, .res-best .pxi-svg { height: 18px; }
.res-stats { display: flex; justify-content: center; gap: 8px; width: 100%; max-width: 420px; }
.stat { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 2px var(--panel3); }
.stat b { display: inline-flex; align-items: center; gap: 6px; font-family: var(--px); font-size: 16px; color: var(--ink); }
.stat b .pxi-svg { height: 18px; }
.stat small { font-family: var(--px); font-size: 8px; letter-spacing: 1px; color: var(--dim); text-transform: uppercase; }
.reward-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 18px; font-family: var(--px); font-size: 22px; color: var(--hl); background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 3px var(--hl); }
.reward-chip .pxi-svg { height: 24px; }
.res-note { max-width: 420px; font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--panel); padding: 12px 14px; box-shadow: 0 4px 0 #000; text-align: left; }
.res-btn-row { display: flex; gap: 10px; } .res-btn-row .btn { flex: 1; }
.qcell .pxi-svg { height: 18px; }
