:root {
  --bg: #eef2f5;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #64748b;
  --line: #e2e8f0;

  --accent: #0d9488;        /* calm teal */
  --accent-press: #0f766e;
  --accent-glow: rgba(13, 148, 136, 0.35);

  --bad: #dc2626;
  --idle: #64748b;

  --radius: 22px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(120% 80% at 50% -10%, #ffffff 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Block accidental selection / callouts during rapid tapping */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.app {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 22px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* ---------- Header ---------- */
.head { text-align: center; margin-top: 6px; }
.title {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}
.subtitle {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.subtitle em { font-style: normal; color: var(--accent); font-weight: 600; }

/* ---------- Readout ---------- */
.readout {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 132px;
  justify-content: center;
}
.rr {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1;
}
.rr-number {
  font-size: 5.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.rr-unit { color: var(--ink-soft); font-size: 1rem; font-weight: 500; }
.rr-unit .slash { opacity: 0.5; margin: 0 1px; }
.rr-meta {
  color: var(--ink-soft);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--idle);
}
.chip::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.chip--idle    { color: var(--idle);  background: #f1f5f9; }
.chip--counting{ color: var(--accent);background: #e6f5f3; }
.chip--bad     { color: var(--bad);   background: #fdecec; }

/* ---------- Big tap button ---------- */
.tap {
  position: relative;
  width: min(74vw, 300px);
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 16px 40px var(--accent-glow), inset 0 -6px 16px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* critical for touch: no scroll/zoom hijack, no tap highlight */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background 0.12s ease, box-shadow 0.12s ease;
  margin: 4px 0;
}
.tap:focus-visible { outline: 4px solid var(--accent-glow); outline-offset: 4px; }

.tap.is-holding {
  background: var(--accent-press);
  transform: scale(0.965);
  box-shadow: 0 8px 22px var(--accent-glow), inset 0 -4px 14px rgba(0,0,0,0.18);
}

/* Expanding ring pulse on each press */
.tap-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.tap.is-holding .tap-ring { animation: pulse 0.7s ease-out; }
@keyframes pulse {
  0%   { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0;    transform: scale(1.35); }
}

.tap-label {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tap-sub {
  font-size: 0.92rem;
  font-weight: 500;
  opacity: 0.9;
  max-width: 80%;
  text-align: center;
  line-height: 1.3;
}

/* ---------- Secondary controls ---------- */
.controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}
.btn {
  flex: 1;
  padding: 13px 16px;
  border-radius: 14px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  transition: opacity 0.12s ease, background 0.12s ease, transform 0.06s ease;
}
.btn:active { transform: scale(0.97); }
.btn--ghost { color: var(--ink-soft); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- Details ---------- */
.details {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 18px;
  box-shadow: var(--shadow);
}
.details summary {
  cursor: pointer;
  padding: 12px 0;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
  list-style: none;
}
.details summary::-webkit-details-marker { display: none; }
.details summary::after { content: " ›"; }
.details[open] summary::after { content: " ⌄"; }

.stats {
  margin: 0 0 6px;
  display: grid;
  gap: 2px;
}
.stats div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.stats dt { color: var(--ink-soft); margin: 0; }
.stats dd {
  margin: 0 0 0 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-align: right;
}

.method {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* ---------- Footer ---------- */
.foot {
  margin-top: auto;
  text-align: center;
  color: var(--ink-soft);
}
.privacy { font-size: 0.82rem; margin: 0 0 4px; }
.disclaimer { font-size: 0.76rem; margin: 0; }

/* Tighten vertical rhythm on short screens */
@media (max-height: 720px) {
  .rr-number { font-size: 4.2rem; }
  .tap { width: min(58vw, 230px); }
  .readout { min-height: 108px; }
}
