/* Yunusbek's Brain Gym: a game world in space.
   Deep-night backdrop, glossy planets, chunky 3D buttons, a little alien coach.
   Every planet has its own color: sun = plus, pink = times, mint = Arabic, sky = arcade. */
:root {
  --night: #2a1309;
  --night2: #4b2412;
  --glass: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.17);
  --ink: #2a1309;
  --white: #ffffff;
  --lime: #b8ff3d;   --lime-d: #6fa800;
  --sun: #ffcf33;    --sun-d: #c48a00;
  --pink: #ff4f8b;   --pink-d: #b81c5a;
  --mint: #2ee6a6;   --mint-d: #0f8f66;
  --sky: #3dd2ff;    --sky-d: #0a84ae;
  --violet: #a569ff; --violet-d: #6a35c4;
  --red: #ff4d5e;    --red-d: #b01f30;
  --a: var(--violet); --ad: var(--violet-d);
  --display: "Bagel Fat One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --arabic: "Baloo Bhaijaan 2", "Noto Naskh Arabic", "Segoe UI", system-ui, sans-serif;
}
[data-accent="sun"] { --a: var(--sun); --ad: var(--sun-d); }
[data-accent="pink"] { --a: var(--pink); --ad: var(--pink-d); }
[data-accent="mint"] { --a: var(--mint); --ad: var(--mint-d); }
[data-accent="sky"] { --a: var(--sky); --ad: var(--sky-d); }
[data-accent="violet"] { --a: var(--violet); --ad: var(--violet-d); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--night);
  color: var(--white);
  font-family: var(--body);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- Space backdrop (fixed behind everything) ---------- */
.space {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(60vmax 45vmax at 12% 6%, rgba(122, 70, 255, 0.55), transparent 60%),
    radial-gradient(55vmax 40vmax at 92% 28%, rgba(255, 70, 160, 0.30), transparent 60%),
    radial-gradient(60vmax 45vmax at 20% 100%, rgba(30, 190, 255, 0.28), transparent 60%),
    linear-gradient(180deg, var(--night2), var(--night));
}
.space::before, .space::after { content: ""; position: absolute; inset: 0; }
.space::before {
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 120px, #fff, transparent),
    radial-gradient(2px 2px at 160px 60px, #ffe9a8, transparent),
    radial-gradient(1px 1px at 230px 180px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 60px 210px, #bfe9ff, transparent),
    radial-gradient(1px 1px at 280px 20px, #fff, transparent);
  background-size: 300px 260px;
  opacity: 0.8;
}
.space::after {
  background-image:
    radial-gradient(2px 2px at 40px 80px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 170px 170px, #ffd6ec, transparent),
    radial-gradient(2px 2px at 120px 20px, #fff, transparent);
  background-size: 210px 230px;
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.2; } to { opacity: 0.95; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--sun); color: var(--ink); padding: 8px 14px; border-radius: 10px; z-index: 90; }
.skip:focus { left: 8px; }
:focus-visible { outline: 4px solid var(--white); outline-offset: 3px; box-shadow: 0 0 0 7px var(--violet-d); }

h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.15; margin: 0 0 10px; }
h3 { font-size: 1.8rem; color: var(--a); }
p { margin: 0 0 12px; }
.muted { opacity: 0.7; }
.small { font-size: 0.95rem; }
.label { font-weight: 800; margin: 16px 0 8px; }

/* ---------- Chunky 3D buttons ---------- */
.btn, .key, .test-card, .choice, .step, .tool {
  --c: var(--sun); --cd: var(--sun-d);
}
.btn {
  font-family: var(--display); font-size: 1.25rem;
  background: var(--c); color: var(--ink);
  border: 0; border-radius: 18px; padding: 10px 28px 12px;
  box-shadow: 0 6px 0 var(--cd), 0 10px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--cd), 0 3px 6px rgba(0, 0, 0, 0.3); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-pink { --c: var(--pink); --cd: var(--pink-d); }
.btn-mint { --c: var(--mint); --cd: var(--mint-d); }
.btn-sky { --c: var(--sky); --cd: var(--sky-d); }
.btn-ghost { --c: rgba(255, 255, 255, 0.14); --cd: rgba(0, 0, 0, 0.35); color: var(--white); }
.link { background: none; border: 0; color: inherit; font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(42, 19, 9, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 8px 20px;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 1.6rem; color: var(--white); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: block; }
.hud { display: flex; align-items: center; gap: 12px; flex: 1 1 320px; min-width: 0; }
.lvlbadge {
  width: 46px; height: 46px; flex: none; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--lime), #5fd01c);
  color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; transform: rotate(45deg);
  box-shadow: 0 3px 0 var(--lime-d);
}
.lvlbadge b { transform: rotate(-45deg); font-family: var(--display); font-weight: 400; font-size: 1.3rem; }
.xpwrap { flex: 1 1 100px; min-width: 70px; }
.xptext { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; font-weight: 800; line-height: 1.2; margin-bottom: 3px; white-space: nowrap; }
.xptext span:last-child { opacity: 0.75; }
.xpbar { height: 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.2); }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--lime), var(--mint)); border-radius: 999px; transition: width 0.5s; }
.pill { background: rgba(255, 255, 255, 0.12); border: 2px solid var(--line); border-radius: 999px; padding: 1px 12px; font-weight: 800; white-space: nowrap; }
.iconbtn {
  width: 40px; height: 40px; flex: none; border-radius: 12px; border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.1); color: var(--white); font-size: 1.2rem; cursor: pointer; line-height: 1;
}
.iconbtn[aria-pressed="false"] { opacity: 0.5; background: rgba(0, 0, 0, 0.3); text-decoration: line-through; }

