/* ==========================================================
   Synapse — shared game HUD, controls and per-game styles
   ========================================================== */
.center { text-align: center; }
.small { font-size: 13px; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; font: 600 11px var(--mono);
    background: rgba(255,255,255,.08); border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--text-2); }
.btn kbd { margin-left: 4px; }
.setup-rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.setup-rules > div { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.setup-rules .icon { width: 20px; height: 20px; color: var(--violet); margin-top: 1px; }
.field-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 6px 0 8px; }

.game-hud { display: grid; grid-template-columns: 1fr auto auto 1fr; align-items: center; gap: 14px; max-width: 760px; margin: 0 auto; width: 100%; }
.hud-item { display: flex; flex-direction: column; line-height: 1.1; }
.hud-item span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.hud-item b { font: 700 24px var(--display); font-variant-numeric: tabular-nums; }
.hud-item.right { text-align: right; align-items: flex-end; }
.hud-item.bump b { animation: lvlpop .7s var(--spring); }
.mx-lives { display: flex; gap: 4px; }
.mx-lives span { color: rgba(255,255,255,.12); transition: color .3s, transform .3s; }
.mx-lives span.on { color: var(--pink); filter: drop-shadow(0 0 6px rgba(244,114,182,.6)); }
.mx-lives .icon { width: 22px; height: 22px; }
.combo-chip { min-width: 54px; height: 30px; padding: 0 10px; border-radius: 99px; display: grid; place-items: center; font: 700 14px var(--mono); color: var(--amber);
    background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.3); opacity: 0; transform: scale(.7); transition: all .3s var(--spring); }
.combo-chip.on { opacity: 1; transform: none; }
.combo-chip.hot { color: #fff; background: linear-gradient(90deg, #f59e0b, #ef4444); box-shadow: 0 0 20px -2px rgba(245,158,11,.7); animation: flicker 1.4s infinite; }
.bonus-bar { max-width: 760px; width: 100%; margin: 12px auto 0; height: 4px; border-radius: 9px; background: rgba(255,255,255,.06); overflow: hidden; }
.bonus-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--pink)); transform-origin: left; box-shadow: 0 0 10px var(--violet); }
.bonus-bar.green i { background: linear-gradient(90deg, var(--emerald), var(--cyan)); box-shadow: 0 0 10px var(--emerald); }
.bonus-bar.pink i { background: linear-gradient(90deg, var(--pink), var(--violet)); transition: transform .4s var(--ease); }
.bonus-bar.amber i { background: linear-gradient(90deg, var(--amber), #fb923c); box-shadow: 0 0 10px var(--amber); }
.bonus-bar.urgent i { background: var(--red); box-shadow: 0 0 12px var(--red); animation: urgent .5s infinite alternate; }
@keyframes urgent { to { opacity: .55; } }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 360px; width: 100%; margin: 0 auto; }
.num { height: 56px; border-radius: 14px; font: 600 24px var(--display); background: linear-gradient(170deg, rgba(255,255,255,.07), rgba(255,255,255,.025)); border: 1px solid var(--line-2);
    transition: transform .1s, background .2s; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.num:hover { background: rgba(255,255,255,.1); }
.num:active { transform: scale(.94); }
.num.fn { color: var(--text-2); font-size: 20px; }
.num.ok { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 17px; background: linear-gradient(90deg, rgba(52,211,153,.22), rgba(34,211,238,.18)); border-color: rgba(52,211,153,.4); color: var(--emerald); }

.ex-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ex-head .icon { width: 20px; height: 20px; }

/* ---------- matrices ---------- */
.mx-defs { position: absolute; width: 0; height: 0; }
.mx-wrap { display: flex; flex-direction: column; gap: 14px; }
.mx-stage { display: grid; grid-template-columns: minmax(0, min(420px, 52vh)) minmax(0, 300px); gap: 24px; justify-content: center; align-items: center; margin-top: 8px; }
.mx-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; border-radius: 20px; background: rgba(12,12,18,.8);
    border: 1px solid rgba(167,139,250,.3); box-shadow: 0 30px 80px -30px rgba(0,0,0,.9), 0 0 60px -25px rgba(167,139,250,.5); }
.mx-cell { aspect-ratio: 1; border-radius: 12px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.06); display: grid; place-items: center;
    animation: mxin .45s var(--spring) both; animation-delay: var(--d, 0ms); }
