:root {
  --bg: #0b0610;
  --panel: rgba(34, 18, 28, 0.82);
  --panel-2: rgba(56, 26, 30, 0.7);
  --line: #fbf1dc;
  --muted: #c4ae92;
  --gold: #fcd34d;
  --flame: #fb923c;
  --crimson: #ef4444;
  --cyan: #38bdf8;
  --pink: #f472b6;
  --lime: #4ade80;
  --violet: #a78bfa;
  --c: var(--gold);
  --rc: var(--gold);
  --gc: var(--gold);
  --hd: 'Baloo 2', 'Be Vietnam Pro', system-ui, sans-serif;
  --serif: 'Noto Serif', Georgia, serif;
  --bd: 'Be Vietnam Pro', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(239, 68, 68, .26) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 60%, rgba(167, 139, 250, .18) 0%, transparent 45%),
    radial-gradient(ellipse at 0% 90%, rgba(251, 146, 60, .14) 0%, transparent 45%), var(--bg);
  color: var(--line); font-family: var(--bd); font-size: 17px; line-height: 1.5;
  min-height: 100vh; overflow-x: hidden;
}
#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#app { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 0 16px 56px; }
a { color: inherit; }
html[lang="vi"] .lang-en, html[lang="en"] .lang-vi { display: none; }

/* ---------- buttons ---------- */
.btn {
  font: 800 16px var(--hd); color: var(--line); text-decoration: none;
  background: rgba(252, 211, 77, .1); border: 2px solid rgba(252, 211, 77, .5);
  padding: 9px 18px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(251, 146, 60, .35); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #fde68a, var(--gold) 45%, var(--flame)); color: #3a1406; border: 0; box-shadow: 0 4px 0 #b45309; }
.btn.primary:hover:not(:disabled) { box-shadow: 0 4px 0 #b45309, 0 8px 24px rgba(251, 146, 60, .45); }
.btn.ghost { background: rgba(255, 255, 255, .04); border-color: rgba(251, 241, 220, .2); }
.btn.small { font-size: 14px; padding: 6px 14px; }
.btn.big { font-size: 20px; padding: 12px 28px; }
.btn.round { width: 44px; height: 44px; padding: 0; font-size: 20px; }
.btn small { opacity: .7; font-family: var(--bd); font-size: 12px; }
.pill { font: 700 14px var(--bd); background: var(--panel); border: 1px solid rgba(251, 241, 220, .15); padding: 6px 12px; border-radius: 999px; color: var(--line); white-space: nowrap; }
.pill.gold { color: var(--gold); }
.unlock-pill { color: #fca5a5; border-color: #ef4444; }
.realm-pill { border-color: color-mix(in srgb, var(--rc) 60%, transparent); color: var(--rc); }
button.pill { cursor: pointer; }
.lang { display: inline-flex; border: 1px solid rgba(251, 241, 220, .2); border-radius: 999px; overflow: hidden; background: var(--panel); }
.lang button { font: 800 12px var(--bd); color: var(--muted); background: none; border: 0; padding: 7px 10px; cursor: pointer; }
.lang button.on { background: var(--gold); color: #3a1406; }

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0; flex-wrap: wrap; }
.hud-right { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.brand { font: 800 22px var(--hd); letter-spacing: .06em; text-decoration: none; }
.brand span { color: var(--flame); margin: 0 .08em; }
@media (max-width: 560px) { .brand { font-size: 16px; letter-spacing: .02em; } }
.hud-hero { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle, rgba(252, 211, 77, .3), transparent 70%); display: block; overflow: hidden; border: 2px solid rgba(252, 211, 77, .5); }
.hud-hero .av { width: 100%; height: 100%; transform: scale(1.35) translateY(8%); }
@media (max-width: 560px) { .realm-pill { display: none; } }

/* ---------- characters & speech ---------- */
.av { display: block; width: 100%; height: auto; overflow: visible; }
.av-elder { filter: drop-shadow(0 0 8px rgba(52, 211, 153, .55)); }
.bounce { animation: bounce .5s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bounce { 0% { transform: scale(.85); } 100% { transform: scale(1); } }
@keyframes float { 50% { transform: translateY(-6px); } }
.say { display: flex; align-items: flex-end; gap: 10px; margin: 12px 0; }
.say-av { width: 64px; flex: none; animation: float 3s ease-in-out infinite; }
.say-bubble { position: relative; background: #fff8ea; color: #3a2210; font-weight: 700; padding: 12px 16px; border-radius: 18px 18px 18px 4px; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); font-size: 17px; }
.say-bubble::before { content: ''; position: absolute; left: -8px; bottom: 6px; border: 8px solid transparent; border-right-color: #fff8ea; border-left: 0; }
.hint-say .say-bubble { background: #ede9fe; }
.hint-say .say-bubble::before { border-right-color: #ede9fe; }
.home-say { max-width: 720px; margin: 8px auto; }

/* ---------- home ---------- */
.home-top { display: flex; align-items: center; gap: 22px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.hero-stage { position: relative; width: 190px; height: 190px; display: block; flex: none; }
.aura { position: absolute; inset: 10px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--rc) 45%, transparent) 0%, transparent 68%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rc) 50%, transparent), 0 0 40px color-mix(in srgb, var(--rc) 50%, transparent); animation: aura 3s ease-in-out infinite; }
@keyframes aura { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--rc) 35%, transparent), 0 0 70px color-mix(in srgb, var(--rc) 70%, transparent); } }
.hero-big { position: absolute; inset: 14px 22px 0; animation: float 3s ease-in-out infinite; }
.pet { position: absolute; width: 74px; right: -14px; bottom: -6px; animation: float 2.4s ease-in-out infinite reverse; }
.home-info { min-width: 260px; flex: 0 1 380px; }
.hello { font: 800 18px var(--hd); color: var(--muted); }
.realm-name { font: 800 34px/1.1 var(--hd); color: var(--rc); text-shadow: 0 0 18px color-mix(in srgb, var(--rc) 50%, transparent); }
.realm-sub { font-weight: 700; color: var(--line); margin-bottom: 6px; }
.realm-sub i { color: var(--muted); font-weight: 600; }
.bar { height: 12px; background: rgba(255, 255, 255, .1); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--flame), var(--crimson)); border-radius: 99px; box-shadow: 0 0 12px var(--flame); }
.realm-next { font-size: 14px; color: var(--muted); margin-top: 4px; }
.home-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.home-btns .big { flex: 1 1 100%; }

