:root {
  --bg: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f3f4f6;
  --go: #22c55e;
  --go-d: #16a34a;
  --bad: #ef4444;
  --bad-d: #dc2626;
  --sel: #3b82f6;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #eef1f5; }
html.wiz-fs, html.wiz-fs body { height: 100%; height: 100dvh; overflow: hidden; }
html.wiz-fs #app { min-height: 100%; min-height: 100dvh; height: 100dvh; }
body { font: 16px/1.5 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); -webkit-text-size-adjust: 100%; }
button { font: inherit; cursor: pointer; }
#app { max-width: 560px; margin: 0 auto; min-height: 100%; background: var(--bg); display: flex; flex-direction: column; position: relative; box-shadow: 0 0 40px rgba(0, 0, 0, .06); }

/* top bar */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.bar .logo img { display: block; border-radius: 4px; }
.bar .x { border: 0; background: none; font-size: 22px; color: var(--muted); width: 32px; height: 32px; }
.prog { flex: 1; height: 14px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.prog i { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }
.xp { margin-left: auto; font-weight: 900; color: #f59e0b; white-space: nowrap; }
.prog + .xp { margin-left: 0; }
.lang { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-weight: 800; font-size: 13px; color: var(--ink); }

.screen { flex: 1; padding: 16px 16px 120px; }

/* level map */
.map h1 { font-weight: 900; font-size: 28px; line-height: 1.15; margin: 8px 0 4px; }
.map .sub { color: var(--muted); margin: 0 0 18px; font-weight: 700; }
.path { display: flex; flex-direction: column; align-items: center; }
.path .link { display: block; width: 4px; height: 22px; background: var(--line); border-radius: 2px; }
.node { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 360px; border: 2px solid var(--line); border-bottom-width: 5px; background: #fff; border-radius: 20px; padding: 12px 14px; text-align: left; transition: transform .1s; }
.node:active { transform: translateY(2px); border-bottom-width: 3px; }
.node:nth-of-type(even) { margin-left: 40px; }
.node .ring { --p: 0; width: 58px; height: 58px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--soft) 0); }
.node .ico { width: 46px; height: 46px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 24px; }
.node.full .ico { background: var(--c); color: #fff; font-weight: 900; }
.node .nm { display: flex; flex-direction: column; }
.node .nm b { font-size: 18px; font-weight: 900; }
.node .nm small { color: var(--muted); font-weight: 700; }
/* cards */
.card .kick { margin: 0 0 4px; font-weight: 900; font-size: 13px; letter-spacing: .03em; text-transform: uppercase; }
.card .kick.sub2 { color: var(--muted); margin-top: 18px; }
.card h2 { font-weight: 900; font-size: 24px; line-height: 1.2; margin: 0 0 8px; }
.card .txt, .card .prompt { font-size: 18px; font-weight: 700; margin: 0 0 14px; line-height: 1.45; }
.card .txt b { color: #111827; background: linear-gradient(transparent 60%, #fde68a 0); }
.simbox { position: relative; border-radius: 16px; overflow: hidden; border: 2px solid var(--line); background: #f7f4ee; }
canvas.scene { display: block; width: 100%; touch-action: pan-y; }
.hint { color: var(--muted); font-weight: 700; font-size: 14.5px; margin: 10px 2px 0; }
.runbtn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border: 0; border-bottom: 4px solid #1d4ed8; background: var(--sel); color: #fff; font-weight: 900; font-size: 18px; padding: 12px 26px; border-radius: 14px; box-shadow: 0 8px 20px rgba(59, 130, 246, .35); }

/* controls */
.ctls { display: grid; gap: 10px; margin-top: 12px; }
.ctl label { display: flex; justify-content: space-between; font-weight: 800; font-size: 14.5px; }
.ctl label b { color: var(--sel); font-variant-numeric: tabular-nums; }
.ctl input[type=range] { width: 100%; height: 30px; accent-color: var(--sel); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; border: 2px solid var(--line); border-bottom-width: 4px; background: #fff; border-radius: 12px; padding: 8px 4px; font-weight: 800; font-size: 14px; }
.seg button.on { border-color: var(--sel); color: var(--sel); background: #eff6ff; }

/* options */
.opts { display: grid; gap: 10px; margin-top: 14px; }
.opts.row { grid-template-columns: repeat(3, 1fr); }
.opt { border: 2px solid var(--line); border-bottom-width: 4px; background: #fff; border-radius: 14px; padding: 14px 10px; font-weight: 800; font-size: 16px; text-align: center; color: var(--ink); }
.opts:not(.row) .opt { text-align: left; padding: 14px 16px; }
.opt .lt { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--soft); margin-right: 6px; font-size: 14px; }
.opt.sel { border-color: var(--sel); background: #eff6ff; color: #1d4ed8; }
.opt.right { border-color: var(--go); background: #dcfce7; color: #14532d; }
.opt.wrong { border-color: var(--bad); background: #fee2e2; color: #7f1d1d; }
.opt:disabled { cursor: default; }
.opts.locked .opt { opacity: .45; cursor: not-allowed; }

/* what-if replays */
.whatif { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 6px; }
.wi { border: 2px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.wi.ok { border-color: var(--go); }
.wi .wl { margin: 0; padding: 6px 10px; font-weight: 900; font-size: 14px; border-bottom: 1px solid var(--line); }
.wi.ok .wl { background: #dcfce7; }
.wi .wv { margin: 0; padding: 6px 10px; font-weight: 800; font-size: 14px; color: var(--muted); }
.wi .wv.y { color: var(--go-d); }
.wi .wv.n { color: var(--bad-d); }
@media (min-width: 520px) { .whatif { grid-template-columns: repeat(3, 1fr); } .whatif.four { grid-template-columns: repeat(2, 1fr); } }

/* footer button */
.foot { position: sticky; bottom: 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, #fff 30%); display: grid; gap: 8px; }
.big { width: 100%; border: 0; border-radius: 16px; padding: 15px; font-weight: 900; font-size: 18px; letter-spacing: .02em; color: #fff; text-transform: uppercase; }
.big.go { background: var(--go); border-bottom: 5px solid var(--go-d); }
.big.red { background: var(--bad); border-bottom: 5px solid var(--bad-d); }
.big.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); border-bottom-width: 5px; }
.big.wa { display: block; text-align: center; text-decoration: none; background: #25D366; border-bottom: 5px solid #128C7E; }
.big:disabled { background: #d1d5db; border-bottom-color: #9ca3af; cursor: default; }
.big:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 3px; }

/* feedback sheet */
.sheet { position: fixed; left: 50%; bottom: 0; width: 100%; max-width: 560px; transform: translate(-50%, 110%); transition: transform .28s ease; z-index: 30; }
.sheet.show { transform: translate(-50%, 0); }
.sh-in { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .12); }
.sheet.good .sh-in { background: #dcfce7; }
.sheet.bad .sh-in { background: #fee2e2; }
.sh-h { margin: 0 0 4px; font-weight: 900; font-size: 20px; }
.sheet.good .sh-h { color: #14532d; }
.sheet.bad .sh-h { color: #7f1d1d; }
.sh-w { margin: 0 0 12px; font-weight: 700; font-size: 16px; color: #374151; }

/* level done */
.done { text-align: center; padding-top: 40px; }
.trophy { width: 120px; height: 120px; margin: 0 auto 16px; border-radius: 50%; background: var(--c); display: grid; place-items: center; font-size: 56px; box-shadow: 0 10px 0 rgba(0, 0, 0, .12); animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
.done h2 { font-weight: 900; font-size: 28px; margin: 0 0 6px; }
.done .sub { color: var(--muted); font-weight: 800; }
body.sheet-open .screen { padding-bottom: 260px; }
.card .kick.sub2 { scroll-margin-top: 64px; }
