/* Klávesový ninja
   Idea: everything you can press looks like a chunky keycap (ink outline + solid depth).
   Finger colours are the only rainbow; the rest is ink on cool paper. */

@font-face {
  font-family: 'Grandstander';
  src: url('../fonts/grandstander-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Grandstander';
  src: url('../fonts/grandstander-latin-ext.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jetbrainsmono-latin.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jetbrainsmono-latin-ext.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #25255e;
  --ink-soft: #5d6096;
  --ink-faint: #9ca2c8;
  --paper: #eceff8;
  --paper-deep: #dfe3f2;
  --card: #ffffff;
  --ok: #1a9461;
  --err: #e23d4f;
  --err-soft: #ffd6da;
  --gold: #ffc531;
  --gold-soft: #fff1c7;

  --f-pinky: #a77bf3;
  --f-ring: #3d8ef0;
  --f-middle: #22b07d;
  --f-index-l: #f5a524;
  --f-index-r: #f2762e;
  --f-thumb: #a3a9c4;

  --line: 2.5px;
  --depth: 5px;
  --font-ui: 'Grandstander', ui-rounded, 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --font-type: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

.f-pinky { --fc: var(--f-pinky); }
.f-ring { --fc: var(--f-ring); }
.f-middle { --fc: var(--f-middle); }
.f-index-l { --fc: var(--f-index-l); }
.f-index-r { --fc: var(--f-index-r); }
.f-thumb { --fc: var(--f-thumb); }

*,
*::before,
*::after { box-sizing: border-box; }

html { font-size: 18px; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.4em; font-weight: 800; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
p { margin: 0 0 0.8em; }
small { font-size: 0.78em; color: var(--ink-soft); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--f-ring); outline-offset: 3px; }
[hidden] { display: none !important; }

kbd {
  display: inline-block;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.85em;
  padding: 0.05em 0.5em 0.1em;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 2px 0 var(--ink);
  line-height: 1.3;
}

/* ---------- keycap primitives ---------- */
.panel {
  background: var(--card);
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 var(--depth) 0 var(--ink);
  padding: 22px 26px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.75em 1.3em 0.8em;
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 var(--depth) 0 var(--ink);
  cursor: pointer;
  transition: transform 0.07s, box-shadow 0.07s, background 0.15s;
}
.btn:hover { background: var(--gold-soft); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--gold); }
.btn.primary:hover { background: #ffd35e; }
.btn.danger { background: var(--err); color: #fff; }
.btn.danger:hover { background: #ea5869; }
.btn.big { font-size: 1.25rem; padding: 0.8em 1.6em 0.85em; }

.icon-btn {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  transition: transform 0.07s, box-shadow 0.07s;
  flex: none;
}
.icon-btn:hover { background: var(--gold-soft); }
.icon-btn:active,
.icon-btn.on { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn.on { background: var(--gold); }

.actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.actions.left { justify-content: flex-start; }

.keycap {
  --size: 64px;
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: var(--size);
  height: var(--size);
  padding: 0 0.35em;
  border: var(--line) solid var(--ink);
  border-radius: calc(var(--size) * 0.2);
  background: color-mix(in srgb, var(--fc, #fff) 30%, #fff);
  box-shadow: 0 calc(var(--size) * 0.08) 0 var(--ink);
  font-weight: 800;
  font-size: calc(var(--size) * 0.46);
  line-height: 1;
}
.keycap.lg { --size: 84px; }
.keycap.xl { --size: 116px; background: var(--fc, #fff); }
.keycap.wide { padding: 0 0.55em; font-size: calc(var(--size) * 0.34); }
.keycap .bump,
.cap .bump {
  position: absolute;
  bottom: 17%;
  left: 50%;
  width: 28%;
  height: 7%;
  min-height: 2px;
  transform: translateX(-50%);
  background: var(--ink);
  border-radius: 9px;
}

/* the one orchestrated motion: keycaps get "typed" once when a screen opens */
@keyframes cap-press {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(calc(var(--size) * 0.07)); box-shadow: 0 0 0 var(--ink); }
}
.brand-caps .keycap,
.hero-caps .keycap { animation: cap-press 0.32s ease-out both; animation-delay: calc(0.25s + var(--i, 0) * 0.13s); }

.belt {
  --belt: #fff;
  position: relative;
  display: inline-block;
  width: 54px;
  height: 11px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--belt);
  vertical-align: middle;
}
.belt::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 16px;
  transform: translate(-50%, -50%) rotate(8deg);
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--belt);
}
.belt.big { width: 70px; height: 14px; }
.belt.big::after { width: 15px; height: 20px; }
.star-glyph { color: var(--gold); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }

/* ---------- brand / profiles / new player ---------- */
.screen { min-height: 100vh; }
.screen-profiles,
.screen-new {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 24px 64px;
  text-align: center;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 36px; }
.brand-word { font-size: 2.6rem; font-weight: 800; letter-spacing: 0.01em; }
.brand-caps { display: flex; gap: 10px; }
.brand-caps .keycap { --size: 78px; background: var(--fc); }
.profiles-q { font-size: 1.6rem; margin-bottom: 26px; }
.profile-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; max-width: 900px; }
.profile-tile {
  width: 170px;
  padding: 20px 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.profile-tile:hover { background: var(--gold-soft); }
.profile-tile:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.pt-avatar { font-size: 64px; line-height: 1.1; }
.pt-name { font-size: 1.25rem; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-meta { color: var(--ink-soft); font-weight: 700; }
.profile-tile.add { background: transparent; border-style: dashed; box-shadow: none; color: var(--ink-soft); justify-content: center; }
.profile-tile.add .pt-avatar { font-size: 56px; font-weight: 300; }
.profile-tile.add:hover { background: #fff; }

.new-form { width: min(560px, 100%); text-align: left; }
.new-form h1 { font-size: 1.7rem; text-align: center; margin-bottom: 18px; }
.field-label { display: block; font-weight: 800; margin: 16px 0 8px; }
.text-input {
  width: 100%;
  font: 700 1.25rem var(--font-ui);
  color: var(--ink);
  padding: 12px 16px;
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
}
.text-input:focus { outline: none; background: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--f-ring) 35%, transparent); }
.form-error { color: var(--err); font-weight: 700; margin: 8px 0 0; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 10px; }
.avatar-opt { position: relative; cursor: pointer; }
.avatar-opt input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-opt span {
  display: grid;
  place-items: center;
  height: 58px;
  font-size: 32px;
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.07s, box-shadow 0.07s;
}
.avatar-opt input:checked + span { background: var(--gold); transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.avatar-opt input:focus-visible + span { outline: 3px solid var(--f-ring); outline-offset: 3px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: var(--line) solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 5;
}
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px 8px 4px 2px;
  border-radius: 14px;
  cursor: pointer;
  min-width: 0;
}
.who:hover { background: var(--paper); }
.who-avatar { font-size: 38px; line-height: 1; }
.who-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.who-name { font-weight: 800; font-size: 1.1rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 10px; }
.tab {
  font-weight: 800;
  padding: 9px 16px 10px;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.07s, box-shadow 0.07s;
}
.tab:hover { background: var(--gold-soft); }
.tab.on { background: var(--gold); transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.star-count { font-weight: 800; font-size: 1.2rem; white-space: nowrap; }

/* ---------- home: lessons ---------- */
.home-main { max-width: 1080px; margin: 0 auto; padding: 30px 24px 70px; }
.hero {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 30px 34px;
  margin-bottom: 40px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 7px 0 var(--ink);
}
.hero-caps { display: flex; gap: 14px; flex: none; }
.hero-text { min-width: 0; }
.hero-unit { color: var(--ink-soft); font-weight: 700; margin-bottom: 4px; }
.hero h1 { font-size: 2.1rem; }
.hero-tip { font-size: 1.1rem; max-width: 46ch; }

.unit { margin-bottom: 34px; }
.unit-head { display: grid; grid-template-columns: 1fr auto; column-gap: 20px; align-items: baseline; margin-bottom: 14px; }
.unit-head h2 { margin: 0; }
.unit-head p { grid-column: 1; margin: 2px 0 0; color: var(--ink-soft); }
.unit-count { grid-column: 2; grid-row: 1; font-weight: 800; color: var(--ink-soft); }
.lesson-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.lesson-tile {
  position: relative;
  width: 112px;
  height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px 6px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.07s, box-shadow 0.07s, background 0.15s;
}
.lesson-tile:hover { background: var(--gold-soft); }
.lesson-tile:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.lt-num { position: absolute; top: 6px; left: 10px; font-size: 0.8rem; font-weight: 800; color: var(--ink-soft); }
.lt-keys { font-size: 1.9rem; font-weight: 800; line-height: 1; margin-top: 6px; white-space: nowrap; }
.lt-keys.long { font-size: 1.3rem; }
.lt-title { font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); text-align: center; line-height: 1.1; max-width: 100%; }
.lt-stars { font-size: 1.15rem; letter-spacing: 1px; color: var(--paper-deep); -webkit-text-stroke: 1.2px var(--ink-faint); }
.lt-stars .on { color: var(--gold); -webkit-text-stroke: 1.2px var(--ink); }
.lesson-tile.current { background: var(--gold); }
.lesson-tile.current .lt-stars { -webkit-text-stroke-color: var(--ink); color: #fff3cc; }
.lesson-tile.locked { background: transparent; border-style: dashed; border-color: var(--ink-faint); box-shadow: none; color: var(--ink-faint); cursor: not-allowed; }
.lesson-tile.locked .lt-num,
.lesson-tile.locked .lt-title { color: var(--ink-faint); }
.lesson-tile.locked:hover { background: transparent; }
.lesson-tile.locked:active { transform: none; }
.lock { font-size: 0.95rem; -webkit-text-stroke: 0; filter: grayscale(1); opacity: 0.6; }
.lesson-tile.nope { animation: shake 0.3s; }

/* ---------- home: games ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.game-tile {
  display: flex;
  align-items: center;
  gap: 22px;
  text-align: left;
  padding: 26px 28px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 7px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.07s, box-shadow 0.07s, background 0.15s;
}
.game-tile:hover { background: var(--gold-soft); }
.game-tile:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); }
.gt-art {
  flex: none;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  font-size: 56px;
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  background: var(--paper);
}
.gt-text h2 { margin-bottom: 4px; }
.gt-text p { margin-bottom: 8px; color: var(--ink-soft); }
.gt-best { font-weight: 800; }
.games-note { margin-top: 26px; color: var(--ink-soft); }
.letter-list { font-family: var(--font-type); font-weight: 600; color: var(--ink); letter-spacing: 0.04em; word-spacing: 0.1em; }

/* ---------- home: badges ---------- */
.belt-ladder { margin-bottom: 30px; }
.ladder { display: flex; flex-wrap: wrap; gap: 18px 26px; margin-bottom: 14px; }
.rung { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 800; color: var(--ink-faint); opacity: 0.55; }
.rung.past { opacity: 0.9; color: var(--ink-soft); }
.rung.now { opacity: 1; color: var(--ink); transform: scale(1.15); }
.ladder-text { margin: 0; font-size: 1.1rem; }
.section-title { margin: 0 0 16px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 18px 14px 16px;
  border: var(--line) dashed var(--ink-faint);
  border-radius: 20px;
  color: var(--ink-soft);
}
.badge .badge-icon { font-size: 44px; filter: grayscale(1); opacity: 0.35; }
.badge-name { font-weight: 800; font-size: 1.05rem; }
.badge-desc { font-size: 0.85rem; }
.badge.got { background: #fff; border-style: solid; border-color: var(--ink); box-shadow: 0 5px 0 var(--ink); color: var(--ink); }
.badge.got .badge-icon { filter: none; opacity: 1; }

/* ---------- home: stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: #fff; border: var(--line) solid var(--ink); border-radius: 18px; }
.stat-num { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.25; }
.heat-panel { margin-bottom: 26px; }
.heat-host .kb-wrap { width: 100%; max-width: 900px; margin: 6px 0 14px; }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 0.9rem; color: var(--ink-soft); }
.swatch { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 5px; margin-right: -8px; vertical-align: middle; }
.swatch.good { background: #bfead3; }
.swatch.ok { background: #fff0b3; }
.swatch.warn { background: #ffcf9f; }
.swatch.bad { background: #ffa9b4; }
.history { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.history th { text-align: left; color: var(--ink-soft); font-weight: 700; padding: 6px 10px 6px 0; border-bottom: 2px solid var(--paper-deep); }
.history td { padding: 8px 10px 8px 0; border-bottom: 2px solid var(--paper); }

/* ---------- lesson ---------- */
.screen-lesson { max-width: 1060px; height: 100vh; min-height: 560px; margin: 0 auto; padding: 14px 24px 16px; display: flex; flex-direction: column; }
.lesson-bar { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.lesson-title { flex: 1; min-width: 0; }
.lesson-unit { display: block; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }
.lesson-title h1 { font-size: 1.45rem; margin: 0; }
.step-dots { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.step-dots li { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; transition: background 0.2s, transform 0.2s; }
.step-dots li.on { background: var(--gold); transform: scale(1.15); }
.step-dots li.done { background: var(--ok); }

.type-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 16px 30px 18px;
  flex: none;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 var(--depth) 0 var(--ink);
  transition: background 0.25s;
}
.type-card.step-ok { background: #e8f7ef; }
.step-label { grid-area: 1 / 1; margin: 0 0 6px; font-weight: 800; color: var(--ink-soft); font-size: 0.95rem; }
.type-card.show-intro .tv-host,
.type-card.show-intro .step-label { visibility: hidden; }
.type-card:not(.show-intro) .intro { visibility: hidden; }
.type-card > .tv-host { grid-area: 2 / 1; }

.tv {
  --lines: 2;
  font-family: var(--font-type);
  font-weight: 500;
  font-size: clamp(1.35rem, min(1.2rem + 1.3vw, 4.8vh), 2.3rem);
  line-height: 1.75;
  height: calc(var(--lines) * 1.75em);
  overflow: hidden;
}
.tv-inner { position: relative; white-space: pre-wrap; word-break: normal; transition: transform 0.22s ease; }
.tv .w { white-space: nowrap; }
.ch { border-radius: 6px; }
.ch.ok { color: var(--ink-faint); }
.ch.fix { color: var(--err); }
.ch.err { color: #fff; background: var(--err); }
.ch.sp.fix { background: var(--err-soft); }
.ch.cur { background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 var(--ink); }
.ch.cur.wrong { background: var(--err-soft); box-shadow: 0 4px 0 var(--err); }
.ch.shake { display: inline-block; animation: shake 0.25s; }

.intro {
  grid-area: 1 / 1 / 3 / 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 12px;
}
.intro > * { flex-shrink: 0; }
.intro .keycap.lg { --size: 70px; }
.intro-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 30px; margin-bottom: 14px; }
.intro-key { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.intro-key .keycap { background: var(--fc); }
.intro-finger { font-weight: 800; font-size: 0.95rem; }
.intro-key.letters { flex-direction: row; gap: 14px; }
.intro-plus { font-size: 2rem; font-weight: 800; }
.intro-letters { font-family: var(--font-type); font-weight: 700; font-size: 1.5rem; max-width: 16ch; text-align: left; line-height: 1.3; }
.intro-tip { font-size: 1.05rem; max-width: 60ch; margin-bottom: 6px; }
.intro-go { margin: 0; font-weight: 800; color: var(--ink-soft); }

.finger-hint { flex: none; text-align: center; font-size: 1.15rem; font-weight: 700; min-height: 1.7em; margin: 12px 0 8px; }
.kb-host { flex: 1 1 0; min-height: 0; container-type: size; }
.dot { display: inline-block; width: 0.95em; height: 0.95em; border: 2px solid var(--ink); border-radius: 50%; background: var(--fc); vertical-align: -0.12em; margin-right: 0.35em; }
.plus { margin: 0 0.4em; color: var(--ink-soft); }

/* ---------- keyboard ---------- */
.kb-wrap { width: min(100%, 980px); margin: 0 auto; }
.kb-host .kb-wrap { width: min(100%, 980px, 100cqh * 1.92); }
.kb-host .kb-wrap.no-hands { width: min(100%, 980px, 100cqh * 2.9); }
.kb { position: relative; aspect-ratio: 3 / 1; container-type: inline-size; }
.key { position: absolute; padding: 0.32cqw; }
.cap {
  position: relative;
  width: 100%;
  height: calc(100% - 0.4cqw);
  display: flex;
  align-items: center;
  justify-content: center;
  border: max(1.5px, 0.2cqw) solid var(--ink);
  border-radius: 0.95cqw;
  background: color-mix(in srgb, var(--fc, #fff) 26%, #fff);
  box-shadow: 0 0.42cqw 0 var(--ink);
  font-weight: 800;
  transition: transform 0.08s, box-shadow 0.08s, background 0.12s;
}
.cap .main { font-size: 2.25cqw; line-height: 1; }
.cap .sh { position: absolute; top: 9%; left: 13%; font-size: 1.3cqw; line-height: 1; color: var(--ink-soft); }
.cap .sh + .main { margin-top: 0.9cqw; }
.cap .lbl { font-size: 1.15cqw; color: var(--ink-soft); }
.key.mod .cap { background: var(--paper-deep); border-color: var(--ink-faint); box-shadow: 0 0.42cqw 0 var(--ink-faint); }
.key.space .cap { background: color-mix(in srgb, var(--fc) 22%, #fff); }

/* ISO Enter is drawn from two parts */
.key.enter-top { padding-bottom: 0; }
.key.enter-top .cap { height: 100%; border-bottom: 0; border-radius: 0.95cqw 0.95cqw 0 0.95cqw; box-shadow: none; z-index: 1; }
.key.enter-top .cap::after {
  content: '';
  position: absolute;
  left: calc(-1 * max(1.5px, 0.2cqw));
  bottom: 0;
  width: calc(16.7% + max(1.5px, 0.2cqw));
  height: max(1.5px, 0.2cqw);
  background: var(--ink);
}
.key.enter-bottom { padding-top: 0; }
.key.enter-bottom .cap { height: calc(100% - 0.4cqw); border-top: 0; border-radius: 0 0 0.95cqw 0.95cqw; }

.key.target .cap {
  background: var(--fc);
  transform: translateY(-0.3cqw);
  box-shadow: 0 0.72cqw 0 var(--ink);
  animation: target-ring 1.1s ease-in-out infinite;
  z-index: 2;
}
.key.target-shift .cap { background: var(--fc); animation: target-ring 1.1s ease-in-out infinite; }
@keyframes target-ring {
  0%, 100% { outline: 0.45cqw solid color-mix(in srgb, var(--fc) 0%, transparent); outline-offset: 0.1cqw; }
  50% { outline: 0.45cqw solid color-mix(in srgb, var(--fc) 55%, transparent); outline-offset: 0.35cqw; }
}
.key.down .cap { transform: translateY(0.35cqw); box-shadow: 0 0.07cqw 0 var(--ink); }
.key.miss .cap { background: var(--err); animation: shake 0.25s; }
.key.nudge .cap { animation: shake 0.3s; }

.heatmap .key .cap { background: #fff; }
.heatmap .key.mod .cap { background: var(--paper-deep); }
.key[data-heat='good'] .cap { background: #bfead3; }
.key[data-heat='ok'] .cap { background: #fff0b3; }
.key[data-heat='warn'] .cap { background: #ffcf9f; }
.key[data-heat='bad'] .cap { background: #ffa9b4; }

/* hands */
.hands { margin-top: 0.4%; }
.hands svg { display: block; width: 100%; height: auto; overflow: visible; }
.hands .finger rect,
.hands .palm { fill: #fff; stroke: var(--ink); stroke-width: 5; }
.hands .nail { fill: var(--fc); stroke: var(--ink); stroke-width: 3; }
.hands .finger { transform-box: fill-box; transform-origin: 50% 100%; }
.hands .finger.lit rect { fill: var(--fc); }
.hands .finger.lit .nail { fill: #fff; }
.hands .finger.lit { animation: finger-tap 0.9s ease-in-out infinite; }
@keyframes finger-tap {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

/* ---------- results ---------- */
.screen-results { display: grid; place-items: center; padding: 40px 24px; }
.result-card { width: min(680px, 100%); text-align: center; padding: 30px 34px 26px; }
.result-lesson { color: var(--ink-soft); font-weight: 700; margin-bottom: 6px; }
.result-stars { display: flex; justify-content: center; gap: 14px; margin-bottom: 8px; }
.rs { font-size: 84px; line-height: 1; color: var(--paper-deep); -webkit-text-stroke: 3px var(--ink-faint); paint-order: stroke fill; }
.rs.on {
  color: var(--gold);
  -webkit-text-stroke-color: var(--ink);
  animation: star-in 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both;
  animation-delay: calc(0.3s + var(--i) * 0.26s);
}
@keyframes star-in {
  from { transform: scale(0.2) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.result-card h1 { font-size: 2.2rem; margin-bottom: 6px; }
.result-sub { font-size: 1.1rem; max-width: 46ch; margin: 0 auto 18px; }
.result-stats { display: flex; justify-content: center; gap: 16px; margin: 0 0 16px; }
.result-stats > div { flex: 1; max-width: 190px; padding: 12px 10px; border: var(--line) solid var(--ink); border-radius: 16px; background: var(--paper); }
.result-stats dt { font-weight: 700; color: var(--ink-soft); font-size: 0.9rem; }
.result-stats dd { margin: 2px 0 0; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.result-stats dd small { font-size: 0.42em; font-weight: 700; }
.result-stats dd.cpm { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.trouble kbd { margin: 0 2px; font-family: var(--font-type); }
.kbd-hint { margin: 14px 0 0; color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- settings ---------- */
.settings-main { max-width: 760px; margin: 0 auto; padding: 30px 24px 70px; }
.settings-for { color: var(--ink-soft); margin-bottom: 24px; }
.settings-main .panel { margin-bottom: 24px; }
.toggle { display: flex; align-items: center; gap: 14px; padding: 10px 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  flex: none;
  position: relative;
  width: 58px;
  height: 32px;
  border: var(--line) solid var(--ink);
  border-radius: 99px;
  background: var(--paper-deep);
  transition: background 0.15s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle input:checked + .toggle-track { background: var(--ok); }
.toggle input:checked + .toggle-track::after { transform: translateX(26px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--f-ring); outline-offset: 3px; }
.toggle-text { font-weight: 700; display: flex; flex-direction: column; }
.toggle-text small { font-weight: 500; }
.choice { border: 0; padding: 10px 0 0; margin: 6px 0 0; }
.choice legend { font-weight: 800; padding: 0; margin-bottom: 6px; }
.choice label { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.choice input { width: 20px; height: 20px; accent-color: var(--ink); }
.danger-zone { border-color: var(--err); box-shadow: 0 var(--depth) 0 var(--err); }

/* ---------- games ---------- */
.screen-game,
.screen-race { max-width: 1120px; margin: 0 auto; padding: 14px 24px 20px; }
.game-bar { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.game-bar h1 { flex: 1; margin: 0; font-size: 1.6rem; }
.hud { display: flex; align-items: center; gap: 22px; font-weight: 700; }
.hud-item b { font-size: 1.5rem; }
.hud-lives { display: flex; gap: 4px; }
.heart { font-size: 1.7rem; line-height: 1; color: var(--err); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.heart.lost { color: var(--paper-deep); -webkit-text-stroke-color: var(--ink-faint); }

.field {
  position: relative;
  height: calc(100vh - 110px);
  min-height: 440px;
  overflow: hidden;
  border: var(--line) solid var(--ink);
  border-radius: 24px;
  background: linear-gradient(180deg, #a9d8ff 0%, #d9efff 78%);
  box-shadow: 0 var(--depth) 0 var(--ink);
}
.field.hurt { animation: hurt 0.35s; }
@keyframes hurt { 30% { box-shadow: 0 var(--depth) 0 var(--ink), inset 0 0 0 10px color-mix(in srgb, var(--err) 60%, transparent); } }
.field-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 70px; background: #9ad8a5; border-top: var(--line) solid var(--ink); }
.launcher { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); font-size: 54px; line-height: 1; z-index: 3; }
.level-banner {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 800;
  padding: 10px 28px;
  background: var(--gold);
  border: var(--line) solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 var(--depth) 0 var(--ink);
  z-index: 6;
}
.level-banner.show { animation: banner-pop 1.4s ease both; }
@keyframes banner-pop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.field-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  backdrop-filter: blur(2px);
  z-index: 8;
}
.overlay-panel { width: min(520px, 100%); text-align: center; }
.overlay-panel h2 { font-size: 1.9rem; }
.overlay-panel .small { font-size: 0.95rem; color: var(--ink-soft); }
.press { font-weight: 800; margin: 14px 0 0; }
.big-score { font-size: 3rem; font-weight: 800; line-height: 1; margin: 6px 0 14px; }

.balloon { position: absolute; left: 0; top: 0; width: 96px; display: flex; flex-direction: column; align-items: center; will-change: transform; z-index: 2; }
.b-body {
  position: relative;
  width: 78px;
  height: 94px;
  background: var(--c);
  border: var(--line) solid var(--ink);
  border-radius: 50% 50% 48% 48% / 56% 56% 44% 44%;
}
.b-body::before { content: ''; position: absolute; top: 14px; left: 15px; width: 13px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, 0.6); transform: rotate(20deg); }
.b-body::after { content: ''; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%); border: 7px solid transparent; border-bottom: 9px solid var(--ink); border-top: 0; }
.b-string { width: 2px; height: 50px; background: var(--ink); opacity: 0.55; margin-top: 8px; }
.b-word {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 9px 3px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 10px;
  font: 700 1.3rem var(--font-type);
  white-space: nowrap;
  z-index: 3;
}
.b-typed { color: var(--ok); }
.balloon.locked { z-index: 4; }
.balloon.locked .b-word { background: var(--gold); }
.balloon.shake .b-word { animation: shake 0.25s; }
.balloon.popped .b-body { animation: pop 0.25s ease-out forwards; }
.balloon.popped .b-string,
.balloon.popped .b-word { opacity: 0; transition: opacity 0.1s; }
@keyframes pop {
  to { transform: scale(1.6); opacity: 0; }
}
.shuriken { position: absolute; left: 0; top: 0; width: 28px; height: 28px; z-index: 5; }
.shuriken svg { width: 100%; height: 100%; display: block; }
.plus-score { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 1.5rem; color: var(--ok); -webkit-text-stroke: 1px #fff; animation: float-up 0.8s ease-out forwards; z-index: 6; pointer-events: none; }
@keyframes float-up {
  to { margin-top: -50px; opacity: 0; }
}

/* race */
.track { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.lane { display: grid; grid-template-columns: 140px 1fr 40px; align-items: center; gap: 14px; }
.lane-name { font-weight: 800; display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; }
.lane-name small { font-weight: 600; }
.road {
  position: relative;
  height: 62px;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  background:
    repeating-linear-gradient(90deg, #fff 0 22px, transparent 22px 44px) center / 100% 3px no-repeat,
    var(--paper-deep);
}
.lane.you .road { background: repeating-linear-gradient(90deg, #fff 0 22px, transparent 22px 44px) center / 100% 3px no-repeat, var(--gold-soft); }
.runner { position: absolute; top: 50%; left: calc(var(--p, 0) * (100% - 52px) + 4px); transform: translateY(-50%) scaleX(-1); font-size: 42px; line-height: 1; transition: left 0.15s linear; }
.lane-flag { font-size: 30px; }
.race-card { min-height: 0; }
.race-card .tv { --lines: 3; }
.race-card .field-overlay { border-radius: 20px; }
.countdown { font-size: 5rem; font-weight: 800; color: var(--ink); animation: banner-pop 0.7s ease both; }
.place-medal { font-size: 64px; line-height: 1; margin: 0 0 6px; }
.race-wpm { min-width: 7em; text-align: right; }

/* ---------- global overlays ---------- */
.banners { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(820px, calc(100% - 24px)); pointer-events: none; }
.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 var(--depth) 0 var(--ink);
  background: var(--gold);
  pointer-events: auto;
}
.banner.warn { background: #ffd0d5; }
.banner-icon { font-size: 1.8rem; line-height: 1; }
.banner-close { margin-left: auto; flex: none; width: 34px; height: 34px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 800; }

#focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ink) 35%, transparent);
  cursor: pointer;
}
.focus-panel { text-align: center; }
.focus-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; }

#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 70; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 var(--depth) 0 var(--ink);
  font-weight: 600;
  animation: toast-in 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
  transition: opacity 0.35s, transform 0.35s;
}
.toast.out { opacity: 0; transform: translateY(14px); }
.toast-icon { font-size: 2rem; line-height: 1; }
@keyframes toast-in { from { transform: translateY(30px); opacity: 0; } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }

.modal-back { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--ink) 40%, transparent); }
.modal { width: min(480px, 100%); text-align: center; font-size: 1.1rem; font-weight: 700; }

#key-catcher { position: fixed; left: -100px; top: 50%; width: 10px; height: 10px; opacity: 0; border: 0; padding: 0; resize: none; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  html { font-size: 16px; }
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .hero { flex-direction: column; align-items: flex-start; gap: 22px; padding: 24px; }
  .keycap.xl { --size: 90px; }
  .brand-caps .keycap { --size: 58px; }
  .lane { grid-template-columns: 90px 1fr 30px; }
  .result-stats { flex-direction: column; align-items: center; }
  .result-stats > div { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
