:root {
  color-scheme: dark;
  --bg: #171a1f;
  --surface: #1f2329;
  --surface-soft: rgba(31, 35, 41, 0.78);
  --text: #e8e9e4;
  --muted: #666d76;
  --muted-strong: #90969d;
  --accent: #f4c95d;
  --accent-soft: rgba(244, 201, 93, 0.13);
  --error: #ef6a72;
  --correct: #d9dbd4;
  --border: rgba(255, 255, 255, 0.06);
  --font-mono: "DM Mono", monospace;
  --font-sans: "Manrope", sans-serif;
}

:root.light {
  color-scheme: light;
  --bg: #f4f1e9;
  --surface: #e9e5dc;
  --surface-soft: rgba(233, 229, 220, 0.82);
  --text: #24272c;
  --muted: #a3a099;
  --muted-strong: #77746d;
  --accent: #c78c14;
  --accent-soft: rgba(199, 140, 20, 0.13);
  --error: #c9444e;
  --correct: #34363a;
  --border: rgba(20, 20, 20, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(244, 201, 93, 0.055), transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  transition: background 250ms ease, color 250ms ease;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(160px);
  opacity: 0.025;
  pointer-events: none;
}

.ambient-one {
  top: -180px;
  right: -100px;
}

.ambient-two {
  bottom: -240px;
  left: -100px;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(1280px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 36px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  padding: 10px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(244, 201, 93, 0.08);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
  place-items: center;
}

.brand-mark span {
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy small {
  margin-bottom: 2px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-copy strong {
  font-family: var(--font-sans);
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.065em;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.page-tabs {
  position: relative;
  z-index: 3;
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: center;
  gap: 0;
  width: 100%;
  margin: 18px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.page-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  min-width: 0;
  padding: 10px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  text-transform: lowercase;
  transition: 160ms ease;
  pointer-events: auto;
}

.page-tab + .page-tab {
  border-left-color: var(--border);
}

.page-tab:hover,
.page-tab.active {
  color: var(--accent);
}

.page-tab.active {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 -2px var(--accent), 0 8px 22px color-mix(in srgb, var(--accent) 9%, transparent);
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 10px;
  cursor: pointer;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  place-items: center;
  transition: 180ms ease;
}

.icon-button:hover {
  background: var(--surface);
  color: var(--accent);
}

svg {
  width: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.test-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 620px;
  padding-bottom: 8vh;
}

.ghost-track {
  width: min(760px, 100%);
  margin: 26px auto -22px;
}

.ghost-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
}

.ghost-label strong {
  color: var(--muted-strong);
  font-weight: 400;
}

.ghost-rail {
  position: relative;
  height: 3px;
  border-radius: 99px;
  background: var(--surface);
}

.ghost-marker,
.runner-marker {
  position: absolute;
  top: 50%;
  left: 0;
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 8px;
  transform: translate(-50%, -50%);
  transition: left 180ms linear;
}

.ghost-marker {
  background: var(--muted);
  color: var(--bg);
}

.runner-marker {
  z-index: 1;
  background: var(--accent);
  color: var(--bg);
}

.controls {
  display: flex;
  align-self: center;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.09);
  backdrop-filter: blur(18px);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.control-divider {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border);
}

.controls button {
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  transition: 160ms ease;
}

.controls button:hover {
  color: var(--muted-strong);
}

.controls button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.option-toggle span,
.mode-button span {
  color: currentColor;
  font-weight: 500;
}

.mode-button {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-button svg {
  width: 13px;
}

.hidden {
  display: none !important;
}

.hero-copy {
  max-width: 820px;
  margin: 8px 0 0;
  color: var(--muted-strong);
}

.hero-copy h1 {
  max-width: 760px;
  margin: 10px 0 14px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(30px, 4.2vw, 52px);
  line-height: 1.12;
  letter-spacing: -0.055em;
}

.hero-copy p:last-of-type {
  max-width: 720px;
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.hero-actions button {
  padding: 11px 14px;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.hero-actions button:hover {
  box-shadow: inset 0 -2px var(--accent);
}

.hero-actions span {
  color: var(--muted);
  font-size: 12px;
}

.test-meta {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  min-height: 130px;
  padding-bottom: 22px;
  color: var(--muted);
}

.language {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
}

.language > svg:first-child {
  width: 15px;
}

.language select {
  max-width: 170px;
  padding: 6px 21px 6px 3px;
  border: 0;
  outline: 0;
  appearance: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  text-transform: lowercase;
}

.language select:hover,
.language select:focus {
  color: var(--accent);
}

.language .select-arrow {
  width: 12px;
  margin-left: -24px;
  pointer-events: none;
}

.language option {
  background: var(--surface);
  color: var(--text);
  text-transform: none;
}

.live-stat {
  display: flex;
  align-items: baseline;
  gap: 9px;
  opacity: 0;
  transition: opacity 180ms ease;
}

.test-panel.running .live-stat {
  opacity: 1;
}

.live-stat.right {
  justify-self: end;
}

.live-stat span {
  color: var(--muted);
  font-size: 11px;
}

.live-stat strong {
  color: var(--accent);
  font-size: 22px;
  font-weight: 500;
}

.typing-wrap {
  position: relative;
  height: 180px;
  overflow: hidden;
  cursor: text;
  outline: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 18%, black 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, black 18%, black 82%, transparent 100%);
}

.words {
  position: absolute;
  top: 54px;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  width: 100%;
  color: var(--muted);
  font-size: clamp(22px, 2.15vw, 31px);
  line-height: 1.5;
  user-select: none;
  transition: transform 180ms ease;
}

.word {
  position: relative;
  display: inline-flex;
}

.word.current-end::after {
  position: absolute;
  top: 0.1em;
  right: -2px;
  width: 2px;
  height: 1.25em;
  border-radius: 2px;
  background: var(--accent);
  content: "";
  animation: blink 1s step-end infinite;
}

.letter {
  position: relative;
  transition: color 80ms linear;
}

.letter.correct {
  color: var(--correct);
}

.letter.incorrect {
  color: var(--error);
}

.letter.current::before {
  position: absolute;
  top: 0.1em;
  left: -1px;
  width: 2px;
  height: 1.25em;
  border-radius: 2px;
  background: var(--accent);
  content: "";
  animation: blink 1s step-end infinite;
}

.word.extra .letter {
  color: var(--error);
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

#typingInput {
  position: fixed;
  top: -1000px;
  left: -1000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.focus-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  cursor: pointer;
  background: rgba(23, 26, 31, 0.7);
  color: var(--muted-strong);
  font-size: 13px;
  opacity: 0;
  backdrop-filter: blur(5px);
  transition: opacity 180ms ease;
  pointer-events: none;
}

:root.light .focus-prompt {
  background: rgba(244, 241, 233, 0.7);
}

.typing-wrap.unfocused .focus-prompt {
  opacity: 1;
  pointer-events: auto;
}

.focus-prompt svg {
  width: 15px;
}

.restart-button {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 8px;
  margin-top: 20px;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: 180ms ease;
}

.restart-button svg {
  width: 18px;
}

.restart-button span {
  display: none;
  font-size: 12px;
}

.restart-button:hover {
  background: var(--surface);
  color: var(--accent);
}

.restart-button:hover span {
  display: inline;
}

.result-card {
  display: grid;
  grid-template-columns: 1.35fr repeat(4, 1fr);
  gap: 16px;
  padding: 28px 32px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
}

.score,
.result-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.result-card span {
  color: var(--muted);
  font-size: 12px;
}

.score strong {
  color: var(--accent);
  font-size: 52px;
  font-weight: 500;
  line-height: 1;
}

.result-detail {
  justify-content: center;
  padding-left: 22px;
  border-left: 1px solid var(--border);
}

.result-detail strong {
  color: var(--text);
  font-size: 21px;
  font-weight: 500;
}

.flow-result strong {
  color: var(--accent);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.result-actions button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 11px;
}

.result-actions button:hover {
  color: var(--accent);
}

.result-actions svg {
  width: 14px;
}

.result-summary,
.leaderboard-submit,
.leaderboard-preview {
  grid-column: 1 / -1;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.result-summary strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
}

.result-summary span {
  display: block;
  color: var(--muted-strong);
  line-height: 1.6;
}

.leaderboard-submit {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.leaderboard-submit label,
.leaderboard-preview > span {
  color: var(--muted);
  font-size: 10px;
}

.leaderboard-submit input {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font: 12px var(--font-mono);
}

.leaderboard-submit button {
  padding: 9px 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 11px;
}

.leaderboard-submit button:hover {
  color: var(--accent);
}

.leaderboard-preview {
  display: grid;
  gap: 8px;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.leaderboard-row strong,
.leaderboard-row span {
  font-size: 11px;
}

.progress-dashboard {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 18px;
  padding: 8px 0 90px;
}

.seo-content,
.faq-section {
  margin: 0 0 34px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 44%, transparent);
  color: var(--muted-strong);
}

.seo-content h2,
.faq-section h2 {
  max-width: 760px;
  margin: 8px 0 12px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(26px, 3.4vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.seo-content p,
.faq-section p {
  max-width: 880px;
  margin: 0;
  font-family: var(--font-sans);
  line-height: 1.75;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 24px;
}

.seo-grid article {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 40%, transparent);
}

.seo-grid h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 18px;
  letter-spacing: -0.035em;
}

.seo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.seo-links a {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: color-mix(in srgb, var(--bg) 34%, transparent);
  color: var(--muted-strong);
  font-size: 11px;
  text-decoration: none;
}

.seo-links a:hover {
  color: var(--accent);
}

.faq-section details {
  padding: 18px 0;
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
}

.faq-section details:first-of-type {
  margin-top: 18px;
}

.faq-section summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.faq-section details p {
  margin-top: 10px;
}

.dashboard-card {
  padding: 25px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.card-heading h2 {
  margin: 5px 0 0;
  font-family: var(--font-sans);
  font-size: 18px;
  letter-spacing: -0.035em;
}

.score-pill,
.mission-count {
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}

.flow-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.flow-card .card-heading {
  align-self: start;
  grid-column: 1 / -1;
}

.flow-gauge {
  position: relative;
  display: grid;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--score) * 1%), var(--surface) 0);
  place-items: center;
  transition: background 400ms ease;
}

.flow-gauge::before {
  position: absolute;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--surface-soft);
  content: "";
}

.flow-gauge > div {
  z-index: 1;
  display: flex;
  align-items: baseline;
}

.flow-gauge strong {
  color: var(--text);
  font-size: 33px;
  font-weight: 500;
}

.flow-gauge span {
  color: var(--muted);
  font-size: 10px;
}

.flow-card p,
.heatmap-card p {
  margin: 0 0 0 22px;
  color: var(--muted-strong);
  font-size: 11px;
  line-height: 1.7;
}

.mission-list {
  display: grid;
  gap: 10px;
}

.mission {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.mission-check {
  display: grid;
  width: 20px;
  height: 20px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  color: transparent;
  font-size: 11px;
  place-items: center;
}

.mission.complete .mission-check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.mission-copy strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 11px;
  font-weight: 400;
}

.mission-copy span,
.mission-progress {
  color: var(--muted);
  font-size: 9px;
}

.heatmap-card {
  grid-column: 1 / -1;
}

.text-button {
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.text-button:hover {
  color: var(--error);
}

.keyboard-heatmap {
  display: grid;
  gap: 6px;
  width: min(780px, 100%);
  margin: 0 auto;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.heat-key {
  display: grid;
  width: clamp(24px, 5vw, 48px);
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: clamp(8px, 1.5vw, 11px);
  place-items: center;
  transition: 180ms ease;
}

.heat-key[data-heat="1"] {
  background: color-mix(in srgb, var(--error) 18%, var(--surface));
  color: var(--muted-strong);
}

.heat-key[data-heat="2"] {
  background: color-mix(in srgb, var(--error) 36%, var(--surface));
  color: var(--text);
}

.heat-key[data-heat="3"] {
  background: color-mix(in srgb, var(--error) 60%, var(--surface));
  color: white;
}

.heat-key[data-heat="4"] {
  background: var(--error);
  color: white;
  box-shadow: 0 0 24px color-mix(in srgb, var(--error) 25%, transparent);
}

.heatmap-card > p {
  margin: 18px 0 0;
  text-align: center;
}

.beginner-tutorial {
  display: grid;
  grid-template-columns: 1fr;
  gap: 26px;
  margin: 42px 0 34px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 34%, transparent);
}

.beginner-tutorial + .test-panel {
  margin-top: 22px;
}

.tutorial-copy h2 {
  margin: 8px 0 12px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.tutorial-copy p {
  max-width: 760px;
  margin: 0;
  color: var(--muted-strong);
  font-family: var(--font-sans);
  line-height: 1.75;
}

.tutorial-copy kbd {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  margin: 0 1px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--accent);
  font: 500 12px var(--font-mono);
  place-items: center;
}

.tutorial-stage {
  display: grid;
  gap: 14px;
  width: 100%;
  min-width: 0;
}

.lesson-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lesson-tab {
  padding: 8px 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.lesson-tab:hover,
.lesson-tab.active {
  color: var(--accent);
}

.lesson-tab.active {
  box-shadow: inset 0 -2px var(--accent);
}

.lesson-line {
  display: grid;
  gap: 7px;
  min-height: 78px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 46%, transparent);
  color: var(--muted);
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.3;
}

.lesson-line-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 1.25em;
}

.lesson-char {
  min-width: 0.68em;
  text-align: center;
}

.lesson-char.space {
  width: 0.8em;
}

.lesson-char.done {
  color: var(--correct);
}

.lesson-char.wrong {
  color: var(--error);
}

.lesson-char.current {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.lesson-input-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.lesson-input-label input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font: 16px var(--font-mono);
}

.lesson-input-label input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.lesson-progress {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface);
}

.lesson-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.tutorial-keyboard {
  display: grid;
  gap: 6px;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tutorial-key-row {
  display: grid;
  grid-auto-columns: minmax(34px, 1fr);
  grid-auto-flow: column;
  gap: 6px;
  min-width: 520px;
}

.tutorial-key-row:nth-child(2) {
  padding-left: 18px;
}

.tutorial-key-row:nth-child(3) {
  padding-left: 42px;
}

.tutorial-key {
  display: grid;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  place-items: center;
  transition: 160ms ease;
}

.tutorial-key.home-key {
  color: var(--muted-strong);
  box-shadow: inset 0 -2px color-mix(in srgb, var(--accent) 36%, transparent);
}

.tutorial-key.next-key {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-2px);
}

.tutorial-key[data-lesson-heat="1"] {
  background: color-mix(in srgb, var(--error) 16%, var(--surface));
}

.tutorial-key[data-lesson-heat="2"] {
  background: color-mix(in srgb, var(--error) 30%, var(--surface));
  color: var(--muted-strong);
}

.tutorial-key[data-lesson-heat="3"] {
  background: color-mix(in srgb, var(--error) 48%, var(--surface));
  color: var(--text);
}

.tutorial-key[data-lesson-heat="4"] {
  background: color-mix(in srgb, var(--error) 72%, var(--surface));
  color: white;
  box-shadow: 0 0 18px color-mix(in srgb, var(--error) 20%, transparent);
}

.tutorial-key.space-key {
  grid-column: span 5;
}

.tutorial-insights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 1.7fr;
  gap: 10px;
}

.tutorial-stat,
.tutorial-wrong-map {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 36%, transparent);
}