@keyframes mxin { from { opacity: 0; transform: scale(.8); } }
.mx-cell.q { font: 700 38px var(--display); color: var(--pink); border: 2px dashed rgba(244,114,182,.55); animation: mxin .45s var(--spring) both, qpulse 1.8s ease-in-out infinite .5s; }
.mx-cell.q.revealed { border-style: solid; border-color: var(--emerald); animation: reveal .5s var(--spring); box-shadow: 0 0 30px -6px rgba(52,211,153,.7); }
@keyframes reveal { from { transform: scale(.6) rotate(-8deg); opacity: 0; } }
.mx-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mx-dot { fill: rgba(255,255,255,.18); }
.mx-line { stroke: var(--violet); stroke-width: 4.5; stroke-linecap: round; filter: drop-shadow(0 0 3px rgba(167,139,250,.8)); }
.mx-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: min(560px, 62vh); width: 100%; margin: 4px auto 0; }
.mx-options.four { max-width: min(420px, 50vh); }
.mx-opt { position: relative; aspect-ratio: 1; border-radius: 14px; padding: 8px; background: linear-gradient(170deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); border: 1px solid var(--line-2);
    transition: transform .2s var(--ease), border-color .2s, box-shadow .2s, opacity .3s; animation: mxin .4s var(--spring) both; animation-delay: var(--d); }
.mx-opt:hover { transform: translateY(-3px); border-color: rgba(167,139,250,.6); box-shadow: 0 12px 30px -12px rgba(167,139,250,.6); }
.mx-opt .opt-key { position: absolute; top: 5px; left: 7px; font: 600 10px var(--mono); color: var(--text-3); }
.mx-opt.right { border-color: var(--emerald); box-shadow: 0 0 0 2px var(--emerald), 0 0 30px -4px rgba(52,211,153,.7); transform: scale(1.04); }
.mx-opt.wrong { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.mx-opt.dim { opacity: .3; }
.mx-explain, .seq-explain { padding: 16px 18px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--line); font-size: 14px; color: var(--text-2);
    opacity: 0; transform: translateX(10px); transition: all .35s var(--ease); min-height: 80px; }
.mx-explain.show, .seq-explain.show { opacity: 1; transform: none; }
.mx-explain .ex-head { color: var(--emerald); }
.mx-explain ul { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.mx-explain li { padding-left: 14px; position: relative; color: var(--text); }
.mx-explain li::before { content: ''; position: absolute; left: 0; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--violet); }
.mx-explain .btn, .seq-explain .btn { margin-top: 6px; }
.mx-demo { display: flex; justify-content: center; }
.mx-demo-grid { display: grid; grid-template-columns: repeat(4, 80px); gap: 8px; }
.mx-demo-grid .mx-cell { padding: 4px; }

/* ---------- sequences ---------- */
.seq-wrap { display: flex; flex-direction: column; gap: 16px; }
.seq-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 16px; min-height: 230px; }
.seq-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.seq-num { min-width: 74px; height: 74px; padding: 0 12px; border-radius: 16px; display: grid; place-items: center; font: 700 30px var(--display); font-variant-numeric: tabular-nums;
    background: linear-gradient(170deg, rgba(52,211,153,.1), rgba(255,255,255,.02)); border: 1px solid rgba(52,211,153,.25); animation: seqin .5s var(--spring) both; animation-delay: var(--d); }