.tabs { display: flex; gap: 4px; }
.tabs a {
  display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--white);
  padding: 6px 14px; border-radius: 14px; font-weight: 800; border: 2px solid transparent;
}
.tabs a:hover { background: rgba(255, 255, 255, 0.1); }
.tabs a[aria-current="page"] { background: var(--white); color: var(--ink); }

/* ---------- Layout and cards ---------- */
main { max-width: 1040px; margin: 0 auto; padding: 0 20px 40px; }
.view { display: grid; gap: 28px; padding-top: 26px; }
.menu { display: grid; gap: 28px; }
.menu.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.quiz-host { display: none; }
.view.in-quiz .quiz-host { display: block; }
.view.in-quiz .menu, .view.in-quiz .banner { display: none; }

.card {
  background: var(--glass);
  border: 2px solid var(--line);
  border-radius: 28px;
  padding: 24px 28px 28px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
}
.card h2 { font-size: 1.7rem; color: var(--a); }
.section-h { font-size: 2rem; margin: 6px 0 -8px; }

.banner { display: flex; align-items: center; gap: 16px; }
.banner h2 { font-size: clamp(2.2rem, 7vw, 3.4rem); margin: 0; -webkit-text-stroke: 0.05em var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ad); color: var(--a); }

/* ---------- Planets ---------- */
.orb {
  --glow: rgba(255, 255, 255, 0.3);
  width: 150px; height: 150px; flex: none; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.85) 0 5%, rgba(255, 255, 255, 0) 16%),
    radial-gradient(circle at 36% 32%, var(--a) 0 40%, var(--ad) 100%);
  box-shadow: inset -16px -18px 0 rgba(0, 0, 0, 0.2), 0 0 50px var(--glow);
}
.orb b { font-family: var(--display); font-weight: 400; font-size: 3.2rem; line-height: 1; color: var(--white); -webkit-text-stroke: 0.06em var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
.orb .arabic-b { font-family: var(--arabic); font-weight: 800; font-size: 4.4rem; }
.orb.ringed::after {
  content: ""; position: absolute; left: -26%; right: -26%; top: 36%; bottom: 36%;
  border: 7px solid rgba(255, 255, 255, 0.6); border-radius: 50%;
  transform: rotate(-16deg); pointer-events: none;
}
.orb.mini { width: 68px; height: 68px; box-shadow: inset -7px -8px 0 rgba(0, 0, 0, 0.2), 0 0 24px var(--glow); }
.orb.mini b { font-size: 1.6rem; }
.orb.mini .arabic-b { font-size: 2.3rem; }
.orb.mini.ringed::after { border-width: 4px; }

.galaxy { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 30px 20px; padding: 12px 0 4px; }
.planet { display: grid; justify-items: center; gap: 6px; text-align: center; text-decoration: none; color: var(--white); padding: 10px 0 14px; border-radius: 24px; }
.planet strong { font-family: var(--display); font-weight: 400; font-size: 1.5rem; line-height: 1.1; margin-top: 10px; }
.planet small { font-weight: 800; opacity: 0.8; font-size: 0.98rem; }
.planet .orb { transition: transform 0.2s; animation: bob 6s ease-in-out infinite; }
.planet:nth-child(2) .orb { animation-delay: -1.5s; }
.planet:nth-child(3) .orb { animation-delay: -3s; }
.planet:nth-child(4) .orb { animation-delay: -4.5s; }
.planet:hover .orb, .planet:focus-visible .orb { transform: scale(1.1) rotate(-4deg); }
.planet:active .orb { transform: scale(0.96); }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -12px; } }
.pl-sun { --a: var(--sun); --ad: var(--sun-d); }
.pl-sun .orb { --glow: rgba(255, 207, 51, 0.55); }
.pl-pink { --a: var(--pink); --ad: var(--pink-d); }
.pl-pink .orb { --glow: rgba(255, 93, 158, 0.55); }
.pl-mint { --a: var(--mint); --ad: var(--mint-d); }
.pl-mint .orb { --glow: rgba(46, 230, 166, 0.5); }
.pl-sky { --a: var(--sky); --ad: var(--sky-d); }
.pl-sky .orb { --glow: rgba(61, 210, 255, 0.55); }
.banner .orb { --glow: color-mix(in srgb, var(--a) 60%, transparent); }

