:root {
  --bg: #080808; --dim: #646669; --ok: #D1D0C5; --bad: #CA4754;
  --accent: #E2B714; --fs: 24px; --line: #1a1a1a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--dim); }
body {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
               "DejaVu Sans Mono", monospace;
  font-size: 14px; min-height: 100vh; overflow-x: hidden;
}
.wrap { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; }

button, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 4px 8px; cursor: pointer; }
button:hover { color: var(--ok); }
button.on { color: var(--accent); }
button:focus-visible, select:focus-visible { outline: 1px solid var(--dim); }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 48px; }
.logo { color: var(--accent); font-size: 20px; font-weight: 700; }
.sub { margin-left: 10px; font-size: 12px; }

#settings {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px;
  border: 1px solid var(--line); padding: 14px; margin-bottom: 32px; font-size: 13px;
}
#settings label { display: flex; align-items: center; gap: 8px; }
select {
  background: #111; border: 1px solid #222; border-radius: 2px;
  color: var(--ok); padding: 2px 4px;
}
#swatches { display: flex; align-items: center; gap: 8px; }
.sw { width: 16px; height: 16px; padding: 0; border: 1px solid transparent; border-radius: 2px; }
.sw.on { border-color: var(--ok); }

.controls {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 4px 20px; margin-bottom: 40px; font-size: 13px;
}
.grp { display: flex; }

.stats {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 4px 22px; margin-bottom: 16px; font-size: 13px;
}
.stats b { color: var(--ok); font-weight: 400; }
.stats b.accent { color: var(--accent); }

#typing {
  position: relative; max-width: 820px; margin: 0 auto;
  --fsx: min(var(--fs), max(16px, 6vw));
}
#view { height: calc(var(--fsx) * 1.6 * 3); overflow: hidden; }
#words {
  position: relative; font-size: var(--fsx); line-height: 1.6;
  color: var(--dim); user-select: none; -webkit-user-select: none;
}
.word { display: inline-block; }
.ch { white-space: pre; }
.ch.ok { color: var(--ok); }
.ch.bad { color: var(--bad); }
.ch.bad.sp { background: rgba(202, 71, 84, .35); }
.ch.cur { position: relative; }
.ch.cur::before {
  content: ""; position: absolute; left: 0; top: .15em; bottom: .15em;
  width: 2px; background: var(--accent);
}
#focusMsg {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  color: var(--ok); pointer-events: none; z-index: 1;
}
#typing.blur #focusMsg { display: flex; }
#typing.blur #words { opacity: .25; }

/* Invisible textarea covering the text: receives physical and mobile keyboard input */
#input {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2;
  opacity: 0; border: 0; padding: 0; resize: none; background: transparent;
  font-size: 16px; /* 16px prevents zoom on iPhone */ caret-color: transparent; cursor: default;
}

#results { text-align: center; margin: 30px 0; }
.big { font-size: 64px; color: var(--accent); line-height: 1; }
.big small { font-size: 16px; color: var(--dim); }
.rgrid { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 32px; margin: 28px 0; }
.rgrid b, .pgrid b { display: block; margin-top: 4px; font-size: 22px; color: var(--ok); font-weight: 400; }

.keys { text-align: center; font-size: 12px; margin-top: 28px; opacity: .7; }

#progress { margin-top: 70px; border-top: 1px solid var(--line); padding-top: 20px; }
#progress h2 { font-size: 13px; font-weight: 400; margin: 0 0 16px; }
.pgrid { display: flex; flex-wrap: wrap; gap: 16px 40px; margin-bottom: 16px; }
#recent { list-style: none; padding: 0; margin: 0 0 16px; font-size: 13px; }
#recent li { padding: 3px 0; }
#recent li span { color: var(--ok); }
#btnReset { padding-left: 0; font-size: 12px; }

@media (max-width: 600px) {
  .wrap { padding: 16px 14px 40px; }
  header { margin-bottom: 28px; }
  .controls { gap: 4px 10px; margin-bottom: 28px; }
  .big { font-size: 48px; }
}