@keyframes seqin { from { opacity: 0; transform: translateY(16px) scale(.85); } }
.seq-num.q { color: var(--emerald); border: 2px dashed rgba(52,211,153,.6); animation: seqin .5s var(--spring) both, qpulse 1.8s ease-in-out infinite .8s; }
.seq-num.q.right { border-style: solid; background: rgba(52,211,153,.2); box-shadow: 0 0 30px -4px rgba(52,211,153,.8); color: #fff; animation: reveal .45s var(--spring); }
.seq-num.q.wrong { border-style: solid; border-color: var(--red); color: var(--red); background: rgba(248,113,113,.12); animation: none; }
.seq-row.long .seq-num { min-width: 62px; height: 64px; font-size: 25px; }
.seq-answer { display: none; }
.seq-explain { width: 100%; max-width: 640px; transform: translateY(8px); text-align: center; }
.seq-explain .ex-head { justify-content: center; color: var(--emerald); }
.seq-explain p { color: var(--text); margin-top: 6px; }
.seq-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; margin: 8px 0 4px; font-family: var(--mono); }
.seq-links .n { font-weight: 700; color: var(--text); font-size: 15px; }
.seq-links .n.ans { color: var(--emerald); }
.seq-links .link { font-size: 12px; color: var(--amber); padding: 2px 6px; border-radius: 6px; background: rgba(251,191,36,.1); animation: fadeup .4s var(--ease) both; animation-delay: var(--d); }
.seq-demo { display: flex; justify-content: center; gap: 8px; font: 700 26px var(--display); }
.seq-demo span { padding: 10px 16px; border-radius: 12px; background: var(--glass-2); border: 1px solid rgba(52,211,153,.25); animation: seqin .5s var(--spring) both; animation-delay: var(--d); }
.seq-demo span.q { color: var(--emerald); border-style: dashed; animation: seqin .5s var(--spring) both .7s, qpulse 1.8s infinite 1.2s; }

