:root {
  --bg: #f3eee4;
  --paper: #fffaf2;
  --ink: #1c1814;
  --muted: #6d645a;
  --line: #e4d9ca;
  --accent: #0f6e62;
  --accent-2: #144f48;
  --soft: #dceee9;
  --danger: #b42318;
  --good: #2f7d4a;
  --shadow: 0 18px 50px rgba(40, 28, 16, 0.08);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Outfit, ui-sans-serif, system-ui, sans-serif;
  --serif: Fraunces, "Iowan Old Style", Georgia, serif;
  --lp: #7c3aed;
  --lr: #2563eb;
  --lm: #0891b2;
  --li: #16a34a;
  --th: #78716c;
  --ri: #ca8a04;
  --rm: #ea580c;
  --rr: #e11d48;
  --rp: #db2777;
  --mark-glow: #173a52;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #efe4cf 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #d9ebe4 0%, transparent 50%),
    var(--bg);
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 20;
  background: var(--paper);
  padding: 8px 12px;
}

.top {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1.25rem;
  align-items: center;
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.mark {
  width: 2.65rem;
  height: 2.65rem;
  display: block;
  border-radius: 0.85rem;
  overflow: hidden;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--mark-glow) 28%, transparent);
  flex-shrink: 0;
  object-fit: cover;
  background: var(--mark-glow);
}

