:root { --bg:#0b0f1e; --panel:#141a2e; --panel2:#1b2340; --text:#e8ecf7; --muted:#9aa5c4; --accent:#ffd166; --good:#4ade80; --bad:#f87171; --info:#7dd3fc; --line:rgba(255,255,255,.08); }
* { box-sizing:border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--text); font-family:Rubik, system-ui, -apple-system, Segoe UI, sans-serif; }
a { color:var(--info); }
button { font:inherit; cursor:pointer; }

/* ---------- catalog ---------- */
.wrap { max-width:1040px; margin:0 auto; padding:32px 16px 64px; }
.hero { display:flex; flex-wrap:wrap; gap:16px; align-items:flex-end; justify-content:space-between; margin-bottom:28px; }
.hero h1 { font-size:clamp(28px,5vw,44px); margin:0 0 8px; letter-spacing:-.02em; }
.hero p { margin:0; color:var(--muted); max-width:620px; line-height:1.5; }
.hero .links a { margin-left:14px; font-size:14px; }
.games { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:18px; }
.game { background:linear-gradient(180deg,var(--panel2),var(--panel)); border:1px solid var(--line); border-radius:16px; padding:20px; display:flex; flex-direction:column; gap:12px; position:relative; overflow:hidden; }
.game .emoji { font-size:40px; line-height:1; }
.game h2 { margin:0; font-size:22px; }
.game .sub { color:var(--accent); font-size:13px; letter-spacing:.04em; text-transform:uppercase; }
.game p { margin:0; color:var(--muted); line-height:1.5; font-size:15px; }
.levels { display:flex; flex-direction:column; gap:6px; margin-top:4px; }
.levels a { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:10px; background:rgba(255,255,255,.04); color:var(--text); text-decoration:none; font-size:14px; border:1px solid transparent; }
.levels a:hover { border-color:rgba(255,255,255,.18); background:rgba(255,255,255,.07); }
.levels a .n { width:22px; height:22px; border-radius:50%; display:grid; place-items:center; font-size:12px; background:var(--panel); border:1px solid var(--line); flex:none; }
.levels a.done .n { background:var(--good); color:#06240f; border-color:transparent; }
.levels a .m { margin-left:auto; color:var(--muted); font-size:12px; }
.game .play { margin-top:auto; display:inline-flex; justify-content:center; padding:12px 16px; border-radius:12px; background:var(--accent); color:#1b1b2a; font-weight:700; text-decoration:none; }
.game .meta { font-size:12px; color:var(--muted); display:flex; gap:12px; }
.how { margin-top:40px; background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:20px 22px; }
.how h3 { margin:0 0 10px; }
.how ol, .how ul { color:var(--muted); line-height:1.6; padding-left:22px; margin:0; }
.how code { background:rgba(255,255,255,.08); padding:1px 5px; border-radius:4px; font-size:13px; }
.doc h2 { margin-top:36px; }
.doc table { width:100%; border-collapse:collapse; font-size:14px; }
.doc th, .doc td { text-align:left; padding:8px 10px; border-bottom:1px solid var(--line); vertical-align:top; }
.doc th { color:var(--muted); font-weight:500; }
.doc pre { background:#0a0d1a; border:1px solid var(--line); border-radius:10px; padding:14px; overflow:auto; font-size:13px; line-height:1.45; }
.doc p, .doc li { line-height:1.6; }
.doc .fields { color:var(--muted); font-size:13px; }

/* ---------- play ---------- */
body.play { overflow:hidden; }
#stage { position:fixed; inset:0; background:#000; }
#c { width:100%; height:100%; display:block; image-rendering:pixelated; image-rendering:crisp-edges; }
#hud { position:absolute; inset:0; pointer-events:none; font-size:14px; }
#hud .top { display:flex; align-items:flex-start; gap:14px; padding:10px 96px 10px 12px; }
#hud .hearts { display:flex; gap:4px; padding-top:3px; }
#hud .hearts i { width:16px; height:14px; display:block; background:#2b2f45; clip-path:polygon(50% 100%, 0 40%, 0 20%, 20% 0, 50% 20%, 80% 0, 100% 20%, 100% 40%); }
#hud .hearts i.on { background:#f87171; }
#hud .title { display:flex; flex-direction:column; line-height:1.15; }
#hud .title .g { font-size:11px; color:var(--accent); text-transform:uppercase; letter-spacing:.06em; }
#hud .title .l { font-weight:700; text-shadow:0 1px 2px #000; }
#hud .counters { margin-left:auto; display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; max-width:55%; }
#hud .ct { background:rgba(10,13,26,.75); border:1px solid rgba(255,255,255,.12); border-radius:8px; padding:4px 8px; font-size:13px; white-space:nowrap; }
#hud .ct.done { border-color:var(--good); color:var(--good); }
#hud .ct b { font-weight:600; color:var(--muted); margin-right:4px; }
#hud .ct .done { color:var(--good); } #hud .ct .todo { color:var(--muted); }
#hud .meter .bar { display:inline-block; width:70px; height:8px; background:#0f131d; border-radius:4px; vertical-align:middle; overflow:hidden; margin:0 4px; }
#hud .meter .bar span { display:block; height:100%; background:var(--info); } #hud .meter .bar .good { background:var(--good); } #hud .meter .bar .bad { background:var(--bad); }
#hud .toasts { position:absolute; left:50%; bottom:84px; transform:translateX(-50%); display:flex; flex-direction:column; align-items:center; gap:6px; width:min(92%,560px); }
#hud .toast { background:rgba(10,13,26,.88); border:1px solid rgba(255,209,102,.35); border-radius:10px; padding:8px 14px; text-align:center; font-size:14px; line-height:1.35; box-shadow:0 6px 20px rgba(0,0,0,.4); }
#hud .carry { position:absolute; left:12px; bottom:14px; background:rgba(10,13,26,.8); border:1px solid rgba(125,211,252,.4); border-radius:8px; padding:6px 10px; font-size:13px; display:none; }
#hud .carry.show { display:block; }
#hud .sentence { display:none; margin:0 12px; background:rgba(10,13,26,.8); border:1px solid rgba(255,255,255,.12); border-radius:10px; padding:8px 12px; font-size:15px; width:max-content; max-width:90%; }
#hud .sentence.show { display:block; } #hud .sentence span { color:var(--good); font-weight:600; } #hud .sentence i { color:var(--muted); }
#overlay { position:absolute; inset:0; display:none; place-items:center; background:rgba(5,7,16,.66); backdrop-filter:blur(3px); padding:16px; }
#overlay.show { display:grid; }
.card { width:min(560px,100%); max-height:92vh; overflow:auto; background:var(--panel); border:1px solid rgba(255,255,255,.12); border-radius:18px; padding:26px 28px; box-shadow:0 30px 80px rgba(0,0,0,.6); }
.card .kicker { color:var(--accent); font-size:12px; letter-spacing:.08em; text-transform:uppercase; margin-bottom:6px; }
.card h2 { margin:0 0 10px; font-size:26px; letter-spacing:-.01em; }
.card .lead { font-size:16px; line-height:1.5; margin:0 0 12px; }
.card .task { background:rgba(255,209,102,.1); border:1px solid rgba(255,209,102,.3); border-radius:10px; padding:10px 12px; margin:0 0 12px; line-height:1.45; }
.card .controls, .card .small { color:var(--muted); font-size:13px; line-height:1.5; margin:10px 0 0; }
.card .concept-hint { color:var(--muted); font-size:14px; margin:0; }
.card .concept { background:linear-gradient(135deg,rgba(125,211,252,.12),rgba(167,139,250,.12)); border:1px solid rgba(125,211,252,.3); border-radius:12px; padding:12px 14px; margin:10px 0; }
.card .concept .k { font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--info); margin-bottom:4px; }
.card .concept p { margin:6px 0 0; line-height:1.5; }
.card .actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:18px; }
.card button { border:1px solid rgba(255,255,255,.14); background:var(--panel2); color:var(--text); border-radius:12px; padding:11px 18px; font-size:15px; }
.card button.primary { background:var(--accent); color:#1b1b2a; border-color:transparent; font-weight:700; }
.card .codex { list-style:none; padding:0; margin:12px 0 0; display:flex; flex-direction:column; gap:8px; }
.card .codex li { border:1px solid var(--line); border-radius:10px; padding:10px 12px; } .card .codex li.known { border-color:rgba(74,222,128,.4); }
.card .codex li p { margin:4px 0 0; color:var(--text); line-height:1.45; font-size:14px; } .card .codex .muted { color:var(--muted); }
#touch { position:absolute; inset:auto 0 0 0; display:none; justify-content:space-between; padding:0 14px 18px; pointer-events:none; }
#touch.show { display:flex; }
#touch .grp { display:flex; gap:10px; pointer-events:auto; }
#touch button { width:62px; height:62px; border-radius:50%; border:2px solid rgba(255,255,255,.25); background:rgba(20,26,46,.6); color:#fff; font-size:22px; touch-action:none; user-select:none; -webkit-user-select:none; }
#touch button.on { background:rgba(255,209,102,.5); }
#touch button.act { font-size:14px; font-weight:700; }
.backlink { position:absolute; top:8px; right:10px; pointer-events:auto; }
.backlink button { background:rgba(10,13,26,.7); border:1px solid rgba(255,255,255,.14); color:var(--text); border-radius:8px; padding:5px 9px; font-size:13px; }