.regions { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px; margin-top: 14px; scrollbar-width: none; }
.region { flex: none; display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left;
  background: var(--panel); border: 2px solid color-mix(in srgb, var(--gc) 30%, transparent); color: var(--line); padding: 8px 14px; border-radius: 16px; cursor: pointer; font-family: var(--bd); }
.region span { grid-row: span 2; font-size: 26px; }
.region b { font: 800 16px var(--hd); color: var(--gc); line-height: 1; }
.region small { color: var(--muted); font-size: 12px; }
.region.on { border-color: var(--gc); background: color-mix(in srgb, var(--gc) 16%, var(--panel)); box-shadow: 0 0 18px color-mix(in srgb, var(--gc) 35%, transparent); }
.region.dim { opacity: .55; }

.map { margin-top: 6px; }
.map-title { font: 800 28px var(--hd); text-align: center; color: var(--gc); margin: 6px 0 4px; }
.path { list-style: none; padding: 0; margin: 0 auto; max-width: 520px; display: flex; flex-direction: column; align-items: center; }
.path li { transform: translateX(calc(var(--o) * clamp(40px, 12vw, 80px))); padding: 10px 0; position: relative; }
.node { position: relative; display: flex; flex-direction: column; align-items: center; text-decoration: none; width: 120px; }
.node-ring { width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--gold) var(--p), rgba(255, 255, 255, .12) 0); padding: 5px; transition: transform .15s; }
.node-ico { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; font-size: 32px;
  background: radial-gradient(circle at 35% 30%, #4a2a36, #241018); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .35); }
a.node:hover .node-ring { transform: scale(1.08); }
.node.done .node-ico { background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b); box-shadow: inset 0 -5px 0 #b45309; }
.node.cur .node-ring { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(252, 211, 77, .25), 0 0 30px rgba(251, 146, 60, .6); } }
.node.locked { opacity: .45; filter: grayscale(.7); }
.node.boss .node-ring { width: 96px; height: 96px; background: conic-gradient(var(--crimson) var(--p), rgba(255, 255, 255, .12) 0); }
.node.boss .node-ico { font-size: 42px; background: radial-gradient(circle at 35% 30%, #7f1d1d, #2a0a0a); }
.node.boss.done .node-ico { background: radial-gradient(circle at 35% 30%, #fecaca, #ef4444); box-shadow: inset 0 -5px 0 #991b1b; }
.boss-tag { position: absolute; top: -6px; font: 800 11px var(--hd); background: var(--crimson); color: #fff; padding: 0 8px; border-radius: 99px; letter-spacing: .08em; }
.node-lbl { margin-top: 6px; font: 700 14px/1.2 var(--hd); text-align: center; color: var(--line); text-shadow: 0 2px 4px #000; }
.node-hero { position: absolute; width: 56px; left: -50px; top: 6px; animation: float 1.6s ease-in-out infinite; }
.soon { max-width: 520px; margin: 20px auto; text-align: center; }
.soon-tag { font: 800 22px var(--hd); color: var(--muted); }
.foot { display: flex; justify-content: center; margin-top: 30px; }

/* ---------- hero editor ---------- */
.editor { max-width: 760px; margin: 10px auto; }
.ed-grid { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; background: var(--panel); border-radius: 24px; padding: 20px; border: 1px solid rgba(251, 241, 220, .12); }
@media (max-width: 640px) { .ed-grid { grid-template-columns: 1fr; } .ed-preview { max-width: 200px; margin: 0 auto; } }
.ed-preview { background: radial-gradient(circle, rgba(252, 211, 77, .3), transparent 70%); border-radius: 50%; padding: 10px; }
.ed-row { margin-bottom: 14px; }
.ed-row b { display: block; font: 800 15px var(--hd); color: var(--gold); margin-bottom: 6px; }
.hairs { display: flex; gap: 8px; flex-wrap: wrap; }
.hair { width: 64px; height: 64px; border-radius: 16px; background: rgba(255, 255, 255, .05); border: 2px solid transparent; cursor: pointer; padding: 2px; overflow: hidden; }
.hair.on, .sw.on { border-color: var(--gold); box-shadow: 0 0 12px rgba(252, 211, 77, .6); }
.sws { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 36px; height: 36px; border-radius: 50%; background: var(--sw); border: 3px solid rgba(255, 255, 255, .2); cursor: pointer; }
.ed-row input { font: 700 18px var(--bd); width: 100%; max-width: 280px; padding: 8px 12px; border-radius: 12px; border: 2px solid rgba(252, 211, 77, .5); background: #120a10; color: var(--line); }

/* ---------- topic ---------- */
.topic { max-width: 640px; margin: 0 auto; text-align: center; }
.topic-head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.topic-ico { font-size: 44px; }
.topic h1 { font: 800 32px var(--hd); color: var(--gold); margin: 0; }
.topic .say { text-align: left; }
.stones { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 20px 0; }
.stone { aspect-ratio: 1; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none;
  background: radial-gradient(circle at 35% 30%, #4a2a36, #241018); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .35); transition: transform .15s; }
.stone b { font: 800 26px var(--hd); line-height: 1; }
.stone small { color: var(--gold); font-size: 11px; letter-spacing: 1px; min-height: 14px; }
.stone.done { background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b); color: #3a1406; box-shadow: inset 0 -5px 0 #b45309; }
.stone.done small { color: #7c2d12; }
.stone.next { outline: 3px solid var(--gold); animation: pulse 1.6s infinite; }
.stone:hover { transform: scale(1.08); }

/* ---------- problem ---------- */
.play { max-width: 760px; margin: 0 auto; position: relative; }
.play-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.topic-chip { font: 800 16px var(--hd); color: var(--gold); }
.dots { display: flex; gap: 6px; }
.dots .dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .15); display: block; }
.dots .dot.done { background: var(--gold); }
.dots .dot.cur { outline: 2px solid var(--line); outline-offset: 2px; }
.card { background: var(--panel); border: 1px solid rgba(251, 241, 220, .12); border-radius: 24px; padding: 16px 20px 20px; margin-top: 10px; }
.q-say .say-bubble { font-size: 19px; }
.fig { background: #0e070c; border-radius: 16px; padding: 8px; margin: 10px 0; border: 1px solid rgba(252, 211, 77, .2); }
.fig svg { display: block; width: 100%; height: auto; max-height: 320px; }
.big { font: 800 clamp(30px, 7vw, 46px)/1.3 var(--hd); text-align: center; margin: 12px 0; color: #fff; text-shadow: 0 0 20px rgba(251, 146, 60, .5); word-break: break-word; }
.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; margin: 0 .12em; font-size: .82em; }
.fr > span:first-child { border-bottom: .08em solid currentColor; padding: 0 .15em; }
.answer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.answer input { flex: 1 1 140px; max-width: 260px; min-width: 0; font: 800 26px var(--hd); text-align: center; color: var(--line); background: #120a10; border: 3px solid rgba(252, 211, 77, .5); border-radius: 16px; padding: 6px 12px; outline: none; }
.answer input:focus { border-color: var(--flame); box-shadow: 0 0 18px rgba(251, 146, 60, .45); }
.slash { font-size: 22px; width: 48px; }
.unit { color: var(--muted); font-weight: 700; }
.choices { display: flex; gap: 14px; justify-content: center; }
.choice { width: 84px; height: 84px; border-radius: 22px; font: 800 40px var(--hd); color: #3a1406; cursor: pointer; border: 0;
  background: linear-gradient(180deg, #fff8ea, #fde68a); box-shadow: 0 6px 0 #b45309; transition: transform .1s; }
.choice.wide { width: auto; min-width: 84px; padding: 0 18px; font-size: 26px; }
.choices { flex-wrap: wrap; }
.choice:hover:not(:disabled) { transform: translateY(-3px); }
.choice.wrong { background: #fecaca; box-shadow: 0 6px 0 #991b1b; opacity: .6; }
.choice.right { background: linear-gradient(180deg, #bbf7d0, #4ade80); box-shadow: 0 6px 0 #15803d; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.fb { min-height: 28px; margin: 10px 0 4px; font: 800 18px var(--hd); text-align: center; }
.fb.bad { color: #fca5a5; }
.fb.good { color: var(--lime); }
.fb.warn { color: var(--gold); }
.tools { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.sol { margin-top: 12px; background: rgba(74, 222, 128, .08); border: 1px dashed rgba(74, 222, 128, .5); border-radius: 16px; padding: 12px 16px; }
.sol b { font-family: var(--hd); color: var(--lime); }
.sol ol { margin: 6px 0 0; padding-left: 22px; }
.sol li { margin: 4px 0; font-weight: 600; }
.win { text-align: center; margin-top: 14px; animation: pop .4s; }
.win-stars { font-size: 48px; letter-spacing: 6px; line-height: 1.2; }
.win-stars span { color: rgba(255, 255, 255, .15); display: inline-block; }
.win-stars span.on { color: var(--gold); text-shadow: 0 0 18px var(--gold); animation: star .5s both; }
@keyframes star { from { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } }
.win-qi { font: 800 18px var(--hd); color: var(--flame); margin-bottom: 10px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.buddies { position: fixed; right: max(8px, calc(50vw - 560px)); bottom: 10px; display: flex; align-items: flex-end; gap: 0; z-index: 5; pointer-events: none; }
.buddy { width: 96px; display: block; }
.buddy.fox { width: 72px; margin-left: -18px; }
.buddies.inline { position: static; justify-content: center; margin-top: 10px; }
@media (max-width: 860px) { .buddies:not(.inline) { position: static; justify-content: center; margin-top: 8px; } .buddy { width: 80px; } .buddy.fox { width: 60px; } }

/* ---------- boss ---------- */
.mission { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .mission { grid-template-columns: 1fr; } }
.holo { position: relative; background: #0e070c; border: 2px solid color-mix(in srgb, var(--c) 55%, transparent); border-radius: 24px; padding: 14px;
  box-shadow: 0 0 40px color-mix(in srgb, var(--c) 16%, transparent); overflow: hidden; scroll-margin-top: 12px; }
.holo.playing { box-shadow: 0 0 60px color-mix(in srgb, var(--c) 35%, transparent); }
.holo-head { font: 800 14px var(--hd); letter-spacing: .1em; color: var(--c); text-align: center; }
.blink { animation: blink 1.2s infinite; color: var(--crimson); }
@keyframes blink { 50% { opacity: .2; } }
.holo .fig { border: 0; padding: 0; background: none; }
.cap { min-height: 56px; margin-top: 6px; padding: 10px 14px; border-radius: 14px; background: rgba(252, 211, 77, .08); font-weight: 600; }
.cap.pop { animation: pop .35s ease; }
.stepno { font: 800 13px var(--hd); color: var(--c); margin-right: 6px; }
.holo-ctl { margin-top: 10px; display: flex; justify-content: center; }
.brief { background: var(--panel); border: 1px solid rgba(251, 241, 220, .12); border-radius: 24px; padding: 16px 18px; }
.question { font: 800 19px var(--hd); margin: 12px 0; padding: 10px 14px; border-radius: 14px; background: rgba(252, 211, 77, .1); border: 2px dashed rgba(252, 211, 77, .5); color: #fff4c2; text-align: center; }

/* ---------- practice ---------- */
.practice { max-width: 720px; margin: 0 auto; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 14px; }
@media (max-width: 560px) { .grades { grid-template-columns: repeat(2, 1fr); } }
.grade { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; text-align: left; padding: 8px 12px; border-radius: 16px; cursor: pointer; color: var(--line);
  background: var(--panel); border: 2px solid color-mix(in srgb, var(--gc) 30%, transparent); font-family: var(--bd); }
.grade span { grid-row: span 2; font-size: 24px; }
.grade b { font: 800 16px var(--hd); color: var(--gc); line-height: 1.1; }
.grade small { color: var(--muted); font-size: 12px; }
.grade.on { border-color: var(--gc); background: color-mix(in srgb, var(--gc) 18%, var(--panel)); box-shadow: 0 0 18px color-mix(in srgb, var(--gc) 35%, transparent); }
.chamber { position: relative; padding: 18px 16px; border-radius: 24px; background: var(--panel); border: 2px solid rgba(251, 146, 60, .4); text-align: center; }
.chamber-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.chamber .buddy { width: 80px; }
.combo { min-height: 30px; font: 800 18px var(--hd); color: var(--flame); }
.combo small { color: var(--muted); }
.flame { display: inline-block; transform: scale(var(--s)); animation: flick .5s ease-in-out infinite alternate; margin-right: 6px; }
@keyframes flick { to { transform: scale(calc(var(--s) * 1.12)) rotate(4deg); } }
.problem { font: 800 clamp(40px, 9vw, 64px)/1.2 var(--hd); color: #fff; margin: 6px 0 14px; text-shadow: 0 0 22px rgba(251, 146, 60, .5); }
.problem.pop { animation: pop .3s; }
.sess { margin-top: 8px; color: var(--muted); font-size: 14px; }
.sess b { color: var(--gold); }
.float-qi { position: absolute; left: 50%; top: 40%; font: 800 26px var(--hd); color: var(--gold); pointer-events: none; animation: rise 1s ease-out forwards; text-shadow: 0 0 12px var(--flame); }
@keyframes rise { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -70px); opacity: 0; } }

/* ---------- world ---------- */
.world { position: relative; border-radius: 24px; overflow: hidden; border: 2px solid rgba(252, 211, 77, .4); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); user-select: none; -webkit-user-select: none; }
.world-cv { display: block; width: 100%; height: clamp(380px, 72vh, 680px); touch-action: none; cursor: pointer; }
.w-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.w-area, .w-gems { font: 800 15px var(--hd); background: rgba(20, 10, 16, .78); border: 1.5px solid rgba(252, 211, 77, .5); color: var(--gold); padding: 4px 12px; border-radius: 999px; }
.w-gems { color: #7dd3fc; border-color: rgba(125, 211, 252, .5); }
.w-zoom { position: absolute; left: 12px; top: 50px; display: flex; flex-direction: column; gap: 6px; }
.w-zoom button { width: 40px; height: 40px; font: 800 18px var(--hd); color: #fff; background: rgba(20, 10, 16, .7); border: 1.5px solid rgba(255, 255, 255, .3); border-radius: 12px; cursor: pointer; }
.w-zoom button:hover { background: rgba(252, 211, 77, .35); }
.w-pad { position: absolute; right: 14px; bottom: 14px; width: 132px; height: 132px; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); }
.w-pad button { font-size: 18px; color: #fff; background: rgba(20, 10, 16, .6); border: 1.5px solid rgba(255, 255, 255, .3); border-radius: 12px; cursor: pointer; touch-action: none; }
.w-pad button:active { background: rgba(252, 211, 77, .5); }
.w-pad [data-d="0,-1"] { grid-area: 1 / 2; } .w-pad [data-d="-1,0"] { grid-area: 2 / 1; } .w-pad [data-d="1,0"] { grid-area: 2 / 3; } .w-pad [data-d="0,1"] { grid-area: 3 / 2; }
.w-msg { position: absolute; left: 12px; bottom: 12px; right: 160px; display: flex; align-items: flex-end; gap: 8px; animation: pop .3s; pointer-events: none; }
.w-msg-av { width: 64px; flex: none; }
.w-msg-b { background: #fff8ea; color: #3a2210; font-weight: 700; padding: 10px 14px; border-radius: 16px 16px 16px 4px; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.w-msg-b b { color: #b45309; }
.w-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, 92%); display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center;
  background: #1d0f18; border: 2px solid var(--gold); border-radius: 22px; padding: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); animation: pop .25s; }
.w-card-ico { font-size: 46px; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; background: radial-gradient(circle, rgba(252, 211, 77, .3), transparent 70%); }
.w-card-ico.gem { background: radial-gradient(circle, rgba(125, 211, 252, .35), transparent 70%); }
.w-card-b small { color: var(--muted); display: block; font-size: 12px; }
.w-card-b b { font: 800 20px/1.2 var(--hd); color: var(--line); }
.w-card-b .w-q { font-size: 30px; }
.w-card-bar { height: 8px; background: rgba(255, 255, 255, .1); border-radius: 9px; overflow: hidden; margin: 6px 0 2px; }
.w-card-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--flame)); }
.w-card > .btn.primary, .w-gem-f { grid-column: 1 / -1; }
.w-gem-f { display: flex; gap: 8px; }
.w-gem-f input { flex: 1; min-width: 0; font: 800 24px var(--hd); text-align: center; background: #120a10; color: var(--line); border: 3px solid rgba(125, 211, 252, .6); border-radius: 14px; padding: 4px; }
.w-x { position: absolute; top: 8px; right: 8px; }
@media (max-width: 560px) { .w-pad { width: 112px; height: 112px; } .w-msg { right: 128px; } .w-msg-av { width: 48px; } .w-msg-b { font-size: 14px; } }

/* ---------- placement ---------- */
.placement { max-width: 760px; margin: 0 auto; }
.pl-grades { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 12px 0; }
.pl-cta, .pl-result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 10px; }
.pl-cta p { color: var(--muted); margin: 0; }
.pl-result .av { width: 160px; }
.pl-result h2 { font: 800 30px var(--hd); color: var(--gold); margin: 0; }

/* ---------- backup ---------- */
.backup { max-width: 860px; margin: 0 auto; }
.bk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.bk-card { background: var(--panel); border: 2px solid rgba(251, 241, 220, .12); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.bk-card h2 { font: 800 22px var(--hd); color: var(--gold); margin: 0; }
.bk-me { display: flex; align-items: center; gap: 10px; font: 800 16px var(--hd); }
.bk-me .av { width: 72px; }
.bk-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.bk-qr { width: min(260px, 80vw); background: #fff; border-radius: 14px; padding: 8px; }
.bk-qr svg { display: block; width: 100%; height: auto; }
.bk-note { color: var(--muted); font-size: 14px; margin: 0; }
.bk-card textarea { width: 100%; font: 600 13px monospace; background: #120a10; color: var(--line); border: 2px solid rgba(252, 211, 77, .4); border-radius: 12px; padding: 8px; resize: vertical; }
.foot { gap: 8px; }

/* ---------- shop ---------- */
.shop { max-width: 980px; margin: 0 auto; }
.shop-grid { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 720px) { .shop-grid { grid-template-columns: 1fr; } .shop-stage { position: static !important; } }
.shop-stage { position: sticky; top: 10px; background: radial-gradient(circle at 50% 40%, rgba(167, 139, 250, .35), var(--panel) 70%); border: 2px solid rgba(167, 139, 250, .5); border-radius: 24px; padding: 14px; text-align: center; }
.shop-wallet { font: 800 26px var(--hd); color: #7dd3fc; }
.shop-hero { width: 200px; margin: 0 auto; animation: float 3s ease-in-out infinite; }
.shop-pet { width: 90px; margin: -50px 0 0 auto; animation: float 2.4s ease-in-out infinite reverse; }
.shop-try { font: 800 15px var(--hd); color: var(--gold); }
.shop-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.shop-tabs button { font: 800 15px var(--hd); color: var(--line); background: var(--panel); border: 2px solid rgba(251, 241, 220, .15); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.shop-tabs button.on { border-color: var(--gold); background: rgba(252, 211, 77, .15); color: var(--gold); }
.shop-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shop-card { background: var(--panel); border: 2px solid rgba(251, 241, 220, .12); border-radius: 18px; padding: 10px; text-align: center; cursor: pointer; display: flex; flex-direction: column; gap: 6px; align-items: center; transition: transform .15s, border-color .2s; }
.shop-card:hover { transform: translateY(-3px); }
.shop-card.try { border-color: #a78bfa; box-shadow: 0 0 18px rgba(167, 139, 250, .5); }
.shop-card.on { border-color: var(--lime); }
.shop-card.locked .shop-art { filter: grayscale(1) brightness(.6); }
.shop-card b { font: 800 15px/1.2 var(--hd); min-height: 36px; display: flex; align-items: center; }
.shop-art { width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle, rgba(252, 211, 77, .2), transparent 70%); }
.tag-on { font: 800 13px var(--hd); color: var(--lime); }
.tag-lock { font-size: 12px; color: var(--muted); }

/* ---------- fight ---------- */
.fight { position: fixed; inset: 0; z-index: 66; background: radial-gradient(circle at 50% 30%, rgba(127, 29, 29, .55), rgba(0, 0, 0, .9)); display: grid; place-items: center; padding: 12px; animation: fade .25s; overflow: auto; }
.fight-in { width: min(640px, 100%); background: #1d0f18; border: 3px solid #ef4444; border-radius: 26px; padding: 14px 16px; box-shadow: 0 0 60px rgba(239, 68, 68, .45); max-height: 96vh; overflow: auto; }
.fight-in.boss { border-color: var(--gold); box-shadow: 0 0 80px rgba(252, 211, 77, .5); }
.f-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.f-side { text-align: center; position: relative; }
.f-av { width: 110px; margin: 0 auto; position: relative; }
.f-mon { width: 140px; animation: float 2s ease-in-out infinite; }
.boss .f-mon { width: 170px; }
.f-vs { font: 800 30px var(--hd); color: var(--crimson); text-shadow: 0 0 14px #ef4444; align-self: center; }
.f-name { font: 800 15px var(--hd); color: #fca5a5; }
.f-hp { height: 12px; background: rgba(255, 255, 255, .12); border-radius: 9px; overflow: hidden; margin: 4px auto 0; width: 140px; border: 1px solid #7f1d1d; }
.f-hp i { display: block; height: 100%; background: linear-gradient(90deg, #ef4444, #f97316); transition: width .4s; }
.f-hearts { font-size: 20px; letter-spacing: 2px; }
.f-hearts .off { filter: grayscale(1); opacity: .3; }
.f-mon.hit { animation: hit .45s; }
@keyframes hit { 20% { transform: translateX(10px) rotate(6deg); filter: brightness(2.2) saturate(.3); } 50% { transform: translateX(-8px); } }
.f-mon.poof { animation: poof .8s forwards; }
@keyframes poof { to { transform: scale(.2) rotate(30deg); opacity: 0; } }
.f-float { position: absolute; left: 50%; top: 10%; font: 800 28px var(--hd); color: #fde047; text-shadow: 0 0 10px #ef4444; animation: rise .9s ease-out forwards; pointer-events: none; }
.f-q { margin-top: 12px; background: rgba(255, 255, 255, .03); border-radius: 18px; padding: 10px 12px; text-align: center; }
.f-chip { display: inline-block; font: 800 13px var(--hd); color: var(--gold); background: rgba(252, 211, 77, .1); border-radius: 99px; padding: 2px 10px; }
.f-qtext { font: 700 18px var(--bd); margin: 6px 0; }
.f-q .fig svg { max-height: 220px; }
.f-q .big { font-size: clamp(26px, 6vw, 38px); margin: 6px 0 10px; }
.f-foot { display: flex; justify-content: center; margin-top: 8px; }
.f-result { padding: 10px 0; }
.f-loot { font: 800 24px var(--hd); color: #7dd3fc; margin: 6px 0 12px; }
@media (max-width: 520px) { .f-av { width: 80px; } .f-mon { width: 100px; } .boss .f-mon { width: 120px; } .f-vs { font-size: 22px; } }

/* ---------- overlays ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--panel); border: 2px solid var(--gold);
  color: var(--gold); font: 800 16px var(--hd); padding: 8px 18px; border-radius: 999px; box-shadow: 0 0 24px rgba(251, 146, 60, .5); animation: pop .3s; white-space: nowrap; }
.modal { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .7); display: grid; place-items: center; padding: 16px; animation: fade .25s; }
.modal-in { position: relative; background: #1d0f18; border: 2px solid rgba(252, 211, 77, .4); border-radius: 24px; padding: 18px; width: min(460px, 100%); max-height: 86vh; overflow: auto; }
.modal-h { font: 800 24px var(--hd); color: var(--gold); margin: 0 0 8px; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ladder li { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; opacity: .5; }
.ladder li.past { opacity: .85; }
.ladder li.now { opacity: 1; background: color-mix(in srgb, var(--rc) 16%, transparent); box-shadow: inset 3px 0 0 var(--rc); }
.l-ico { font-size: 20px; text-align: center; }
.l-name { font: 800 16px var(--hd); color: var(--rc); }
.l-name small { color: var(--muted); font: italic 500 12px var(--serif); }
.l-qi { font-size: 13px; color: var(--muted); }
.l-gear { grid-column: 2 / 4; font-size: 12px; color: var(--gold); margin-top: -4px; }
.gear-row { display: flex; justify-content: space-between; gap: 4px; margin-top: 12px; }
.gear-row span { width: 19%; background: radial-gradient(circle, rgba(252, 211, 77, .25), transparent 70%); border-radius: 50%; }
.gear-row span.dim { filter: grayscale(1) brightness(.5); }
.gear-say { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.soul { margin-top: 10px; color: var(--muted); }
.soul b { color: var(--cyan); }
.bt { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: radial-gradient(circle, rgba(0, 0, 0, .55), rgba(0, 0, 0, .92)); padding: 16px; animation: fade .4s; }
@keyframes fade { from { opacity: 0; } }
.bt-ring { position: absolute; width: min(80vw, 520px); aspect-ratio: 1; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--rc), transparent 30%, var(--flame), transparent 60%, var(--rc), transparent);
  filter: blur(18px); opacity: .7; animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bt-in { position: relative; text-align: center; max-width: 440px; }
.bt-kicker { font: 800 clamp(38px, 9vw, 60px) var(--hd); color: var(--gold); text-shadow: 0 0 30px var(--flame); animation: slam .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes slam { from { transform: scale(2.4); opacity: 0; } }
.bt-hero { position: relative; width: 160px; margin: 0 auto; animation: float 2s ease-in-out infinite; }
.bt-icon { position: absolute; right: -10px; bottom: 0; font-size: 48px; }
.bt-name { font: 800 clamp(32px, 7vw, 46px) var(--hd); color: var(--rc); text-shadow: 0 0 24px var(--rc); }
.bt-alt { font: italic 600 16px var(--serif); color: var(--muted); }
.bt-desc { color: #f3e3c3; font-weight: 600; }
.burst { position: fixed; left: 50%; top: 50%; z-index: 80; pointer-events: none; }
.burst i { position: absolute; width: 10px; height: 10px; border-radius: 50%; animation: fly 1.2s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes fly { to { transform: translate(var(--x), var(--y)); opacity: 0; } }

/* ---------- SVG figure vocabulary ---------- */
.fig svg * { transform-box: view-box; }
.ln { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; }
.ln.thin { stroke-width: 1.4; }
.ln.faint { opacity: .45; }
.dash, .laser { stroke-dasharray: 6 5; }
.grid { stroke: rgba(251, 241, 220, .1); stroke-width: 1; }
.sh { fill: #3b82f6; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; }
.sh.thin, .cellbg.thin { stroke-width: .8; }
.sh.lite { fill: #60a5fa; } .sh.dark { fill: #1d4ed8; }
.sh-soft { fill: rgba(59, 130, 246, .25); }
.cellbg { fill: rgba(255, 255, 255, .06); stroke: var(--line); stroke-width: 2; }
.pk { fill: var(--pink); stroke: var(--line); stroke-width: 1.5; stroke-linejoin: round; }
.gold { fill: var(--gold); stroke: var(--line); stroke-width: 1.5; }
.laser { stroke: var(--gold); stroke-width: 2; fill: none; }
.beam { stroke: var(--gold); stroke-width: 6; stroke-linecap: round; }
.frame { fill: none; stroke: var(--gold); stroke-width: 3; stroke-dasharray: 8 6; filter: drop-shadow(0 0 6px var(--gold)); }
.ov { fill: rgba(252, 211, 77, .12); stroke: var(--gold); stroke-width: 3; }
.wg { stroke: none; opacity: 0; }
.edge { stroke-width: 5; stroke-linecap: round; }
.eg { stroke: var(--gold); }
.ep { stroke: var(--pink); }
.cell { stroke: #0e070c; stroke-width: 1.5; }
.blk { fill: #3b82f6; stroke: #0e070c; stroke-width: 1; }
.blk.pkb { fill: var(--pink); }
.qd { fill: rgba(56, 189, 248, 0); stroke: none; }
.tri { fill: rgba(244, 114, 182, 0); stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 5 4; }
.flag { fill: var(--crimson); }
.dot { fill: var(--gold); }
.pkdot { fill: var(--pink); stroke: #fff; stroke-width: 2; }
.hid { opacity: 0; }
.lbl { fill: var(--line); font: 800 17px var(--hd); }
.lbl.sm { font-size: 14px; }
.lbl.xs { font: 800 10px var(--bd); fill: var(--crimson); letter-spacing: .08em; }
.lbl.big { font-size: 22px; fill: var(--gold); }
.lbl.gold, .lbl.pkt { fill: var(--gold); }
.lbl.pkt { fill: var(--pink); }
.lbl.dark { fill: #3a1406; font-size: 15px; }
.emoji { font-size: 24px; }
.cnt { fill: var(--gold); font: 800 19px var(--hd); filter: drop-shadow(0 0 6px rgba(251, 146, 60, .7)); }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .cnt { font-size: 16px; }
  .stones { gap: 8px; }
  .choice { width: 72px; height: 72px; font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