/* ---------- n-back ---------- */
.nb-setup { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; }
.nb-setup-col, .nb-howto { padding: 18px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--line); }
.nb-howto { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.nb-howto ul { list-style: none; font-size: 13.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; text-align: left; }
.nb-demo-text { font-size: 14px; color: var(--text); }
.n-picker { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.n-btn { width: 44px; height: 44px; border-radius: 12px; font: 600 22px var(--display); background: var(--glass-2); border: 1px solid var(--line-2); }
.n-btn:hover { background: var(--glass-3); }
.n-val { display: flex; align-items: baseline; gap: 4px; min-width: 64px; justify-content: center; }
.n-val b { font: 800 40px var(--display); color: var(--pink); text-shadow: 0 0 20px rgba(244,114,182,.5); }
.n-val span { color: var(--text-3); font-weight: 700; }
.nb-setup-col .muted.small { margin-top: 12px; }
.nb-mini { display: grid; grid-template-columns: repeat(3, 30px); gap: 5px; }
.nb-mini span { width: 30px; height: 30px; border-radius: 7px; background: rgba(255,255,255,.05); border: 1px solid rgba(244,114,182,.2); }
.nb-mini span.c { background: transparent; border-color: transparent; }
.nb-mini span:not(.c) { animation: nlight 2.8s linear infinite; animation-delay: var(--d); }
.nb-wrap { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.nb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(420px, 86vw); aspect-ratio: 1; margin-top: 12px; }
.nb-cell { border-radius: 18px; background: rgba(255,255,255,.035); border: 1px solid rgba(244,114,182,.15); transition: background .3s, box-shadow .3s; }
.nb-cell.center { background: transparent; border: 0; display: grid; place-items: center; }
.nb-cell.center::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.35); }
.nb-cell.lit { background: radial-gradient(circle at 50% 40%, #fbcfe8, var(--pink) 45%, #be185d); border-color: transparent;
    box-shadow: 0 0 40px 4px rgba(244,114,182,.6), inset 0 0 20px rgba(255,255,255,.4); animation: litpop .9s var(--ease) forwards; }
@keyframes litpop { 0% { transform: scale(.85); opacity: .4; } 12% { transform: scale(1.03); opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(.97); } }
.nb-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; width: min(420px, 86vw); }
.nb-btn { height: 74px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 600;
    background: linear-gradient(170deg, rgba(255,255,255,.07), rgba(255,255,255,.02)); border: 1px solid var(--line-2); transition: transform .1s, background .25s, border-color .25s, box-shadow .25s;
    touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.nb-btn:active { transform: scale(.96); }
.nb-btn.good { background: rgba(52,211,153,.2); border-color: var(--emerald); box-shadow: 0 0 30px -6px rgba(52,211,153,.8); }
.nb-btn.bad { background: rgba(248,113,113,.18); border-color: var(--red); }
.nb-btn.missed { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.nb-table { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.nb-tr { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.035); }
.nb-tr.head { background: none; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 0 10px; }
.nb-tr span:first-child { text-align: left; }
.nb-tr b { font-family: var(--mono); }
.nb-next { margin-top: 6px; padding: 10px; border-radius: 10px; font-weight: 600; background: rgba(255,255,255,.04); }
.nb-next.up { color: var(--emerald); background: rgba(52,211,153,.1); }
.nb-next.down { color: var(--amber); background: rgba(251,191,36,.08); }

/* ---------- speed math ---------- */
.sp-wrap { display: flex; flex-direction: column; gap: 14px; }
.sp-time { transition: color .3s; }
.sp-time.urgent { color: var(--red); animation: urgent .5s infinite alternate; }
.sp-combo { display: flex; align-items: center; gap: 10px; grid-column: 2 / 4; justify-self: center; }
.sp-mult { font: 800 22px var(--display); color: var(--text-2); min-width: 52px; text-align: center; transition: all .3s var(--spring); }
.sp-mult.hot { color: var(--amber); text-shadow: 0 0 16px rgba(251,191,36,.7); transform: scale(1.12); }
.sp-mult.fire { color: #fff; text-shadow: 0 0 12px #f97316, 0 0 30px #ef4444; animation: flicker 1s infinite; }
.combo-segs { display: flex; gap: 4px; }
.combo-segs i { width: 18px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.08); transition: all .25s var(--spring); }
.combo-segs i.on { background: var(--amber); box-shadow: 0 0 10px var(--amber); transform: scaleY(1.3); }
.sp-stage { display: grid; place-items: center; min-height: 240px; }
.sp-card { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 30px 40px; min-width: min(420px, 90vw); border-radius: 26px;
    background: linear-gradient(170deg, rgba(251,191,36,.1), rgba(255,255,255,.02)); border: 1px solid rgba(251,191,36,.25); box-shadow: 0 30px 80px -30px rgba(0,0,0,.9); }
.sp-card.in { animation: spin-in .28s var(--spring); }
.sp-card.out { animation: spout .12s ease-in forwards; }
@keyframes spin-in { from { opacity: 0; transform: translateY(24px) scale(.94); } }
@keyframes spout { to { opacity: 0; transform: translateY(-24px) scale(1.04); } }
.sp-problem { font: 700 clamp(44px, 10vw, 72px) var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sp-slots { display: flex; gap: 8px; }
.sp-slots span { width: 46px; height: 58px; border-radius: 12px; display: grid; place-items: center; font: 700 32px var(--mono); color: var(--amber);
    background: rgba(0,0,0,.3); border: 2px solid rgba(255,255,255,.1); }
.sp-slots span.f { border-color: rgba(251,191,36,.6); animation: cellpop .2s var(--spring); }
.sp-demo { display: flex; justify-content: center; align-items: baseline; gap: 8px; font: 700 40px var(--display); }
.sp-demo b { color: var(--amber); text-shadow: 0 0 20px rgba(251,191,36,.6); animation: ansin 2s ease-in-out infinite; }

@media (max-width: 900px) {
    .mx-stage { grid-template-columns: minmax(0, min(420px, 52vh)); }
    .mx-explain { transform: translateY(8px); }
}
@media (max-width: 640px) {
    .setup-rules { grid-template-columns: 1fr; }
    .nb-setup { grid-template-columns: 1fr; }
    .game-hud { grid-template-columns: auto 1fr auto; gap: 8px; }
    .game-hud .combo-chip { display: none; }
    .game-hud .mx-lives { justify-self: center; }
    .hud-item b { font-size: 20px; }
    .mx-board { gap: 5px; padding: 8px; border-radius: 16px; }
    .mx-options { gap: 6px; }
    .mx-opt { padding: 4px; border-radius: 10px; }
    .mx-stage { gap: 12px; }
    .mx-cell.q { font-size: 28px; }
    .mx-demo-grid { grid-template-columns: repeat(4, 64px); }
    .seq-num { min-width: 52px; height: 56px; font-size: 22px; padding: 0 8px; border-radius: 12px; }
    .seq-row { gap: 6px; }
    .seq-row.long .seq-num { min-width: 44px; height: 50px; font-size: 19px; }
    .seq-stage { min-height: 180px; margin-top: 6px; }
    .num { height: 50px; }
    .sp-combo { grid-column: 2; }
    .sp-card { padding: 24px 18px; }
    .sp-stage { min-height: 200px; }
    .sp-slots span { width: 40px; height: 50px; font-size: 26px; }
    .seq-demo { font-size: 20px; }
}
