:root {
  --bg: #0b0e14;
  --panel: #11151f;
  --panel-border: #1e2532;
  --text: #e6e9ef;
  --muted: #6b7487;
  --ghost: #333c4e;      /* untyped chars */
  --correct: #e6e9ef;    /* typed-correct chars */
  --incorrect: #ff5c6c;  /* typed-wrong chars */
  --accent: #5eead4;
  --accent-dim: #2dd4bf33;
  --cursor: #5eead4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.app__header { text-align: center; margin-bottom: 1.5rem; }
.app__title {
  font-size: 2rem;
  letter-spacing: 0.06em;
  margin: 0 0 0.25rem;
}
.app__subtitle { color: var(--muted); margin: 0; }

/* Controls */
.controls {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.controls__label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.controls__input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  resize: vertical;
  font-family: inherit;
}
.controls__input:focus { outline: none; border-color: var(--accent); }
.controls__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.45rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #ffffff10; border-color: #ffffff30; }
.btn--primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.btn--primary:hover { background: #5eead422; border-color: var(--accent); }
.controls__difficulty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted);
}
.controls__difficulty select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font: inherit;
}

/* Stats */
.stats {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.stat { text-align: center; min-width: 70px; }
.stat__value {
  display: block;
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}
.stat__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* Passage */
.passage-wrap {
  position: relative;
  cursor: text;
}
.passage {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.45rem;
  line-height: 2;
  letter-spacing: 0.02em;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  min-height: 12rem;
  word-break: break-word;
  user-select: none;
}
.passage__char {
  color: var(--ghost);
  transition: color 0.1s;
}
.passage__char--correct { color: var(--correct); }
.passage__char--incorrect { color: var(--incorrect); }
.passage__char--cursor {
  position: relative;
}
.passage__char--cursor::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 0.15em;
  bottom: 0.15em;
  width: 2px;
  background: var(--cursor);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}
.hint--hidden { visibility: hidden; }

/* Footer / status */
.app__footer { margin-top: 1.25rem; text-align: center; }
.status { color: var(--muted); font-size: 0.9rem; }

/* Results modal */
.results {
  position: fixed;
  inset: 0;
  background: #000000aa;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.results[hidden] { display: none; }
.results__card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 420px;
  width: calc(100% - 2rem);
}
.results__card h2 { margin: 0 0 1.25rem; }
.results__grid {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .passage { font-size: 1.1rem; }
  .controls__difficulty { margin-left: 0; }
}
