[hidden] {
  display: none !important;
}

:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --bg-2: #12151c;
  --ink: #f4f1ea;
  --muted: #b7b1a6;
  --faint: #8d877c;
  --line: rgba(244, 241, 234, 0.1);
  --lime: #dff25a;
  --lime-ink: #17190c;
  --good: #3dce8a;
  --bad: #ff5c73;
  --pending: #8b93a0;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans JP", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(980px 420px at 8% -12%, rgba(223, 242, 90, 0.08), transparent 55%),
    radial-gradient(820px 380px at 100% 0%, rgba(61, 206, 138, 0.07), transparent 50%),
    var(--bg);
}

::selection {
  background: var(--lime);
  color: var(--lime-ink);
}

:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}

a {
  color: inherit;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--lime);
  color: var(--lime-ink);
  padding: 6px 10px;
  border-radius: 8px;
}

.skip:focus {
  top: 8px;
}

.site-header {
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 12, 16, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 2px 0 var(--lime);
  backdrop-filter: blur(16px);
}

.bar,
.first-screen,
.panel,
.site-footer {
  width: min(1120px, calc(100% - 48px));
  margin-left: auto;
  margin-right: auto;
}

.bar {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
  font-size: 15px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.site-nav a:hover {
  color: var(--ink);
}

.lang-menu {
  position: relative;
  margin-left: auto;
}

.lang-menu summary {
  list-style: none;
  cursor: pointer;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
}

.lang-menu summary::-webkit-details-marker {
  display: none;
}

.lang-menu summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-1px) rotate(45deg);
}

.lang-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 168px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #171b22;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.lang-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}

.lang-menu a:hover {
  background: rgba(255, 255, 255, 0.05);
}

.lang-menu a[aria-current="page"] {
  background: var(--lime);
  color: var(--lime-ink);
  font-weight: 650;
}

.first-screen {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px 0 18px;
  min-height: calc(100vh - 48px);
  min-height: calc(100svh - 48px);
}

.first-screen > * {
  min-width: 0;
}

h1,
.h1 {
  margin: 0;
  font-size: 32px;
  line-height: 36px;
  font-weight: 600;
  letter-spacing: -0.038em;
  white-space: nowrap;
}

.lede {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 22px;
}

.mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.control-label {
  color: var(--faint);
  font-size: 12px;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #161a22;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px/1 var(--sans);
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.seg button[aria-pressed="true"] {
  background: var(--lime);
  color: var(--lime-ink);
}

.seg button:hover {
  color: var(--ink);
}

.seg button[aria-pressed="true"]:hover {
  color: var(--lime-ink);
}

.restart {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 10px 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  font: 600 13px/1 var(--sans);
}

.restart:hover {
  border-color: rgba(223, 242, 90, 0.45);
}

.shortcut-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--faint);
  font-weight: 500;
}

kbd {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 4px 2px;
  background: #12151c;
}

