/* ─────────────────────────────────────────────────────────────
   Typing Stars — kid-first UI. Mobile up to desktop.
   ───────────────────────────────────────────────────────────── */

:root {
  --brand:      #6d4aff;
  --brand-2:    #9b6bff;
  --brand-ink:  #4a2fd0;

  --bg:         #f4f2ff;
  --surface:    #ffffff;
  --surface-2:  #f7f6fd;
  --line:       #e7e3f7;

  --ink:        #1c1733;
  --ink-2:      #4a4468;
  --ink-muted:  #7b7597;

  --ok:         #16a34a;
  --ok-soft:    #dcfce7;
  --bad:        #e11d48;
  --bad-soft:   #ffe4e9;
  --warn:       #f59e0b;

  --f-l1: #f472b6;  /* pinky  */
  --f-l2: #a78bfa;  /* ring   */
  --f-l3: #60a5fa;  /* middle */
  --f-l4: #34d399;  /* index  */
  --f-th: #fbbf24;  /* thumb  */

  --r:    18px;
  --r-lg: 26px;
  --shadow:    0 2px 4px rgba(40,20,90,.05), 0 10px 28px rgba(40,20,90,.07);
  --shadow-lg: 0 8px 20px rgba(40,20,90,.10), 0 24px 60px rgba(40,20,90,.13);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14121f;
    --surface:   #1e1b2e;
    --surface-2: #262238;
    --line:      #322c4a;
    --ink:       #f2f0ff;
    --ink-2:     #cfc9e8;
    --ink-muted: #948db4;
    --ok-soft:   #10331f;
    --bad-soft:  #3b1220;
    --shadow:    0 2px 4px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 .8em; }
a  { color: var(--brand); text-decoration: none; }
small { font-size: .78rem; }

.muted  { color: var(--ink-muted); font-size: .87rem; }
.err    { color: var(--bad); font-weight: 600; }
.flash  { background: var(--ok-soft); color: var(--ok); padding: .7em 1em;
          border-radius: var(--r); font-weight: 600; }
.empty  { padding: 1.4rem 0; text-align: center; }

