/* Matematička raketa: a separate file because fun4all.io's CSP
   (style-src 'self') drops inline <style> and style attributes. Fonts sit
   next to it in fonts/ (copied from fun4all.io's /fonts/ for khanbabajic.com). */
@font-face { font-family: Fredoka; src: url("fonts/fredoka-var.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: Nunito; src: url("fonts/nunito-var.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  --bg0: #070a24; --bg1: #150e45; --bg2: #2a0f55;
  --ink: #ffffff; --muted: #b9bdf0; --dim: #7f84c4;
  --glass: rgba(255, 255, 255, .08); --glass2: rgba(255, 255, 255, .14); --edge: rgba(255, 255, 255, .18);
  --gold: #ffd23f; --gold-d: #c98a00; --orange: #ff9a1f; --pink: #ff5ea8; --pink-d: #c21f6c;
  --cyan: #3fe0ff; --cyan-d: #0f8fb8; --green: #3fe08a; --green-d: #13995a; --red: #ff5a6e; --red-d: #b8213a;
  --purple: #9b6bff; --purple-d: #5b2bd6;
  --r-common: #9fb3d9; --r-rare: #3fa9ff; --r-epic: #b46bff; --r-legend: #ffc93f;
  --font-h: Fredoka, "Avenir Next Rounded", "SF Pro Rounded", ui-rounded, "Trebuchet MS", sans-serif;
  --font-b: Nunito, "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100%; color: var(--ink); font: 600 18px/1.4 var(--font-b);
  background: radial-gradient(1200px 700px at 85% -10%, #4a1a8a 0%, rgba(74, 26, 138, 0) 60%),
              radial-gradient(900px 700px at -10% 110%, #0d3f86 0%, rgba(13, 63, 134, 0) 60%),
              linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 55%, var(--bg2) 100%);
  background-color: var(--bg0); background-attachment: fixed;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; overscroll-behavior: none;
}
body.lock { overflow: hidden; height: 100%; position: fixed; inset: 0; }
canvas#bg, canvas#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; display: block; }
canvas#bg { z-index: 0; }
canvas#fx { z-index: 80; }
#app { position: relative; z-index: 1; }
button { font-family: inherit; color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.nebula { position: fixed; inset: -20%; z-index: 0; pointer-events: none; opacity: .55;
  background: radial-gradient(40% 30% at 30% 40%, rgba(255, 94, 168, .18), rgba(255, 94, 168, 0) 70%),
              radial-gradient(35% 30% at 70% 65%, rgba(63, 224, 255, .14), rgba(63, 224, 255, 0) 70%);
  animation: drift 40s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(-3%, -2%) rotate(0deg); } to { transform: translate(3%, 2%) rotate(8deg); } }

/* ---------- shared bits ---------- */
.screen { position: relative; min-height: 100vh; min-height: 100dvh; }
.wrap { max-width: 760px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.topbar h1 { flex: 1; margin: 0; text-align: center; font: 700 28px/1.1 var(--font-h); letter-spacing: .5px; }
.icon-btn { flex: none; width: 52px; height: 52px; border-radius: 18px; border: 2px solid var(--edge); background: var(--glass); font-size: 24px; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 0 rgba(0, 0, 0, .35); transition: transform .08s; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.icon-btn.off { opacity: .45; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: rgba(0, 0, 0, .35); border: 2px solid var(--edge); font: 700 20px/1 var(--font-h); white-space: nowrap; }
.cn { display: inline-block; width: .95em; height: .95em; border-radius: 50%; vertical-align: -.12em; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff6b0 0 18%, #ffd23f 40%, #e09200 75%, #a86400 100%);
  box-shadow: inset 0 0 0 .08em rgba(168, 100, 0, .55), 0 0 .35em rgba(255, 210, 63, .55); }
.st { color: var(--gold); text-shadow: 0 0 10px rgba(255, 210, 63, .6); }
.muted { color: var(--muted); }
.center { text-align: center; }

.btn {
  appearance: none; border: 0; cursor: pointer; min-height: 60px; padding: 12px 26px; border-radius: 22px;
  font: 700 24px/1.1 var(--font-h); letter-spacing: .3px; color: #4a2600; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(180deg, #ffe680 0%, #ffc21f 55%, #ffa600 100%);
  box-shadow: 0 6px 0 var(--gold-d), 0 12px 24px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .6);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--gold-d), 0 6px 14px rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .6); }
.btn.big { min-height: 76px; font-size: 32px; padding: 14px 40px; border-radius: 26px; }
.btn.cyan { color: #00303f; background: linear-gradient(180deg, #a5f3ff 0%, #3fe0ff 55%, #14b6e0 100%); box-shadow: 0 6px 0 var(--cyan-d), 0 12px 24px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .6); }
.btn.cyan:active { box-shadow: 0 2px 0 var(--cyan-d), inset 0 2px 0 rgba(255, 255, 255, .6); }
.btn.pink { color: #fff; background: linear-gradient(180deg, #ff9fcd 0%, #ff5ea8 55%, #e8338a 100%); box-shadow: 0 6px 0 var(--pink-d), 0 12px 24px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .5); }
.btn.pink:active { box-shadow: 0 2px 0 var(--pink-d), inset 0 2px 0 rgba(255, 255, 255, .5); }
.btn.green { color: #003a1c; background: linear-gradient(180deg, #a6ffcb 0%, #3fe08a 55%, #1fbf6a 100%); box-shadow: 0 6px 0 var(--green-d), 0 12px 24px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .6); }
.btn.green:active { box-shadow: 0 2px 0 var(--green-d), inset 0 2px 0 rgba(255, 255, 255, .6); }
.btn.purple { color: #fff; background: linear-gradient(180deg, #c9a8ff 0%, #9b6bff 55%, #7c4dff 100%); box-shadow: 0 6px 0 var(--purple-d), 0 12px 24px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn.purple:active { box-shadow: 0 2px 0 var(--purple-d), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn.ghost { color: #fff; background: var(--glass2); border: 2px solid var(--edge); box-shadow: 0 5px 0 rgba(0, 0, 0, .4); }
.btn.ghost:active { box-shadow: 0 1px 0 rgba(0, 0, 0, .4); }
.btn.red { color: #fff; background: linear-gradient(180deg, #ff9aa6 0%, #ff5a6e 55%, #e8334c 100%); box-shadow: 0 6px 0 var(--red-d), 0 12px 24px rgba(0, 0, 0, .35); }
.btn[disabled] { filter: grayscale(.8) brightness(.7); cursor: default; }
.btn small { display: block; font: 700 15px/1.2 var(--font-b); opacity: .75; letter-spacing: 0; }
.btn .col { display: flex; flex-direction: column; align-items: flex-start; }

.card { background: linear-gradient(180deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .05)); border: 2px solid var(--edge); border-radius: 26px; padding: 18px; box-shadow: 0 14px 40px rgba(0, 0, 0, .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.bar { height: 14px; border-radius: 99px; background: rgba(0, 0, 0, .4); overflow: hidden; border: 2px solid rgba(255, 255, 255, .12); }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--purple), var(--pink)); transition: width .6s cubic-bezier(.2, .9, .3, 1.2); }

/* ---------- home ---------- */
.home .wrap { display: flex; flex-direction: column; align-items: stretch; min-height: 100vh; min-height: 100dvh; }
.home-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.home-top .pills { display: flex; gap: 8px; flex-wrap: wrap; }
.home-top .btns { display: flex; gap: 8px; }
.title { margin: 14px 0 0; text-align: center; font: 700 clamp(40px, 10vw, 74px)/.95 var(--font-h); letter-spacing: 1px; text-transform: uppercase;
  background: linear-gradient(180deg, #fff 0%, #ffe680 40%, #ff9a1f 75%, #ff5ea8 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #6a1d7a) drop-shadow(0 10px 18px rgba(0, 0, 0, .5)); }
.title span { display: block; font-size: .62em; letter-spacing: 6px; }
.rocket-slot { cursor: pointer; flex: 1 1 auto; min-height: 190px; max-height: 340px; height: 34vh; }
.pilot { display: flex; align-items: center; gap: 14px; margin: 0 auto 16px; width: 100%; max-width: 520px; }
.pilot .badge { width: 64px; height: 64px; flex: none; border-radius: 20px; display: grid; place-items: center; font-size: 34px; background: linear-gradient(180deg, #4b3bb0, #2a1d7a); border: 2px solid var(--edge); }
.pilot .info { flex: 1; min-width: 0; }
.pilot .nm { font: 700 22px/1.1 var(--font-h); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pilot .rk { color: var(--muted); font-size: 16px; margin: 2px 0 6px; }
.pilot .bar { height: 12px; }
.play-btn { width: 100%; max-width: 520px; margin: 0 auto; animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.play-btn:active { animation: none; }
.home-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; max-width: 520px; margin: 18px auto 0; }
.home-row .btn { flex-direction: column; gap: 2px; font-size: 18px; min-height: 86px; padding: 10px 6px; }
.home-row .btn .e { font-size: 32px; line-height: 1; }
.streak { margin: 14px auto 0; text-align: center; color: var(--muted); font-size: 16px; }
.streak b { color: var(--orange); }

/* ---------- map ---------- */
.worlds { display: flex; flex-direction: column; gap: 16px; }
.world { position: relative; padding: 16px; }
.world.locked { opacity: .55; filter: saturate(.4); }
.world.current { border-color: rgba(63, 224, 255, .7); box-shadow: 0 0 0 3px rgba(63, 224, 255, .18), 0 14px 40px rgba(0, 0, 0, .35); }
.world-head { display: flex; align-items: center; gap: 14px; }
.world-head canvas { width: 86px; height: 86px; flex: none; }
.world-head .wt { flex: 1; min-width: 0; }
.world-head .wn { font: 700 22px/1.1 var(--font-h); }
.world-head .ws { color: var(--muted); font-size: 16px; margin-top: 2px; }
.world-head .wst { font: 700 18px/1 var(--font-h); white-space: nowrap; }
.nodes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; position: relative; }
.nodes::before { content: ""; position: absolute; left: 12%; right: 12%; top: 34px; border-top: 4px dashed rgba(255, 255, 255, .2); }
.node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; padding: 0; cursor: pointer; }
.node .c { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; font: 700 28px/1 var(--font-h);
  background: radial-gradient(circle at 35% 30%, #8d7dff, #4b36d6 70%); border: 3px solid rgba(255, 255, 255, .5); box-shadow: 0 5px 0 rgba(0, 0, 0, .4), 0 0 18px rgba(155, 107, 255, .35); }
.node.boss .c { font-size: 34px; background: radial-gradient(circle at 35% 30%, #ff8aa0, #c21f4c 70%); box-shadow: 0 5px 0 rgba(0, 0, 0, .4), 0 0 18px rgba(255, 90, 110, .45); }
.node.done .c { border-color: var(--gold); }
.node.locked { cursor: default; }
.node.locked .c { background: #2b2d55; border-color: rgba(255, 255, 255, .15); box-shadow: 0 5px 0 rgba(0, 0, 0, .4); font-size: 24px; }
.node.next .c { animation: nodepulse 1.4s ease-in-out infinite; border-color: var(--cyan); }
@keyframes nodepulse { 0%, 100% { box-shadow: 0 5px 0 rgba(0, 0, 0, .4), 0 0 0 0 rgba(63, 224, 255, .7); } 50% { box-shadow: 0 5px 0 rgba(0, 0, 0, .4), 0 0 0 12px rgba(63, 224, 255, 0); } }
.node .ss { font-size: 15px; letter-spacing: 1px; color: rgba(255, 255, 255, .25); }
.node .ss b { color: var(--gold); font-weight: 400; }
.node.pop .c { animation: unlockpop .9s cubic-bezier(.2, 1.6, .4, 1) both, nodepulse 1.4s ease-in-out .9s infinite; }
@keyframes unlockpop { 0% { transform: scale(.3) rotate(-30deg); } 60% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0deg); } }
.lockmsg { margin-top: 10px; color: var(--muted); font-size: 15px; text-align: center; }

/* ---------- play ---------- */
.play { display: grid; height: 100vh; height: 100dvh; overflow: hidden;
  grid-template-columns: 1fr; grid-template-rows: auto minmax(110px, 1fr) auto auto;
  grid-template-areas: "hud" "scene" "q" "pad";
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); gap: 8px; }
.hud { grid-area: hud; display: flex; align-items: center; gap: 10px; }
.hud .mid { flex: 1; min-width: 0; display: flex; justify-content: center; }
.dots { display: flex; gap: 6px; flex-wrap: nowrap; }
.dots i { width: clamp(14px, 3.2vw, 24px); height: clamp(14px, 3.2vw, 24px); border-radius: 50%; background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 255, 255, .22); display: block; }
.dots i.on { background: radial-gradient(circle at 35% 30%, #fff6b0, #ffd23f 50%, #e09200); border-color: #fff2a0; box-shadow: 0 0 10px rgba(255, 210, 63, .8); animation: dotpop .45s cubic-bezier(.2, 1.8, .4, 1); }
.dots i.cur { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(63, 224, 255, .25); }
@keyframes dotpop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
.bossbar { width: 100%; max-width: 420px; }
.bossbar .bn { font: 700 16px/1 var(--font-h); text-align: center; margin-bottom: 5px; color: #ffd0d8; }
.bossbar .hp { height: 18px; border-radius: 99px; background: rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .25); overflow: hidden; }
.bossbar .hp i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, #ff3b5c, #ff8a3c); box-shadow: 0 0 12px rgba(255, 59, 92, .8); transition: width .35s cubic-bezier(.2, .9, .3, 1.2); }
.hud .pill.coins { font-size: 22px; }
.hud .pill.coins.bump { animation: bump .25s ease-out; }
@keyframes bump { 50% { transform: scale(1.18); } }

.scene { grid-area: scene; position: relative; min-height: 0; }
.combo { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, .35); border: 2px solid rgba(255, 255, 255, .15); font: 700 22px/1 var(--font-h); transition: transform .2s; }
.combo.t0 { opacity: .5; }
.combo.t1 { border-color: #ff9a1f; color: #ffd08a; }
.combo.t2 { border-color: #3fb8ff; color: #b8e8ff; box-shadow: 0 0 14px rgba(63, 184, 255, .5); }
.combo.t3 { border-color: #b45cff; color: #e6c8ff; box-shadow: 0 0 18px rgba(180, 92, 255, .6); }
.combo.t4 { border-color: #ffd23f; color: #fff2b0; box-shadow: 0 0 22px rgba(255, 210, 63, .7); animation: rainbowglow 1.2s linear infinite; }
@keyframes rainbowglow { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
.combo.bump { animation: combobump .35s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes combobump { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
.combo .fire { display: inline-block; animation: flick .5s ease-in-out infinite alternate; }
@keyframes flick { from { transform: scale(1) rotate(-6deg); } to { transform: scale(1.15) rotate(6deg); } }
.combo .sh { margin-left: 4px; }
.combo .mult { font-size: 15px; padding: 2px 7px; border-radius: 99px; background: rgba(255, 255, 255, .15); margin-left: 4px; }
.hearts { position: absolute; right: 0; top: 0; font-size: 26px; letter-spacing: 2px; }
.hearts .lost { filter: grayscale(1) brightness(.5); opacity: .5; }
.hearts .pop { display: inline-block; animation: heartlost .6s ease-out; }
@keyframes heartlost { 0% { transform: scale(1.6); } 100% { transform: scale(1); } }
.banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap; text-align: center;
  font: 700 clamp(40px, 9vw, 88px)/1 var(--font-h); letter-spacing: 1px; opacity: 0; }
.banner.go { animation: banner 1.3s cubic-bezier(.2, 1.3, .4, 1) forwards; }
.banner span { background: linear-gradient(180deg, #fff 0%, #ffe680 35%, #ff9a1f 70%, #ff3b8a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #5a1270) drop-shadow(0 0 22px rgba(255, 154, 31, .6)); }
.banner small { display: block; font-size: .38em; margin-top: 6px; color: #fff; text-shadow: 0 2px 0 #5a1270; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.2) rotate(-10deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(3deg); } 30% { transform: translate(-50%, -50%) scale(1) rotate(0deg); } 75% { opacity: 1; transform: translate(-50%, -62%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -90%) scale(.9); } }
.count { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font: 700 clamp(70px, 18vw, 160px)/1 var(--font-h); color: #fff; text-shadow: 0 6px 0 #4a1a8a, 0 0 30px rgba(63, 224, 255, .8); }
.count b { display: block; animation: countin .9s ease-out forwards; font-weight: 700; }
.count b.go { font-size: .5em; color: var(--gold); }
@keyframes countin { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.7); opacity: 0; } }

.q { grid-area: q; position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 16px 12px; background: linear-gradient(180deg, rgba(40, 30, 104, .94), rgba(24, 18, 72, .94)); }
.q .tag { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px; background: var(--purple); font: 700 14px/1.2 var(--font-h); white-space: nowrap; box-shadow: 0 3px 0 var(--purple-d); }
.prob { display: flex; align-items: center; justify-content: center; gap: .22em; font: 700 clamp(36px, 10vw, 96px)/1 var(--font-h); white-space: nowrap; }
.prob.enter { animation: probin .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes probin { 0% { transform: scale(.5) translateY(20px); opacity: 0; } 100% { transform: scale(1) translateY(0); opacity: 1; } }
.prob .n { text-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 0 24px rgba(155, 107, 255, .5); }
.prob .op { color: var(--cyan); text-shadow: 0 0 18px rgba(63, 224, 255, .6); font-size: .9em; }
.ans { position: relative; min-width: 1.7em; height: 1.25em; padding: 0 .18em; border-radius: .22em; display: inline-grid; place-items: center;
  background: rgba(0, 0, 0, .35); border: .06em dashed rgba(63, 224, 255, .8); color: #fff; transition: background .15s, border-color .15s; }
.ans:empty::before { content: "?"; color: rgba(63, 224, 255, .55); animation: blink 1.1s steps(2) infinite; }
.ans.ghost:empty::before { content: attr(data-ghost); color: rgba(63, 224, 255, .35); animation: none; }
.ans.typed { border-style: solid; border-color: var(--cyan); }
.ans.ok { background: linear-gradient(180deg, #5cffa6, #13c46a); border: .06em solid #c8ffe0; color: #fff; text-shadow: 0 3px 0 rgba(0, 80, 40, .5); animation: okpop .45s cubic-bezier(.2, 1.8, .4, 1); }
.ans.bad { background: rgba(255, 90, 110, .35); border: .06em solid var(--red); animation: shake .45s; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes okpop { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-.14em) rotate(-4deg); } 40% { transform: translateX(.14em) rotate(4deg); } 60% { transform: translateX(-.1em); } 80% { transform: translateX(.08em); } }
.speed { position: relative; width: min(100%, 420px); height: 12px; border-radius: 99px; background: rgba(0, 0, 0, .45); border: 2px solid rgba(255, 255, 255, .12); overflow: visible; }
.speed i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffe680, #ffd23f, #ff9a1f); box-shadow: 0 0 10px rgba(255, 210, 63, .7); transform-origin: left center; }
.speed i.out { background: rgba(255, 255, 255, .15); box-shadow: none; }
.speed span { position: absolute; right: -6px; top: 50%; transform: translateY(-50%); font-size: 20px; filter: drop-shadow(0 0 6px rgba(255, 210, 63, .9)); }
.speed.out span { filter: grayscale(1); opacity: .5; }
.praise { min-height: 1.3em; font: 700 22px/1.3 var(--font-h); text-align: center; }
.praise.good { color: var(--green); }
.praise.bad { color: #ffb0bc; }
.praise.fast { color: var(--gold); }
.hint { width: min(100%, 560px); padding: 10px 14px; border-radius: 18px; background: rgba(155, 107, 255, .2); border: 2px solid rgba(155, 107, 255, .55); text-align: center; animation: hintin .3s ease-out; }
@keyframes hintin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.hint .rule { font: 700 18px/1.3 var(--font-h); color: #e6d8ff; margin-bottom: 4px; }
.hint .steps { font: 700 clamp(20px, 3.6vw, 26px)/1.35 var(--font-h); display: flex; flex-wrap: wrap; justify-content: center; column-gap: .45em; }
.hint .steps b { color: var(--gold); font-weight: 700; }
.hint .dots10 { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 6px 0 2px; }
.hint .frame { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 5px; border-radius: 10px; background: rgba(0, 0, 0, .3); }
.hint .dot { width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.hint .dot.a { background: radial-gradient(circle at 35% 30%, #a5f3ff, #14b6e0); }
.hint .dot.b { background: radial-gradient(circle at 35% 30%, #ffd0e6, #ff5ea8); }
.hint .dot.x { background: radial-gradient(circle at 35% 30%, #a5f3ff, #14b6e0); opacity: .35; position: relative; }
.hint .dot.x::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 3px; margin-top: -1.5px; background: var(--red); border-radius: 2px; transform: rotate(-45deg); }
.hint-btn { position: absolute; right: 0; bottom: 4px; width: 52px; height: 52px; z-index: 2; border-radius: 16px; border: 2px solid var(--edge); background: var(--glass); font-size: 22px; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.hint-btn:active { transform: translateY(2px); box-shadow: none; }
.hint-btn[disabled] { opacity: .3; cursor: default; }

.pad { grid-area: pad; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 480px; margin: 0 auto; }
.key { appearance: none; border: 0; cursor: pointer; height: clamp(54px, 8.6vh, 86px); border-radius: 20px; font: 700 clamp(28px, 4.6vh, 42px)/1 var(--font-h); color: #fff;
  background: linear-gradient(180deg, #4f45c9 0%, #3a2fa8 100%); box-shadow: 0 6px 0 #1f1670, 0 10px 18px rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .25);
  transition: transform .06s, box-shadow .06s, filter .1s; }
.key:active, .key.press { transform: translateY(4px); box-shadow: 0 2px 0 #1f1670, inset 0 2px 0 rgba(255, 255, 255, .25); filter: brightness(1.25); }
.key.del { background: linear-gradient(180deg, #6b6f9e, #4a4d7a); box-shadow: 0 6px 0 #26284a, inset 0 2px 0 rgba(255, 255, 255, .2); font-size: clamp(24px, 3.6vh, 34px); }
.key.del:active, .key.del.press { box-shadow: 0 2px 0 #26284a; }
.key.ok { background: linear-gradient(180deg, #5cffa6, #13c46a); box-shadow: 0 6px 0 #0a7a40, inset 0 2px 0 rgba(255, 255, 255, .45); color: #00391b; }
.key.ok:active, .key.ok.press { box-shadow: 0 2px 0 #0a7a40; }
.pad.off .key { pointer-events: none; }

@media (min-aspect-ratio: 11/10) and (min-width: 700px) {
  .play { grid-template-columns: 1fr minmax(300px, 400px); grid-template-rows: auto minmax(120px, 1fr) auto; grid-template-areas: "hud hud" "scene pad" "q pad"; column-gap: 24px; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .pad { align-self: center; max-width: 400px; }
  .key { height: clamp(60px, 13vh, 96px); font-size: clamp(30px, 6vh, 46px); }
}
@media (max-height: 560px) {
  .play { gap: 4px; }
  .prob { font-size: clamp(36px, 9vh, 64px); }
  .key { height: clamp(40px, 10vh, 60px); border-radius: 14px; }
  .q { padding: 10px 12px 8px; }
  .praise { font-size: 18px; }
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(5, 4, 25, .72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); overflow-y: auto; }
.modal .box { position: relative; width: min(100%, 540px); padding: 24px 20px 22px; text-align: center; animation: boxin .45s cubic-bezier(.2, 1.5, .4, 1); background: linear-gradient(180deg, #2c2378 0%, #1a1452 100%); }
@keyframes boxin { 0% { transform: scale(.6) translateY(30px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 8px; font: 700 clamp(28px, 6vw, 40px)/1.1 var(--font-h); }
.modal h2.glow { background: linear-gradient(180deg, #fff 0%, #ffe680 45%, #ff9a1f 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #5a1270); }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 18px; }
.modal .acts { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }
.modal .acts .btn { flex: 1 1 160px; }
.bigstars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 14px; }
.bigstars span { font-size: clamp(56px, 14vw, 80px); line-height: 1; color: rgba(255, 255, 255, .12); text-shadow: none; transform: scale(.8); transition: color .1s; }
.bigstars span:nth-child(2) { transform: translateY(-14px) scale(.8); }
.bigstars span.on { color: var(--gold); text-shadow: 0 0 22px rgba(255, 210, 63, .9), 0 4px 0 #b06a00; animation: starin .5s cubic-bezier(.2, 1.8, .4, 1) forwards; }
.bigstars span:nth-child(2).on { animation-name: starin2; }
@keyframes starin { 0% { transform: scale(2.4) rotate(-40deg); } 100% { transform: scale(1) rotate(0deg); } }
@keyframes starin2 { 0% { transform: translateY(-14px) scale(2.4) rotate(-40deg); } 100% { transform: translateY(-14px) scale(1) rotate(0deg); } }
.rows { display: grid; gap: 8px; text-align: left; margin: 0 auto; max-width: 380px; }
.rows div { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-radius: 14px; background: rgba(0, 0, 0, .25); font-size: 18px; }
.rows b { font: 700 22px/1 var(--font-h); display: inline-flex; align-items: center; gap: 6px; }
.rows .hl { background: linear-gradient(90deg, rgba(255, 210, 63, .25), rgba(255, 94, 168, .25)); border: 2px solid rgba(255, 210, 63, .6); animation: hlpulse 1.2s ease-in-out infinite; }
@keyframes hlpulse { 50% { box-shadow: 0 0 18px rgba(255, 210, 63, .5); } }
.namebox { width: 100%; max-width: 360px; margin: 6px auto 4px; display: block; padding: 14px 18px; border-radius: 18px; border: 3px solid var(--edge); background: rgba(0, 0, 0, .35); color: #fff; font: 700 26px/1.1 var(--font-h); text-align: center; -webkit-user-select: text; user-select: text; }
.namebox::placeholder { color: rgba(255, 255, 255, .35); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.choice { appearance: none; cursor: pointer; padding: 14px 10px; border-radius: 18px; border: 3px solid var(--edge); background: rgba(0, 0, 0, .3); font: 700 20px/1.15 var(--font-h); color: #fff; }
.choice small { display: block; margin-top: 4px; font: 700 14px/1.2 var(--font-b); color: var(--muted); }
.choice.on { border-color: var(--cyan); background: rgba(63, 224, 255, .18); box-shadow: 0 0 0 3px rgba(63, 224, 255, .2); }
.toggles { display: grid; gap: 10px; margin: 8px 0; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; background: rgba(0, 0, 0, .25); border: 0; cursor: pointer; font: 700 20px/1.1 var(--font-h); color: #fff; text-align: left; }
.toggle i { width: 56px; height: 32px; border-radius: 99px; background: rgba(255, 255, 255, .2); position: relative; flex: none; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on i { background: var(--green); }
.toggle.on i::after { transform: translateX(24px); }
.sep { height: 2px; background: rgba(255, 255, 255, .1); margin: 16px 0; border: 0; }

/* chest + reveal */
.chest-stage { position: relative; height: 260px; display: grid; place-items: center; }
.rays { position: absolute; left: 50%; top: 50%; width: 460px; height: 460px; margin: -230px 0 0 -230px; border-radius: 50%; pointer-events: none; opacity: .0; transition: opacity .4s;
  background: repeating-conic-gradient(from 0deg, rgba(255, 230, 128, .35) 0deg 10deg, rgba(255, 230, 128, 0) 10deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0) 68%); mask: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0) 68%); animation: spin 9s linear infinite; }
.rays.on { opacity: 1; }
.rays.r-rare { filter: hue-rotate(170deg) saturate(1.4); }
.rays.r-epic { filter: hue-rotate(230deg) saturate(1.6); }
@keyframes spin { to { transform: rotate(360deg); } }
.chest { position: relative; font-size: 130px; line-height: 1; background: none; border: 0; cursor: pointer; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .5)); animation: chestidle 1.6s ease-in-out infinite; padding: 0; }
.chest.s1 { animation: chestshake .35s; }
.chest.s2 { animation: chestshake2 .35s; }
.chest.s3 { animation: chestshake3 .4s; }
@keyframes chestidle { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }
@keyframes chestshake { 0%, 100% { transform: scale(1.05) rotate(0); } 25% { transform: scale(1.08) rotate(-9deg); } 75% { transform: scale(1.08) rotate(9deg); } }
@keyframes chestshake2 { 0%, 100% { transform: scale(1.12) rotate(0); } 25% { transform: scale(1.16) rotate(-13deg); } 75% { transform: scale(1.16) rotate(13deg); } }
@keyframes chestshake3 { 0%, 100% { transform: scale(1.2) rotate(0); } 20% { transform: scale(1.28) rotate(-16deg); } 50% { transform: scale(1.3) rotate(16deg); } 80% { transform: scale(1.28) rotate(-12deg); } }
.taps { font: 700 20px/1.2 var(--font-h); color: var(--gold); margin-top: 4px; }
.reveal { position: relative; display: flex; flex-direction: column; align-items: center; animation: revealin .7s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes revealin { 0% { transform: scale(.1) rotate(-200deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.reveal .em { font-size: 120px; line-height: 1.05; filter: drop-shadow(0 0 26px var(--rc, #fff)); animation: floaty 2s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-8px) scale(1.04); } }
.reveal .rn { font: 700 28px/1.1 var(--font-h); margin-top: 6px; }
.rar { display: inline-block; margin-top: 8px; padding: 4px 14px; border-radius: 999px; font: 700 15px/1.3 var(--font-h); letter-spacing: 2px; color: #10102a; }
.rar.common { background: var(--r-common); }
.rar.rare { background: var(--r-rare); }
.rar.epic { background: var(--r-epic); color: #fff; }
.rar.legend { background: linear-gradient(90deg, #ffe680, #ffb21f, #ffe680); background-size: 200% 100%; animation: shine 1.4s linear infinite; }
@keyframes shine { to { background-position: -200% 0; } }
.reveal.common { --rc: rgba(159, 179, 217, .9); }
.reveal.rare { --rc: rgba(63, 169, 255, .95); }
.reveal.epic { --rc: rgba(180, 107, 255, .95); }
.reveal.legend { --rc: rgba(255, 201, 63, 1); }
.newtag { position: absolute; top: -6px; right: -30px; padding: 4px 10px; border-radius: 10px; background: var(--pink); font: 700 16px/1.2 var(--font-h); transform: rotate(12deg); box-shadow: 0 3px 0 var(--pink-d); animation: dotpop .5s .3s both cubic-bezier(.2, 1.8, .4, 1); }
.dupe { margin-top: 10px; color: var(--muted); font-size: 18px; }
.dupe b { color: var(--gold); }
.planet-big { width: 150px; height: 150px; display: block; margin: 0 auto 8px; }

/* ---------- album ---------- */
.album-head { padding: 16px; margin-bottom: 14px; }
.album-head .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font: 700 20px/1.2 var(--font-h); }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.cr { position: relative; padding: 12px 6px 10px; border-radius: 20px; text-align: center; background: rgba(0, 0, 0, .3); border: 3px solid var(--r-common); }
.cr.rare { border-color: var(--r-rare); }
.cr.epic { border-color: var(--r-epic); box-shadow: 0 0 14px rgba(180, 107, 255, .35); }
.cr.legend { border-color: var(--r-legend); box-shadow: 0 0 18px rgba(255, 201, 63, .45); }
.cr .em { font-size: 48px; line-height: 1.1; }
.cr .nm { font: 700 14px/1.15 var(--font-h); margin-top: 6px; min-height: 2.3em; display: flex; align-items: center; justify-content: center; }
.cr .x { position: absolute; top: 6px; right: 8px; font: 700 13px/1 var(--font-h); color: var(--muted); }
.cr.no { border-color: rgba(255, 255, 255, .12); box-shadow: none; }
.cr.no .em { filter: brightness(0) invert(1); opacity: .12; }
.cr.no .nm { color: var(--dim); }

/* ---------- hangar ---------- */
.hangar-hero { position: relative; height: 230px; margin-bottom: 8px; }
.hangar-hero .slot { position: absolute; inset: 0; cursor: pointer; }
.tabs { display: flex; gap: 8px; justify-content: center; margin: 4px 0 14px; }
.tabs .btn { min-height: 50px; font-size: 20px; padding: 8px 20px; }
.tabs .btn.ghost.on { background: rgba(63, 224, 255, .25); border-color: var(--cyan); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.item { padding: 12px 10px; border-radius: 22px; background: rgba(0, 0, 0, .3); border: 3px solid rgba(255, 255, 255, .14); display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.item.active { border-color: var(--green); box-shadow: 0 0 16px rgba(63, 224, 255, .3); }
.item canvas { width: 80px; height: 110px; }
.item .ic { font-size: 56px; height: 110px; display: grid; place-items: center; line-height: 1; }
.item .nm { font: 700 18px/1.1 var(--font-h); min-height: 2.2em; display: flex; align-items: center; }
.item .btn { width: 100%; min-height: 48px; font-size: 18px; padding: 6px 10px; border-radius: 16px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); z-index: 90; transform: translate(-50%, -140%); padding: 12px 20px; border-radius: 18px; background: linear-gradient(180deg, #3a2fa8, #2a1f80); border: 2px solid var(--edge); font: 700 20px/1.2 var(--font-h); box-shadow: 0 12px 30px rgba(0, 0, 0, .45); transition: transform .45s cubic-bezier(.2, 1.4, .4, 1); white-space: nowrap; }
.toast.on { transform: translate(-50%, 0); }

.shake-s { animation: scrshake .35s; }
.shake-l { animation: scrshake2 .55s; }
@keyframes scrshake { 0%, 100% { transform: none; } 25% { transform: translate(-5px, 3px); } 50% { transform: translate(5px, -3px); } 75% { transform: translate(-3px, -2px); } }
@keyframes scrshake2 { 0%, 100% { transform: none; } 15% { transform: translate(-10px, 6px); } 30% { transform: translate(9px, -6px); } 45% { transform: translate(-7px, -4px); } 60% { transform: translate(6px, 5px); } 80% { transform: translate(-3px, 2px); } }

@media (prefers-reduced-motion: reduce) {
  .nebula, .play-btn, .combo .fire, .chest { animation: none; }
  .shake-s, .shake-l { animation: none; }
}
@media (max-width: 420px) {
  .btn.big { font-size: 28px; min-height: 70px; }
  .home-row .btn { font-size: 16px; }
  .node .c { width: 58px; height: 58px; font-size: 24px; }
  .nodes::before { top: 29px; }
  .world-head canvas { width: 70px; height: 70px; }
  .world-head .wn { font-size: 19px; }
  .chest { font-size: 110px; }
}