.tutorial-stat span,
.tutorial-wrong-map span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
}

.tutorial-stat strong,
.tutorial-wrong-map strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 18px;
  font-weight: 500;
}

.tutorial-wrong-map strong {
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.55;
}

.tutorial-complete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  border-radius: 4px;
  background: var(--accent-soft);
}

.tutorial-complete strong {
  display: block;
  margin: 5px 0 6px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 18px;
}

.tutorial-complete p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.6;
}

.tutorial-complete-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tutorial-complete-actions button {
  min-width: 112px;
  padding: 10px 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 11px;
}

.tutorial-complete-actions button:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--accent);
}

.toast {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  opacity: 0;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
  transform: translateY(10px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

footer {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px 0 30px;
  color: var(--muted);
  font-size: 10px;
}

footer kbd {
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted-strong);
  font: inherit;
}

.footer-note {
  margin-left: auto;
}

dialog {
  width: min(440px, calc(100% - 36px));
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.35);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 16px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
}

dialog h2 {
  margin: 10px 0 12px;
  font-family: var(--font-sans);
  font-size: 26px;
  letter-spacing: -0.04em;
}

dialog p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 28px, 1280px);
  }

  .topbar {
    padding: 24px 0;
  }

  .page-tabs {
    margin-top: 14px;
  }

  .page-tab {
    flex: 1;
  }

  .test-panel {
    min-height: 560px;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }

  .control-divider {
    display: none;
  }

  .test-meta {
    min-height: 100px;
  }

  .words {
    font-size: 22px;
  }

  .result-card {
    grid-template-columns: repeat(2, 1fr);
    padding: 22px;
  }

  .score {
    grid-column: 1 / -1;
  }

  .result-detail {
    padding: 14px 0 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .progress-dashboard {
    grid-template-columns: 1fr;
  }

  .beginner-tutorial {
    grid-template-columns: 1fr;
    padding: 24px 18px;
  }

  .heatmap-card {
    grid-column: auto;
    overflow: hidden;
  }

  footer span:nth-child(2) {
    display: none;
  }
}

