:root {
  --bg: #0f0f23;
  --fg: #f8fafc;
  --muted: #27273b;
  --muted-fg: #c7c9d9;
  --border: #312e81;
  --primary: #1e1b4b;
  --accent: #22c55e;
  --accent-ink: #052e16;
  --danger: #fca5a5;
  --ok: #86efac;
  --white-key: #f8fafc;
  --black-key: #18181b;
  --space: 1rem;
  --font: "Poppins", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --display: "Righteous", "Arial Black", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; }

.top, .hero, .drill, .how, .foot {
  width: min(880px, calc(100% - 2rem));
  margin-inline: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--display);
  letter-spacing: 0.02em;
  text-decoration: none;
  font-size: 1.25rem;
}

.mark { width: 1.75rem; height: 1.75rem; color: var(--accent); }

.nav { display: flex; gap: 1rem; }

.nav a {
  color: var(--muted-fg);
  text-decoration: none;
  padding: 0.4rem 0.2rem;
}

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

.hero { padding: 1.5rem 0 0.5rem; }

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.15; }

h1 { margin: 0 0 0.75rem; font-size: clamp(2rem, 5vw, 3.25rem); }

.lede { margin: 0; max-width: 38rem; color: var(--muted-fg); }

.drill {
  margin-top: 1.75rem;
  padding: 1.25rem;
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: 1rem;
}

.drill-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.drill-head h2 { margin: 0; font-size: 1.35rem; }

.score { margin: 0; color: var(--muted-fg); }

.dot {
  display: inline-block;
  width: 0.3rem;
  height: 0.3rem;
  margin: 0 0.45rem;
  border-radius: 50%;
  background: var(--border);
  vertical-align: middle;
}

.keys {
  display: flex;
  height: 7.5rem;
  margin: 1.25rem 0;
  position: relative;
}

.key {
  position: relative;
  border: 0;
  border-radius: 0 0 0.35rem 0.35rem;
}

.key.white {
  flex: 1;
  background: var(--white-key);
  color: #18181b;
  z-index: 1;
}

.key.black {
  width: 1.4rem;
  height: 62%;
  margin: 0 -0.7rem;
  background: var(--black-key);
  z-index: 2;
  border-radius: 0 0 0.25rem 0.25rem;
}

.key.on.white { background: var(--accent); }
.key.on.black { background: #16a34a; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

button, .switch {
  font: inherit;
}

button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}

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

.play {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.play svg { width: 1.1rem; height: 1.1rem; }

.play:hover { background: #4ade80; }

.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}

.ghost:hover:not(:disabled) { border-color: var(--fg); }

button:disabled { opacity: 0.45; cursor: not-allowed; }

.status { min-height: 1.5rem; margin: 1rem 0 0.75rem; color: var(--muted-fg); }

.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.6rem;
}

.choices button {
  background: var(--muted);
  color: var(--fg);
  border-color: transparent;
  text-align: left;
}

.choices button small {
  display: block;
  color: var(--muted-fg);
  font-size: 0.75rem;
}

.choices button:hover:not(:disabled) { border-color: var(--accent); }

.choices button.correct { background: #14532d; color: var(--ok); }
.choices button.wrong { background: #450a0a; color: var(--danger); }

.range { margin-top: 1rem; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  cursor: pointer;
  color: var(--muted-fg);
}

.how { padding: 2.5rem 0 1rem; }

.how h2 { margin: 0 0 1rem; }

.how ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .how ol { grid-template-columns: repeat(3, 1fr); }
}

.how li {
  margin: 0;
  padding: 1rem;
  background: var(--muted);
  border-radius: 0.8rem;
}

.how strong { display: block; margin-bottom: 0.25rem; font-size: 1.05rem; }
.how span { color: var(--muted-fg); }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0 2.5rem;
  color: var(--muted-fg);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button { transition: none; }
}
