:root {
  color-scheme: dark;
  --bg: #080a0e;
  --surface: #0f1218;
  --surface-raised: #151922;
  --surface-soft: #1a1f29;
  --text: #f4f6ef;
  --text-soft: #c3c9c4;
  --muted: #737b80;
  --accent: #c8ff5a;
  --accent-strong: #adf02b;
  --accent-soft: rgba(200, 255, 90, 0.12);
  --cyan: #67e8f9;
  --bad: #ff6b78;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font-family:
    Inter, "Aptos", "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  min-width: 320px;
  overflow: hidden;
  background: var(--bg);
}

body {
  width: 100%;
  height: 100%;
  min-width: 320px;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 17% -8%, rgba(103, 232, 249, 0.09), transparent 26rem),
    radial-gradient(circle at 87% 8%, rgba(200, 255, 90, 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.22;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

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

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: rgba(200, 255, 90, 0.24);
  color: var(--text);
}

.app {
  width: min(1280px, calc(100vw - 40px));
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(14px, 2vh, 20px);
  padding: clamp(18px, 2.6vh, 28px) 0;
}

.topbar,
.stats,
.controls {
  display: flex;
  align-items: center;
}

.topbar,
.controls,
.test-meta,
.typing-hint,
.stats .metric {
  transition:
    opacity 420ms ease,
    filter 520ms var(--ease-out),
    transform 520ms var(--ease-out),
    border-color 220ms ease,
    background-color 220ms ease,
    box-shadow 220ms ease;
}

.topbar {
  min-height: 70px;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(15, 18, 24, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(200, 255, 90, 0.28);
  border-radius: 13px;
  background:
    linear-gradient(145deg, rgba(200, 255, 90, 0.17), rgba(200, 255, 90, 0.03)),
    var(--surface-raised);
  color: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 12px 30px rgba(0, 0, 0, 0.22);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-copy {
  display: grid;
  gap: 2px;
  line-height: 1;
}

.brand-copy strong {
  font-size: 1rem;
  font-weight: 780;
  letter-spacing: -0.025em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.035em;
}

.duration-control {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 5px 7px 5px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(5, 7, 10, 0.56);
}

.control-eyebrow,
.duration-unit,
.control-title {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.tab,
.text-button,
.icon-button,
.result-button {
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms var(--ease-out);
}

.tab {
  min-width: 43px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
}

.tab.is-active {
  border-color: rgba(200, 255, 90, 0.22);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.duration-unit {
  padding-right: 5px;
}

.icon-button {
  min-width: 104px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 15px;
  border-color: var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
  font-size: 0.79rem;
  font-weight: 720;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 1050px);
  min-height: 82px;
  margin: 0 auto;
}

.metric {
  position: relative;
  min-width: 0;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(15, 18, 24, 0.62);
}

.metric::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 2px;
  border-radius: 99px;
  background: var(--line-strong);
}

.metric:nth-child(1)::before {
  background: var(--cyan);
}

.metric:nth-child(3)::before {
  background: var(--accent);
}

.metric-label {
  max-width: 8ch;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 760;
  letter-spacing: 0.055em;
  line-height: 1.25;
  text-transform: uppercase;
}

.metric-value {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
}

.metric strong {
  color: var(--text);
  font-size: clamp(1.7rem, 3.1vw, 2.45rem);
  font-weight: 710;
  line-height: 1;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}

.metric small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 740;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.timer-metric {
  border-color: rgba(200, 255, 90, 0.15);
  background:
    linear-gradient(135deg, rgba(200, 255, 90, 0.08), transparent 68%),
    rgba(15, 18, 24, 0.74);
}

.timer-metric strong,
.timer-metric small {
  color: var(--accent);
}

.metric.is-hidden-during-test strong,
.metric.is-hidden-during-test small {
  visibility: hidden;
}

.app.is-test-active .topbar,
.app.is-test-active .controls,
.app.is-test-active .test-meta,
.app.is-test-active .typing-hint,
.app.is-test-active .stats .metric:not(.timer-metric) {
  opacity: 0.11;
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

.app.is-test-active .topbar {
  transform: translateY(-3px) scale(0.995);
}

.app.is-test-active .controls {
  transform: translateY(3px) scale(0.995);
}

.app.is-test-active .timer-metric {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 5;
  width: min(235px, calc(25% - 8px));
  transform: translateX(-50%) scale(1.04);
  border-color: rgba(200, 255, 90, 0.32);
  background:
    radial-gradient(circle at 82% 12%, rgba(200, 255, 90, 0.14), transparent 7rem),
    rgba(15, 18, 24, 0.94);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(200, 255, 90, 0.05);
}

.typing-shell {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(20px, 2.8vw, 34px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 105%, rgba(103, 232, 249, 0.055), transparent 30rem),
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 42%),
    rgba(15, 18, 24, 0.88);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.typing-shell::before {
  content: "";
  position: absolute;
  top: 0;
  left: clamp(34px, 6vw, 92px);
  right: clamp(34px, 6vw, 92px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 255, 90, 0.58), transparent);
  opacity: 0.65;
}

.skip-test-button {
  position: absolute;
  top: clamp(17px, 2.5vw, 28px);
  right: clamp(17px, 2.5vw, 28px);
  z-index: 8;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid rgba(200, 255, 90, 0.2);
  border-radius: 12px;
  background: rgba(15, 18, 24, 0.94);
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 720;
  letter-spacing: 0.015em;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-5px);
  transition:
    opacity 180ms ease,
    visibility 180ms ease,
    transform 240ms var(--ease-out),
    color 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
  cursor: pointer;
}

.skip-test-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-test-button:hover {
  border-color: rgba(200, 255, 90, 0.42);
  background: rgba(200, 255, 90, 0.1);
  color: var(--accent);
}

.app.is-test-active .skip-test-button {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.test-meta {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 670;
}

.test-state,
.latency {
  display: inline-flex;
  align-items: center;
}

.test-state {
  gap: 9px;
}

.test-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(200, 255, 90, 0.08);
}

.latency {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 7, 10, 0.36);
  font-variant-numeric: tabular-nums;
}

.word-stage {
  min-height: 0;
  display: grid;
  align-content: center;
  padding: clamp(28px, 5vh, 58px) 0;
}

.typing-input {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  opacity: 0;
  pointer-events: none;
  resize: none;
}

.words {
  --word-font-size: clamp(1.52rem, 2.18vw, 2.06rem);
  --word-line-height: 1.42;
  --word-row-gap: 9px;
  position: relative;
  z-index: 2;
  width: min(100%, 940px);
  height: calc(3lh + (var(--word-row-gap) * 2) + 8px);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: var(--word-row-gap) 15px;
  overflow: hidden;
  outline: 0;
  color: #777f84;
  font-family: "Aptos Mono", "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: var(--word-font-size);
  font-weight: 520;
  line-height: var(--word-line-height);
  letter-spacing: -0.035em;
  user-select: none;
}

.words[lang="zh"] {
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  letter-spacing: 0;
}

.word {
  display: inline-flex;
  padding: 0 1px 3px;
  border-bottom: 2px solid transparent;
  white-space: pre;
  transition:
    border-color 180ms ease,
    color 180ms ease,
    opacity 180ms ease;
}

.word.current {
  border-color: rgba(200, 255, 90, 0.42);
  color: #91999d;
}

.char {
  display: inline-block;
  min-width: 0;
  will-change: color, background-color, opacity, transform;
  transition:
    color 145ms ease,
    background-color 145ms ease,
    opacity 145ms ease,
    transform 145ms var(--ease-out);
}

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

.char.wrong {
  border-radius: 4px;
  background: rgba(255, 107, 120, 0.12);
  color: var(--bad);
  text-decoration: underline;
  text-decoration-color: rgba(255, 107, 120, 0.45);
  text-underline-offset: 5px;
}

.char.pending {
  color: #6f777c;
}

.char.extra {
  color: #ff94a0;
}

.char.fresh {
  animation: settleChar 150ms ease-out;
}

.caret {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 2px;
  height: 1.42em;
  border-radius: 99px;
  opacity: 0;
  background: var(--accent);
  box-shadow: 0 0 11px rgba(200, 255, 90, 0.22);
  transform: translate3d(0, 0, 0);
  transition: transform 82ms var(--ease-out);
  will-change: transform;
  pointer-events: none;
}

.caret.is-visible {
  opacity: 1;
  animation: blink 1.15s ease-in-out infinite;
}

.typing-hint {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: #5e666b;
  font-size: 0.68rem;
  font-weight: 640;
}

.typing-hint span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

kbd {
  min-width: 22px;
  min-height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-color: rgba(255, 255, 255, 0.19);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font: inherit;
  font-size: 0.62rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.32);
}