/* Advertisement placements */
@media (max-width: 480px) {
  .option-toggle {
    font-size: 0 !important;
  }

  .option-toggle span {
    font-size: 14px;
  }

  .test-meta {
    grid-template-columns: 1fr auto 1fr;
  }

  .live-stat {
    flex-direction: column;
    gap: 0;
  }

  .live-stat.right {
    align-items: flex-end;
  }

  .typing-wrap {
    height: 210px;
  }

  .result-card {
    gap: 10px;
  }

  .leaderboard-submit {
    grid-template-columns: 1fr;
  }

  .leaderboard-row {
    flex-direction: column;
    gap: 4px;
  }

  .flow-card {
    grid-template-columns: 1fr;
  }

  .flow-gauge {
    margin: 0 auto 18px;
  }

  .flow-card p {
    margin: 0;
    text-align: center;
  }

  .dashboard-card {
    padding: 20px 16px;
  }

  .key-row {
    gap: 3px;
  }

  .lesson-line {
    padding: 14px;
  }

  .tutorial-key-row {
    min-width: 470px;
  }

  .tutorial-insights {
    grid-template-columns: 1fr;
  }

  .tutorial-complete {
    align-items: stretch;
    flex-direction: column;
  }

  .tutorial-complete-actions button {
    flex: 1;
  }

  .result-detail strong {
    font-size: 16px;
  }
}

