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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.45);
  --accent: #ff6b35;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  overflow: hidden;
}

.back-link {
  position: fixed;
  top: 1.2rem;
  left: 1.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
  z-index: 10;
}

.back-link:hover {
  color: var(--text);
}

#install-btn {
  position: fixed;
  top: 1.2rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
  z-index: 10;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#install-btn:hover {
  color: var(--text);
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: 4.5rem 1.5rem 2rem;
  overflow-y: auto;
  overflow-x: hidden;
}

html, body {
  overflow: unset;
}

#display {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(3.5rem, 18vw, 7rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
  margin: auto 0;
  padding: 2rem 0 1.5rem;
  transition: color 0.15s ease;
}

#display.running {
  color: var(--accent);
}

#controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

#controls button {
  appearance: none;
  border: 1.5px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.65rem 1.4rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

#controls button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

#controls button:disabled {
  opacity: 0.3;
  cursor: default;
}

#btn-start.active {
  border-color: var(--accent);
  color: var(--accent);
}

#lap-list {
  width: 100%;
  max-width: 480px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#lap-list li {
  display: grid;
  grid-template-columns: 2rem 1fr 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

#lap-list li:first-child {
  border-top: 1px solid var(--border);
}

#lap-list li .lap-num {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

#lap-list li .lap-split {
  font-family: 'Courier New', Courier, monospace;
  font-weight: 600;
  color: var(--text);
}

#lap-list li .lap-total {
  font-family: 'Courier New', Courier, monospace;
  color: var(--muted);
  text-align: right;
}