.caps-warning {
  position: absolute;
  top: 58px;
  left: clamp(20px, 2.8vw, 34px);
  z-index: 6;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 7px;
  border: 1px solid rgba(200, 255, 90, 0.26);
  border-radius: 10px;
  background: rgba(17, 21, 26, 0.95);
  color: var(--accent);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.3);
  font-size: 0.7rem;
  font-weight: 760;
  opacity: 0;
  transform: translateY(-5px);
  transition:
    opacity 160ms ease,
    transform 180ms var(--ease-out);
  pointer-events: none;
}

.caps-warning kbd {
  color: var(--accent);
}

.caps-warning.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.controls {
  position: relative;
  z-index: 10;
  width: fit-content;
  max-width: 100%;
  min-height: 66px;
  justify-self: center;
  gap: 15px;
  margin: 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(15, 18, 24, 0.76);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(16px);
}

.control-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
}

.language-control {
  position: relative;
}

.language-picker {
  position: relative;
}

.language-trigger {
  min-width: 132px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  background: rgba(5, 7, 10, 0.52);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 730;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.language-trigger:hover,
.language-trigger[aria-expanded="true"] {
  border-color: rgba(200, 255, 90, 0.2);
  background: rgba(200, 255, 90, 0.07);
  color: var(--accent);
}

.language-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.language-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  transition: transform 180ms var(--ease-out);
}