@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;
  }
}

/* KeyTypingChamp layout theme — preserves the existing color palette */
.shell {
  width: min(1180px, calc(100% - 48px));
}

.topbar {
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  border-radius: 4px;
}

.icon-button {
  border: 1px solid transparent;
  border-radius: 4px;
}

.icon-button:hover {
  border-color: var(--border);
}

.test-panel {
  position: relative;
  justify-content: flex-start;
  min-height: 610px;
  margin-top: 42px;
  padding: 70px 46px 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 34%, transparent);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.08);
}

.test-panel::before {
  position: absolute;
  top: 23px;
  left: 46px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
  content: "KEYTYPINGCHAMP / PRACTICE DECK";
}

.test-panel::after {
  position: absolute;
  top: 27px;
  right: 46px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
  content: "";
}

.controls {
  align-self: stretch;
  justify-content: flex-start;
  padding: 10px;
  border-radius: 4px;
  background: var(--surface);
  box-shadow: none;
}

.controls button {
  border-radius: 3px;
}

.controls button.active {
  box-shadow: inset 0 -2px var(--accent);
}

.test-meta {
  min-height: 105px;
  padding: 0 18px 16px;
}

.language {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.typing-wrap {
  height: 250px;
  padding: 0 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 48%, transparent);
  -webkit-mask-image: none;
  mask-image: none;
}

