:root {
  --bg: #0f172a;
  --bg-run: #06281d;
  --card: rgba(255, 255, 255, .06);
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #16a34a;
  --green-dark: #15803d;
  --red: #dc2626;
  --red-dark: #b91c1c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background .4s ease;
  overscroll-behavior: none;
}
body.running { background: var(--bg-run); }

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}
.hidden { display: none !important; }

.app-head {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.conn { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; }
.conn.off { background: #f59e0b; }

.clock {
  font-size: clamp(52px, 17vw, 84px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1;
}
.started { color: var(--muted); font-size: 15px; min-height: 20px; }

.big {
  width: min(76vw, 300px);
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: .06em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .12s ease, background .25s ease, box-shadow .25s ease;
}
.big .icon { font-size: 44px; line-height: 1; }
.big:active { transform: scale(.96); }
.big.start { background: var(--green); box-shadow: 0 0 0 12px rgba(22, 163, 74, .16), 0 18px 40px rgba(0, 0, 0, .45); }
.big.start:active { background: var(--green-dark); }
.big.stop { background: var(--red); box-shadow: 0 0 0 12px rgba(220, 38, 38, .16), 0 18px 40px rgba(0, 0, 0, .45); }
.big.stop:active { background: var(--red-dark); }

.totals {
  display: flex;
  gap: 10px;
  width: min(100%, 420px);
}
.totals > div {
  flex: 1;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.totals .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.totals .value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.queued { color: #fbbf24; font-size: 14px; margin: 0; }
.hint { min-height: 20px; margin: 0; }
.link {
  background: none; border: none; color: var(--muted);
  text-decoration: underline; font-size: 14px; cursor: pointer;
}

h1 { font-size: 26px; margin: 0; }
.lead { color: var(--muted); margin: 0; max-width: 320px; }
.error { color: #fca5a5; }

#pair-code {
  width: min(90vw, 300px);
  padding: 16px;
  font-size: 26px;
  text-align: center;
  letter-spacing: .18em;
  text-transform: uppercase;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
}
#screen-pair .big { aspect-ratio: auto; width: min(90vw, 300px); border-radius: 14px; padding: 18px; font-size: 20px; background: var(--green); }

.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .15);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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