:root {
  --ink: #18242f;
  --muted: #68737a;
  --paper: #f4f0e8;
  --card: #fffdf8;
  --line: #d9d5cd;
  --keyboard: #1e2a34;
  --keyboard-key: #34424e;
  --coral: #ff6f55;
  --green: #4caa7c;
  --red: #dd5b5b;
  --shadow: 0 24px 70px rgba(31, 39, 45, 0.09);
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background:
    radial-gradient(circle at 13% 4%, rgba(255, 255, 255, 0.95) 0, transparent 26rem),
    var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  background-image: linear-gradient(rgba(24, 36, 47, 0.025) 1px, transparent 1px);
  background-size: 100% 5rem;
}

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

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(255, 111, 85, 0.4);
  outline-offset: 3px;
}

.app-shell {
  width: min(1460px, calc(100% - 64px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--ink);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
  font-family: "DM Mono", monospace;
}

.brand-mark span {
  transform: translateY(-1px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sound-toggle {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}

.sound-toggle svg {
  width: 18px;
  fill: currentColor;
}

.sound-toggle path:last-child {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.sound-toggle.muted .sound-waves {
  display: none;
}

.sound-toggle:hover {
  transform: translateY(-1px);
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 32px;
  padding: 18px 0 20px;
}

.eyebrow,
.section-label {
  margin: 0;
  color: #657078;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--coral);
}

.eyebrow span {
  width: 22px;
  height: 2px;
  background: currentColor;
}

h1 {
  max-width: 800px;
  margin: 6px 0 5px;
  font-size: clamp(32px, 3.3vw, 46px);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 0.96;
}

h1 br {
  display: none;
}

h1 em {
  color: var(--coral);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.045em;
}

.intro-text {
  max-width: none;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.stats {
  display: flex;
  gap: 0;
  margin: 0 0 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.64);
}

.stats div {
  min-width: 102px;
  padding: 13px 17px;
}

.stats div + div {
  border-left: 1px solid var(--line);
}

.stats dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stats dd {
  margin: 0;
  font-family: "DM Mono", monospace;
  font-size: 25px;
  font-weight: 500;
}

.stats dd span {
  margin-left: 2px;
  color: var(--muted);
  font-size: 13px;
}

.trainer {
  --typing-board-width: 737px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
}

.trainer-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 30px 22px;
  border-bottom: 1px solid var(--line);
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.mode-tab {
  min-height: 35px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.mode-tab:hover {
  border-color: var(--line);
  color: var(--ink);
}

.mode-tab.active {
  color: white;
  background: var(--ink);
}

.layout-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(76, 170, 124, 0.13);
}

.status-line {
  display: flex;
  align-items: center;
  min-height: 43px;
  padding: 0 34px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #dbe3e7;
  background: var(--keyboard);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.status-icon {
  margin-right: 9px;
  color: #91a0a9;
}

.status-hint {
  margin-left: auto;
  color: #82909a;
}

.trainer[data-status="correct"] .status-icon {
  color: #6fd19b;
}

.trainer[data-status="wrong"] .status-icon {
  color: #ff8277;
}

.keyboard-scroll {
  overflow-x: auto;
  padding: 26px 34px 30px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%) 0 0 / 8px 8px,
    var(--keyboard);
  scrollbar-color: #596874 transparent;
  scrollbar-width: thin;
}

.keyboard {
  width: var(--typing-board-width);
  margin: 0 auto;
}

.typing-board {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyboard-row {
  display: flex;
  gap: 6px;
}

.key {
  position: relative;
  display: flex;
  width: calc(43px * var(--key-width, 1) + (var(--key-width, 1) - 1) * 6px);
  height: 43px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #4a5964;
  border-radius: 7px;
  color: #e8edf0;
  background: var(--keyboard-key);
  box-shadow: 0 3px 0 #111b22, inset 0 1px 0 rgba(255, 255, 255, 0.07);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  text-align: center;
  transition: transform 80ms ease, box-shadow 80ms ease, color 120ms ease, background-color 120ms ease;
}

.key::after {
  position: absolute;
  right: 5px;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--finger-color);
  content: "";
  opacity: 0.72;
}

.key-special {
  color: #bac5cb;
  font-size: 8px;
  letter-spacing: -0.02em;
}

.key-home::before {
  position: absolute;
  bottom: 7px;
  width: 12px;
  height: 1px;
  border-radius: 1px;
  background: #91a0a9;
  content: "";
}

.key-legend {
  color: #9ca9b1;
  font-size: 8px;
  font-weight: 400;
  transition: color 120ms ease, font-size 120ms ease, font-weight 120ms ease;
}

.key-legend + .key-legend {
  margin-left: 4px;
}

.key-legend.is-emphasized {
  color: inherit;
  font-size: 11px;
  font-weight: 700;
}

.key-special .key-legend,
.key-special .key-legend.is-emphasized {
  font-size: inherit;
}

.key-special .key-legend.is-emphasized {
  font-weight: 500;
}

.key.target {
  z-index: 2;
  border-color: color-mix(in srgb, var(--active-color) 75%, white);
  color: white;
  background: color-mix(in srgb, var(--active-color) 58%, #27343e);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--active-color) 40%, #10171c), 0 0 0 3px color-mix(in srgb, var(--active-color) 18%, transparent), 0 0 20px color-mix(in srgb, var(--active-color) 28%, transparent);
  animation: breathe 1.7s ease-in-out infinite;
}

.key.modifier-target {
  border-style: dashed;
}

@keyframes breathe {
  50% { filter: brightness(1.14); }
}

.key.pressed {
  transform: translateY(3px);
  box-shadow: 0 0 0 #111b22, inset 0 1px 4px rgba(0, 0, 0, 0.12);
  animation: none;
}

.key.wrong {
  border-color: #ff8b80;
  color: white;
  background: #a44747;
}

.guidance {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 38px;
  min-height: 186px;
  padding: 28px 34px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.hands {
  display: flex;
  grid-column: 2;
  align-items: flex-end;
  justify-self: center;
  gap: 42px;
}

.hand {
  position: relative;
  display: flex;
  align-items: end;
  gap: 4px;
  height: 93px;
}

.finger {
  position: relative;
  display: grid;
  width: 21px;
  place-items: center;
  border: 1px solid #cbd0cd;
  border-radius: 9px 9px 5px 5px;
  color: #79838a;
  background: #e9e8e2;
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease;
}

.finger span {
  font-family: "DM Mono", monospace;
  font-size: 7px;
}

.finger-pinky { height: 48px; }
.finger-ring { height: 63px; }
.finger-middle { height: 75px; }
.finger-index { height: 68px; }
.finger-thumb {
  width: 36px;
  height: 25px;
  margin: 0 -5px 5px;
  border-radius: 12px 7px 7px 12px;
  transform: rotate(-20deg);
}

.hand-right .finger-thumb {
  border-radius: 7px 12px 12px 7px;
  transform: rotate(20deg);
}

.palm {
  position: absolute;
  right: 0;
  bottom: -19px;
  left: 0;
  z-index: 0;
  height: 39px;
  border: 1px solid #cbd0cd;
  border-radius: 4px 4px 12px 12px;
  color: #939b9e;
  background: #e1e2de;
  text-align: center;
}

.palm span {
  font-family: "DM Mono", monospace;
  font-size: 7px;
  text-transform: uppercase;
}

.finger,
.finger span {
  z-index: 1;
}

.finger.active {
  border-color: var(--active-color);
  color: white;
  background: var(--active-color);
  box-shadow: 0 5px 13px color-mix(in srgb, var(--active-color) 35%, transparent);
  transform: translateY(-10px);
}

.finger.active.finger-thumb {
  transform: rotate(-20deg) translateY(-9px);
}

.hand-right .finger.active.finger-thumb {
  transform: rotate(20deg) translateY(-9px);
}

.finger.secondary {
  outline: 2px dashed color-mix(in srgb, var(--active-color) 60%, transparent);
  outline-offset: 2px;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 24px 2px 45px;
  color: #8c9499;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

footer p {
  margin: 0;
}

footer p span {
  margin: 0 7px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .intro-grid {
    grid-template-columns: 1fr;
  }

  .stats {
    width: fit-content;
  }

}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 28px, 1460px);
  }

  .topbar {
    min-height: 64px;
  }

  .sound-toggle span {
    display: none;
  }

  .sound-toggle {
    padding: 0 12px;
  }

  .intro-grid {
    gap: 24px;
    padding: 24px 0 26px;
  }

  h1 {
    font-size: clamp(40px, 12vw, 58px);
  }

  h1 br {
    display: initial;
  }

  .stats {
    width: 100%;
  }

  .stats div {
    min-width: 0;
    flex: 1;
    padding: 14px 16px;
  }

  .trainer-toolbar {
    align-items: flex-start;
    padding: 20px;
  }

  .layout-note {
    display: none;
  }

  .status-line {
    padding: 0 20px;
  }

  .status-hint {
    display: none;
  }

  .keyboard-scroll {
    padding: 22px 20px 26px;
  }

  .guidance {
    grid-template-columns: 1fr;
    padding: 28px 20px;
  }

  .hands {
    grid-column: 1;
    justify-content: center;
    gap: 28px;
  }

  footer p:last-child {
    display: none;
  }
}

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

a:hover {
  color: var(--coral);
}

a {
  color: inherit;
}
