/* IQ CHALLENGE – feniksgames · styles (mobile first) */
:root {
  --bg0: #070b26; --bg1: #0f1650; --bg2: #1b1f6e;
  --panel: rgba(28, 36, 110, .72); --panel2: rgba(40, 50, 140, .55);
  --neon: #3ee0ff; --violet: #a26bff; --orange: #ff9a3c; --gold: #ffd23f; --pink: #ff6b9a;
  --text: #f4f6ff; --muted: #b9c2ee; --good: #2fe3b4; --soft: #ffb86b;
  --r: 18px; --tap: 48px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg0); }
body {
  font-family: var(--font); color: var(--text); font-size: 17px; line-height: 1.35;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #3b2fb0aa, transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, #ff7a3d33, transparent 70%),
    radial-gradient(ellipse 60% 50% at 0% 70%, #1fd1ff22, transparent 70%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
body::before { /* discreet star particles */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55;
  background-image: radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent), radial-gradient(1px 1px at 78% 12%, #fff, transparent), radial-gradient(1.5px 1.5px at 42% 72%, #cfe, transparent), radial-gradient(1px 1px at 88% 64%, #fff, transparent), radial-gradient(1px 1px at 22% 88%, #fff, transparent), radial-gradient(1.5px 1.5px at 62% 36%, #ffd, transparent), radial-gradient(1px 1px at 6% 52%, #fff, transparent), radial-gradient(1px 1px at 94% 90%, #fff, transparent);
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { to { opacity: .25; } }
#app { position: relative; z-index: 1; max-width: 820px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l)); }
button { font-family: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 80vh; font-weight: 900; letter-spacing: .08em; color: var(--gold); }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid #ffffff22; border-top-color: var(--orange); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap); padding: 10px 18px; border-radius: 16px; border: 0; cursor: pointer;
  font-weight: 800; font-size: 1rem; letter-spacing: .02em; color: var(--text);
  background: linear-gradient(180deg, #4453c9, #2b358f); box-shadow: 0 5px 0 #1a2163, 0 8px 18px #0006, inset 0 1px 0 #ffffff40;
  transition: transform .08s, box-shadow .08s, filter .2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #1a2163, 0 4px 10px #0006; }
.btn:disabled { filter: grayscale(.7) brightness(.7); cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #ffb347, #ff7a1f); box-shadow: 0 5px 0 #b84d00, 0 10px 24px #ff7a1f55, inset 0 1px 0 #ffffff80; color: #2a1200; }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 #b84d00, 0 4px 12px #ff7a1f55; }
.btn.ghost { background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 2px #ffffff26; }
.btn.ghost:active { transform: translateY(2px); }
.btn.danger { background: linear-gradient(180deg, #ff6b8b, #d93a5c); box-shadow: 0 4px 0 #8a1f38; }
.btn.big { min-height: 58px; font-size: 1.2rem; padding: 12px 26px; border-radius: 20px; }
.btn.sm { min-height: 44px; padding: 8px 14px; font-size: .92rem; }
.btn svg { width: 20px; height: 20px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .9rem; min-height: 44px; }
.ibtn { width: 46px; height: 46px; border-radius: 14px; border: 0; cursor: pointer; display: inline-grid; place-items: center; background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 2px #ffffff22; color: #fff; flex: none; }
.ibtn svg { width: 24px; height: 24px; }
.ibtn:active { transform: scale(.94); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 12px; }
.lang { display: inline-flex; background: rgba(0, 0, 0, .25); border-radius: 14px; padding: 3px; gap: 3px; box-shadow: inset 0 0 0 2px #ffffff1a; }
.lang button { min-width: 46px; min-height: 40px; border: 0; border-radius: 11px; background: transparent; font-weight: 900; cursor: pointer; color: var(--muted); }
.lang button.on { background: linear-gradient(180deg, var(--neon), #1e9fd6); color: #04203a; }

/* ---------- top bars ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.topbar h2 { flex: 1; margin: 0; font-size: 1.05rem; text-align: center; font-weight: 900; letter-spacing: .03em; }
.tb-right { display: flex; gap: 8px; }

/* ---------- menu ---------- */
.hero { text-align: center; margin-top: 2px; }
.logo { margin: 4px 0 0; line-height: .95; font-weight: 1000; letter-spacing: .02em; }
.logo .l1 { display: block; font-size: clamp(2rem, 9vw, 3.4rem); background: linear-gradient(180deg, #fff 20%, #9fe8ff 60%, #3ee0ff); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #1d2bb0) drop-shadow(0 0 18px #3ee0ff88); }
.logo .l2 { display: inline-block; font-size: clamp(1.7rem, 8.5vw, 3.2rem); background: linear-gradient(180deg, #fff3a0, var(--gold) 45%, var(--orange)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #a2410a) drop-shadow(0 0 16px #ff9a3c88); letter-spacing: .06em; }
.sub { margin: 6px 0 0; font-size: 1.1rem; font-weight: 800; color: #cfe8ff; text-shadow: 0 0 12px #3ee0ff66; }
.mascot { width: min(46vw, 210px); margin: 0 auto -6px; }
.sect { text-align: center; font-size: 1.05rem; margin: 8px 0; color: var(--gold); letter-spacing: .06em; text-transform: uppercase; }
.agecards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.agecard {
  position: relative; border: 0; cursor: pointer; border-radius: 22px; padding: 12px 8px 12px; min-height: 150px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: #fff;
  box-shadow: 0 6px 0 #0006, 0 10px 26px #0007, inset 0 1px 0 #ffffff55, inset 0 0 0 2px #ffffff22; transition: transform .15s, box-shadow .15s;
}
.agecard.ageA { background: linear-gradient(160deg, #ffb347, #ff6a3d 55%, #c23a6b); }
.agecard.ageB { background: linear-gradient(160deg, #4fd8ff, #3a7bff 55%, #4b2fc0); }
.agecard.ageC { background: linear-gradient(160deg, #c98bff, #7a43ff 55%, #2b1f8a); }
.agecard.sel { transform: translateY(-4px) scale(1.03); box-shadow: 0 0 0 4px var(--gold), 0 0 28px #ffd23f99, 0 10px 26px #0007; }
.agecard:active { transform: scale(.97); }
.agebadge { font-size: 1.25rem; font-weight: 1000; background: rgba(0, 0, 0, .28); padding: 2px 10px; border-radius: 99px; }
.ageicon { width: 46px; height: 46px; filter: drop-shadow(0 3px 4px #0006); }
.agename { font-weight: 1000; font-size: .9rem; letter-spacing: .03em; line-height: 1.1; }
.agedesc { font-size: .72rem; opacity: .92; line-height: 1.2; }
.agebest { position: absolute; top: -8px; right: -4px; background: var(--gold); color: #3a2a00; border-radius: 99px; font-size: .75rem; font-weight: 900; padding: 2px 8px 2px 4px; display: inline-flex; align-items: center; gap: 2px; }
.agebest svg { width: 14px; height: 14px; }
.modes { margin-top: 14px; display: grid; gap: 10px; }
.btn.start { flex-direction: column; gap: 0; min-height: 74px; font-size: 1.6rem; letter-spacing: .12em; animation: breathe 2.4s ease-in-out infinite; }
.btn.start small { font-size: .78rem; letter-spacing: .02em; font-weight: 800; opacity: .8; }
@keyframes breathe { 50% { filter: brightness(1.12); } }
.modes2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn.mode { flex-direction: column; gap: 2px; padding: 10px 6px; min-height: 76px; }
.btn.mode b { font-size: .85rem; }
.btn.mode small { font-size: .68rem; font-weight: 700; opacity: .85; line-height: 1.15; }
.btn.mode.locked { filter: grayscale(.6) brightness(.8); }
.bottomnav { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bottomnav .btn { font-size: .85rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 10px; }

/* ---------- practice ---------- */
.lead { text-align: center; color: var(--muted); margin: 6px 0 12px; }
.catcards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.catcard { border: 0; border-radius: 20px; min-height: 120px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #fff; font-size: 1rem; background: var(--panel); box-shadow: 0 5px 0 #0005, inset 0 0 0 2px #ffffff22; }
.catcard:active { transform: translateY(3px); }
.caticon { width: 56px; height: 56px; display: grid; place-items: center; }
.caticon svg { width: 100%; height: 100%; }
.caticon-num { font-weight: 1000; font-size: 1.4rem; color: var(--gold); }
.cat-vis { --cc: #ff9a3c; } .cat-num { --cc: #3ea8ff; } .cat-spa { --cc: #34d27b; } .cat-log { --cc: #b072ff; } .cat-mem { --cc: #ff6b9a; } .cat-att { --cc: #ffd23f; }
.catcard { box-shadow: 0 5px 0 #0005, inset 0 0 0 2px var(--cc), 0 0 18px color-mix(in srgb, var(--cc) 35%, transparent); }

/* ---------- game ---------- */
.screen.game { display: flex; flex-direction: column; min-height: calc(100dvh - 24px - var(--safe-t) - var(--safe-b)); }
.gamebar { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.gb-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mini-ph { width: 46px; height: 46px; flex: none; }
.gb-title { display: flex; flex-direction: column; min-width: 0; }
.gb-title b { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gb-right { display: flex; align-items: center; gap: 6px; }
.qcount, .pill, .speedscore { font-weight: 900; background: rgba(0, 0, 0, .3); border-radius: 99px; padding: 6px 10px; font-size: .9rem; white-space: nowrap; }
.speedclock { font-weight: 1000; font-size: 1.2rem; color: var(--gold); min-width: 3ch; text-align: right; }
.diffpill { font-size: .66rem; font-weight: 900; padding: 1px 8px; border-radius: 99px; width: fit-content; letter-spacing: .05em; }
.diffpill.dE { background: #2fe3b433; color: #8fffe0; } .diffpill.dM { background: #ffd23f33; color: #ffe58a; } .diffpill.dH { background: #ff6b9a33; color: #ffb3c9; }
.progress { position: relative; height: 14px; margin: 8px 2px 28px; border-radius: 99px; background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 2px #ffffff1a; }
.progress > i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: linear-gradient(90deg, var(--neon), var(--violet), var(--orange)); box-shadow: 0 0 12px #3ee0ff88; transition: width .5s cubic-bezier(.3, 1.4, .5, 1); }
.catdots { position: absolute; left: 0; right: 0; top: 20px; display: flex; gap: 6px; justify-content: center; }
.cd { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(var(--cc) calc(var(--p) * 1%), #ffffff22 0); display: grid; place-items: center; transition: transform .3s; }
.cd em { width: 8px; height: 8px; border-radius: 50%; background: var(--bg1); }
.cd.full { transform: scale(1.15); box-shadow: 0 0 10px var(--cc); }
.cd.full em { background: var(--cc); }
.qtimer { height: 6px; border-radius: 99px; background: #0004; margin: 2px; overflow: hidden; } .qtimer i { display: block; height: 100%; width: 100%; background: var(--gold); transition: width .2s linear; }
.trialbanner { text-align: center; background: #2fe3b422; color: #8fffe0; border-radius: 12px; padding: 6px 10px; margin: 6px 0; font-weight: 800; font-size: .9rem; }
.instr { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0 8px; min-height: 48px; }
.instr p { margin: 0; text-align: center; font-weight: 900; font-size: clamp(1.05rem, 4.4vw, 1.35rem); text-shadow: 0 2px 0 #0006; }
.instr .listen { background: linear-gradient(180deg, var(--neon), #1e9fd6); color: #04203a; }
.board { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 12px 8px; border-radius: 26px; background: var(--panel); box-shadow: inset 0 0 0 2px #6a7cff44, 0 0 30px #3ee0ff1a, 0 12px 30px #0006; backdrop-filter: blur(4px); }
.stem { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; width: 100%; }
.tile { width: clamp(48px, 15vw, 84px); aspect-ratio: 1; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .07); box-shadow: inset 0 0 0 2px #ffffff18; padding: 4px; }
.tile.big { width: clamp(120px, 42vw, 200px); }
.tile.wide { width: min(100%, 280px); aspect-ratio: 100 / 92; }
.tile.blank { background: rgba(255, 210, 63, .1); box-shadow: inset 0 0 0 3px var(--gold); animation: glow 1.8s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: inset 0 0 0 3px var(--gold), 0 0 18px #ffd23f88; } }
.qmark { font-size: 2rem; font-weight: 1000; color: var(--gold); }
.art { width: 100%; height: 100%; display: block; overflow: visible; }
.arrow { color: var(--muted); font-weight: 900; font-size: 1.4rem; }
.seq { flex-wrap: nowrap; gap: 4px; }
.seq .tile { width: min(80px, calc((min(100vw, 800px) - 70px) / var(--n) - 10px)); flex: none; }
.matrix { display: grid; gap: 6px; }
.matrix.m2 { grid-template-columns: repeat(2, clamp(64px, 22vw, 110px)); }
.matrix.m3 { grid-template-columns: repeat(3, clamp(60px, 21vw, 100px)); }
.matrix .tile { width: 100%; }
.numseq .num, .numgrid .num, .sum .num { font-size: clamp(1.5rem, 7vw, 2.2rem); font-weight: 1000; min-width: 1.6em; padding: 6px 10px; border-radius: 14px; background: rgba(255, 255, 255, .08); text-align: center; }
.num.blank { color: var(--gold); box-shadow: inset 0 0 0 3px var(--gold); background: rgba(255, 210, 63, .1); }
.comma { color: var(--muted); font-size: 1.4rem; font-weight: 900; }
.numgrid { display: grid; grid-template-columns: repeat(3, auto); gap: 8px; }
.iconfield { display: grid; grid-template-columns: repeat(4, clamp(48px, 16vw, 76px)); gap: 6px; justify-content: center; }
.iconfield.n3, .iconfield.n5, .iconfield.n6 { grid-template-columns: repeat(3, clamp(48px, 18vw, 80px)); }
.ic { aspect-ratio: 1; display: block; filter: drop-shadow(0 3px 3px #0006); }
.sum { gap: 6px; flex-wrap: nowrap; }
.sumgrp { display: grid; grid-template-columns: repeat(var(--c, 3), clamp(26px, 8.5vw, 52px)); gap: 4px; padding: 8px; border-radius: 16px; background: rgba(255, 255, 255, .06); }
.sumgrp .gone { opacity: .3; position: relative; }
.sumgrp .gone::after { content: ""; position: absolute; inset: 45% -6%; height: 4px; background: var(--pink); border-radius: 4px; transform: rotate(-35deg); }
.op { font-size: 2rem; font-weight: 1000; color: var(--gold); }
.mirror { gap: 10px; flex-wrap: nowrap; }
.mirror .tile.big { width: clamp(100px, 36vw, 180px); }
.mirrorline.v { width: 6px; align-self: stretch; min-height: 120px; border-radius: 6px; background: linear-gradient(180deg, #bff4ff, #6fd6ff, #bff4ff); box-shadow: 0 0 14px #6fd6ff; }
.mirrorline.h { width: 100%; max-width: 220px; height: 6px; border-radius: 6px; background: linear-gradient(90deg, #bff4ff, #6fd6ff, #bff4ff); box-shadow: 0 0 14px #6fd6ff; flex-basis: 100%; }
.scales { display: grid; gap: 8px; width: 100%; max-width: 560px; justify-items: center; grid-template-columns: 1fr; }
.scales.n2 { grid-template-columns: 1fr 1fr; } .scales.n3 { grid-template-columns: 1fr 1fr 1fr; }
.clues { margin: 0; padding: 12px 16px 12px 36px; border-radius: 16px; background: rgba(0, 0, 0, .22); font-size: clamp(1rem, 4vw, 1.15rem); font-weight: 700; max-width: 560px; width: 100%; }
.clues li { margin: 4px 0; }
.analogy .sep { width: 2px; height: 50px; background: #ffffff33; margin: 0 8px; }
.items.n7 .tile, .items.n8 .tile { width: clamp(40px, 11vw, 70px); }
.scatter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: min(100%, 380px); }
.scatter.n12, .scatter.n14 { grid-template-columns: repeat(5, 1fr); }
.scatter.n16, .scatter.n18 { grid-template-columns: repeat(6, 1fr); }
.sc { aspect-ratio: 1; }
.target .tlabel { font-size: 2rem; }
.targettile { box-shadow: inset 0 0 0 3px var(--neon), 0 0 18px #3ee0ff66; }
.stroop { font-size: clamp(2.6rem, 14vw, 4.5rem); font-weight: 1000; letter-spacing: .04em; padding: 10px 22px; border-radius: 20px; background: #f4f6ff; text-shadow: 0 2px 0 #0002; }
.rule .chip { box-shadow: inset 0 0 0 3px var(--neon); }
.rulebanner { font-weight: 1000; font-size: 1.1rem; background: linear-gradient(90deg, var(--violet), #5a3fd8); padding: 8px 14px; border-radius: 14px; box-shadow: 0 0 18px #a26bff66; text-align: center; }
.hintrow { color: var(--muted); }

/* 3D cube (CSS 3D; 2D net fallback via button) */
.cube3d-wrap { width: 170px; height: 170px; perspective: 600px; display: grid; place-items: center; touch-action: none; cursor: grab; margin: 10px; }
.cube3d { width: 110px; height: 110px; position: relative; transform-style: preserve-3d; transition: transform .05s; }
.cube3d .f { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 8px; box-shadow: inset 0 0 0 2px #2a3570; background: #eef3ff; }
.f-front { transform: translateZ(55px); } .f-back { transform: rotateY(180deg) translateZ(55px); }
.f-right { transform: rotateY(90deg) translateZ(55px); } .f-left { transform: rotateY(-90deg) translateZ(55px); }
.f-top { transform: rotateX(90deg) translateZ(55px); } .f-bottom { transform: rotateX(-90deg) translateZ(55px); }

/* ---------- options ---------- */
.opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; max-width: 520px; }
.opts.n3 { grid-template-columns: repeat(3, 1fr); }
.opts.n4.v-num, .opts.n4.v-name, .opts.n4.v-color { grid-template-columns: repeat(2, 1fr); }
.opts.v-pieces { grid-template-columns: repeat(2, 1fr); }
.opt {
  position: relative; border: 0; cursor: pointer; border-radius: 18px; padding: 8px; min-height: 64px; aspect-ratio: 1.15;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: linear-gradient(180deg, #ffffff1f, #ffffff0a); box-shadow: 0 5px 0 #0005, inset 0 0 0 2px #ffffff26; color: #fff;
  transition: transform .12s, box-shadow .15s, background .15s;
}
.opts.v-num .opt, .opts.v-name .opt, .opts.v-color .opt { aspect-ratio: auto; min-height: 76px; }
.opt .art { max-width: 92px; max-height: 92px; }
.opt:active:not(:disabled) { transform: translateY(3px) scale(.98); }
.opt.sel { background: linear-gradient(180deg, #3ee0ff44, #3ee0ff18); box-shadow: 0 0 0 4px var(--neon), 0 0 22px #3ee0ffaa, 0 5px 0 #0005; transform: translateY(-2px); }
.opt.right { box-shadow: 0 0 0 4px var(--good), 0 0 22px #2fe3b499; background: #2fe3b422; }
.opt.wrongpick { box-shadow: 0 0 0 4px var(--soft); background: #ffb86b1a; }
.opt:disabled { cursor: default; }
.optkey { position: absolute; top: 4px; left: 8px; font-size: .7rem; font-weight: 900; opacity: .45; }
.numopt { font-size: clamp(1.8rem, 8vw, 2.4rem); font-weight: 1000; }
.optlabel { font-weight: 900; font-size: 1rem; }
.avatar { width: 46px; height: 46px; }
.swatch { width: 52px; height: 52px; }
.pieces { display: flex; gap: 4px; width: 100%; justify-content: center; }
.pieces .piece { flex: 1; max-width: 70px; aspect-ratio: 1; }
.optgrid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px; width: 100%; max-width: 480px; }
.optgrid .opt { aspect-ratio: 1; min-height: 0; padding: 4px; border-radius: 12px; }
.optgrid .opt .art { max-width: 100%; max-height: 100%; }
.optgrid .optkey { display: none; }
.optgrid.cells .opt { background: #ffffff14; }
.optgrid.cells .opt.sel { background: linear-gradient(180deg, #ffd23f, #ff9a3c); }
.cellbox { display: block; width: 100%; height: 100%; }
.selcount { color: var(--muted); font-weight: 800; font-size: .9rem; min-height: 1.2em; }
.slots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.slot { width: clamp(52px, 16vw, 80px); aspect-ratio: 1; border-radius: 14px; background: #0003; box-shadow: inset 0 0 0 2px #ffffff33; position: relative; display: grid; place-items: center; padding: 4px; }
.slot.filled { background: #3ee0ff22; box-shadow: inset 0 0 0 3px var(--neon); }
.slot.right { box-shadow: inset 0 0 0 3px var(--good); } .slot.wrongpick { box-shadow: inset 0 0 0 3px var(--soft); }
.slotn { position: absolute; top: 2px; left: 6px; font-size: .72rem; font-weight: 900; opacity: .6; }
.slot .numopt { font-size: 1.6rem; }
.answerrow { opacity: .9; }
.opts.pool { grid-template-columns: repeat(4, 1fr); }
.opts.pool.n3 { grid-template-columns: repeat(3, 1fr); }
.opts.pool .opt { aspect-ratio: 1; }
.opt.used { opacity: .3; }

/* ---------- memo ---------- */
.memo { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.memobanner { width: 100%; max-width: 420px; text-align: center; font-weight: 1000; font-size: 1.4rem; color: var(--gold); text-shadow: 0 0 14px #ffd23f88; }
.memobar { height: 10px; border-radius: 99px; background: #0004; margin-top: 6px; overflow: hidden; }
.memobar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), var(--orange)); }
.cellgrid { display: grid; grid-template-columns: repeat(var(--n), clamp(52px, 17vw, 86px)); gap: 8px; }
.cellgrid.small { grid-template-columns: repeat(var(--n), 34px); gap: 4px; }
.mcell { aspect-ratio: 1; border-radius: 12px; background: #ffffff14; box-shadow: inset 0 0 0 2px #ffffff22; }
.mcell.lit { background: radial-gradient(circle at 35% 30%, #fff7b0, var(--gold) 45%, var(--orange)); box-shadow: 0 0 20px #ffd23faa; }
.seqshow { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.seqshow .tile.big { width: clamp(130px, 40vw, 180px); }
.seqshow .pop { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.seqdots { display: flex; gap: 6px; } .seqdots i { width: 12px; height: 12px; border-radius: 50%; background: #ffffff33; } .seqdots i.on { background: var(--gold); }
.ready { font-weight: 900; color: var(--muted); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ---------- footer & feedback ---------- */
.gamefoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; position: sticky; bottom: calc(4px + var(--safe-b)); z-index: 3; }
.gf-left { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.gamefoot .confirm { min-width: 150px; }
.fb { min-height: 0; }
.fbox { margin: 10px auto 0; max-width: 560px; border-radius: 18px; padding: 12px 16px; background: rgba(0, 0, 0, .3); box-shadow: inset 0 0 0 2px #ffffff22; animation: pop .3s ease-out; }
.fbox.ok { box-shadow: inset 0 0 0 3px var(--good), 0 0 20px #2fe3b444; } .fbox.no { box-shadow: inset 0 0 0 3px var(--soft); }
.fbox b { font-size: 1.15rem; } .fbox p { margin: 6px 0 0; }
.savedmsg { text-align: center; font-weight: 900; color: #8fffe0; margin-top: 8px; animation: pop .3s; }
.board.flash-good { animation: flashg .45s; } .board.flash-soft { animation: flashs .45s; } .board.flash-saved { animation: flashv .5s; }
@keyframes flashg { 40% { box-shadow: inset 0 0 0 4px var(--good), 0 0 40px #2fe3b488; } }
@keyframes flashs { 40% { box-shadow: inset 0 0 0 4px var(--soft); } }
@keyframes flashv { 40% { box-shadow: inset 0 0 0 4px var(--neon), 0 0 30px #3ee0ff66; } }

/* ---------- results ---------- */
.rescard { text-align: center; padding: 14px; border-radius: 28px; background: var(--panel); box-shadow: inset 0 0 0 2px #6a7cff55, 0 0 40px #a26bff33; }
.resph { width: 150px; margin: -6px auto -10px; }
.restitle { margin: 4px 0; font-size: clamp(1.8rem, 8vw, 2.6rem); font-weight: 1000; background: linear-gradient(180deg, #fff3a0, var(--gold), var(--orange)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #a2410a); }
.scorelabel { font-weight: 900; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-size: .9rem; }
.score { font-weight: 1000; font-size: clamp(3.4rem, 18vw, 5.2rem); line-height: 1; color: #fff; text-shadow: 0 0 24px #3ee0ff99, 0 4px 0 #1d2bb0; }
.score small { font-size: 1.2rem; color: var(--muted); margin-left: 6px; text-shadow: none; }
.newbest { display: inline-block; margin: 6px 0; padding: 4px 12px; border-radius: 99px; background: var(--gold); color: #3a2a00; font-weight: 900; animation: pop .5s .6s both; }
.medal { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0; animation: pop .6s .8s both; }
.medalsvg { width: 70px; height: 70px; filter: drop-shadow(0 4px 8px #0008); }
.medal b { font-size: 1.3rem; }
.medal.none p { margin: 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 10px 0; }
.stats div { background: #0003; border-radius: 14px; padding: 8px 4px; display: flex; flex-direction: column; }
.stats b { font-size: 1.25rem; } .stats span { font-size: .76rem; color: var(--muted); }
.rescard h3 { margin: 12px 0 6px; color: var(--gold); }
.catbars { display: grid; gap: 6px; text-align: left; }
.catbar { display: grid; grid-template-columns: 9.5em 1fr 3.2em; align-items: center; gap: 8px; font-weight: 800; font-size: .92rem; }
.cbl { display: flex; align-items: center; gap: 6px; } .cbl .caticon { width: 26px; height: 26px; }
.cbt { height: 14px; border-radius: 99px; background: #0004; overflow: hidden; }
.cbt i { display: block; height: 100%; width: var(--w); border-radius: 99px; background: linear-gradient(90deg, var(--cc), color-mix(in srgb, var(--cc) 60%, #fff)); animation: grow 1.2s cubic-bezier(.3, 1.2, .5, 1) both; }
@keyframes grow { from { width: 0; } }
.praise { font-weight: 800; font-size: 1.05rem; margin: 12px 0; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.badges h3 { flex-basis: 100%; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border-radius: 99px; background: linear-gradient(180deg, #ffffff22, #ffffff0a); box-shadow: inset 0 0 0 2px var(--gold); font-weight: 900; font-size: .9rem; }
.badgeicon { width: 28px; height: 28px; }
.badges small { flex-basis: 100%; color: var(--muted); }
.disclaimer { font-size: .78rem; color: var(--muted); margin: 10px 0 0; }
.resbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.resbtns .primary { grid-column: 1 / -1; }
.reviewtag { text-align: center; font-weight: 900; padding: 6px; border-radius: 12px; margin: 4px 0; }
.reviewtag.ok { background: #2fe3b422; color: #8fffe0; } .reviewtag.no { background: #ffb86b22; color: #ffd6a8; } .reviewtag.sk { background: #ffffff14; color: var(--muted); }
.reviewmemo { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 8px; color: var(--muted); }
.reviewmemo .tile { width: 44px; }
.reviewround { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* ---------- modal ---------- */
#modal.open { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b)); }
.mback { position: absolute; inset: 0; background: #020518cc; backdrop-filter: blur(4px); }
.mbox { position: relative; width: min(520px, 100%); max-height: 100%; overflow: auto; border-radius: 26px; padding: 16px; background: linear-gradient(180deg, #232a86, #141a55); box-shadow: inset 0 0 0 2px #6a7cff77, 0 0 40px #3ee0ff33; animation: pop .25s ease-out; }
.mhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mhead h2 { margin: 0; font-size: 1.3rem; }
.mfoot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.setlist { display: grid; gap: 6px; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #ffffff14; font-weight: 800; }
.setrow small { display: block; font-weight: 600; color: var(--muted); font-size: .78rem; }
.switch { position: relative; width: 82px; height: 44px; border-radius: 99px; border: 0; background: #ffffff1f; cursor: pointer; flex: none; box-shadow: inset 0 0 0 2px #ffffff26; }
.switch i { position: absolute; top: 5px; left: 5px; width: 34px; height: 34px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 2px 4px #0006; }
.switch em { position: absolute; right: 10px; top: 12px; font-style: normal; font-size: .72rem; font-weight: 900; }
.switch.on { background: linear-gradient(180deg, var(--good), #17a985); } .switch.on i { left: 43px; } .switch.on em { left: 10px; right: auto; color: #033; }
.howto { text-align: center; } .howto .phoenix { width: 110px; } .howcats { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: left; }
.howcats li { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: .9rem; } .howcats .caticon { width: 34px; height: 34px; }
.confirmbox { text-align: center; } .confirmbox .phoenix { width: 110px; } .confirmbox p { font-weight: 800; font-size: 1.05rem; }
.lb { padding-left: 24px; } .lb li { display: flex; justify-content: space-between; padding: 4px 0; } .localbest { list-style: none; padding: 0; } .localbest li { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 0; border-bottom: 1px solid #ffffff14; } .localbest b { flex-basis: 100%; }
.lbinfo { color: var(--muted); }
.tutorial { text-align: center; } .tutph { width: 120px; margin: 0 auto; } .tuttext { font-weight: 900; font-size: 1.2rem; }
.tutdemo { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 110px; margin: 0 auto; max-width: 360px; }
.tutdemo.opts .opt { aspect-ratio: 1; }
.progress.demo { width: 200px; position: relative; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #ffd23f88, 0 0 24px #ffd23f; } }
.tutdots { display: flex; gap: 6px; justify-content: center; margin-top: 8px; } .tutdots i { width: 10px; height: 10px; border-radius: 50%; background: #ffffff33; } .tutdots i.on { background: var(--gold); }

/* ---------- toasts & confetti ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); z-index: 60; display: grid; gap: 6px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 14px; font-weight: 800; text-align: center; background: #1f2780ee; box-shadow: 0 6px 20px #0008, inset 0 0 0 2px #6a7cff88; animation: pop .25s ease-out; transition: opacity .4s, transform .4s; }
.toast.ok { box-shadow: 0 6px 20px #0008, inset 0 0 0 2px var(--good); } .toast.warn { box-shadow: 0 6px 20px #0008, inset 0 0 0 2px var(--soft); }
.toast.out { opacity: 0; transform: translateY(-8px); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Baby Phoenix animations ---------- */
.phoenix { width: 100%; height: auto; display: block; overflow: visible; }
.phoenix .ph-all { transform-origin: 100px 180px; }
.phoenix .ph-wing-l { transform-origin: 60px 100px; } .phoenix .ph-wing-r { transform-origin: 140px 100px; }
.phoenix .ph-tuft { transform-origin: 100px 62px; animation: flicker 1.4s ease-in-out infinite; }
.phoenix .ph-tail { transform-origin: 125px 155px; animation: sway 3s ease-in-out infinite; }
.phoenix .ph-think, .phoenix .ph-heart { opacity: 0; transition: opacity .3s; }
.phoenix .ph-eyes { animation: blink 4.5s infinite; transform-origin: 100px 108px; }
.phoenix.idle .ph-all { animation: bob 3s ease-in-out infinite; }
.phoenix.wave .ph-wing-r { animation: wave .5s ease-in-out 4 alternate; } .phoenix.wave .ph-all { animation: bob 3s ease-in-out infinite; }
.phoenix.think .ph-think { opacity: 1; } .phoenix.think .ph-all { animation: tilt 2.4s ease-in-out infinite; }
.phoenix.jump .ph-all { animation: jump .6s cubic-bezier(.3, 1.5, .5, 1) 2; } .phoenix.jump .ph-wing-l, .phoenix.jump .ph-wing-r { animation: flap .15s ease-in-out 8 alternate; }
.phoenix.cheer .ph-heart { opacity: 1; } .phoenix.cheer .ph-all { animation: nod .5s ease-in-out 3; }
.phoenix.nod .ph-all { animation: nod .45s ease-in-out 1; }
.phoenix.celebrate .ph-all { animation: jump .7s cubic-bezier(.3, 1.5, .5, 1) infinite; } .phoenix.celebrate .ph-wing-l, .phoenix.celebrate .ph-wing-r { animation: flap .18s ease-in-out infinite alternate; }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes flicker { 50% { transform: scale(1.08, .92) skewX(3deg); } }
@keyframes sway { 50% { transform: rotate(6deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes wave { to { transform: rotate(-38deg); } }
@keyframes flap { from { transform: rotate(-14deg); } to { transform: rotate(18deg); } }
.phoenix .ph-wing-l { animation-direction: alternate-reverse; }
@keyframes jump { 40% { transform: translateY(-26px) scale(1.04, .96); } 70% { transform: translateY(0) scale(1.06, .94); } }
@keyframes tilt { 50% { transform: rotate(-6deg); } }
@keyframes nod { 50% { transform: translateY(4px) rotate(3deg); } }

/* ---------- responsive ---------- */
@media (max-width: 380px) {
  body { font-size: 16px; }
  .agecard { min-height: 138px; padding: 10px 4px; } .agename { font-size: .78rem; } .agedesc { font-size: .64rem; }
  .modes2 { grid-template-columns: 1fr; } .btn.mode { min-height: 56px; flex-direction: row; justify-content: space-between; padding: 8px 14px; } .btn.mode small { text-align: right; max-width: 55%; }
  .catbar { grid-template-columns: 7.6em 1fr 3em; font-size: .82rem; }
  .gamefoot .confirm { min-width: 120px; }
}
@media (min-width: 700px) {
  #app { padding-top: calc(16px + var(--safe-t)); }
  .mascot { width: 220px; }
  .agecard { min-height: 190px; padding: 16px 10px; } .ageicon { width: 64px; height: 64px; } .agename { font-size: 1.05rem; } .agedesc { font-size: .82rem; }
  .bottomnav { grid-template-columns: repeat(4, 1fr); }
  .catcards { grid-template-columns: repeat(3, 1fr); }
  .opts.n4 { grid-template-columns: repeat(4, 1fr); }
  .opts.n4.v-num, .opts.n4.v-name, .opts.n4.v-color { grid-template-columns: repeat(4, 1fr); }
  .resbtns { grid-template-columns: repeat(4, 1fr); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .screen.game { min-height: auto; }
  .board { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; }
  .stem { width: auto; max-width: 48%; }
  .opts, .optgrid { max-width: 48%; }
  .instr { margin: 4px 0; }
  .mascot { width: 120px; }
  .tile.big { width: 120px; }
}

/* reduced motion: user setting or system preference */
body.rm *, body.rm *::before, body.rm *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }
/* slower phones: drop decorative effects, keep the game */
body.lowend::before { display: none; } body.lowend .board, body.lowend .mback { backdrop-filter: none; } body.lowend .phoenix .ph-tuft, body.lowend .phoenix .ph-tail { animation: none; }

.numseq { flex-wrap: nowrap; gap: 3px; }
.numseq .num { font-size: min(2.2rem, calc((min(100vw, 800px) - 60px) / var(--n) / 1.9)); min-width: 1.3em; padding: 6px 5px; }
.numseq .comma { font-size: 1rem; }
.cbl .caticon-num { font-size: .72rem; }
.memo .tile { width: clamp(60px, 20vw, 104px); }
.memo .items.n7 .tile, .memo .items.n8 .tile { width: clamp(44px, 14vw, 80px); }
/* Professor Phoenix: tassel swings, cap tilts a little while waving */
.phoenix .ph-tassel { transform-origin: 140px 58px; animation: tassel 2.6s ease-in-out infinite; }
.phoenix.wave .ph-cap { transform-origin: 100px 60px; animation: captip 1s ease-in-out 2 alternate; }
@keyframes tassel { 50% { transform: rotate(-10deg); } }
@keyframes captip { to { transform: rotate(-6deg) translateY(-3px); } }
/* Professor Phoenix in the game corner + speech bubble */
.mini-ph { width: 58px; height: 58px; border: 0; padding: 0; background: none; cursor: pointer; margin: -6px -2px -4px -4px; }
.mini-ph:active { transform: scale(.94); }
#phbubble { position: fixed; z-index: 45; max-width: min(250px, 64vw); padding: 9px 13px; border-radius: 16px 16px 16px 4px; background: #fffdf4; color: #1b1f4a; font-weight: 900; font-size: .86rem; line-height: 1.25; box-shadow: 0 6px 18px #0007, 0 0 0 3px #ffd23f; pointer-events: none; opacity: 0; transform: scale(.4) translateY(-6px); transform-origin: 0 0; transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1); }
#phbubble::before { content: ""; position: absolute; left: 6px; top: -9px; border: 7px solid transparent; border-bottom-color: #ffd23f; border-left-color: #ffd23f; }
#phbubble.show { opacity: 1; transform: none; }
.phoenix.talk .ph-all { animation: talk .32s ease-in-out 6 alternate; }
@keyframes talk { to { transform: translateY(-4px) rotate(-3deg); } }
