:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #262c36;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3fb950;
  --accent-hover: #4ac25b;
  --danger: #f85149;
  --danger-hover: #ff6259;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #656d76;
    --accent: #1a7f37;
    --accent-hover: #1c8139;
    --danger: #cf222e;
    --danger-hover: #d5343f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Meiryo", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.title {
  margin: 0 0 24px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--muted);
}

/* --- 時間表示 --- */

.display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding: 28px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  line-height: 1;
}

.time {
  font-size: clamp(3rem, 17vw, 4.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.ms {
  font-size: clamp(1.5rem, 8vw, 2.25rem);
  font-weight: 500;
  color: var(--muted);
}

/* --- ボタン --- */

.controls {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 15px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) { border-color: var(--muted); }

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  flex: 1.4;
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: transparent;
}

.btn-primary.running {
  background: var(--danger);
}

.btn-primary.running:hover:not(:disabled) {
  background: var(--danger-hover);
}

/* --- ヒント --- */

.hint {
  margin: 16px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

/* --- ラップ --- */

.laps {
  margin-top: 20px;
  max-height: 40vh;
  overflow-y: auto;
}

.lap-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lap-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.lap-item:first-child { border-top: 1px solid var(--border); }

.lap-no {
  color: var(--muted);
  font-size: 0.8rem;
}

.lap-split {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.lap-total { font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
