:root {
  --bg: #111111;
  --fg: #f2f2f2;
  --muted: #9a9a9a;
  --panel: #1d1d1d;
  --amber: #f59e0b;
  --green: #22c55e;
  --blue: #3b82f6;
  --red: #ef4444;
  --tint-getReady: #2b2006;
  --tint-exercise: #0b2916;
  --tint-rest: #0b1c36;
  --accent: var(--fg);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

main { height: 100%; }

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  transition: background-color 0.4s ease;
}

h1 { margin: 0; font-size: 2rem; font-weight: 700; }

/* Controls ----------------------------------------------------------------- */

.controls {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  min-height: 76px;
  border: 0;
  border-radius: 18px;
  background: #333;
  color: var(--fg);
  font: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.btn:active { filter: brightness(1.25); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn-go { background: var(--green); color: #06210f; }
.btn-quit { background: #5b1a1a; color: #ffdada; }

/* Start ------------------------------------------------------------------- */

.start-header { margin-bottom: 12px; }
.total { margin: 6px 0 0; font-size: 1.25rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.total strong { color: var(--fg); }

.exercise-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: ex;
}
.exercise-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid #262626;
  font-size: 1.25rem;
  counter-increment: ex;
}
.exercise-list li::before {
  content: counter(ex);
  min-width: 1.6em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.exercise-list li.rest {
  counter-increment: none;
  padding: 6px 4px;
  font-size: 1rem;
  color: var(--blue);
}
.exercise-list li.rest::before { content: ""; }
.exercise-list .name { flex: 1; }
.exercise-list .secs { color: var(--muted); font-variant-numeric: tabular-nums; }

.errors {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #3a1212;
  color: #ffd0d0;
  font-size: 1.05rem;
}
.errors p { margin: 0 0 6px; }
.errors ul { margin: 0; padding-left: 1.2em; }

.notes {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.95rem;
}
.notes li { padding: 2px 0; }

/* Running and paused ------------------------------------------------------ */

.running[data-phase="getReady"] { background: var(--tint-getReady); --accent: var(--amber); }
.running[data-phase="exercise"] { background: var(--tint-exercise); --accent: var(--green); }
.running[data-phase="rest"]     { background: var(--tint-rest);     --accent: var(--blue); }

.run-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: opacity 0.2s ease;
}

.run-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.2rem;
}
.phase-label { color: var(--accent); font-weight: 800; letter-spacing: 0.12em; }
.exercise-count { color: var(--muted); font-variant-numeric: tabular-nums; }

.main-line {
  margin: 28px 0 0;
  font-size: 2.3rem;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.running[data-phase="getReady"] .main-line,
.running[data-phase="rest"] .main-line { color: var(--accent); }

.countdown {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: min(46vw, 34vh);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.progress {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 6px;
}
.time-remaining {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.15rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.paused-banner { display: none; }
.running.paused .paused-banner {
  display: block;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-align: center;
}
.running.paused .run-body { opacity: 0.4; }

.running #btn-resume, .running #btn-quit { display: none; }
.running.paused #btn-pause { display: none; }
.running.paused #btn-resume, .running.paused #btn-quit { display: block; }
.running.paused .btn { font-size: 1.35rem; }
.running.paused #btn-resume { flex: 1.3; }

/* Finished ---------------------------------------------------------------- */

.finished-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 18px;
}
.finished h1 { font-size: 2.4rem; color: var(--green); }
.finished-time { margin: 0; font-size: 3.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.phrase { margin: 0; min-height: 3em; font-size: 1.5rem; line-height: 1.35; }