.mark svg,
.intro-mark svg,
.mark img,
.intro-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.name {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tag,
.kicker,
.hint-line,
.kb-note,
.fine {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-block {
  min-width: 0;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.rail {
  height: 0.4rem;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.rail i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
}

.game-xp {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.7rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.game-xp[hidden],
.game-hud[hidden] {
  display: none;
}

.game-xp-rail {
  grid-column: 1 / -1;
  height: 0.3rem;
  overflow: hidden;
  border-radius: 99px;
  background: color-mix(in srgb, #8b5cf6 18%, var(--line));
}

.game-xp-rail i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b5cf6, #ec4899, #f59e0b);
  transition: width 0.35s ease;
}

.live-stats {
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
}

.live-stats div {
  text-align: right;
  min-width: 4.6rem;
}

.live-stats span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.live-stats strong {
  display: inline-block;
  min-width: 4.5ch;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.75rem 0 1rem;
}

.lesson-head {
  flex-shrink: 0;
}

.lesson-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 0.1rem 0 0.3rem;
}

.tip {
  max-width: 46rem;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.trainer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0.7rem 0;
  padding: 0.9rem 1.25rem 0.8rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

.game-mode .trainer {
  border-color: color-mix(in srgb, #8b5cf6 32%, var(--line));
  box-shadow:
    0 18px 50px rgba(91, 33, 182, 0.11),
    inset 0 3px 0 color-mix(in srgb, #8b5cf6 22%, transparent);
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: -0.15rem 0 0.3rem;
}

.combo-meter,
.score-meter {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.combo-meter strong,
.score-meter strong {
  color: var(--ink);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.combo-meter b {
  color: #7c3aed;
  font-size: 0.95rem;
}

.combo-flame {
  display: inline-block;
  font-size: 1rem;
  filter: grayscale(0.75);
  transform-origin: bottom center;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.combo-meter[data-power="2"] .combo-flame {
  filter: none;
  transform: scale(1.15);
}

.combo-meter[data-power="3"] .combo-flame {
  filter: none;
  transform: scale(1.3);
}

.combo-meter[data-power="4"] .combo-flame,
.combo-meter[data-power="5"] .combo-flame {
  filter: none;
  transform: scale(1.45);
  animation: flame-dance 0.45s ease-in-out infinite alternate;
}

.game-toast {
  position: absolute;
  left: 50%;
  top: 5.2rem;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 0.5rem) scale(0.9);
  padding: 0.55rem 0.9rem;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(91, 33, 182, 0.25);
}

.game-toast.show {
  animation: toast-pop 1.1s ease both;
}

.finger-hint {
  min-height: 1.35rem;
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.finger-hint i {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 99px;
  display: inline-block;
}

.text {
  font-family: var(--mono);
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  line-height: 1.75;
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
}

.text.flash {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--danger) 55%, white);
  border-radius: 0.6rem;
}

.text span {
  border-radius: 0.2rem;
}

.text .sp {
  display: inline-block;
  width: 1ch;
}

.text .ok {
  color: color-mix(in srgb, var(--ink) 55%, var(--good));
}

.text .wait {
  color: color-mix(in srgb, var(--ink) 38%, var(--bg));
}

.text .now {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.hint-line {
  margin-top: 0.65rem;
  flex-shrink: 0;
}

.nav-row,
.kb-tools,
.dialog-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.nav-row {
  justify-content: space-between;
  margin-top: 0.85rem;
  flex-shrink: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.primary,
.ghost,
.icon-btn {
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-2);
}

.ghost,
.icon-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.game-toggle {
  position: relative;
  flex-shrink: 0;
  min-width: 7.6rem;
  padding: 0.58rem 0.9rem 0.58rem 2.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
}

.game-toggle::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 50%;
  width: 1.25rem;
  height: 0.72rem;
  border-radius: 99px;
  background: var(--line);
  transform: translateY(-50%);
  transition: background 0.2s ease;
}

.game-toggle::after {
  content: "";
  position: absolute;
  left: 0.66rem;
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  transition: transform 0.2s ease;
}

.game-toggle:hover {
  background: var(--paper);
}

.game-toggle.active {
  color: #6d28d9;
  border-color: color-mix(in srgb, #8b5cf6 45%, var(--line));
  background: color-mix(in srgb, #ede9fe 75%, var(--paper));
}

.game-toggle.active::before {
  background: linear-gradient(90deg, #8b5cf6, #db2777);
}

.game-toggle.active::after {
  transform: translate(0.53rem, -50%);
}

.sound-toggle {
  padding-inline: 0.8rem;
}

.sound-toggle[aria-pressed="false"] {
  color: var(--muted);
  background: color-mix(in srgb, var(--line) 35%, transparent);
}

.layout-switch {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.layout-switch select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
}

.icon-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.ghost:hover,
.icon-btn:hover {
  background: var(--paper);
}

.primary:disabled,
.ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.site-foot {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.25rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.45rem 1.5rem 0.65rem;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.site-foot p {
  margin: 0;
  flex: 1 1 18rem;
}

.site-foot-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.site-foot a {
  color: var(--accent-2);
  font-weight: 500;
  text-decoration: none;
}

.site-foot a:hover {
  text-decoration: underline;
}

.cookie-pricing,
.cookie-legal {
  margin: 0.55rem 0 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.cookie-legal a {
  color: var(--accent-2);
}

.primary:hover:disabled {
  background: var(--accent);
}

body.page {
  height: auto;
  min-height: 100dvh;
  overflow: auto;
  display: block;
}

body.page .page-top,
body.page .page-foot {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
}

.page-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
}

.page-top .brand {
  text-decoration: none;
  color: inherit;
}

.page-top .back {
  color: var(--accent-2);
  font-weight: 500;
  text-decoration: none;
}

.page-main {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto 3rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1.4rem 1.5rem 1.7rem;
  box-shadow: var(--shadow);
}

.page-main h1 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  margin: 0 0 0.4rem;
}

.page-main h2 {
  font-size: 1.05rem;
  margin: 1.4rem 0 0.4rem;
}

.page-main p,
.page-main li {
  color: var(--ink);
  line-height: 1.55;
}

.page-main .muted,
.draft-banner {
  color: var(--muted);
  font-size: 0.92rem;
}

.draft-banner {
  margin: 0 0 1rem;
  padding: 0.65rem 0.8rem;
  background: var(--soft);
  border-radius: 0.75rem;
}

html:has(body.page) {
  height: auto;
  min-height: 100dvh;
}

a.primary {
  display: inline-block;
  text-decoration: none;
  white-space: nowrap;
}

[data-locale] {
  display: none;
}

html[data-legal-lang="da"] [data-locale="da"],
html[data-legal-lang="en"] [data-locale="en"] {
  display: revert;
}

.plan-list {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.plan-card {
  display: none;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: color-mix(in srgb, var(--bg) 55%, white);
}

html[data-offer-currency="DKK"] .plan-card[data-currency="DKK"],
html[data-offer-currency="EUR"] .plan-card[data-currency="EUR"],
html[data-offer-currency="USD"] .plan-card[data-currency="USD"] {
  display: flex;
}

.plan-card[hidden] {
  display: none !important;
}

.plan-card p {
  margin: 0;
}

.plan-card .interval {
  color: var(--muted);
  font-size: 0.85rem;
}

.page-foot {
  padding: 0 0 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.page-foot a {
  color: var(--accent-2);
  margin-right: 0.9rem;
}

.ghost.danger {
  color: var(--danger);
  width: calc(100% - 1.5rem);
  margin: 0.5rem 0.75rem 1rem;
}

.kb-section {
  margin-top: 0.7rem;
  flex-shrink: 0;
}

.kb-tools {
  justify-content: space-between;
  margin-bottom: 0.45rem;
  width: 100%;
}

.keyboard-wrap {
  overflow-x: auto;
  padding-bottom: 0.4rem;
}

.keyboard {
  user-select: none;
  width: 100%;
  margin: 0 auto;
  background:
    linear-gradient(180deg, #efe6d8 0%, #e2d6c6 100%);
  border: 1px solid color-mix(in srgb, var(--line) 70%, #c4b8a6);
  border-radius: 1.15rem;
  padding: 0.55rem 0.55rem 0.6rem;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(40, 28, 16, 0.06);
}

.kb-row {
  display: flex;
  gap: 0.22rem;
  margin-bottom: 0.22rem;
}

.kb-row:last-child {
  margin-bottom: 0;
}

.key {
  position: relative;
  min-width: 0;
  height: clamp(1.9rem, 3.4vh, 2.45rem);
  border-radius: 0.45rem;
  background: linear-gradient(180deg, #fffefb 0%, #f6f0e6 100%);
  border: 1px solid color-mix(in srgb, var(--line) 80%, #cfc3b2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  box-shadow:
    0 1px 0 rgba(40, 28, 16, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.key.dim {
  opacity: 0.38;
}

.key.mod,
.key.space {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.key .glyph {
  line-height: 1;
  pointer-events: none;
  font-size: 0.95rem;
  font-weight: 600;
}

.key.bump .dot {
  position: absolute;
  left: 50%;
  bottom: 0.18rem;
  width: 0.7rem;
  height: 0.18rem;
  border-radius: 99px;
  background: var(--ink);
  opacity: 0.85;
  transform: translateX(-50%);
}

.key.bump.active .dot {
  background: #fff;
  opacity: 1;
}

.key.home {
  box-shadow:
    inset 0 -2px 0 color-mix(in srgb, currentColor 20%, transparent),
    0 1px 0 rgba(40, 28, 16, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.key.active {
  transform: translateY(1px);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(15, 110, 98, 0.25);
}

.intro-mark {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: 0.85rem;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--mark-glow) 28%, transparent);
  object-fit: cover;
  display: block;
  background: var(--mark-glow);
}

.key.f-lp.active,
.key[data-finger="lp"].active { background: var(--lp); }
.key.f-lr.active,
.key[data-finger="lr"].active { background: var(--lr); }
.key.f-lm.active,
.key[data-finger="lm"].active { background: var(--lm); }
.key.f-li.active,
.key[data-finger="li"].active { background: var(--li); }
.key.f-th.active,
.key[data-finger="th"].active { background: var(--th); }
.key.f-ri.active,
.key[data-finger="ri"].active { background: var(--ri); }
.key.f-rm.active,
.key[data-finger="rm"].active { background: var(--rm); }
.key.f-rr.active,
.key[data-finger="rr"].active { background: var(--rr); }
.key.f-rp.active,
.key[data-finger="rp"].active { background: var(--rp); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 20, 0.38);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 10;
}

.overlay[hidden] {
  display: none;
}

.dialog {
  width: min(36rem, 100%);
  background: var(--paper);
  border-radius: 1.4rem;
  padding: 1.6rem 1.6rem 1.4rem;
  box-shadow: var(--shadow);
}

.dialog h2 {
  font-family: var(--serif);
  margin: 0.2rem 0 0.6rem;
  letter-spacing: -0.03em;
}

.lead {
  color: var(--muted);
  line-height: 1.55;
}

.steps {
  padding-left: 1.2rem;
  line-height: 1.55;
}

.steps li {
  margin: 0.4rem 0;
}

.dialog-actions {
  margin-top: 1.2rem;
  justify-content: flex-end;
}

.stars {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.2em;
  font-size: 1.2rem;
}

.game-mode .stars {
  color: #f59e0b;
  animation: star-pop 0.5s cubic-bezier(0.2, 1.7, 0.4, 1) both;
}

.game-result {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-top: 0.7rem;
}

.game-result div {
  padding: 0.7rem;
  border-radius: 0.8rem;
  color: #5b21b6;
  background: linear-gradient(145deg, #f5f3ff, #fdf2f8);
}

.game-result span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.game-result strong {
  display: block;
  margin-top: 0.12rem;
  font-size: 1.08rem;
}

.level-up {
  margin: 0.8rem 0 0;
  padding: 0.7rem;
  border-radius: 0.8rem;
  color: #fff;
  text-align: center;
  font-weight: 700;
  background: linear-gradient(120deg, #7c3aed, #db2777, #f59e0b);
  background-size: 200% 100%;
  animation: level-glow 1.2s ease-in-out infinite alternate;
}

.dialog.is-level-up {
  border: 2px solid color-mix(in srgb, #f59e0b 75%, white);
  box-shadow:
    0 22px 70px rgba(91, 33, 182, 0.28),
    0 0 0 6px rgba(245, 158, 11, 0.12);
  animation: level-arrive 0.55s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.badge-rewards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.badge-rewards p {
  width: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.game-badge {
  padding: 0.45rem 0.65rem;
  border: 1px solid color-mix(in srgb, #f59e0b 42%, var(--line));
  border-radius: 999px;
  background: #fffbeb;
  font-size: 0.78rem;
  font-weight: 600;
  animation: badge-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 20;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -1.5rem;
  left: var(--x);
  width: 0.55rem;
  height: 0.85rem;
  border-radius: 0.12rem;
  background: var(--color);
  animation: confetti-fall var(--duration) var(--delay) cubic-bezier(0.15, 0.7, 0.45, 1) both;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.result-stats div {
  background: var(--bg);
  border-radius: 0.8rem;
  padding: 0.7rem;
}

.result-stats dt {
  font-size: 0.75rem;
  color: var(--muted);
}

.result-stats dd {
  margin: 0.15rem 0 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.drawer {
  position: relative;
}

.drawer-backdrop {
  display: none;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(22rem, 92vw);
  background: var(--paper);
  border-left: 1px solid var(--line);
  transform: translateX(105%);
  transition: transform 0.22s ease;
  z-index: 8;
  overflow: auto;
}

.drawer.open .drawer-panel {
  transform: none;
}

.drawer.open .drawer-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 20, 0.25);
  z-index: 7;
}

.drawer-head {
  padding: 1.2rem 1.1rem 0.4rem;
}

.drawer-head h2 {
  margin: 0 0 0.3rem;
  font-family: var(--serif);
}

#lesson-list h3 {
  margin: 1rem 1.1rem 0.3rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.lesson-item {
  width: calc(100% - 1rem);
  margin: 0.15rem 0.5rem;
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0.6rem;
  padding: 0.45rem 0.5rem;
}

.lesson-item:hover,
.lesson-item.current {
  background: var(--soft);
}

.lesson-item .n {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lesson-item .s {
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 15;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.9rem 1.1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  max-height: min(42dvh, 22rem);
  overflow: auto;
}

.cookie-banner[hidden] {
  display: none !important;
}

.cookie-copy {
  flex: 1 1 16rem;
}

.cookie-copy h2 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.cookie-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.cookie-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

@keyframes flame-dance {
  from { transform: scale(1.4) rotate(-6deg); }
  to { transform: scale(1.55) rotate(6deg); }
}

@keyframes toast-pop {
  0% { opacity: 0; transform: translate(-50%, 0.5rem) scale(0.8); }
  18%, 72% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -0.65rem) scale(0.96); }
}

@keyframes star-pop {
  from { opacity: 0; transform: scale(0.4) rotate(-10deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes badge-pop {
  from { opacity: 0; transform: scale(0.65); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes level-arrive {
  from { opacity: 0; transform: scale(0.86) rotate(-1deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes level-glow {
  from { background-position: 0 0; transform: scale(1); }
  to { background-position: 100% 0; transform: scale(1.015); }
}

@keyframes confetti-fall {
  from { opacity: 1; transform: translate3d(0, -2vh, 0) rotate(0); }
  to { opacity: 0.85; transform: translate3d(var(--drift), 105vh, 0) rotate(var(--spin)); }
}

@media (max-width: 900px) {
  .top {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "progress progress"
      "stats stats";
  }
  .brand { grid-area: brand; }
  .progress-block { grid-area: progress; }
  .live-stats { grid-area: stats; justify-content: space-between; }
  .header-actions { grid-area: actions; }
  .layout-label { display: none; }
  .game-toggle {
    min-width: auto;
    padding-right: 0.7rem;
  }
  .key {
    height: 2.15rem;
    font-size: 0.68rem;
    border-radius: 0.38rem;
  }
  .key.mod,
  .key.space {
    font-size: 0.58rem;
  }
}

@media (max-width: 640px) {
  .top {
    padding-inline: 0.75rem;
  }
  .brand .tag,
  .header-actions .layout-switch,
  #btn-cookies {
    display: none;
  }
  .game-toggle {
    font-size: 0.78rem;
  }
  .sound-toggle {
    min-width: 2.5rem;
    padding-inline: 0.65rem;
  }
  .sound-toggle #sound-label {
    display: none;
  }
  .game-result {
    grid-template-columns: 1fr;
  }
  .keyboard {
    display: none;
  }
}

@media (max-height: 800px) {
  .hint-line {
    display: none;
  }
}

@media (max-height: 700px) {
  html,
  body {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }
  main {
    flex: none;
    padding-bottom: 1.5rem;
  }
  .trainer {
    flex: none;
  }
  .text {
    min-height: 6rem;
    overflow: visible;
  }
}

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