/* ── decorative background ─────────────────────────────── */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-blobs i {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .30;
}
.bg-blobs i:nth-child(1) { width: 44vw; height: 44vw; background: #a78bfa; top: -12vw; left: -8vw; }
.bg-blobs i:nth-child(2) { width: 36vw; height: 36vw; background: #67e8f9; top: 30vh; right: -10vw; }
.bg-blobs i:nth-child(3) { width: 40vw; height: 40vw; background: #fbcfe8; bottom: -14vw; left: 24vw; }
@media (prefers-color-scheme: dark) { .bg-blobs i { opacity: .16; } }
@media (prefers-reduced-motion: no-preference) {
  .bg-blobs i { animation: drift 22s ease-in-out infinite alternate; }
  .bg-blobs i:nth-child(2) { animation-duration: 28s; }
  .bg-blobs i:nth-child(3) { animation-duration: 34s; }
}
@keyframes drift { to { transform: translate3d(4vw, 3vh, 0) scale(1.12); } }

/* ── layout ────────────────────────────────────────────── */
.wrap { max-width: 1060px; margin: 0 auto; padding: 18px 16px 96px; }
.wrap.narrow { max-width: 640px; }
.pagehead { margin: 4px 0 16px; }
.pagehead p { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.cards2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 780px) { .cards2 { grid-template-columns: 1fr 1fr; } }

/* ── buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border: 0; border-radius: 999px;
  padding: .72em 1.5em; font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(109,74,255,.35);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s;
  text-decoration: none;
}
.btn:hover  { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.big    { font-size: 1.12rem; padding: .85em 1.9em; }
.btn.ghost  { background: var(--surface-2); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px;
}

.iconbtn {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-size: 1.15rem; cursor: pointer; text-decoration: none;
}
.iconbtn:hover { background: var(--surface-2); }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer;
           font: inherit; font-size: .82rem; padding: 2px 4px; }
.linkbtn.danger { color: var(--bad); }
.pill { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
        border-radius: 999px; padding: .25em .8em; font-size: .78rem; font-weight: 700; }

/* ── top bar / tab bar ─────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  max-width: 1060px; margin: 0 auto; padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-ico { font-size: 1.6rem; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt b { font-size: 1.02rem; }
.brand-txt small { color: var(--ink-muted); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }

.mainnav { display: none; gap: 4px; margin-left: auto; }
@media (min-width: 900px) { .mainnav { display: flex; } }
.mainnav a {
  display: flex; align-items: center; gap: .45em;
  padding: .5em 1em; border-radius: 999px; color: var(--ink-2); font-weight: 600; font-size: .92rem;
}
.mainnav a:hover { background: var(--surface); }
.mainnav a.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

.who {
  display: flex; align-items: center; gap: 9px; margin-left: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 14px 5px 5px; color: var(--ink); box-shadow: var(--shadow);
}
@media (min-width: 900px) { .who { margin-left: 0; } }
.who-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
          background: var(--c, var(--brand)); font-size: 1.1rem; }
.who-txt { display: flex; flex-direction: column; line-height: 1.15; }
.who-txt b { font-size: .88rem; }
.who-txt small { color: var(--ink-muted); font-size: .72rem; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { .tabbar { display: none; } }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px;
            color: var(--ink-muted); font-size: .66rem; font-weight: 600; padding: 5px 8px; border-radius: 12px; }
.tabbar a span { font-size: 1.25rem; line-height: 1; }
.tabbar a.on { color: var(--brand); background: var(--surface-2); }

.topbar.plain { border-bottom: 1px solid var(--line); }

/* ── profile picker ────────────────────────────────────── */
.pick-page { display: grid; place-items: center; min-height: 100dvh; }
.picker { width: 100%; max-width: 760px; padding: 28px 18px; text-align: center; }
.picker-hero { margin-bottom: 26px; }
.picker-logo { font-size: 3.4rem; }
.picker-hero h1 {
  background: linear-gradient(135deg, var(--brand), #ec4899);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-size: clamp(2rem, 7vw, 2.8rem);
}
.picker-hero p { color: var(--ink-2); font-weight: 600; }

.picker-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.kid-card {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--ink); box-shadow: var(--shadow); cursor: pointer;
  transition: transform .14s ease, border-color .14s, box-shadow .14s;
  font: inherit;
}
.kid-card:hover { transform: translateY(-4px); border-color: var(--c, var(--brand)); box-shadow: var(--shadow-lg); }
.kid-av { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
          font-size: 2rem; background: color-mix(in srgb, var(--c, var(--brand)) 18%, var(--surface)); }
.kid-card b { font-size: 1.05rem; }
.kid-card small { color: var(--ink-muted); font-size: .72rem; }
.kid-card.add { border-style: dashed; }
.picker-foot { margin-top: 26px; }
.picker-foot a { color: var(--ink-muted); font-size: .85rem; }
.narrowform { max-width: 340px; margin: 0 auto; text-align: left; }

/* ── forms ─────────────────────────────────────────────── */
label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=password], input:not([type]), textarea {
  width: 100%; margin-top: 6px; padding: .72em .9em;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-2); color: var(--ink); font: inherit;
}
textarea { resize: vertical; }

.avpick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.avopt input { position: absolute; opacity: 0; pointer-events: none; }
.avopt span {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.4rem; background: var(--surface-2); border: 2px solid var(--line); cursor: pointer;
}
.avopt input:checked + span { border-color: var(--brand); transform: scale(1.06); }
.avopt.col span { width: 38px; height: 38px; border-radius: 50%; }

.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0;
          border-bottom: 1px solid var(--line); font-weight: 400; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle > span { flex: 0 0 50px; height: 30px; border-radius: 999px; background: var(--line);
                 position: relative; transition: background .16s; cursor: pointer; }
.toggle > span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
                        border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25);
                        transition: transform .16s; }