/* ---------- Home hero ---------- */
.hero { display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap; padding: 10px 0 0; }
.hero-mascot { width: clamp(150px, 26vw, 230px); flex: none; filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.4)); }
.hero-text { flex: 1 1 340px; min-width: 0; }
.hello { font-family: var(--display); font-size: 1.5rem; margin: 0; color: var(--lime); transform: rotate(-3deg); transform-origin: left; }
#name { font-family: var(--display); font-weight: 400; font-size: clamp(3.2rem, 13vw, 7.6rem); line-height: 1.05; margin: 0; display: flex; flex-wrap: wrap; }
.word { display: inline-flex; white-space: nowrap; }
.letter {
  display: inline-block; padding: 0; border: 0; background: none; font: inherit; color: var(--c, #fff); cursor: pointer;
  -webkit-text-stroke: 0.07em var(--ink); paint-order: stroke fill; text-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.35);
  transition: color 0.15s;
}
.letter.pop { animation: pop 0.55s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop {
  0% { transform: translateY(0) rotate(0) scale(1); }
  35% { transform: translateY(-0.28em) rotate(-10deg) scale(1.2); }
  100% { transform: translateY(0) rotate(0) scale(1); }
}
.tagline { font-size: 1.3rem; font-weight: 800; max-width: 30ch; margin: 12px 0 0; }
.hint { display: inline-block; margin: 12px 0 0; padding: 2px 14px; background: var(--sun); color: var(--ink); border-radius: 999px; font-weight: 800; font-size: 0.95rem; transform: rotate(2deg); transition: opacity 0.4s; box-shadow: 0 3px 0 var(--sun-d); }
.hint.gone { opacity: 0; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.quest, .levelcard { display: flex; align-items: center; gap: 20px; }
.quest p, .levelcard p { margin: 0; }
.ring {
  --p: 0; width: 92px; height: 92px; flex: none; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--sun) calc(var(--p) * 1%), rgba(255, 255, 255, 0.16) 0);
  font-family: var(--display); font-size: 1.15rem;
}
.ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--night2); }
.ring span { position: relative; }
.lc-badge { width: 76px; height: 76px; flex: none; display: grid; place-items: center; background: linear-gradient(160deg, var(--lime), #5fd01c); border: 4px solid var(--ink); border-radius: 22px; transform: rotate(45deg); box-shadow: 0 5px 0 var(--lime-d); margin: 8px; }
.lc-badge b { transform: rotate(-45deg); font-family: var(--display); font-weight: 400; font-size: 2.2rem; color: var(--ink); }
.levelcard h2 { color: var(--lime); }

.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 14px; }
.badge { border-radius: 20px; padding: 12px 8px; background: rgba(0, 0, 0, 0.25); border: 2px dashed var(--line); text-align: center; line-height: 1.25; }
.badge span { display: grid; place-items: center; width: 60px; height: 60px; margin: 0 auto 6px; border-radius: 50%; font-size: 1.9rem; background: rgba(255, 255, 255, 0.08); filter: grayscale(1); opacity: 0.5; }
.badge b { display: block; font-size: 0.98rem; }
.badge small { font-size: 0.82rem; opacity: 0.75; }
.badge.on { background: rgba(255, 207, 51, 0.16); border: 2px solid var(--sun); }
.badge.on span { filter: none; opacity: 1; background: radial-gradient(circle at 35% 30%, #fff3b0, var(--sun) 60%, var(--sun-d)); box-shadow: 0 0 18px rgba(255, 207, 51, 0.6); }

/* ---------- Chips, steppers, tips ---------- */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  font-family: var(--body); font-weight: 800; font-size: 1.05rem; color: var(--white);
  background: rgba(255, 255, 255, 0.1); border: 2px solid var(--line); border-radius: 999px; padding: 5px 16px; cursor: pointer;
}
.chip-btn:hover { background: rgba(255, 255, 255, 0.2); }
.chip-btn.on { background: var(--a); color: var(--ink); border-color: transparent; box-shadow: 0 3px 0 var(--ad); }
.tip { background: rgba(255, 255, 255, 0.09); border-left: 6px solid var(--a); border-radius: 12px; padding: 8px 14px; margin: 14px 0 0; }

/* ---------- Plus planet: dot lab ---------- */
.lab-ctrl { display: flex; flex-wrap: wrap; gap: 14px 26px; align-items: center; margin: 14px 0; }
.stepper { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.stepper output { font-family: var(--display); font-size: 1.9rem; min-width: 2ch; text-align: center; }
.step { --c: var(--white); --cd: #dcc4a0; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--c); color: var(--ink); box-shadow: 0 4px 0 var(--cd); font-family: var(--display); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.step:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cd); }
.lab-stage { background: var(--white); color: var(--ink); border-radius: 22px; min-height: 120px; padding: 16px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.dotgroup { display: flex; flex-wrap: wrap; gap: 6px; max-width: 290px; }
.dot { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffa9cf, var(--pink)); box-shadow: inset -3px -4px 0 rgba(0, 0, 0, 0.15); }
.dot.d2 { background: radial-gradient(circle at 35% 30%, #9fb0ff, #4666ff); }
.dot.d3 { background: transparent; border: 3px dashed #aaa; box-shadow: none; position: relative; }
.dot.d3::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.8rem; font-weight: 800; color: #999; }
.sym { font-family: var(--display); font-size: 2.2rem; }
.lab-eq { font-family: var(--display); font-size: 2.6rem; margin: 14px 0 0; line-height: 1.1; color: var(--a); }

/* ---------- Times planet ---------- */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; margin-bottom: 14px; }
.picker .chip-btn { padding: 6px 0; text-align: center; font-size: 1.15rem; }
.picker .chip-btn.done::after { content: " ✓"; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 800; margin-bottom: 12px; }
.check input { width: 22px; height: 22px; accent-color: var(--pink); }
.t-grid { display: grid; grid-template-columns: minmax(200px, 290px) 1fr; gap: 20px; align-items: start; }
.t-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.t-row { width: 100%; text-align: left; cursor: pointer; background: rgba(255, 255, 255, 0.1); border: 2px solid var(--line); border-radius: 14px; padding: 3px 14px; font-family: var(--display); font-size: 1.35rem; color: var(--white); }
.t-row:hover { background: rgba(255, 255, 255, 0.2); }
.t-row.on { background: var(--a); color: var(--ink); border-color: transparent; }
.t-row .ans.hid { color: transparent; background: rgba(255, 255, 255, 0.25); border-radius: 6px; }
.t-visual { background: var(--white); color: var(--ink); border-radius: 22px; padding: 16px; min-height: 160px; overflow: auto; }
.array { display: grid; grid-template-columns: repeat(var(--cols), 16px); gap: 4px; margin-bottom: 8px; }
.array i { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffa9cf, var(--pink)); }
.test-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.test-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer;
  background: var(--c); color: var(--ink); border: 0; border-radius: 22px; padding: 16px 20px 18px;
  box-shadow: 0 6px 0 var(--cd), 0 12px 20px rgba(0, 0, 0, 0.3);
  font-family: var(--body); font-size: 1rem; font-weight: 700; transition: transform 0.08s, box-shadow 0.08s;
}
.test-card strong { font-family: var(--display); font-weight: 400; font-size: 1.45rem; }
.test-card.c1 { --c: var(--sun); --cd: var(--sun-d); }
.test-card.c2 { --c: var(--mint); --cd: var(--mint-d); }
.test-card.c3 { --c: var(--pink); --cd: var(--pink-d); }
.test-card:hover { filter: brightness(1.07); }
.test-card:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--cd); }

/* ---------- Arabic moon ---------- */
.ar { font-family: var(--arabic); font-weight: 800; }
.flash-wrap { margin-top: 16px; display: grid; gap: 14px; justify-items: center; }
.flash {
  width: 100%; max-width: 480px; min-height: 280px; background: var(--white); color: var(--ink);
  border: 0; border-radius: 30px; box-shadow: 0 8px 0 #e3c9a3, 0 18px 30px rgba(0, 0, 0, 0.35);
  display: grid; place-content: center; gap: 4px; text-align: center; cursor: pointer; padding: 16px;
}
.flash .emo { font-size: 3.6rem; line-height: 1.1; }
.flash .ar { font-size: 5.4rem; line-height: 1.3; }
.flash .en-big { font-family: var(--display); font-size: 3rem; line-height: 1.1; }
.flash .tr { font-size: 1.5rem; font-weight: 800; opacity: 0.7; }
.flash.flip { animation: flipin 0.3s ease-out; }
@keyframes flipin { from { transform: rotateX(80deg) scale(0.95); } to { transform: none; } }
.flash-ctrl { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.flash-ctrl .btn { font-size: 1.05rem; padding: 8px 20px 10px; }
.flash-note { font-weight: 800; margin: 0; opacity: 0.85; }

/* ---------- Mascot ---------- */
.mascot { width: 100%; height: auto; display: block; overflow: visible; }
.mascot [data-m] { display: none; }
.mascot[data-mood="happy"] [data-m="happy"],
.mascot[data-mood="sad"] [data-m="sad"],
.mascot[data-mood="wow"] [data-m="wow"],
.mascot[data-mood="cheer"] [data-m="cheer"] { display: inline; }
.mascot .body { transform-origin: 100px 180px; }
.hero-mascot .mascot .body { animation: float 4s ease-in-out infinite; }
.mascot.jump .body { animation: jump 0.5s ease-out; }
.mascot.shake .body { animation: shakeit 0.45s; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-9px) rotate(2deg); } }
@keyframes jump { 0% { transform: scale(1, 1); } 30% { transform: translateY(-22px) scale(0.94, 1.08); } 60% { transform: translateY(0) scale(1.08, 0.92); } 100% { transform: none; } }
@keyframes shakeit { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px) rotate(-4deg); } 40% { transform: translateX(9px) rotate(3deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }

/* ---------- Test mode (quiz engine) ---------- */
.quiz { max-width: 760px; margin: 0 auto; position: relative; }
.q-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.quit { width: 40px; height: 40px; flex: none; border-radius: 12px; border: 2px solid var(--line); background: rgba(255, 255, 255, 0.1); color: var(--white); font-size: 1.1rem; font-weight: 800; cursor: pointer; }
.segs { flex: 1; display: flex; gap: 4px; }
.segs i { flex: 1; height: 14px; border-radius: 99px; background: rgba(255, 255, 255, 0.16); }
.segs i.ok { background: var(--lime); }
.segs i.bad { background: var(--red); }
.segs i.cur { background: var(--white); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 0.4; } to { opacity: 1; } }
.bar { flex: 1; height: 14px; border-radius: 99px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--lime), var(--mint)); border-radius: 99px; transition: width 0.3s; }
.count { font-weight: 800; white-space: nowrap; }
.combo { font-weight: 800; padding: 1px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); white-space: nowrap; border: 2px solid var(--line); }
.combo.hot { background: var(--sun); color: var(--ink); border-color: transparent; box-shadow: 0 0 18px rgba(255, 207, 51, 0.7); }
.timer { position: relative; height: 26px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); overflow: hidden; margin-bottom: 12px; border: 2px solid var(--line); }
.timer i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(90deg, var(--sky), var(--mint)); transition: width 0.1s linear; }
.timer .tnum { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 1rem; color: var(--ink); mix-blend-mode: normal; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }
.timer.low i { background: linear-gradient(90deg, var(--red), var(--sun)); }
.timer.low { animation: nudge 0.5s infinite; }
@keyframes nudge { 50% { transform: scale(1.015); } }