.best-chip {
  margin: 0;
  color: var(--faint);
  font-size: 13px;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: rgba(18, 21, 28, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 14px 10px;
  min-width: 0;
}

.stat .value {
  font-family: var(--mono);
  font-size: 40px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.stat .value.wpm {
  color: var(--lime);
}

.stat .label {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arena {
  position: relative;
  height: 392px;
  padding: 18px 22px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(223, 242, 90, 0.08), transparent 28px),
    var(--bg-2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

.arena.is-done {
  height: auto;
  min-height: 0;
}

.track {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.words {
  position: relative;
  margin: 0;
  font-family: var(--mono);
  font-size: 26px;
  line-height: 44px;
  white-space: pre-wrap;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  transition: transform 140ms ease;
}

.token {
  display: inline-block;
  white-space: pre;
  vertical-align: top;
  line-height: inherit;
}

.char {
  color: var(--pending);
  white-space: pre;
}

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

.char.incorrect {
  color: var(--bad);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.12em;
}

.char.sp.incorrect {
  background: rgba(255, 92, 115, 0.2);
  border-radius: 3px;
}

.char.active {
  color: var(--ink);
}

.char.nl {
  font-size: 0.72em;
  opacity: 0.8;
}

.caret {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 32px;
  border-radius: 1px;
  background: var(--lime);
  box-shadow: 0 0 12px rgba(223, 242, 90, 0.75);
  pointer-events: none;
  z-index: 2;
  transition: transform 60ms linear;
}

.ime-capture {
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 0;
  resize: none;
  overflow: hidden;
  opacity: 0;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  font: inherit;
}

.noscript-note,
.boot-error,
.empty-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.results {
  display: grid;
  gap: 14px;
}

.results-head h2,
.panel h2,
.results h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

.results-head h2 {
  font-size: 22px;
}

.results-meta {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.metrics div {
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(8, 9, 12, 0.35);
  border: 1px solid var(--line);
}

.metrics dt {
  color: var(--faint);
  font-size: 12px;
}

.metrics dd {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 26px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.chart {
  width: 100%;
  height: 200px;
  display: block;
  border-radius: 12px;
  background: #0e1218;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 14px;
  height: 3px;
  border-radius: 99px;
  display: inline-block;
}

.swatch.net {
  background: var(--good);
}

.swatch.raw {
  background: var(--lime);
}

.swatch.err {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--bad);
}

.hot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hot-grid h3,
.results h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.hotkey {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.hk-name {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hk-bar {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: rgba(244, 241, 234, 0.08);
  overflow: hidden;
}

.hk-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--good), var(--lime));
}

.hot-grid section:last-child .hk-bar span {
  background: linear-gradient(90deg, #ff8b98, var(--bad));
}

.hk-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.history-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
}

.history-list li + li {
  margin-top: 4px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn {
  appearance: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
}

.btn-primary {
  border: 0;
  background: var(--lime);
  color: var(--lime-ink);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
}

.btn-quiet {
  border: 0;
  background: transparent;
  color: var(--faint);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding-inline: 8px;
  font-weight: 500;
}

.panel {
  margin-top: 8px;
  margin-bottom: 28px;
}

.panel h2 {
  font-size: 22px;
  margin-bottom: 10px;
}

.method-list,
.mode-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.method-list li,
.mode-list li,
.feature p,
.faq p {
  margin: 0;
  color: var(--muted);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.feature {
  padding: 14px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(18, 21, 28, 0.75);
}

.feature h3,
.mode-list h3,
.partner-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.mode-list li {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.faq details {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.faq summary {
  cursor: pointer;
  font-weight: 650;
}

.faq p {
  margin-top: 6px;
}

.disclosure {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(223, 242, 90, 0.28);
  background: rgba(223, 242, 90, 0.06);
  color: #e7e2d6;
  font-size: 14px;
}

.partner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.partner-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(18, 21, 28, 0.75);
}

.partner-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.partner-link {
  color: var(--lime);
  font-weight: 650;
}

.site-footer {
  height: 40px;
  display: flex;
  align-items: center;
  color: var(--faint);
  font-size: 12px;
  line-height: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--line);
}

.not-found {
  width: min(720px, calc(100% - 48px));
  margin: 48px auto 72px;
}

.not-found h1 {
  white-space: normal;
  font-size: 32px;
  line-height: 38px;
}

.not-found p {
  color: var(--muted);
}

.not-found a {
  color: var(--lime);
}

@media (max-width: 800px) {
  h1,
  .h1 {
    white-space: normal;
    font-size: 26px;
    line-height: 32px;
  }

  .lede {
    white-space: normal;
  }

  .site-nav {
    display: none;
  }

  .bar,
  .first-screen,
  .panel,
  .site-footer,
  .not-found {
    width: min(1120px, calc(100% - 28px));
  }

  .stat .value {
    font-size: 30px;
  }

  .words {
    font-size: 18px;
    line-height: 32px;
  }

  .arena {
    height: 220px;
    padding: 14px;
  }

  .restart {
    margin-left: 0;
  }

  .metrics,
  .feature-grid,
  .partner-grid,
  .hot-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .metrics,
  .feature-grid,
  .partner-grid,
  .hot-grid,
  .hud {
    grid-template-columns: 1fr;
  }
}

@media (pointer: coarse) {
  .ime-capture {
    width: 100%;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .words,
  .caret,
  .btn-primary {
    transition: none;
  }
}
