/* CPS Test — minimal, fast, mobile-first */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #388bfd66;
  --success: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
  --tap-min: 44px;
  --focus: 2px solid var(--accent);
  --focus-offset: 2px;
}

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

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
  border-radius: 2px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

.wrap {
  width: min(1100px, 100% - 2rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.logo {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-main a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.25rem;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
}

.nav-main a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.nav-main a:hover {
  color: var(--accent);
  text-decoration: none;
}

.hero {
  padding: 1.5rem 0 2rem;
  text-align: center;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 5vw, 2.75rem);
  letter-spacing: -0.02em;
}

.hero .sub {
  margin: 0 auto 1.5rem;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.05rem;
}

/* CPS tool */
.cps-app {
  width: min(100%, 860px);
  max-width: 860px;
  margin: 0 auto 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.cps-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.cps-toolbar-heading {
  width: 100%;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.duration-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  border: none;
  margin: 0;
  padding: 0;
}

.duration-group input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.duration-group label {
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9rem;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  user-select: none;
}

.duration-group label:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

.duration-group input:focus-visible + label {
  outline: var(--focus);
  outline-offset: 2px;
}

.duration-group input:checked + label {
  border-color: var(--accent);
  color: var(--accent);
  background: #388bfd22;
}

.cps-start-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.cps-start-mode label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}

.cps-start-mode input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.cps-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.cps-stat {
  padding: 0.65rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.cps-stat .val {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.cps-stat .lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.cps-target {
  position: relative;
  width: 100%;
  min-height: 340px;
  aspect-ratio: 1.45 / 1;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--bg) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, transform 0.08s ease;
  overflow: hidden; /* clip ripple */

  --ripple-x: 50%;
  --ripple-y: 50%;
}

@media (max-width: 800px) {
  .cps-target {
    min-height: 260px;
    aspect-ratio: auto;
  }
}

.cps-target:hover:not(:disabled) {
  border-color: var(--accent-dim);
}

.cps-target:focus-visible {
  outline: var(--focus);
  outline-offset: 4px;
}

.cps-target:active:not(:disabled) {
  transform: scale(0.992);
}

.cps-target.is-active {
  border-style: solid;
  border-color: var(--accent);
}

/* Click feedback: outward white "wave" ripple (clipped to the box). */
.cps-target::after {
  content: "";
  position: absolute;
  left: var(--ripple-x);
  top: var(--ripple-y);
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%) scale(0.05);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(255, 255, 255, 0.35) 30%,
    rgba(255, 255, 255, 0) 62%
  );
}

.cps-target.is-flash::after {
  animation: cps-ripple 0.45s ease-out;
}

@keyframes cps-ripple {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.05);
  }
  70% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(14);
  }
}

.cps-target:disabled {
  cursor: not-allowed;
  opacity: 0.85;
}

.cps-target-inner {
  pointer-events: none;
}

.cps-target-hint {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.cps-target-sub {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.cps-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.6rem 1.1rem;
  min-height: var(--tap-min);
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  border-color: var(--accent-dim);
  background: #30363d;
}

.btn:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1117;
}

.btn-primary:hover {
  filter: brightness(1.08);
  border-color: var(--accent);
}

.cps-result-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: center;
}

.cps-result-panel[hidden] {
  display: none !important;
}

.cps-cps-big {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 0 0 0.25rem;
  letter-spacing: -0.03em;
}

.cps-label-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.cps-label-average {
  background: #30363d;
  color: var(--muted);
}
.cps-label-good {
  background: #23863644;
  color: var(--success);
}
.cps-label-fast {
  background: #388bfd33;
  color: var(--accent);
}
.cps-label-pro {
  background: #f8514944;
  color: #ff7b72;
}

.cps-meter {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 0.75rem 0 0;
}

.cps-meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--success), var(--accent));
  width: 0%;
  transition: width 0.35s ease;
}

.cps-best-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

/* Content sections */
main > section {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
}

main > section:first-of-type {
  border-top: none;
}

.section-head {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

.prose {
  max-width: 65ch;
  color: var(--muted);
}

.prose p {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose strong {
  color: var(--text);
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 0.75rem 0 0.75rem 2.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.steps li:last-child {
  border-bottom: none;
}

.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  margin-top: 1rem;
}

.card {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--accent-dim);
  text-decoration: none;
}

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--text);
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--surface);
  padding: 0;
}

.faq-list summary {
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: var(--tap-min);
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  color: var(--muted);
  font-weight: 400;
}

.faq-list details[open] summary::after {
  content: "−";
}

.faq-list .faq-a {
  padding: 0 1rem 1rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 0;
  padding-top: 0.75rem;
}

.site-footer {
  margin-top: 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer .cols {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.site-footer h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer li {
  margin-bottom: 0.35rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-copy {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted);
}

.page-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
}

.page-lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  max-width: 55ch;
}

.breadcrumb {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 1rem 0 0;
}

.breadcrumb a {
  color: var(--muted);
}

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

.example-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.example-box strong {
  color: var(--text);
}

/* —— Additional skill tests —— */
.tool-app {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tool-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.tool-stat {
  padding: 0.5rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--muted);
}

.tool-stat strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.reaction-zone {
  min-height: 200px;
  width: 100%;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.reaction-zone:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
}

.reaction-zone.is-idle {
  background: var(--surface-2);
  color: var(--text);
}

.reaction-zone.is-wait {
  background: #f8514944;
  border-color: var(--danger);
  color: #ff7b72;
}

.reaction-zone.is-go {
  background: #23863655;
  border-color: var(--success);
  color: var(--success);
}

.reaction-zone.is-foul {
  background: #d2992233;
  border-color: var(--warn);
  color: var(--warn);
}

.reaction-zone:disabled {
  cursor: not-allowed;
  opacity: 0.85;
}

.aim-field {
  position: relative;
  width: 100%;
  min-height: min(420px, 70dvh);
  max-height: 520px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  touch-action: none;
  overflow: hidden;
}

.aim-target {
  position: absolute;
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 12px #388bfd66;
  padding: 0;
}

.aim-target:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.apm-zone {
  min-height: 220px;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.apm-zone.is-active {
  border-style: solid;
  border-color: var(--accent);
}

.apm-zone:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
}

.typing-display {
  font-size: 1.35rem;
  line-height: 1.7;
  letter-spacing: 0.02em;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  min-height: 5rem;
  word-break: break-word;
}

.typing-display .ok {
  color: var(--success);
}

.typing-display .bad {
  color: var(--danger);
  text-decoration: underline;
}

.typing-display .cur {
  background: #388bfd44;
  border-radius: 2px;
}

.typing-input {
  width: 100%;
  min-height: 3.5rem;
  padding: 0.75rem;
  font: inherit;
  font-size: 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
}

.typing-input:focus {
  outline: var(--focus);
  outline-offset: 2px;
  border-color: var(--accent);
}

.stopwatch-readout {
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 1rem 0;
  letter-spacing: -0.03em;
}

.rhythm-visual {
  width: 120px;
  height: 120px;
  margin: 1rem auto;
  border-radius: 50%;
  background: var(--surface-2);
  border: 3px solid var(--border);
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.rhythm-visual.is-pulse {
  transform: scale(1.08);
  box-shadow: 0 0 24px var(--accent-dim);
  border-color: var(--accent);
}

.rhythm-tap {
  min-height: 160px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  margin-top: 0.75rem;
}

.rhythm-tap.is-live {
  border-color: var(--accent);
}

.rhythm-tap:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
}

.tool-result-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
}

.tool-result-panel[hidden] {
  display: none !important;
}

.tool-big {
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 0.25rem 0;
}