.q-stage { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.q-mascot { width: 84px; flex: none; }
.bubble { position: relative; background: var(--white); color: var(--ink); border-radius: 18px; padding: 8px 16px; font-weight: 800; margin: 0; flex: 1; min-height: 2.6em; display: flex; align-items: center; }
.bubble::before { content: ""; position: absolute; left: -10px; top: 50%; margin-top: -9px; border: 9px solid transparent; border-right-color: var(--white); border-left: 0; }
.bubble .ar { font-size: 1.3em; }

.q-card { background: var(--white); color: var(--ink); border-radius: 28px; padding: 18px 22px 22px; text-align: center; box-shadow: 0 8px 0 #e3c9a3, 0 18px 30px rgba(0, 0, 0, 0.35); margin-bottom: 20px; }
.q-card.good { animation: goodpulse 0.4s; }
.q-card.bad { animation: shakeit 0.45s; }
@keyframes goodpulse { 50% { transform: scale(1.03); box-shadow: 0 8px 0 #e3c9a3, 0 0 40px rgba(184, 255, 61, 0.9); } }
.q-title { font-weight: 800; opacity: 0.55; margin: 0 0 2px; font-size: 0.95rem; }
.q-prompt { font-family: var(--display); font-size: clamp(2.6rem, 11vw, 4.6rem); line-height: 1.2; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 18px; }
.q-prompt .emo { font-size: 0.9em; }
.q-prompt .ar { font-size: 1.25em; }
.speak { font-size: 1.5rem; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--mint); box-shadow: 0 4px 0 var(--mint-d); cursor: pointer; }
.speak:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--mint-d); }

/* keypad */
.numarea { display: grid; justify-items: center; gap: 14px; }
.num-display {
  min-width: 190px; text-align: center; font-family: var(--display); font-size: 3.2rem; line-height: 1.2; padding: 2px 24px;
  background: rgba(0, 0, 0, 0.35); border: 3px solid var(--line); border-radius: 20px; color: var(--white);
}
.num-display .ph { opacity: 0.3; }
.num-display.good { border-color: var(--lime); color: var(--lime); }
.num-display.bad { border-color: var(--red); color: #ff8a96; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(100%, 340px); }
.key {
  --c: var(--white); --cd: #dcc4a0;
  font-family: var(--display); font-size: 1.9rem; color: var(--ink); background: var(--c);
  border: 0; border-radius: 18px; padding: 8px 0 10px; cursor: pointer; box-shadow: 0 6px 0 var(--cd);
  transition: transform 0.06s, box-shadow 0.06s;
}
.key:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--cd); }
.key-del { --c: var(--sun); --cd: var(--sun-d); }
.key-go { --c: var(--lime); --cd: var(--lime-d); }
.key:disabled { opacity: 0.5; }

/* choices */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.choice {
  position: relative; font-family: var(--display); font-size: 1.6rem; line-height: 1.2; color: var(--ink);
  background: var(--c); border: 0; border-radius: 22px; padding: 16px 12px 18px; min-height: 80px; cursor: pointer;
  box-shadow: 0 6px 0 var(--cd), 0 12px 18px rgba(0, 0, 0, 0.25); transition: transform 0.06s, box-shadow 0.06s, opacity 0.2s;
}
.choice:nth-child(1) { --c: var(--sun); --cd: var(--sun-d); }
.choice:nth-child(2) { --c: var(--sky); --cd: var(--sky-d); }
.choice:nth-child(3) { --c: var(--pink); --cd: var(--pink-d); }
.choice:nth-child(4) { --c: var(--mint); --cd: var(--mint-d); }
.choice .hk { position: absolute; left: 12px; top: 8px; font-family: var(--body); font-size: 0.8rem; font-weight: 800; opacity: 0.55; }
.choice .ar { font-size: 2.5rem; }
.choice:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--cd); }
.choice.right { --c: var(--lime); --cd: var(--lime-d); }
.choice.wrong { --c: var(--red); --cd: var(--red-d); color: var(--white); }
.choice.gone { opacity: 0.15; }
.choice:disabled:not(.right):not(.wrong) { cursor: default; }
.q-tools { display: flex; justify-content: center; margin-top: 18px; min-height: 8px; }
.tool { --c: rgba(255, 255, 255, 0.14); --cd: rgba(0, 0, 0, 0.4); font-family: var(--body); font-weight: 800; font-size: 1rem; color: var(--white); background: var(--c); border: 0; border-radius: 14px; padding: 6px 16px 8px; box-shadow: 0 4px 0 var(--cd); cursor: pointer; }
.tool:disabled { opacity: 0.4; cursor: default; }
.next-row { display: flex; justify-content: center; margin-top: 16px; min-height: 8px; }

