:root {
  --bg: #0f1420; --panel: #171e2e; --panel2: #1f2838; --text: #e8ecf4; --muted: #8a94a8;
  --accent: #5b8cff; --ok: #3ddc84; --bad: #ff5c6c; --gold: #ffc53d; --border: #2a3448;
  --lp: #ff7eb6; --lr: #ffa94d; --lm: #ffe066; --li: #69db7c; --th: #868e96;
  --ri: #4dabf7; --rm: #b197fc; --rr: #63e6be; --rp: #ff8787;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
b { font-weight: 600; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
h2 { margin: 0 0 8px; font-size: 20px; }

.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { color: var(--text); font-weight: 700; white-space: nowrap; }
.progress { flex: 1; max-width: 420px; }
.level { font-size: 14px; display: flex; justify-content: space-between; }
.bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); width: 0; transition: width .4s; }
.stats-mini { margin-left: auto; display: flex; gap: 18px; font-size: 15px; }
.stats-mini a { color: var(--text); }

.screen { max-width: 1100px; margin: 0 auto; padding: 24px; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.lvl { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 14px; opacity: .55; }
.lvl.reached { opacity: 1; }
.lvl.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91,140,255,.3); }
.lvl b { display: block; font-size: 16px; }
.lvl .muted { font-size: 13px; }

.section { margin-bottom: 28px; }
.section h2 span { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 8px; }
.section.locked h2 { color: var(--muted); }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.lesson { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; text-align: left; color: var(--text); font: inherit; transition: transform .1s, border-color .1s; }
.lesson:hover { transform: translateY(-2px); border-color: var(--accent); }
.lesson:disabled { opacity: .45; cursor: not-allowed; transform: none; border-color: var(--border); }
.lesson .t { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.lesson .d { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.lesson .best { font-size: 13px; display: flex; justify-content: space-between; }
.lesson .pbar { height: 5px; background: var(--panel2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.lesson .pbar div { height: 100%; background: var(--ok); }
.star { color: var(--gold); letter-spacing: 1px; }
.star .off { color: var(--border); }

.badges { margin-bottom: 28px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.badge { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.badge .ic { font-size: 26px; }
.badge.locked { opacity: .4; filter: grayscale(1); }
.badge b { display: block; font-size: 14px; }
.method { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; font-size: 15px; }
.method ul { margin: 0 0 8px; padding-left: 20px; }

.btn { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.ghost { background: var(--panel2); color: var(--text); }
.btn:hover { filter: brightness(1.1); }

.lesson-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lesson-head h2 { flex: 1; }
.live { display: flex; gap: 18px; font-size: 14px; color: var(--muted); }
.live b { color: var(--text); font-size: 17px; margin-left: 2px; }

.text-box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px 26px; margin: 12px 0 8px; font-size: 26px; line-height: 1.7; font-family: "SF Mono", Menlo, Consolas, monospace; outline: none; max-height: 150px; overflow: hidden; position: relative; }
.text-box.focus { border-color: var(--accent); }
.text-box.dict #text { filter: blur(9px); user-select: none; }
#text { transition: margin-top .15s; }
#text span { border-radius: 3px; }
#text .ok { color: var(--ok); }
#text .bad { color: var(--bad); background: rgba(255,92,108,.18); text-decoration: underline; }
#text .cur { background: var(--accent); color: #fff; animation: blink 1s infinite; }
#text .cur.space { box-shadow: inset 0 -3px 0 #fff; }
#text .ws { white-space: pre; }
@keyframes blink { 50% { background: rgba(91,140,255,.45); } }
.hint { font-size: 14px; color: var(--muted); min-height: 22px; }
.hint.warn { color: var(--gold); }
.finger-hint { font-size: 15px; min-height: 24px; margin-bottom: 8px; }
.finger-hint b { padding: 1px 8px; border-radius: 6px; color: #10141c; }

.hands-kbd { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.keyboard { display: flex; flex-direction: column; gap: 6px; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; user-select: none; width: 100%; max-width: 820px; }
.krow { display: flex; gap: 6px; }
.key { --w: 1; flex: var(--w) 0 0; min-width: 0; height: 46px; background: var(--panel2); border-radius: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 15px; position: relative; border-bottom: 3px solid rgba(0,0,0,.35); color: var(--text); }
.key small { font-size: 10px; color: var(--muted); line-height: 1; position: absolute; top: 4px; left: 6px; }
.key::before { content: ""; position: absolute; inset: 0; border-radius: 7px; background: var(--fc); opacity: .18; }
.key.home::after { content: ""; position: absolute; bottom: 5px; width: 14px; height: 3px; border-radius: 2px; background: var(--fc); opacity: .9; }
.key.active { background: var(--fc); color: #10141c; box-shadow: 0 0 0 3px #fff, 0 0 18px var(--fc); transform: translateY(-2px); z-index: 1; }
.key.active small { color: #10141c; }
.key.active::before { opacity: 0; }
.key.pressed { transform: translateY(2px); border-bottom-width: 1px; }
.key.wrong { background: var(--bad); color: #fff; }
.key.wrong::before { opacity: 0; }

.hands { display: flex; gap: 60px; }
.hands svg { width: 190px; height: 170px; }
.hands .f { fill: var(--panel2); stroke: var(--border); stroke-width: 2; transition: fill .1s; }
.hands .palm { fill: var(--panel2); stroke: var(--border); stroke-width: 2; }
.hands .f.on { fill: var(--fc); stroke: #fff; filter: drop-shadow(0 0 8px var(--fc)); }
.hands .f.dim { fill: var(--fc); fill-opacity: .25; }

.modal { position: fixed; inset: 0; background: rgba(5,8,14,.75); display: flex; align-items: center; justify-content: center; z-index: 10; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 28px 32px; width: min(520px, 92vw); text-align: center; }
.stars { font-size: 44px; color: var(--gold); margin: 6px 0 12px; }
.stars .off { color: var(--border); }
.r-goals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.r-goals div { background: var(--panel2); border-radius: 10px; padding: 10px 4px; border: 1px solid transparent; }
.r-goals div.ok { border-color: var(--ok); }
.r-goals div.fail { border-color: var(--bad); opacity: .8; }
.r-goals b { display: block; font-size: 22px; }
.r-goals span { font-size: 12px; color: var(--muted); display: block; }
.goals { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin: 6px 0 4px; }
.goals b { color: var(--text); }
.drill-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin-top: 12px; }
.drill { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.drill:hover { border-color: var(--accent); }
.drill:disabled { opacity: .45; cursor: not-allowed; border-color: var(--border); }
.drill .n { color: var(--muted); font-size: 13px; min-width: 24px; }
.drill .t { flex: 1; font-size: 14px; }
.drill .star { font-size: 13px; }
.drill.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91,140,255,.3); }
.xp-gain { font-size: 18px; color: var(--ok); margin: 8px 0; }
.new-badge, .level-up { background: var(--panel2); border-radius: 10px; padding: 10px; margin: 8px 0; }
.level-up { color: var(--gold); font-weight: 700; font-size: 18px; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
#free-box { margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
#free-box textarea { width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font: inherit; }

@media (max-width: 760px) {
  .top { gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
  .progress { order: 3; flex-basis: 100%; max-width: none; }
  .screen { padding: 16px; }
  .levels { grid-template-columns: repeat(2, 1fr); }
  .text-box { font-size: 20px; padding: 14px 16px; }
  .hands { gap: 20px; }
  .hands svg { width: 130px; height: 120px; }
  .key { height: 36px; font-size: 12px; }
  .key small { display: none; }
  .r-goals { grid-template-columns: 1fr; }
}