.language-trigger[aria-expanded="true"] .language-chevron {
  transform: rotate(180deg);
}

.language-menu {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 9px);
  left: 0;
  width: 100%;
  min-width: 154px;
  display: grid;
  gap: 3px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px;
  background: rgba(12, 15, 20, 0.97);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
  transform-origin: bottom left;
  animation: language-menu-in 150ms var(--ease-out);
}

.language-menu[hidden] {
  display: none;
}

.language-option {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 710;
  text-align: left;
  transition:
    color 150ms ease,
    background-color 150ms ease;
}

.language-option:hover,
.language-option:focus-visible {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}

.language-option.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.language-check {
  opacity: 0;
  font-size: 0.82rem;
}

.language-option.is-active .language-check {
  opacity: 1;
}

@keyframes language-menu-in {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.control-title {
  position: absolute;
  top: -5px;
  left: 11px;
  z-index: 2;
  padding: 0 5px;
  background: #0f1218;
  color: var(--text-soft);
  font-size: 0.61rem;
  line-height: 1;
  letter-spacing: 0.09em;
  pointer-events: none;
}

.control-options {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  background: rgba(5, 7, 10, 0.46);
}

.control-divider {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.text-button {
  min-height: 38px;
  min-width: 72px;
  padding: 0 13px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 730;
}

.text-button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
}

.text-button.is-active,
.text-button[aria-pressed="true"] {
  border-color: rgba(200, 255, 90, 0.2);
  background: var(--accent-soft);
  color: var(--accent);
}

.option-button[aria-pressed="true"]::before {
  content: "";
  width: 5px;
  height: 5px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
}

.words.show-results {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: block;
  margin: 0;
  overflow: hidden;
  border-radius: 20px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.35;
  letter-spacing: 0;
  user-select: auto;
}

.words.show-results:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.app.has-results {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.app.has-results .typing-shell {
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  padding: clamp(16px, 2vw, 24px);
}

.app.has-results .test-meta,
.app.has-results .typing-hint {
  display: none;
}

.app.has-results .word-stage {
  align-content: stretch;
  padding: 0;
}

.results {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 0.78fr) minmax(0, 1.22fr);
  align-items: stretch;
  gap: clamp(12px, 1.5vw, 18px);
  animation: resultEnter 340ms var(--ease-out);
}

.result-hero,
.result-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
}

.result-hero {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 18px;
  padding: clamp(22px, 3vw, 38px);
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 17%, rgba(200, 255, 90, 0.16), transparent 12rem),
    radial-gradient(circle at 15% 88%, rgba(103, 232, 249, 0.09), transparent 13rem),
    rgba(10, 13, 17, 0.7);
}

.result-hero::after {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  right: -70px;
  bottom: -90px;
  border: 1px solid rgba(200, 255, 90, 0.12);
  border-radius: 50%;
  box-shadow:
    0 0 0 28px rgba(200, 255, 90, 0.025),
    0 0 0 56px rgba(200, 255, 90, 0.015);
}

.result-label {
  position: relative;
  z-index: 1;
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(200, 255, 90, 0.24);
  border-radius: 999px;
  background: rgba(200, 255, 90, 0.08);
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 780;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.result-score {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 11px;
}

.result-score::before {
  content: none;
}

.result-score strong {
  color: var(--text);
  font-size: clamp(5rem, 9vw, 8.2rem);
  font-weight: 690;
  line-height: 0.82;
  letter-spacing: -0.075em;
  font-variant-numeric: tabular-nums;
}

.result-score span {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 780;
  letter-spacing: 0.08em;
}

.result-hero p {
  position: relative;
  z-index: 1;
  max-width: 34ch;
  margin: 0;
  color: var(--text-soft);
  font-size: 0.93rem;
  line-height: 1.58;
}

.result-hero p strong {
  color: var(--text);
}

.result-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 10px;
  padding: clamp(14px, 2vw, 22px);
  background: rgba(10, 13, 17, 0.52);
}

.result-highlights,
.result-grid {
  display: grid;
  gap: 8px;
}

.result-highlights {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.result-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  min-height: 0;
}

.result-highlight,
.result-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.result-highlight {
  min-height: 92px;
  padding: 14px;
}

.result-highlight:first-child {
  border-color: rgba(200, 255, 90, 0.16);
  background: rgba(200, 255, 90, 0.045);
}

.result-highlight span,
.result-item span {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 760;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-transform: uppercase;
}

.result-highlight strong {
  display: block;
  margin-top: 11px;
  color: var(--text);
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  font-weight: 690;
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.result-item {
  min-height: 0;
  padding: 11px 12px;
}

.result-item strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 1.14rem;
  font-weight: 680;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.result-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border-color: rgba(200, 255, 90, 0.3);
  border-radius: 13px;
  background: var(--accent);
  color: #111509;
  font-size: 0.78rem;
  font-weight: 790;
}

.result-button-secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
}

.result-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.result-button-secondary:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.075);
}

.result-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

@keyframes settleChar {
  from {
    opacity: 0.55;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes resultEnter {
  from {
    opacity: 0;
    transform: translateY(9px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 900px) {
  html:has(.app.has-results),
  body:has(.app.has-results) {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }

  .app {
    width: min(100% - 28px, 760px);
  }

  .app.has-results {
    height: auto;
    min-height: 100dvh;
    grid-template-rows: auto auto auto auto;
  }

  .words.show-results,
  .results,
  .result-hero,
  .result-panel {
    height: auto;
    max-height: none;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .duration-control {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .app.is-test-active .timer-metric {
    width: min(230px, calc(50% - 5px));
  }

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

  .result-hero {
    min-height: 260px;
  }
}

@media (max-width: 640px) {
  body::before {
    background-size: 36px 36px;
  }

  .app {
    width: min(100% - 20px, 520px);
    height: 100dvh;
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 11px;
    padding: 10px 0 14px;
  }

  .topbar {
    min-height: 60px;
    gap: 10px;
    padding: 8px;
    border-radius: 17px;
  }

  .brand {
    min-width: 0;
    gap: 9px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .brand-copy small,
  .button-label,
  .control-eyebrow,
  .duration-unit {
    display: none;
  }

  .icon-button {
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 12px;
  }

  .duration-control {
    min-height: 45px;
    gap: 0;
    padding: 4px;
    border-radius: 13px;
  }

  .mode-tabs {
    width: 100%;
  }

  .tab {
    min-width: 0;
    flex: 1 1 0;
    padding: 0 6px;
  }

  .stats {
    gap: 7px;
  }

  .metric {
    min-height: 66px;
    padding: 11px 12px;
    border-radius: 14px;
  }

  .metric::before {
    top: 14px;
    bottom: 14px;
  }

  .metric-label {
    font-size: 0.59rem;
  }

  .metric strong {
    font-size: clamp(1.5rem, 7vw, 2rem);
  }

  .metric small {
    display: none;
  }

  .app.is-test-active .timer-metric {
    width: min(190px, calc(50% - 4px));
  }

  .typing-shell {
    min-height: 0;
    padding: 18px 15px;
    border-radius: 20px;
  }

  .skip-test-button {
    top: 13px;
    right: 13px;
    min-height: 36px;
    padding: 0 10px;
  }

  .test-meta {
    font-size: 0.67rem;
  }

  .latency {
    display: none;
  }

  .caps-warning {
    top: 51px;
    left: 15px;
  }

  .word-stage {
    padding: 28px 0;
  }

  .words {
    --word-font-size: clamp(1.28rem, 6vw, 1.58rem);
    --word-row-gap: 7px;
    width: 100%;
    gap: var(--word-row-gap) 11px;
    letter-spacing: -0.045em;
  }

  .typing-hint {
    justify-content: flex-start;
  }

  .typing-hint span:last-child {
    display: none;
  }

  .controls {
    width: 100%;
    display: grid;
    gap: 8px;
    padding: 8px;
    border-radius: 17px;
  }

  .control-group {
    display: block;
  }

  .language-picker,
  .language-trigger {
    width: 100%;
  }

  .language-menu {
    right: 0;
    left: auto;
  }

  .control-divider {
    display: none;
  }

  .control-options {
    width: 100%;
    min-width: 0;
  }

  .text-button {
    min-width: 0;
    flex: 1 1 0;
    padding: 0 8px;
  }

  .result-highlights {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-highlight {
    min-height: 80px;
    padding: 11px;
  }

  .result-highlight strong {
    font-size: 1.45rem;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .brand-copy strong {
    font-size: 0.9rem;
  }

  .metric {
    gap: 7px;
    padding-inline: 10px;
  }

  .metric-label {
    max-width: 6ch;
  }

  .typing-hint {
    display: none;
  }

  .result-highlights {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) and (max-height: 720px) {
  .app {
    gap: 7px;
    padding-block: 6px 8px;
  }

  .topbar {
    gap: 6px;
    padding: 6px;
  }

  .duration-control {
    min-height: 40px;
  }

  .tab {
    min-height: 32px;
  }

  .stats {
    gap: 5px;
  }

  .metric {
    min-height: 54px;
    padding: 8px 10px;
  }

  .typing-shell {
    padding: 12px;
  }

  .word-stage {
    padding-block: 10px;
  }

  .typing-hint {
    display: none;
  }

  .controls {
    gap: 5px;
    min-height: 0;
    padding: 6px;
  }

  .language-trigger,
  .text-button {
    min-height: 34px;
  }
}

@media (max-height: 720px) and (min-width: 641px) {
  .app {
    gap: 11px;
    padding-block: 12px;
  }

  .topbar {
    min-height: 60px;
  }

  .stats,
  .metric {
    min-height: 68px;
  }

  .typing-shell {
    min-height: 0;
  }

  .word-stage {
    padding-block: 22px;
  }

  .controls {
    min-height: 58px;
  }
}

@media (max-height: 720px) and (min-width: 901px) {
  .app.has-results .typing-shell {
    padding: 12px;
  }

  .result-hero {
    gap: 12px;
    padding: 22px;
  }

  .result-score strong {
    font-size: clamp(4rem, 8vw, 6.8rem);
  }

  .result-panel {
    gap: 6px;
    padding: 12px;
  }

  .result-highlights,
  .result-grid {
    gap: 6px;
  }

  .result-highlight {
    min-height: 70px;
    padding: 10px;
  }

  .result-highlight strong {
    margin-top: 7px;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
  }

  .result-item {
    padding: 7px 10px;
  }

  .result-item strong {
    margin-top: 4px;
    font-size: 1rem;
  }

  .result-actions {
    gap: 6px;
    margin-top: 0;
  }

  .result-button {
    min-height: 42px;
  }
}

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