/* --------------------------------------------------------------------------
   BASIC RESET
   A tiny reset makes spacing and sizing more predictable across browsers.
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

:root {
  --bg: #000;
  --surface: #000;
  --text: #cfc6c6;
  --muted: #747474;
  --line: #deded9;
  --soft: #efefeb;
  --accent: #171717;
  --correct: #1f7a4f;
  --incorrect: #bf3b31;
  --radius: 0px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   PAGE LAYOUT
   -------------------------------------------------------------------------- */
.app-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 7vw, 2rem);
  line-height: 0.9;
  letter-spacing: -0.065em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.header-copy,
.section-heading p {
  color: var(--muted);
}

.header-copy {
  max-width: 280px;
  margin-bottom: 3px;
  text-align: right;
}

.settings-card,
.typing-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   SETTINGS
   -------------------------------------------------------------------------- */
.settings-card {
  padding: 24px;
  margin-bottom: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-heading p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 24px;
}

.setting-group {
  min-width: 0;
}

.setting-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-button {
  border: 1px solid var(--line);
  border-radius: 0px;
  padding: 9px 14px;
  background: transparent;
  color: var(--text);
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.option-button:hover {
  border-color: #b8b8b2;
}

.option-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.start-button {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 0px;
  padding: 13px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.start-button:hover {
  opacity: 0.9;
}

/* --------------------------------------------------------------------------
   TYPING AREA
   -------------------------------------------------------------------------- */
.typing-card {
  padding: 24px;
}

.test-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 30px;
}

.test-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.dot {
  color: #b6b6b1;
}

.prompt {
  min-height: 145px;
  margin-bottom: 22px;
  color: #9c9c96;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.65;
  letter-spacing: -0.03em;
  white-space: pre-wrap;
}

/* JavaScript applies these classes to individual prompt characters. */
.prompt-char.correct {
  color: var(--correct);
}

.prompt-char.incorrect {
  color: var(--incorrect);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.prompt-char.current {
  color: var(--text);
  border-left: 2px solid var(--text);
}

#typing-input {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 0px;
  padding: 14px;
  background: #fbfbf9;
  color: var(--text);
  outline: none;
}

#typing-input:focus {
  border-color: #a8a8a2;
}

#typing-input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

/* --------------------------------------------------------------------------
   RESULT MODAL
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 20, 20, 0.38);
}

.result-modal {
  width: min(480px, 100%);
  border-radius: var(--radius);
  padding: 26px;
  background: var(--surface);
}

.result-header {
  margin-bottom: 24px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.result-item {
  border: 2px solid var(--line);
  border-radius: 0px;
  padding: 18px;
}

.result-value,
.result-label {
  display: block;
}

.result-value {
  margin-bottom: 4px;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.result-label {
  color: var(--muted);
  font-size: 0.8rem;
}

/* Utility class used by JavaScript to hide things. */
.is-hidden {
  display: none !important;
}

/* Screen-reader-only label: accessible, but not visually shown. */
.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;
}

/* --------------------------------------------------------------------------
   SMALL SCREEN ADJUSTMENTS
   -------------------------------------------------------------------------- */
@media (max-width: 700px) {
  .app-shell {
    padding-top: 32px;
  }

  .site-header,
  .section-heading,
  .test-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-copy {
    text-align: left;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}