.typing-wrap::before,
.typing-wrap::after {
  position: absolute;
  z-index: 2;
  top: 14px;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.12em;
  pointer-events: none;
}

.typing-wrap::before {
  left: 16px;
  content: "INPUT";
}

.typing-wrap::after {
  right: 16px;
  content: "LIVE";
}

.words {
  top: 62px;
  left: 24px;
  width: calc(100% - 48px);
  line-height: 1.58;
}

.ghost-track {
  width: 100%;
  margin: 22px 0 12px;
  padding: 0 18px;
}

.restart-button {
  align-self: flex-end;
  margin-top: 14px;
  border: 1px solid transparent;
  border-radius: 3px;
}

.restart-button:hover {
  border-color: var(--border);
}

.result-card {
  border-radius: 4px;
  box-shadow: inset 3px 0 var(--accent);
}

.result-actions button {
  border: 1px solid var(--border);
  border-radius: 3px;
}

.progress-dashboard {
  grid-template-columns: 0.9fr 1.1fr;
  gap: 14px;
  padding-top: 22px;
}

.dashboard-card {
  border-radius: 4px;
  box-shadow: none;
}

.flow-card {
  border-top: 3px solid var(--accent);
}

.mission-card {
  border-top: 3px solid var(--muted);
}

.heatmap-card {
  border-top: 3px solid var(--surface);
}

.mission,
.heat-key,
.score-pill,
.mission-count {
  border-radius: 3px;
}

footer {
  border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 28px, 1180px);
  }

  .test-panel {
    margin-top: 22px;
    padding: 62px 20px 24px;
  }

  .test-panel::before {
    left: 20px;
  }

  .test-panel::after {
    right: 20px;
  }

  .controls {
    justify-content: center;
  }

  .typing-wrap {
    height: 235px;
    padding: 0 14px;
  }

  .words {
    left: 14px;
    width: calc(100% - 28px);
  }

  .progress-dashboard {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    font-size: clamp(29px, 9vw, 40px);
    line-height: 1.14;
  }

  .seo-content,
  .faq-section {
    padding: 24px 18px;
  }

  .seo-grid {
    grid-template-columns: 1fr;
  }
}
