﻿/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 0 20px; border: 0; border-radius: var(--r-m);
  font: 600 16px var(--font); color: #fff; background: var(--go);
  box-shadow: 0 4px 0 var(--go-d); cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--go-d); }
.btn.gold { background: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 0 var(--gold-d); }
.btn.gold:active { box-shadow: 0 1px 0 var(--gold-d); }
.btn.bad { background: var(--bad); box-shadow: 0 4px 0 var(--bad-d); }
.btn.bad:active { box-shadow: 0 1px 0 var(--bad-d); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--line); }
.btn.ghost:active { transform: none; }

.btn.sm { width: auto; min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; box-shadow: 0 3px 0 var(--go-d); }
.btn.sm.gold { box-shadow: 0 3px 0 var(--gold-d); }
.btn.sm.ghost { box-shadow: none; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }

/* ---------- home ---------- */
.top { background: var(--brand); color: #fff; padding: 12px 18px 72px; border-radius: 0 0 var(--r-l) var(--r-l); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tools { display: flex; align-items: center; }
.icon-btn.lang { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font: 600 14px var(--font); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; background: var(--brand-d); font-size: 14px; font-weight: 500; }
.chip .ic { width: 18px; height: 18px; }
.chip.gold { background: var(--gold); color: var(--gold-ink); }
.top h1 { font-size: 24px; font-weight: 600; line-height: 1.4; margin-top: 18px; }
.top .sub { color: var(--mint); font-size: 14px; margin-top: 2px; }
.lvl { margin-top: 16px; }
.lvl .bar { background: var(--brand-d); height: 10px; }
.lvl .bar > i { background: var(--gold); }
.lvl small { display: block; margin-top: 6px; font-size: 13px; color: var(--mint); }

.today {
  margin: -42px 18px 0; position: relative; background: var(--surface); border: 2px solid var(--line);
  border-radius: 20px; padding: 16px; display: flex; align-items: center; gap: 14px;
}
.today .info { flex: 1; min-width: 0; }
.today .t { font-weight: 600; font-size: 16px; line-height: 1.4; }
.today .m { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.today .btn { width: auto; min-height: 46px; padding: 0 22px; }

.path { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px 0 60px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.tile {
  width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center;
  background: var(--gold); color: var(--gold-ink); box-shadow: 0 7px 0 var(--gold-d);
  transition: transform .1s, box-shadow .1s;
}
.tile .ic { width: 38px; height: 38px; }
.node:active .tile { transform: translateY(5px); box-shadow: 0 2px 0 var(--gold-d); }
.node.done .tile { background: var(--go); color: #fff; box-shadow: 0 7px 0 var(--go-d); }
.node.locked { color: var(--ink-3); pointer-events: none; }
.node.locked .tile { background: var(--line); color: var(--ink-3); box-shadow: 0 7px 0 var(--line); filter: brightness(.94); }
.node .cap { font-size: 14px; font-weight: 500; text-align: center; max-width: 220px; }
.node.now .tile { animation: nudge 1.2s var(--ease) 1; }
.link-line { width: 6px; height: 28px; background: var(--line); border-radius: 3px; }
.empty { text-align: center; color: var(--ink-2); font-size: 14px; max-width: 260px; }

/* ---------- progress bar ---------- */
.bar { flex: 1; height: 16px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--go); border-radius: 99px; transition: width .5s var(--ease); }

/* ---------- quiz ---------- */
.qbar { display: flex; align-items: center; gap: 10px; padding: 12px 12px 8px 18px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.qbar .icon-btn:hover { background: var(--line); }
.qbar .icon-btn { color: var(--ink-2); }
.qmain { padding: 10px 18px 190px; outline: none; }
.prompt { font-size: 20px; font-weight: 500; line-height: 1.55; margin: 8px 0 22px; text-align: start; }
.prompt.ar { font-size: 18px; }
.opts { display: grid; gap: 12px; }

.opt, .tok, .cell, .flash {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  background: var(--surface); color: var(--ink); cursor: pointer;
  border: 2px solid var(--line); border-bottom-width: 5px; border-radius: var(--r-m);
  padding: 12px 14px; min-height: 56px; font: 400 16px/1.5 var(--font);
  transition: transform .08s, border-color .12s, background .12s;
}
.opt:active, .tok:active, .cell:active { transform: translateY(2px); }
.key {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px;
  border: 2px solid var(--line); font: 600 13px var(--font); color: var(--ink-2);
}
.opt[aria-checked="true"] { border-color: var(--p2); background: color-mix(in srgb, var(--p2) 12%, var(--surface)); }
.opt[aria-checked="true"] .key { background: var(--p2); border-color: var(--p2); color: #fff; }
.is-right { border-color: var(--go) !important; background: var(--go-t) !important; color: var(--go-ink); }
.is-right .key { background: var(--go) !important; border-color: var(--go) !important; color: #fff !important; }
.is-wrong { border-color: var(--bad) !important; background: var(--bad-t) !important; color: var(--bad-ink); }
.is-wrong .key { background: var(--bad) !important; border-color: var(--bad) !important; color: #fff !important; }
.locked { pointer-events: none; }
.pop { animation: pop .35s var(--ease); }
.shake { animation: shake .4s; }

.slots { min-height: 70px; display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 2px dashed var(--line); border-radius: var(--r-m); margin-bottom: 18px; }
.slots .hint { color: var(--ink-3); font-size: 14px; text-align: center; margin: auto; }
.pool { display: flex; flex-wrap: wrap; gap: 10px; }
.tok { width: auto; min-height: 48px; padding: 8px 14px; }
.slots .tok { width: 100%; }
.tok .n { width: 26px; height: 26px; border-radius: 50%; background: var(--go); color: #fff; display: grid; place-items: center; font: 600 13px var(--font); flex: none; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.cell { min-height: 64px; font-size: 14.5px; }
.cell.sel { border-color: var(--p2); background: color-mix(in srgb, var(--p2) 12%, var(--surface)); }
.cell.p0 { border-color: var(--p0); background: color-mix(in srgb, var(--p0) 14%, var(--surface)); }
.cell.p1 { border-color: var(--p1); background: color-mix(in srgb, var(--p1) 14%, var(--surface)); }
.cell.p2 { border-color: var(--p2); background: color-mix(in srgb, var(--p2) 14%, var(--surface)); }
.cell.p3 { border-color: var(--p3); background: color-mix(in srgb, var(--p3) 14%, var(--surface)); }

textarea.code {
  display: block; width: 100%; min-height: 240px; resize: vertical; padding: 14px 16px;
  background: var(--code-bg); color: var(--code-ink); border: 2px solid transparent; border-radius: var(--r-m);
  font: 400 14px/1.7 var(--mono); tab-size: 4;
}
textarea.code.is-right { border-color: var(--go); background: var(--code-bg) !important; color: var(--code-ink); }
textarea.code.is-wrong { border-color: var(--bad); background: var(--code-bg) !important; color: var(--code-ink); }
.note { font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }

.flash { min-height: 170px; justify-content: center; text-align: center; font-size: 19px; font-family: var(--mono); border-bottom-width: 6px; flex-direction: column; }
.flash small { font: 400 13px var(--font); color: var(--ink-3); }
.flash.back { background: var(--go-t); border-color: var(--go); color: var(--go-ink); }
.flip-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }

/* ---------- bottom dock ---------- */
.dock {
  position: fixed; inset-inline: 0; bottom: 0; background: var(--surface); border-top: 2px solid var(--line);
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
}
.dock-in { max-width: 484px; margin: 0 auto; display: grid; gap: 10px; }
.dock.good { background: var(--go-t); border-color: var(--go); }
.dock.bad { background: var(--bad-t); border-color: var(--bad); }
.dock.enter { animation: rise .3s var(--ease); }
.dock .hint { text-align: center; font-size: 14px; color: var(--bad); min-height: 0; }
.fb-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; }
.dock.good .fb-title { color: var(--go-ink); }
.dock.bad .fb-title { color: var(--bad-ink); }
.fb-badge { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.dock.good .fb-badge { background: var(--go); }
.dock.bad .fb-badge { background: var(--bad); }
.fb-correct { font-size: 14px; color: var(--bad-ink); }
.fb-correct pre { margin: 4px 0 0; white-space: pre-wrap; font: 500 14px/1.6 var(--mono); direction: ltr; text-align: left; }
.fb-why { font-size: 14.5px; color: var(--ink); }
.dock.good .fb-why { color: var(--go-ink); }
.dock.bad .fb-why { color: var(--bad-ink); }

.xp-pop {
  position: fixed; inset-inline: 0; bottom: 210px; text-align: center; pointer-events: none;
  font: 700 28px var(--font); color: var(--gold-d); animation: floatup 1s var(--ease) forwards;
}

/* ---------- results ---------- */
.done-wrap { padding: 56px 24px 40px; text-align: center; position: relative; overflow: hidden; }
.medal { width: 132px; height: 132px; margin: 0 auto 22px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--gold-ink); box-shadow: 0 8px 0 var(--gold-d); animation: pop .6s var(--ease); }
.medal b { font-size: 38px; font-weight: 700; line-height: 1; }
.done-wrap h1 { font-size: 26px; font-weight: 600; }
.done-wrap .sub { color: var(--ink-2); margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 28px 0; }
.stat { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-m); padding: 12px 6px; }
.stat b { display: block; font-size: 22px; font-weight: 600; }
.stat span { font-size: 13px; color: var(--ink-2); }
.stat.gold { border-color: var(--gold); }
.stat.gold b { color: var(--gold-d); }
.levelup { display: inline-block; background: var(--go); color: #fff; border-radius: 99px; padding: 4px 16px; font-weight: 600; margin-top: 12px; animation: pop .5s var(--ease) .4s both; }
.stack { display: grid; gap: 12px; }

.burst { position: absolute; inset-inline-start: 50%; top: 150px; width: 0; height: 0; pointer-events: none; }
.burst i { position: absolute; width: 10px; height: 14px; border-radius: 2px; animation: confetti 1.3s var(--ease) forwards; }

.msg { padding: 60px 24px; text-align: center; color: var(--ink-2); }
.msg h1 { color: var(--ink); font-size: 20px; margin-bottom: 8px; }
.msg code { direction: ltr; display: inline-block; background: var(--line); padding: 2px 8px; border-radius: 6px; }

/* ---------- motion ---------- */
@keyframes pop { 0% { transform: scale(.9); } 55% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes floatup { 0% { opacity: 0; transform: translateY(14px) scale(.9); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-60px) scale(1.1); } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10px); } 70% { transform: translateY(2px); } }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }

