:root {
  --bg: #0b0b0d;
  --panel: #0e0f12;
  --ink: #ffffff;
  --muted: #7d828a;
  --green: #12c96d;
  --green-light: #25e08a;
  --red: #ff4d4f;
  --stage: #101114;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
  background: #000;
}

body {
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
svg { display: block; }

.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.995);
  transition: opacity 0.32s ease, transform 0.32s ease, visibility 0.32s;
  pointer-events: none;
}
.screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  z-index: 2;
}

/* ---------- start screen ---------- */
.home-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.home-scroll::-webkit-scrollbar { display: none; }

.hero {
  position: relative;
  overflow: hidden;
  height: 44vh;
  max-height: 400px;
  min-height: 240px;
  background: var(--stage);
}
.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 45%;
  display: block;
  transform: scale(1.06);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 11, 13, 0) 30%, rgba(11, 11, 13, 0.35) 62%, var(--bg) 98%);
}

.home-body {
  position: relative;
  z-index: 2;
  margin-top: -34px;
  padding: 0 22px;
}
.home-body h1 {
  margin: 0 0 6px;
  font-size: 31px;
  line-height: 1.1;
  letter-spacing: -0.032em;
  font-weight: 700;
  color: #fff;
}
.home-sub {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: #8b8f97;
}

.stats {
  display: flex;
  margin: 20px 0 0;
}
.stat { flex: 1; }
.stat + .stat {
  border-left: 1px solid rgba(255, 255, 255, 0.09);
  padding-left: 15px;
  margin-left: 15px;
}
.stat b {
  display: block;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.stat span {
  display: block;
  margin-top: 2px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6c7077;
}

.move-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
}
.move-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13.5px;
  color: #e3e5e8;
}
.move-list li.m-head {
  padding: 18px 2px 5px;
  border-top: 0;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5f636a;
}
.m-index {
  width: 22px;
  font-size: 11px;
  color: #5a5e65;
  font-variant-numeric: tabular-nums;
}
.m-name { flex: 1; font-weight: 550; letter-spacing: -0.01em; }
.m-time {
  font-size: 12px;
  color: #767a81;
  font-variant-numeric: tabular-nums;
}

.home-cta {
  flex: none;
  display: flex;
  justify-content: center;
  padding: 14px 0 calc(24px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(11, 11, 13, 0), var(--bg) 46%);
}

.go-btn {
  width: 106px;
  height: 106px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--green-light), #0fbe6a);
  color: #032313;
  font-size: 25px;
  font-weight: 780;
  letter-spacing: 0.06em;
  box-shadow: 0 16px 38px rgba(16, 194, 109, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.14s ease, box-shadow 0.14s;
}
.go-btn:active {
  transform: scale(0.95);
  box-shadow: 0 10px 24px rgba(16, 194, 109, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.go-btn--small {
  width: 92px;
  height: 92px;
  font-size: 16px;
  letter-spacing: 0.08em;
}

/* ---------- workout screen ---------- */
.screen--player { background: #000; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--stage);
  margin-bottom: -22px;
}
.vid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  opacity: 0;
  transition: opacity 0.36s ease;
  background: var(--stage);
}
.vid.is-active { opacity: 1; }
.app.is-fit .vid { object-fit: contain; }

.stage::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: calc(var(--safe-top) + 6px);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0));
  z-index: 2;
  pointer-events: none;
}

.stage-overlay {
  position: absolute;
  left: 16px;
  bottom: 42px;
  display: flex;
  gap: 7px;
  z-index: 3;
}
.pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(12, 12, 14, 0.46);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}
.pill--green { background: rgba(11, 168, 92, 0.9); }

.panel {
  position: relative;
  z-index: 4;
  flex: none;
  background: var(--panel);
  border-radius: 26px 26px 0 0;
  padding: 14px 20px calc(16px + var(--safe-bottom));
  box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.42);
}

.overall-track {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.overall-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0fbe6a, #3ce094);
  transition: width 0.18s linear;
}
.overall-ticks { position: absolute; inset: 0; }
.overall-ticks i {
  position: absolute;
  top: 0;
  width: 1.5px;
  height: 4px;
  background: #0e0f12;
  transform: translateX(-0.75px);
}
.overall-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: #70757d;
  font-variant-numeric: tabular-nums;
}

.main-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 6px;
}
.counter { display: flex; align-items: baseline; }
.counter b {
  font-size: 34px;
  line-height: 1;
  font-weight: 680;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.counter span {
  margin-left: 5px;
  font-size: 14px;
  font-weight: 550;
  color: #6f747c;
  font-variant-numeric: tabular-nums;
}
.countdown {
  font-size: 34px;
  line-height: 1;
  font-weight: 660;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  transition: color 0.2s;
}
.countdown.is-low { color: #ffcf5c; }

.step-name {
  margin: 9px 0 2px;
  font-size: 19px;
  font-weight: 640;
  letter-spacing: -0.015em;
  color: #fff;
}
.step-note {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.42;
  color: #858a92;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 32px;
  max-height: 32px;
}

.step-bar {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  margin-top: 11px;
}
.step-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #ffffff;
  transition: width 0.18s linear;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 11vw, 44px);
  margin-top: 14px;
  min-height: 72px;
}
.controls--paused { display: none; }
.screen--player.is-paused .controls--playing { display: none; }
.screen--player.is-paused .controls--paused { display: flex; gap: 34px; }

