:root {
  --bg: #0f1216;
  --card: #181d24;
  --text: #e8ecf1;
  --muted: #97a1af;
  --accent: #4fd1c5;
  --accent-strong: #2bb3a8;
  --border: #262d37;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem 1rem 3rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.subheading {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.display {
  margin: 0.5rem 0 1.25rem;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: clamp(2.5rem, 12vw, 4rem);
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--accent);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  flex: 1 1 5rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #212832;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent-strong);
}

button:active {
  transform: translateY(1px);
}

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

button:disabled:active {
  transform: none;
}

#stopwatch-start,
#countdown-start {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #06231f;
  font-weight: 600;
}

.setup {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
}

/* On a narrow screen the four columns squeeze the number fields to nothing,
   so each label moves next to its own field on its own row. */
@media (max-width: 26rem) {
  .setup {
    grid-template-columns: auto 1fr;
  }
}

.setup label {
  color: var(--muted);
  font-size: 0.9rem;
}

.setup input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #212832;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.setup input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.laps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.laps li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: #212832;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
}

.lap-number {
  color: var(--muted);
}

.lap-split {
  color: var(--text);
  font-weight: 600;
}

.lap-total {
  color: var(--muted);
}

/* Column names for the lap table, so the two times are not just numbers. */
.lap-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  padding: 0 0.6rem 0.3rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* The author rule above outranks the browser's [hidden] rule, so the
   header needs the hidden case spelled out. */
.lap-head[hidden] {
  display: none;
}

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

.message {
  min-height: 1.4rem;
  margin: 0.9rem 0 0;
  color: var(--accent);
  font-size: 0.95rem;
}
