:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --line: #262d38;
  --text: #e6edf3;
  --muted: #8b96a5;
  --accent: #3fb950;
  --accent-hover: #4ac95c;
  --danger: #f0603a;
  --best: #3fb950;
  --worst: #f0603a;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa;
    --bg-elev: #ffffff;
    --line: #e2e7ee;
    --text: #1a1f26;
    --muted: #6b7684;
    --accent: #1f9c3a;
    --accent-hover: #178030;
    --danger: #d94a24;
    --best: #1f9c3a;
    --worst: #d94a24;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  display: flex;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--muted);
  text-align: center;
  text-transform: none;
}

/* ---- 表示 ---- */
.display {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
  transition: border-color .2s ease;
}

.display.running { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.d-main {
  font-family: "Consolas", "SF Mono", ui-monospace, monospace;
  font-size: clamp(48px, 17vw, 76px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.02em;
}

.d-sub {
  font-family: "Consolas", "SF Mono", ui-monospace, monospace;
  font-size: clamp(24px, 8.5vw, 38px);
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
}

/* ---- ボタン ---- */
.controls {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 10px;
}

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease, transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

.btn-main {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 17px;
}
.btn-main:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-main.stop {
  background: var(--danger);
  border-color: var(--danger);
}
.btn-main.stop:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 85%, #fff);
  border-color: color-mix(in srgb, var(--danger) 85%, #fff);
}

/* ---- ラップ ---- */
.laps {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.laps-head,
.laps-list li {
  display: grid;
  grid-template-columns: 3.5rem 1fr 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 11px 16px;
}

.laps-head {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.laps-head span:not(:first-child),
.laps-list li span:not(:first-child) { text-align: right; }

.laps-list {
  list-style: none;
  max-height: 45vh;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
  font-family: "Consolas", "SF Mono", ui-monospace, monospace;
  font-size: 14px;
}

.laps-list li + li { border-top: 1px solid var(--line); }
.laps-list li .no { color: var(--muted); font-size: 12px; }
.laps-list li .total { color: var(--muted); }
.laps-list li.best .split { color: var(--best); font-weight: 700; }
.laps-list li.worst .split { color: var(--worst); font-weight: 700; }

/* ---- ヒント ---- */
.hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

kbd {
  font-family: inherit;
  font-size: 11px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
}

@media (hover: none) and (pointer: coarse) {
  .hint { display: none; }
}