.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  color: #fff;
  transition: transform 0.12s ease, background 0.15s;
}
.round-btn svg { width: 20px; height: 20px; fill: currentColor; }
.round-btn:active { transform: scale(0.93); background: rgba(255, 255, 255, 0.12); }

.play-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 0;
  background: #ffffff;
  color: #101114;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease;
}
.play-btn svg { width: 26px; height: 26px; fill: currentColor; }
.play-btn:active { transform: scale(0.94); }

.play-btn--green {
  background: linear-gradient(180deg, var(--green-light), #0fbe6a);
  color: #042213;
  box-shadow: 0 12px 28px rgba(16, 194, 109, 0.32);
}

.stop-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 0;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 28px rgba(255, 77, 79, 0.26);
  transition: transform 0.12s ease;
}
.stop-btn svg { width: 26px; height: 26px; fill: currentColor; }
.stop-btn:active { transform: scale(0.94); }

/* ---------- done ---------- */
.screen--done { justify-content: space-between; }
.done-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 30px;
}
.done-badge {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--green-light), var(--green));
  box-shadow: 0 16px 40px rgba(18, 201, 109, 0.3);
  margin-bottom: 26px;
}
.done-badge svg { width: 38px; height: 38px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.done-body h2 { margin: 0 0 8px; font-size: 25px; letter-spacing: -0.03em; color: #fff; }
.done-sub { margin: 0; font-size: 13.5px; color: #7d828a; }
.done-stats { display: flex; gap: 34px; margin-top: 34px; }
.done-stats div { text-align: center; }
.done-stats b {
  display: block;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #fff;
}
.done-stats span {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6c7077;
}
.done-cta {
  flex: none;
  display: flex;
  justify-content: center;
  padding: 10px 0 calc(40px + var(--safe-bottom));
}

/* ---------- 3 · 2 · 1 · GO ---------- */
.countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  background: rgba(6, 6, 8, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}
.countdown-overlay.is-on { opacity: 1; visibility: visible; }

.countdown-overlay__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 40px;
}
.countdown-overlay__label {
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.countdown-overlay__num {
  font-size: 132px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: -0.05em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.countdown-overlay__num.is-go {
  font-size: 104px;
  color: var(--green-light);
  letter-spacing: 0.02em;
}
.countdown-overlay__num.pop { animation: num-pop 0.42s cubic-bezier(0.2, 0.9, 0.2, 1); }
@keyframes num-pop {
  0% { transform: scale(0.72); opacity: 0; }
  55% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.countdown-overlay__next {
  margin-top: 18px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.62);
  letter-spacing: 0.01em;
}

/* ---------- confirm ---------- */
.confirm-backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 26px;
  background: rgba(0, 0, 0, 0.66);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0.24s;
}
.confirm-backdrop.is-open { opacity: 1; visibility: visible; }
.confirm {
  width: 100%;
  max-width: 320px;
  background: #17181c;
  border-radius: 22px;
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  transform: scale(0.94);
  transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.confirm-backdrop.is-open .confirm { transform: none; }
.confirm h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -0.02em; color: #fff; }
.confirm p { margin: 0 0 18px; font-size: 12.5px; color: #8b8f97; }
.confirm__actions { display: flex; gap: 8px; }

.btn-quiet, .btn-danger {
  flex: 1;
  height: 46px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
}
.btn-danger {
  background: rgba(255, 77, 79, 0.14);
  border-color: rgba(255, 77, 79, 0.3);
  color: #ff6163;
}

/* ---------- small phones ---------- */
@media (max-height: 700px) {
  .hero { height: 38vh; min-height: 210px; }
  .home-body h1 { font-size: 27px; }
  .stats { margin-top: 16px; }
  .move-list { margin-top: 14px; }
  .move-list li { padding: 9px 2px; }
  .go-btn { width: 92px; height: 92px; font-size: 22px; }
  .counter b, .countdown { font-size: 30px; }
  .step-name { font-size: 17.5px; }
  .step-note { min-height: 30px; max-height: 30px; }
  .play-btn, .stop-btn { width: 64px; height: 64px; }
  .play-btn svg, .stop-btn svg { width: 23px; height: 23px; }
  .controls { min-height: 64px; margin-top: 10px; }
}

/* ---------- desktop preview frame ---------- */
@media (min-width: 560px) and (min-height: 640px) {
  body { display: flex; align-items: center; justify-content: center; background: #050506; }
  .app {
    height: min(920px, 94vh);
    width: 420px;
    border-radius: 42px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.07);
  }
}
