:root {
  --bg: #f5efe2;
  --surface: #ece1c8;
  --surface-2: #e1d2ac;
  --surface-3: #d3bf8e;
  --text: #1f3a28;
  --text-muted: #3c5a44;
  --text-faint: #5e7a68;
  --accent: #2f6b41;
  --accent-strong: #3f8752;
  --accent-soft: #d9e8db;
  --good: #3f8752;
  --focus: #2f6b41;
  --danger: #b3413c;
  --footer-text: #7a7059;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- shell / nav ---------- */

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 1.5rem 1rem 3rem;
}

.nav {
  display: flex;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 999px;
  padding: 0.3rem;
  margin-bottom: 1.75rem;
}

.nav button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav button.active {
  background: var(--accent);
  color: var(--bg);
}

.view { display: none; width: min(94vw, 34rem); }
.view.active { display: flex; flex-direction: column; align-items: center; }

/* ---------- timer view ---------- */

.rig {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 3.5vh, 1.75rem);
}

.challenge-line {
  font-size: clamp(0.95rem, 2.6vw, 1.1rem);
  font-weight: 700;
  color: var(--text);
  text-align: center;
  text-wrap: balance;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.eyebrow .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.eyebrow .dot.done { background: var(--good); }

.round-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--text-muted);
}

.round-line .current {
  font-size: clamp(1.7rem, 5.5vw, 2.6rem);
  font-weight: 600;
  color: var(--text);
}


.round-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.round-label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
}

.clock {
  font-size: clamp(4.6rem, 20vw, 8.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  transition: color 0.2s ease;
}

.clock.tick { animation: pulse 0.32s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .clock.tick { animation: none; }
}

@keyframes pulse {
  0% { color: var(--accent); transform: scale(1.04); }
  100% { color: var(--text); transform: scale(1); }
}

.bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: inherit;
  transform-origin: left;
}

.session-line {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.session-line strong { color: var(--text); font-weight: 600; }

/* ---------- reps panel ---------- */

.reps-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 1rem;
  padding: 1.1rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.reps-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.reps-panel-head .label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.reps-panel-head .hint {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.reps-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stepper-full { grid-column: 1 / -1; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: 0.75rem;
  padding: 0.5rem 0.6rem;
}

.stepper .exercise {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 0.3rem;
}

.stepper .exercise-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stepper .exercise-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
}

.stepper-btns { display: flex; gap: 0.3rem; }

.stepper button {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.55rem;
  border: 1px solid var(--surface-3);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
}

.stepper button:hover { border-color: var(--accent); color: var(--accent-strong); }
.stepper button:active { background: var(--surface-3); }

.totals-line {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.totals-line strong { color: var(--text); }

/* ---------- controls ---------- */

.controls { display: flex; gap: 0.6rem; width: 100%; }

button { font-family: inherit; }

.btn {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 0.7rem;
  padding: 0.9rem 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { flex: 1.3; background: var(--accent); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }

.btn-secondary { flex: 1; background: transparent; color: var(--text-muted); border-color: var(--surface-2); }
.btn-secondary:hover:not(:disabled) { color: var(--text); border-color: var(--text-faint); }

.btn-end { flex: 1; background: transparent; color: var(--danger); border-color: var(--surface-2); }
.btn-end:hover:not(:disabled) { border-color: var(--danger); }

.sound-toggle {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  width: 2.3rem;
  height: 2.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1rem;
  cursor: pointer;
}

.sound-toggle:hover { color: var(--text); }

.hint-line { font-size: 0.7rem; color: var(--text-faint); }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 7, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 50;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: min(92vw, 26rem);
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 1.1rem;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.modal h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  text-wrap: balance;
}

.modal h2.win { color: var(--accent-strong); }

.modal p { margin: 0; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }

.modal-stats {
  display: flex;
  gap: 0.75rem;
}

.modal-stat {
  flex: 1;
  background: var(--surface-2);
  border-radius: 0.75rem;
  padding: 0.8rem;
  text-align: center;
}

.modal-stat .n { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.modal-stat .g { font-size: 0.68rem; color: var(--text-faint); margin-top: 0.15rem; }

.modal-actions { display: flex; gap: 0.6rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field input {
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: 0.6rem;
  padding: 0.75rem 0.85rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.field input:focus { outline: none; border-color: var(--accent); }

.divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-faint);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--surface-2);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  background: #fff;
  color: #1a0f09;
  border-radius: 0.7rem;
  padding: 0.85rem;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
}

.btn-google:hover { background: #f1f1f1; }

.error-line { color: var(--danger); font-size: 0.8rem; display: none; }
.error-line.show { display: block; }

/* ---------- hall of fame / leaderboard ---------- */

.hall-head {
  text-align: center;
  margin-bottom: 0.5rem;
}

.hall-head h1 {
  font-size: 1.5rem;
  margin: 0 0 0.35rem;
  text-wrap: balance;
}

.hall-head p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }

.hall-section {
  width: 100%;
  margin-top: 1.75rem;
}

.hall-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hall-section-title.wof { color: var(--accent); }

.hall-row {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 0.7rem;
  margin-bottom: 0.5rem;
}

.hall-row .rank {
  font-weight: 700;
  color: var(--text-faint);
  font-size: 0.95rem;
}

.hall-row.wof .rank { color: var(--accent); }

.hall-row .handle {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hall-row .handle:hover { color: var(--accent-strong); }

.hall-row .stat {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  min-width: 3.2rem;
}

.hall-row .stat .v { color: var(--text); font-weight: 600; }

.hall-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  padding: 1.25rem 0.5rem;
}

/* ---------- footer ---------- */

.site-footer {
  position: fixed;
  right: 0.9rem;
  bottom: 0.6rem;
  max-width: calc(100vw - 1.8rem);
  font-size: 0.66rem;
  line-height: 1.4;
  color: var(--footer-text);
  text-align: right;
  z-index: 10;
  pointer-events: none;
}

.site-footer a {
  color: var(--footer-text);
  text-decoration: underline;
  text-underline-offset: 0.15rem;
  pointer-events: auto;
}

.site-footer a:hover { color: var(--text); }

.hidden { display: none !important; }
