:root {
  --bg: #fff7e8; --card: #ffffff; --ink: #2b2d42; --muted: #6c6f80; --line: #f0e4d0;
  --orange: #ff8c42; --teal: #2ec4b6; --purple: #7b5cff; --yellow: #ffd166; --green: #06d6a0; --red: #ef476f; --blue: #4cc9f0;
  --pinky: #ff6b9d; --ring: #ffb347; --middle: #ffe66d; --index: #6bd97a; --thumb: #6cc5ff;
  --radius: 20px; --shadow: 0 6px 24px rgba(60, 40, 0, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Nunito', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.45; min-height: 100vh; }
body::before { content: ''; position: fixed; inset: 0; z-index: -1; background:
  radial-gradient(circle at 10% 10%, rgba(255,140,66,0.10), transparent 40%),
  radial-gradient(circle at 90% 20%, rgba(46,196,182,0.10), transparent 40%),
  radial-gradient(circle at 50% 100%, rgba(123,92,255,0.08), transparent 40%); }
a { color: var(--purple); }
button, input, select { font: inherit; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: 34px; font-weight: 900; }
h2 { font-size: 24px; font-weight: 900; }
h3 { font-size: 18px; font-weight: 800; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.loading { text-align: center; padding: 80px 16px; font-size: 22px; font-weight: 800; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }
.hidden { display: none !important; }

/* buttons */
.btn { border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 900; font-size: 16px; cursor: pointer; background: var(--orange); color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,0.12); transition: transform .08s, box-shadow .08s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.btn.teal { background: var(--teal); }
.btn.purple { background: var(--purple); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.big { padding: 16px 30px; font-size: 20px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 800; font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=tel], select { border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 18px; background: #fff; outline: none; width: 100%; }
input:focus, select:focus { border-color: var(--teal); }
.pin-input { letter-spacing: 12px; text-align: center; font-size: 28px; font-family: 'Roboto Mono', monospace; }
.error { color: var(--red); font-weight: 800; min-height: 22px; }

/* header */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 0 14px; flex-wrap: wrap; }
.logo { font-size: 30px; font-weight: 900; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.logo span { color: var(--orange); }
.player-chip { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 999px; padding: 6px 14px 6px 6px; box-shadow: var(--shadow); }
.player-chip .av { width: 40px; height: 40px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 24px; }
.player-chip b { display: block; line-height: 1.1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 18px; }
.tab { border: 0; background: transparent; padding: 10px 16px; border-radius: 999px; font-weight: 900; color: var(--muted); cursor: pointer; font-size: 16px; }
.tab.on { background: var(--ink); color: #fff; }
.tab:hover:not(.on) { background: #fff; }

/* players screen */
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.player-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 12px; text-align: center; cursor: pointer; border: 3px solid transparent; transition: transform .1s; }
.player-card:hover { transform: translateY(-3px); border-color: var(--teal); }
.player-card .av { font-size: 52px; line-height: 1; }
.player-card b { display: block; font-size: 18px; margin-top: 8px; }
.player-card.new { border: 3px dashed var(--line); background: transparent; box-shadow: none; display: grid; place-items: center; min-height: 140px; color: var(--muted); }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-pick button { font-size: 30px; width: 54px; height: 54px; border-radius: 14px; border: 3px solid var(--line); background: #fff; cursor: pointer; }
.avatar-pick button.on { border-color: var(--orange); background: #fff3e6; }
.band-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.band-pick button { border: 3px solid var(--line); background: #fff; border-radius: 14px; padding: 10px; cursor: pointer; text-align: center; }
.band-pick button.on { border-color: var(--teal); background: #eafaf8; }
.band-pick b { display: block; }
.modal-bg { position: fixed; inset: 0; background: rgba(43,45,66,0.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 24px; padding: 26px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }

/* lessons */
.continue-card { display: flex; gap: 16px; align-items: center; background: linear-gradient(135deg, var(--purple), var(--teal)); color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.continue-card h2 { color: #fff; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.lesson-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; border: 3px solid transparent; position: relative; }
.lesson-card:hover { border-color: var(--orange); }
.lesson-card.locked { opacity: .55; cursor: not-allowed; }
.lesson-card.done { border-color: var(--green); }
.lesson-card .num { font-size: 13px; font-weight: 900; color: var(--muted); }
.lesson-card .title { font-weight: 900; font-size: 17px; margin: 2px 0 6px; }
.lesson-card .keys { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.keycap { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 7px; background: #f4f0e8; border: 1px solid #e2d8c6; box-shadow: 0 2px 0 #d8ccb6; font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 13px; }
.dots { display: flex; gap: 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #eee5d6; }
.dot.s1 { background: var(--yellow); } .dot.s2 { background: var(--orange); } .dot.s3 { background: var(--green); }
.stars-txt { font-size: 13px; font-weight: 800; color: var(--muted); float: right; }
.lock { position: absolute; top: 12px; right: 14px; font-size: 18px; }
.act-list { display: flex; flex-direction: column; gap: 8px; }
.act { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent; }
.act:hover { border-color: var(--teal); }
.act .stage { font-size: 12px; font-weight: 900; text-transform: uppercase; padding: 4px 8px; border-radius: 8px; color: #fff; min-width: 96px; text-align: center; }
.stage.Review { background: var(--blue); } .stage.Learn { background: var(--purple); } .stage.Practice { background: var(--teal); } .stage.Build { background: var(--orange); }
.act .stars { margin-left: auto; font-size: 18px; letter-spacing: 2px; }
.act .best { font-size: 13px; color: var(--muted); }
.tip-box { background: #fff9ea; border-left: 6px solid var(--yellow); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }

/* drill */
.drill-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.drill-head h2 { margin: 0; }
.drill-stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.stat { background: #fff; border-radius: 14px; padding: 8px 16px; box-shadow: var(--shadow); min-width: 96px; text-align: center; }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.stat.goal b { color: var(--purple); }
#d-kbtoggle { margin-left: auto; }
.progress { height: 8px; background: #efe6d6; border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--green)); transition: width .15s; }
.txt-wrap { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 22px 26px; max-height: 210px; overflow: hidden; position: relative; }
.txt { font-family: 'Roboto Mono', monospace; font-size: 30px; line-height: 1.7; font-weight: 500; color: #9a9db0; word-break: normal; }
.txt .w { white-space: nowrap; }
.txt .c { border-radius: 5px; padding: 0 1px; }
.txt .c.ok { color: var(--ink); }
.txt .c.err { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 3px; }
.txt .c.cur { background: var(--yellow); color: var(--ink); box-shadow: 0 3px 0 var(--orange); }
.txt .c.sp.cur { background: var(--yellow); min-width: .5em; display: inline-block; }
.txt .c.nl { color: var(--purple); font-size: .8em; }
.txt .c.bad { background: var(--red); color: #fff; }
.txt.shake { animation: shake .22s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 30% { transform: translateX(-5px); } 60% { transform: translateX(5px); } }
.hint { text-align: center; font-weight: 800; color: var(--muted); margin: 10px 0 4px; min-height: 24px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 14px; font-weight: 800; opacity: 0; transition: all .2s; pointer-events: none; z-index: 40; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.caps-warn { display: none; background: var(--red); color: #fff; font-weight: 900; padding: 10px 16px; border-radius: 12px; margin-bottom: 10px; text-align: center; }
.caps-warn.show { display: block; }

/* keyboard */
.kb-area { position: relative; margin-top: 10px; transition: max-height .3s, opacity .3s; max-height: 600px; overflow: hidden; }
.kb-area.kb-hidden { max-height: 0; opacity: 0; }
.kb { display: flex; flex-direction: column; gap: 5px; max-width: 760px; margin: 0 auto; user-select: none; }
.kb-row { display: flex; gap: 5px; }
.key { height: 42px; border-radius: 8px; background: #fff; border: 1px solid #e6dccb; box-shadow: 0 3px 0 #d9cfbd; display: flex; align-items: center; justify-content: center; position: relative; font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 15px; color: var(--ink); transition: transform .08s; }
.key .kshift { position: absolute; top: 3px; left: 6px; font-size: 10px; color: var(--muted); }
.key .kmain { position: relative; top: 2px; }
.key.wide .kmain { font-size: 11px; font-family: 'Nunito', sans-serif; font-weight: 800; color: var(--muted); }
.key .bump { position: absolute; bottom: 5px; left: 50%; width: 10px; height: 3px; margin-left: -5px; border-radius: 2px; background: #bfb5a4; }
.key.f-L-pinky, .key.f-R-pinky { background: #ffe1ea; } .key.f-L-ring, .key.f-R-ring { background: #ffefd9; }
.key.f-L-middle, .key.f-R-middle { background: #fffad4; } .key.f-L-index, .key.f-R-index { background: #e3f8e6; } .key.f-R-thumb { background: #e0f2ff; }
.key.cur { transform: translateY(2px); box-shadow: 0 1px 0 #d9cfbd, 0 0 0 4px rgba(255,140,66,.45); animation: pulse 1s infinite; z-index: 1; }
.key.cur.f-L-pinky, .key.cur.f-R-pinky { background: var(--pinky); color: #fff; } .key.cur.f-L-ring, .key.cur.f-R-ring { background: var(--ring); }
.key.cur.f-L-middle, .key.cur.f-R-middle { background: var(--middle); } .key.cur.f-L-index, .key.cur.f-R-index { background: var(--index); } .key.cur.f-R-thumb { background: var(--thumb); }
.key.cur-shift { background: var(--pinky); color: #fff; box-shadow: 0 1px 0 #d9cfbd, 0 0 0 4px rgba(255,107,157,.4); }
@keyframes pulse { 0%,100% { box-shadow: 0 1px 0 #d9cfbd, 0 0 0 3px rgba(255,140,66,.3); } 50% { box-shadow: 0 1px 0 #d9cfbd, 0 0 0 7px rgba(255,140,66,.15); } }
.paw-marker { position: absolute; top: 0; left: 0; width: 32px; height: 32px; font-size: 26px; line-height: 32px; text-align: center; transition: transform .7s cubic-bezier(.4,0,.2,1); pointer-events: none; z-index: 3; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.hands { max-width: 420px; margin: 8px auto 0; }
.hands-svg { width: 100%; height: auto; display: block; }
.hands-svg .palm { fill: #fbe3cc; stroke: #e6c8a6; stroke-width: 2; }
.hands-svg .finger { fill: #fbe3cc; stroke: #e6c8a6; stroke-width: 2; transition: fill .15s; }
.hands-svg .finger.on { stroke: var(--ink); stroke-width: 3; }
.hands-svg .f-L-pinky, .hands-svg .f-R-pinky { fill: #ffd5e1; } .hands-svg .f-L-ring, .hands-svg .f-R-ring { fill: #ffe6c7; }
.hands-svg .f-L-middle, .hands-svg .f-R-middle { fill: #fff6c2; } .hands-svg .f-L-index, .hands-svg .f-R-index { fill: #d8f5dc; } .hands-svg .f-L-thumb, .hands-svg .f-R-thumb { fill: #d6ecff; }
.hands-svg .finger.on.f-L-pinky, .hands-svg .finger.on.f-R-pinky { fill: var(--pinky); } .hands-svg .finger.on.f-L-ring, .hands-svg .finger.on.f-R-ring { fill: var(--ring); }
.hands-svg .finger.on.f-L-middle, .hands-svg .finger.on.f-R-middle { fill: var(--middle); } .hands-svg .finger.on.f-L-index, .hands-svg .finger.on.f-R-index { fill: var(--index); } .hands-svg .finger.on.f-L-thumb, .hands-svg .finger.on.f-R-thumb { fill: var(--thumb); }
.finger-legend { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; font-size: 13px; font-weight: 800; color: var(--muted); margin-top: 6px; }
.finger-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* intro overlay and results */
.intro-overlay { display: grid; place-items: center; padding: 6px 0; }
.drill-area { position: relative; }
.intro-card { background: #fff; border-radius: 24px; padding: 28px 32px; max-width: 560px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.intro-title { font-size: 30px; font-weight: 900; margin-bottom: 8px; }
.intro-body { font-size: 18px; margin-bottom: 14px; }
.intro-go { font-weight: 900; color: var(--purple); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .4; } }
.result-card { background: #fff; border-radius: 24px; padding: 26px 30px; max-width: 520px; margin: 0 auto; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.big-stars { font-size: 54px; letter-spacing: 6px; margin: 4px 0 8px; }
.big-stars .off { opacity: .2; }
.big-stars .pop { display: inline-block; animation: popin .5s both; }
.big-stars .pop:nth-child(2) { animation-delay: .25s; } .big-stars .pop:nth-child(3) { animation-delay: .5s; }
@keyframes popin { 0% { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.3) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
.result-msg { font-size: 22px; font-weight: 900; margin-bottom: 8px; }
.result-nums { display: flex; justify-content: center; gap: 18px; margin: 12px 0 18px; flex-wrap: wrap; }
.result-nums div b { display: block; font-size: 28px; }
.result-nums div span { font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* games */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.game-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; cursor: pointer; border: 3px solid transparent; }
.game-card:hover { border-color: var(--purple); }
.game-card .icon { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.game-card b { font-size: 19px; display: block; }
.game-stage { position: relative; background: linear-gradient(180deg, #dff6ff, #eafff5); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
canvas.game { display: block; width: 100%; height: auto; }
.game-hud { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pond { position: relative; height: 440px; }
.pad { position: absolute; width: 74px; height: 74px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #9be27a, #3fa34d); box-shadow: 0 4px 0 #2f7d3a; display: grid; place-items: center; font-family: 'Roboto Mono', monospace; font-size: 34px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.3); animation: bob 1.4s ease-in-out infinite; transition: transform .1s; }
.pad.caught { transform: scale(0); }
.pad .life { position: absolute; bottom: -8px; left: 8px; right: 8px; height: 5px; background: rgba(0,0,0,.2); border-radius: 3px; overflow: hidden; }
.pad .life i { display: block; height: 100%; background: var(--yellow); }
@keyframes bob { 50% { margin-top: -6px; } }
.race { background: #fff; border-radius: 16px; padding: 14px 18px 10px; margin-bottom: 12px; box-shadow: var(--shadow); }
.lane { position: relative; height: 44px; border-bottom: 3px dashed #eee3cf; }
.lane .runner { position: absolute; top: 2px; font-size: 32px; transition: left .12s linear; }
.lane .flag { position: absolute; right: 0; top: 4px; font-size: 26px; }
.lane .who { position: absolute; left: 0; top: -2px; font-size: 12px; font-weight: 900; color: var(--muted); }

/* leaderboards, trophies, stats */
.boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.board { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.board h3 { display: flex; align-items: center; gap: 8px; }
.board .sub { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; }
.board li.me { background: #fff3e6; }
.board li .medal { width: 26px; text-align: center; font-weight: 900; color: var(--muted); }
.board li .val { margin-left: auto; font-weight: 900; font-family: 'Roboto Mono', monospace; }
.board .empty { color: var(--muted); font-style: italic; padding: 6px 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 14px; text-align: center; }
.tile b { display: block; font-size: 28px; }
.tile span { font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.patches { display: flex; gap: 12px; flex-wrap: wrap; }
.patch { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; text-align: center; font-weight: 900; background: #f1ebe0; color: #b8b0a0; border: 4px dashed #ddd3c2; line-height: 1.1; }
.patch b { font-size: 24px; display: block; }
.patch.earned { background: radial-gradient(circle at 30% 30%, #ffe9a8, var(--orange)); color: #5a2d00; border: 4px solid var(--yellow); box-shadow: 0 6px 16px rgba(255,140,66,.4); }
.rank-bar { height: 14px; background: #efe6d6; border-radius: 7px; overflow: hidden; margin: 8px 0; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--yellow)); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.badge { aspect-ratio: 1; border-radius: 14px; display: grid; place-items: center; font-weight: 900; background: #f1ebe0; color: #b8b0a0; font-size: 15px; }
.badge.done { background: #dff5ee; color: #1b7a63; } .badge.gold { background: linear-gradient(135deg, #ffe9a8, var(--yellow)); color: #6b4a00; }
.trouble { display: flex; gap: 10px; flex-wrap: wrap; }
.trouble .keycap { min-width: 44px; height: 44px; font-size: 20px; }
.trouble .k { text-align: center; font-size: 12px; color: var(--muted); font-weight: 800; }
table.parent { width: 100%; border-collapse: collapse; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); font-size: 14px; }
table.parent th, table.parent td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.parent th { background: #fbf4e6; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch input { width: 22px; height: 22px; }
.posture { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 12px 0; }
.posture > div { background: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.posture .ic { font-size: 30px; }

@media (max-width: 700px) {
  body { font-size: 15px; }
  .txt { font-size: 22px; }
  .key { height: 34px; font-size: 12px; }
  .stat { min-width: 70px; padding: 6px 10px; } .stat b { font-size: 20px; }
  h1 { font-size: 26px; }
  .band-pick { grid-template-columns: 1fr; }
}
table.parent select { width: auto; min-width: 120px; padding: 6px 8px; font-size: 14px; }