.toggle input:checked + span { background: var(--brand); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle div b { display: block; font-size: .95rem; }
.toggle div small { color: var(--ink-muted); }

/* ── home ──────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 55%, #ec4899);
  border-radius: var(--r-lg); color: #fff; padding: 26px 22px;
  box-shadow: var(--shadow-lg); margin-bottom: 16px;
  display: grid; gap: 16px; grid-template-columns: 1fr;
}
@media (min-width: 720px) { .hero { grid-template-columns: 1.4fr .9fr; align-items: center; } }
.hero h1 { color: #fff; font-size: clamp(1.6rem, 5vw, 2.3rem); }
.hero p { color: rgba(255,255,255,.9); }
.hero .btn { background: #fff; color: var(--brand-ink); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.hero-next { margin: 12px 0 0; font-size: .85rem; }
.wave { display: inline-block; }
@media (prefers-reduced-motion: no-preference) { .wave { animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; } }
@keyframes wave { 0%,60%,100% { transform: rotate(0); } 15% { transform: rotate(16deg); } 30% { transform: rotate(-8deg); } }

.hero-art { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hero-emoji { font-size: 4rem; filter: drop-shadow(0 6px 12px rgba(0,0,0,.25)); }
.hero-keys { display: flex; gap: 5px; }
.hero-keys span {
  width: 30px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: rgba(255,255,255,.22); color: #fff; font-weight: 700; font-size: .82rem;
  border-bottom: 3px solid rgba(0,0,0,.15);
}

.stat-row { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
@media (min-width: 620px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; text-align: center; box-shadow: var(--shadow);
}
.stat-ico { font-size: 1.2rem; }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat small { color: var(--ink-muted); }

.weekbars { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 100px; margin: 10px 0; }
.wb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wb i { display: block; width: 100%; max-width: 30px; border-radius: 6px 6px 3px 3px;
        background: color-mix(in srgb, var(--brand) 32%, var(--surface-2)); }
.wb.today i { background: linear-gradient(180deg, var(--brand), var(--brand-2)); }
.wb span { font-size: .7rem; color: var(--ink-muted); font-weight: 700; }

.quicklinks { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.ql {
  display: flex; flex-direction: column; gap: 2px; padding: 14px;
  border-radius: var(--r); color: var(--ink);
  background: color-mix(in srgb, var(--c) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line));
}
.ql:hover { background: color-mix(in srgb, var(--c) 20%, var(--surface)); }
.ql span { font-size: 1.4rem; }
.ql small { color: var(--ink-muted); }

.levelstrip { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.lvl { display: flex; flex-direction: column; gap: 5px; padding: 13px; border-radius: var(--r);
       background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.lvl:hover { border-color: var(--c); }
.lvl-ico { font-size: 1.4rem; }
.lvl b { font-size: .9rem; }
.lvl small { color: var(--ink-muted); font-size: .72rem; }
.bar { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--c, var(--brand)); }

/* ── lessons list ──────────────────────────────────────── */
.level-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.level-head h2 { margin: 0; }
.level-head p { margin: 0; }
.level-head .pill { margin-left: auto; }
.level-ico { font-size: 1.9rem; width: 52px; height: 52px; flex: 0 0 52px; border-radius: 16px;
             display: grid; place-items: center; background: color-mix(in srgb, var(--c) 16%, var(--surface-2)); }

.lesson-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
.lesson-card {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  padding: 14px 13px; border-radius: var(--r); color: var(--ink);
  background: var(--surface-2); border: 2px solid var(--line);
  transition: transform .12s, border-color .12s;
}
.lesson-card:hover { transform: translateY(-3px); border-color: var(--c); }
.lesson-card.done { background: color-mix(in srgb, var(--c) 10%, var(--surface));
                    border-color: color-mix(in srgb, var(--c) 38%, var(--line)); }
.lesson-card.locked { opacity: .5; }
.lesson-card .ln { position: absolute; top: 10px; right: 12px; font-size: .72rem;
                   color: var(--ink-muted); font-weight: 800; }
.lesson-card b { font-size: .96rem; padding-right: 18px; }
.lesson-card small { color: var(--ink-muted); font-size: .72rem; }

.stars { letter-spacing: 1px; }
.star { color: var(--line); font-size: 1rem; }
.star.on { color: #fbbf24; text-shadow: 0 1px 4px rgba(251,191,36,.5); }
.stars.big .star { font-size: 2.3rem; }

/* ── lesson / typing screen ────────────────────────────── */
.lesson-page, .game-page { background: var(--bg); }
.lesson-shell, .game-shell { max-width: 1000px; margin: 0 auto; padding: 12px 14px 30px; }

.lbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lbar-title { flex: 1; min-width: 0; text-align: center; line-height: 1.15; }
.lbar-title small { display: block; color: var(--ink-muted); font-size: .72rem; }
.lbar-title b { font-size: 1.08rem; }

.focusbar { display: flex; align-items: center; justify-content: center; gap: 8px;
            margin-bottom: 12px; color: var(--ink-2); font-size: .85rem; font-weight: 600; flex-wrap: wrap; }
kbd {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 8px; background: var(--surface); border: 1px solid var(--line);
  border-bottom-width: 3px; font-family: var(--mono); font-size: .9rem; font-weight: 700; color: var(--ink);
}

.typearea {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px 18px 22px; margin-bottom: 12px;
  min-height: 190px;
}
.lineprog { display: flex; gap: 5px; justify-content: center; margin-bottom: 14px; }
.lineprog i { width: 22px; height: 5px; border-radius: 99px; background: var(--line); }
.lineprog i.done { background: var(--ok); }
.lineprog i.now  { background: var(--c, var(--brand)); }

.text {
  font-family: var(--mono);
  font-size: clamp(1.15rem, 4.4vw, 1.85rem);
  line-height: 1.75; letter-spacing: .01em;
  text-align: center; word-break: break-word; cursor: text;
  min-height: 2.6em;
}
.text .c { position: relative; padding: 1px 0; border-radius: 4px; color: var(--ink-2); }
.text .c.sp { display: inline-block; min-width: .55em; }
.text .c.ok  { color: var(--ok); background: var(--ok-soft); }
.text .c.bad { color: var(--bad); background: var(--bad-soft); text-decoration: underline wavy; }
.text .c.cur {
  color: #fff; background: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .text .c.cur { animation: pulse 1.1s ease-in-out infinite; }
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--brand) 12%, transparent); } }
.text.shake { animation: shake .22s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.nextline { text-align: center; font-family: var(--mono); color: var(--ink-muted);
            opacity: .55; margin-top: 10px; font-size: .95rem; min-height: 1.2em; }

.capture { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; border: 0;
           left: 50%; bottom: 0; pointer-events: none; }

.startveil {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; justify-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(3px); border-radius: var(--r-lg); text-align: center; padding: 20px;
}
.startveil p { color: var(--ink-muted); font-size: .85rem; margin: 0; }

.livestats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.ls { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
      padding: 10px 6px; text-align: center; }
.ls b { display: block; font-size: 1.35rem; line-height: 1.15; }
.ls small { color: var(--ink-muted); font-size: .7rem; }

/* ── on-screen keyboard ────────────────────────────────── */
.kbdwrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
           padding: 12px 10px 10px; box-shadow: var(--shadow); }