/* Get ready overlay */
.get-ready { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; background: rgba(42, 19, 9, 0.94); border-radius: 28px; min-height: 380px; cursor: pointer; }
.get-ready .gm { width: 130px; }
.get-ready p { margin: 0; font-weight: 800; }
.get-ready .cd { font-family: var(--display); font-size: 6rem; line-height: 1; color: var(--sun); animation: cdpop 0.8s ease-out; }
@keyframes cdpop { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Report card */
.results { text-align: center; }
.stamp { width: 150px; height: 150px; margin: 6px auto 8px; display: grid; place-items: center; border-radius: 50%; border: 8px double currentColor; font-family: var(--display); font-size: 4.6rem; line-height: 1; transform: rotate(-8deg); animation: stampin 0.5s cubic-bezier(.2, 1.6, .4, 1) both; background: rgba(0, 0, 0, 0.25); }
.stamp.g-A { color: var(--lime); }
.stamp.g-B { color: var(--sky); }
.stamp.g-C { color: var(--sun); }
.stamp.g-D, .stamp.g-E { color: var(--pink); }
@keyframes stampin { from { transform: rotate(-30deg) scale(3); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
.results h3 { font-size: 2.3rem; margin: 6px 0 4px; color: var(--white); }
.verdict { font-family: var(--display); font-size: 1.3rem; margin: 0 0 6px; }
.verdict.pass { color: var(--lime); }
.verdict.fail { color: var(--sun); }
.rstars { font-size: 3.2rem; letter-spacing: 6px; margin: 4px 0 12px; }
.rstars span { display: inline-block; animation: starin 0.5s cubic-bezier(.2, 1.8, .4, 1) both; animation-delay: var(--d); }
@keyframes starin { from { transform: scale(0) rotate(-120deg); opacity: 0; } to { transform: none; opacity: 1; } }
.rgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 10px 0 18px; }
.rgrid div { background: rgba(255, 255, 255, 0.09); border: 2px solid var(--line); border-radius: 18px; padding: 8px 6px; }
.rgrid b { display: block; font-family: var(--display); font-weight: 400; font-size: 1.9rem; line-height: 1.1; }
.rgrid span { font-size: 0.9rem; font-weight: 800; opacity: 0.75; }
.results ul { list-style: none; padding: 0; margin: 10px auto 18px; max-width: 440px; text-align: left; display: grid; gap: 6px; }
.results li { background: rgba(255, 93, 158, 0.18); border-left: 6px solid var(--pink); border-radius: 12px; padding: 4px 12px; font-weight: 800; }
.results .row { justify-content: center; margin-top: 12px; }

/* ---------- Rocket Dash ---------- */
.dash-stage { position: relative; width: min(100%, 420px); margin: 14px auto; border-radius: 26px; overflow: hidden; background: #1f0e06; box-shadow: 0 0 0 4px var(--a), 0 0 40px rgba(61, 210, 255, 0.35); touch-action: none; user-select: none; }
.dash-hud { position: absolute; left: 0; right: 0; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; background: linear-gradient(180deg, rgba(30, 12, 5, 0.95), rgba(30, 12, 5, 0)); font-weight: 800; pointer-events: none; }
.dash-q { font-family: var(--display); font-size: 1.7rem; color: var(--sun); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); text-align: center; flex: 1; line-height: 1.1; }
.dash-q .ar { font-size: 1.3em; }
#dash-score { font-family: var(--display); font-size: 1.6rem; min-width: 2ch; text-align: right; }
#dash-hearts { letter-spacing: 1px; font-size: 1.1rem; min-width: 4.2em; }
#dash-canvas { display: block; width: 100%; touch-action: none; }
.dash-overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; background: rgba(30, 12, 5, 0.82); padding: 20px; }
.dash-overlay h4 { font-family: var(--display); font-weight: 400; font-size: 2.2rem; margin: 0; color: var(--sun); }
.dash-overlay p { margin: 0; font-weight: 800; }
.dash-overlay .big { font-family: var(--display); font-size: 4rem; line-height: 1; }
.dash-overlay.hide { display: none; }

/* ---------- Star catcher and jokes ---------- */
.joke-q { font-family: var(--display); font-size: 1.7rem; line-height: 1.25; margin: 0 0 6px; max-width: 30ch; }
.joke-a { font-size: 1.4rem; font-weight: 800; min-height: 2.2em; margin: 0 0 14px; color: var(--lime); }
.scoreboard { display: flex; flex-wrap: wrap; gap: 6px 24px; font-weight: 800; margin-bottom: 14px; }
.scoreboard strong { font-family: var(--display); font-weight: 400; font-size: 1.5rem; }
.arena { position: relative; height: 320px; background: #1f0e06; border-radius: 22px; overflow: hidden; display: grid; place-items: center; touch-action: manipulation; box-shadow: 0 0 0 3px var(--line); }
.arena .msg { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; font-family: var(--display); font-size: 1.7rem; padding: 16px; background: rgba(30, 12, 5, 0.88); }
.arena .msg p { margin: 0; }
.star { position: absolute; width: 64px; height: 64px; border: 0; background: none; padding: 0; font-size: 3.2rem; line-height: 1; cursor: pointer; animation: appear 0.2s ease-out; filter: drop-shadow(0 0 10px rgba(255, 207, 51, 0.8)); }
@keyframes appear { from { transform: scale(0); } to { transform: scale(1); } }

/* ---------- Toasts, bursts, footer ---------- */
.toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--sun); color: var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--sun-d), 0 14px 24px rgba(0, 0, 0, 0.4); padding: 8px 16px; font-weight: 800; text-align: center; animation: drop 0.3s ease-out; }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
.burst-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.bit { position: absolute; font-size: 1.6rem; animation: fly 0.8s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
footer { max-width: 1040px; margin: 0 auto; padding: 0 20px 60px; font-weight: 800; opacity: 0.85; }
footer .link { font-size: 0.9rem; opacity: 0.7; }

/* ---------- Small screens: tabs move to the bottom ---------- */
@media (max-width: 760px) {
  body { padding-bottom: 88px; font-size: 1.05rem; }
  .topbar { padding: 8px 14px; gap: 6px 12px; }
  .brand { font-size: 1.35rem; }
  .brand-mark { width: 36px; height: 36px; }
  .hud { flex-basis: 100%; order: 3; gap: 8px; }
  .lvlbadge { width: 38px; height: 38px; border-radius: 11px; margin: 2px 4px; }
  .lvlbadge b { font-size: 1.05rem; }
  .xptext span:last-child { display: none; }
  .iconbtn { width: 36px; height: 36px; font-size: 1.05rem; }
  .pill { padding: 0 8px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(42, 19, 9, 0.96); backdrop-filter: blur(12px); border-top: 2px solid var(--line); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabs a { flex-direction: column; gap: 0; padding: 2px 10px; font-size: 0.8rem; line-height: 1.2; }
  .tabs a span { font-size: 1.5rem; }
  .toasts { top: 124px; }
  main { padding: 0 14px 30px; }
  .card { padding: 20px 18px 24px; }
  .t-grid { grid-template-columns: 1fr; }
  .hero { justify-content: center; text-align: center; }
  #name { justify-content: center; }
  .tagline { margin-inline: auto; }
  .orb { width: 128px; height: 128px; }
  .orb b { font-size: 2.7rem; }
  .q-mascot { width: 64px; }
  .flash .ar { font-size: 4.4rem; }
  .arena { height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .space::after, .planet .orb, .hero-mascot .mascot .body, .letter.pop, .star, .bit, .flash.flip, .toast,
  .segs i.cur, .timer.low, .stamp, .rstars span, .get-ready .cd, .q-card.good, .q-card.bad, .mascot.jump .body, .mascot.shake .body { animation: none; }
  .bit { display: none; }
  .btn, .key, .choice, .test-card, .xpbar i, .bar i, .timer i { transition: none; }
}
