:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #14161a;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1b6ef3;
  --accent-text: #ffffff;
  --danger: #d93a3a;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 8px 24px rgba(16, 20, 28, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --panel: #161b22;
    --text: #e8ecf1;
    --muted: #9aa4b2;
    --line: #272e38;
    --accent: #4c8dff;
    --accent-text: #08111f;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 16px;
  -webkit-text-size-adjust: 100%;
}

.app {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  text-align: center;
}

.title {
  margin: 0 0 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  margin-bottom: 24px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.main-time {
  font-size: clamp(44px, 15vw, 60px);
  font-weight: 300;
  letter-spacing: -.02em;
  line-height: 1;
}

.ms-time {
  font-size: clamp(22px, 7vw, 28px);
  font-weight: 300;
  color: var(--muted);
  line-height: 1;
}

.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
}

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

.btn:hover:not(:disabled) { opacity: .85; }
.btn:active:not(:disabled) { transform: scale(.98); }

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

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

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

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

.hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
}

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

.laps-wrap:not(:empty) { margin-top: 4px; }

.laps {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 190px;
  overflow-y: auto;
  text-align: left;
}

.laps:not(:empty) {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.laps li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.laps li .no { color: var(--muted); font-size: 13px; }
.laps li .split { color: var(--muted); font-size: 13px; margin-left: auto; }
.laps li .total { font-weight: 600; min-width: 92px; text-align: right; }

.footer {
  margin-top: 18px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  max-width: 420px;
}

.footer p { margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