.kbd { display: flex; flex-direction: column; gap: 5px; }
.kbd-row { display: flex; gap: 5px; }
.key {
  flex: 1 1 0; min-width: 0; height: clamp(28px, 5.2vw, 42px);
  display: grid; place-items: center; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px;
  font-family: var(--mono); font-size: clamp(.58rem, 1.5vw, .82rem); color: var(--ink-2);
  text-transform: uppercase; overflow: hidden; transition: transform .08s, background .1s;
}
.key.f-l1 { background: color-mix(in srgb, var(--f-l1) 16%, var(--surface-2)); }
.key.f-l2 { background: color-mix(in srgb, var(--f-l2) 16%, var(--surface-2)); }
.key.f-l3 { background: color-mix(in srgb, var(--f-l3) 16%, var(--surface-2)); }
.key.f-l4 { background: color-mix(in srgb, var(--f-l4) 16%, var(--surface-2)); }
.key.f-r1 { background: color-mix(in srgb, var(--f-l4) 16%, var(--surface-2)); }
.key.f-r2 { background: color-mix(in srgb, var(--f-l3) 16%, var(--surface-2)); }
.key.f-r3 { background: color-mix(in srgb, var(--f-l2) 16%, var(--surface-2)); }
.key.f-r4 { background: color-mix(in srgb, var(--f-l1) 16%, var(--surface-2)); }
.key.f-th { background: color-mix(in srgb, var(--f-th) 16%, var(--surface-2)); }
.key.next {
  background: var(--brand); color: #fff; border-color: var(--brand-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); transform: translateY(-2px);
}
.key.hit  { background: var(--ok); color: #fff; }
.key.miss { background: var(--bad); color: #fff; }

.handrow { display: flex; justify-content: center; gap: 34px; margin-top: 10px; }
.hand { display: flex; gap: 5px; align-items: flex-end; }
.hand.left  { flex-direction: row; }
.hand.right { flex-direction: row-reverse; }
.hand i { display: block; width: 13px; border-radius: 8px 8px 3px 3px;
          background: var(--line); transition: background .12s, height .12s; }
.hand i:nth-child(1) { height: 22px; }   /* pinky  */
.hand i:nth-child(2) { height: 30px; }   /* ring   */
.hand i:nth-child(3) { height: 34px; }   /* middle */
.hand i:nth-child(4) { height: 29px; }   /* index  */
.hand i.on { background: var(--brand); box-shadow: 0 0 10px color-mix(in srgb, var(--brand) 60%, transparent); }
.hand.thumb::after { content: ''; width: 26px; height: 12px; border-radius: 8px;
                     background: var(--f-th); align-self: center; margin: 0 4px; }

/* ── dialogs ───────────────────────────────────────────── */
dialog.sheet {
  border: 0; border-radius: var(--r-lg); padding: 24px 22px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg); width: min(460px, 92vw);
}
dialog.sheet::backdrop { background: rgba(20,10,50,.5); backdrop-filter: blur(3px); }
.sheet-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.result { text-align: center; }
.res-burst { font-size: 3rem; }
@media (prefers-reduced-motion: no-preference) { .res-burst { animation: pop .5s cubic-bezier(.2,1.4,.4,1); } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.res-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.res-grid > div { background: var(--surface-2); border-radius: 14px; padding: 10px 4px; }
.res-grid b { display: block; font-size: 1.3rem; }
.res-grid small { color: var(--ink-muted); font-size: .68rem; }
.res-msg { color: var(--ink-2); font-size: .9rem; }
.res-badges h4 { margin: 12px 0 8px; }
.nb { display: flex; align-items: center; gap: 10px; background: #fff8e1; color: #7a5b00;
      border-radius: 14px; padding: 10px 14px; margin-bottom: 8px; text-align: left; }
.nb span { font-size: 1.6rem; }
.nb b { flex: 1; }

/* ── badges page ───────────────────────────────────────── */
.badgegrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.badge { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
         padding: 16px 13px; text-align: center; box-shadow: var(--shadow); }
.badge .b-ico { font-size: 2.4rem; display: block; }
.badge b { display: block; margin: 4px 0 2px; font-size: .95rem; }
.badge small { color: var(--ink-muted); display: block; min-height: 2.4em; font-size: .74rem; }
.badge em { font-style: normal; font-size: .72rem; color: var(--ink-muted); font-weight: 700; }
.badge.got { border-color: #fbbf24; background: linear-gradient(180deg, #fffbeb, var(--surface)); }
.badge.got em { color: var(--warn); }
.badge.locked { opacity: .62; }
@media (prefers-color-scheme: dark) { .badge.got { background: linear-gradient(180deg, #2b2415, var(--surface)); } }

/* ── charts ────────────────────────────────────────────── */
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart figcaption { margin-top: 8px; }
.grid { stroke: var(--line); stroke-width: 1; }
.axis { fill: var(--ink-muted); font-size: 11px; font-family: inherit; }
.lbl  { fill: var(--ink-2); font-size: 12px; font-weight: 700; font-family: inherit; }
.series-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.dot.key { fill: var(--brand-ink); }
.bar { fill: color-mix(in srgb, var(--brand) 55%, var(--surface)); }
.bar.today { fill: var(--brand); }
.bar:hover, .dot:hover { filter: brightness(1.15); }

.tableview { margin-top: 12px; }
.tableview summary { cursor: pointer; color: var(--brand); font-size: .85rem; font-weight: 600; }
.tableview table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .84rem; }
.tableview th, .tableview td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }

.mastery { display: flex; flex-direction: column; gap: 14px; }
.mrow { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
.mico { font-size: 1.3rem; grid-row: span 2; }
.mrow b { font-size: .92rem; }
.mlist { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.mchip { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600;
         padding: .35em .7em; border-radius: 999px; background: var(--surface-2);
         border: 1px solid var(--line); color: var(--ink-2); }
.mchip span { color: #fbbf24; }
.mchip.s0 span { color: var(--ink-muted); }
.mchip.s3 { background: color-mix(in srgb, var(--c) 16%, var(--surface)); border-color: var(--c); color: var(--ink); }

/* ── pick cards (practice / games) ─────────────────────── */
.card.pick { display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.card.pick:hover { border-color: var(--c, var(--brand)); transform: translateY(-3px); }
.pick-ico { font-size: 2.2rem; }
.card.pick .pill { align-self: flex-start; margin-top: 8px; }

/* ── game ──────────────────────────────────────────────── */
.arena {
  position: relative; height: min(58vh, 460px); overflow: hidden;
  background: linear-gradient(180deg, #1e1b4b, #4c1d95 60%, #7c3aed);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); margin-bottom: 12px;
}
.arena .ground { position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
                 background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.05));
                 border-top: 2px dashed rgba(255,255,255,.35); }
.arena.hurt { animation: shake .25s; }
.meteor {
  position: absolute; padding: .3em .75em; border-radius: 999px;
  background: rgba(255,255,255,.94); color: #2b1a5e;
  font-family: var(--mono); font-weight: 700; font-size: clamp(.95rem, 3vw, 1.3rem);
  box-shadow: 0 4px 16px rgba(0,0,0,.35); white-space: nowrap;
}
.meteor.targeted { background: #fde68a; box-shadow: 0 0 0 3px rgba(253,224,71,.6), 0 4px 16px rgba(0,0,0,.35); }
.meteor .m-done { color: var(--ok); }
.meteor.boom  { animation: boom .26s forwards; }
.meteor.crash { animation: crash .26s forwards; }
@keyframes boom  { to { transform: scale(1.8); opacity: 0; } }
@keyframes crash { to { transform: scale(.4) translateY(20px); opacity: 0; filter: hue-rotate(-60deg); } }

.gstats { display: flex; gap: 12px; font-size: .9rem; font-weight: 700; }
.gtype { position: relative; text-align: center; }
.gtyped { display: inline-block; min-height: 2.2rem; min-width: 120px; padding: .3em 1em;
          border-radius: 999px; background: var(--surface); border: 2px dashed var(--line);
          font-family: var(--mono); font-size: 1.2rem; font-weight: 700; letter-spacing: .06em; }
.gtyped.bad { animation: shake .2s; border-color: var(--bad); color: var(--bad); }

/* ── parent tables ─────────────────────────────────────── */
.ptable { width: 100%; border-collapse: collapse; font-size: .87rem; display: block; overflow-x: auto; white-space: nowrap; }
.ptable th, .ptable td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.ptable th { color: var(--ink-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.tav { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
       font-size: .85rem; vertical-align: middle; }
.rowacts { display: flex; gap: 6px; }
.rowacts form { display: inline; }
.tips { margin: 0; padding-left: 1.1em; color: var(--ink-2); font-size: .9rem; }
.tips li { margin-bottom: .5em; }
code { background: var(--surface-2); padding: .1em .4em; border-radius: 6px; font-family: var(--mono); font-size: .85em; }
