* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --p1: #7c3aed; --p2: #ec4899; --p3: #f59e0b;
  --blue: #06b6d4; --green: #22c55e;
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Heebo', 'Rubik', system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #1e1b4b 0%, #4c1d95 45%, #831843 100%);
  color: #fff;
  user-select: none;
  touch-action: manipulation;
}
#app { height: 100%; position: relative; }

.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column; align-items: center;
  padding: 24px 20px; overflow-y: auto;
}
.screen.active { display: flex; animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ===== HOME ===== */
.stars {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff, transparent),
    radial-gradient(2px 2px at 80% 20%, #fde68a, transparent),
    radial-gradient(1px 1px at 50% 60%, #fff, transparent),
    radial-gradient(2px 2px at 30% 80%, #f9a8d4, transparent),
    radial-gradient(1px 1px at 90% 70%, #fff, transparent);
  opacity: .5; animation: twinkle 3s infinite alternate;
}
@keyframes twinkle { to { opacity: .9; } }

.title {
  font-size: 42px; font-weight: 800; text-align: center; margin-top: 10px;
  background: linear-gradient(90deg, #fbbf24, #f472b6, #a78bfa);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.1; z-index: 1;
}
.sub { opacity: .85; margin: 10px 0 4px; text-align: center; font-size: 15px; z-index: 1; }
.level-badge { z-index:1; font-size: 13px; opacity:.9; min-height: 20px; margin-bottom: 4px; }
.level-badge b { color:#fde68a; }

.pick { font-size: 18px; margin: 18px 0 10px; align-self: flex-start; z-index: 1; }
.opts { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; z-index: 1; }
.opts.levels .opt { flex: 1 1 42%; }

.opt {
  flex: 1 1 20%; min-width: 70px;
  padding: 14px 8px; border: none; border-radius: 16px;
  background: rgba(255,255,255,.1); color: #fff; font-size: 16px; font-weight: 700;
  backdrop-filter: blur(4px); border: 2px solid transparent;
  transition: transform .12s, background .2s, border-color .2s; cursor: pointer;
}
.opt:active { transform: scale(.94); }
.opt.active {
  background: linear-gradient(135deg, var(--p1), var(--p2));
  border-color: #fff; box-shadow: 0 6px 20px rgba(236,72,153,.5);
}
.opt.lvl.active { box-shadow: 0 6px 20px rgba(124,58,237,.6); }

.start {
  margin-top: 26px; width: 100%; padding: 18px;
  border: none; border-radius: 20px; z-index: 1;
  background: linear-gradient(135deg, #f59e0b, #ec4899, #7c3aed);
  background-size: 200% 200%; animation: shift 4s infinite;
  color: #fff; font-size: 20px; font-weight: 800; cursor: pointer;
  box-shadow: 0 8px 28px rgba(236,72,153,.45);
  transition: transform .12s;
}
.start:active { transform: scale(.96); }
.start:disabled { opacity: .5; animation: none; background: rgba(255,255,255,.12); box-shadow:none; }
@keyframes shift { 50% { background-position: 100% 50%; } }

/* ===== WORKOUT ===== */
.wo-top { display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 16px; }
.quit {
  width: 40px; height: 40px; flex-shrink: 0; border: none; border-radius: 50%;
  background: rgba(255,255,255,.14); color: #fff; font-size: 20px; cursor: pointer;
}
.progress-wrap { flex: 1; height: 10px; background: rgba(255,255,255,.14); border-radius: 10px; overflow: hidden; }
.progress { height: 100%; width: 0; border-radius: 10px;
  background: linear-gradient(90deg, #fbbf24, #ec4899); transition: width .4s; }
.count { font-size: 14px; font-weight: 700; opacity: .9; flex-shrink: 0; }

.ring-wrap { position: relative; width: 240px; height: 240px; margin: 14px 0; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 8; }
.ring-fg { fill: none; stroke: url(#g); stroke-width: 8; stroke-linecap: round;
  stroke: #fbbf24; transition: stroke-dashoffset 1s linear; }
.ex-emoji { position: absolute; top: 34%; left: 50%; transform: translate(-50%,-50%); font-size: 64px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { transform: translate(-50%,-50%) scale(1.12); } }
.timer { position: absolute; bottom: 30%; left: 50%; transform: translateX(-50%); font-size: 52px; font-weight: 800; }

.ex-name { font-size: 28px; font-weight: 800; text-align: center; margin-top: 6px; }
.ex-desc { font-size: 16px; opacity: .9; text-align: center; margin: 8px 16px; line-height: 1.4; }
.ex-tip {
  margin: 10px 0; padding: 10px 16px; border-radius: 14px;
  background: rgba(251,191,36,.18); font-size: 14px; text-align: center;
}
.wo-btns { display: flex; gap: 12px; width: 100%; margin-top: auto; padding-top: 16px; }
.pause, .skip {
  flex: 1; padding: 16px; border: none; border-radius: 16px;
  font-size: 17px; font-weight: 700; color: #fff; cursor: pointer;
}
.pause { background: rgba(255,255,255,.16); }
.skip { background: rgba(236,72,153,.35); }
.pause:active, .skip:active { transform: scale(.95); }

/* ===== REST ===== */
#rest { justify-content: center; }
.rest-title { font-size: 26px; margin-bottom: 20px; }
.rest-timer {
  font-size: 90px; font-weight: 800;
  background: linear-gradient(90deg,#22c55e,#06b6d4);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: pop .5s; 
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.rest-next { opacity: .8; margin-top: 20px; }
.rest-next-name { font-size: 24px; font-weight: 800; margin: 6px 0 30px; color: #fde68a; }

/* ===== DONE ===== */
#done { justify-content: center; }
.trophy { font-size: 90px; animation: bounce 1.2s infinite; }
@keyframes bounce { 50% { transform: translateY(-16px); } }
.done-title {
  font-size: 40px; font-weight: 800; margin: 8px 0;
  background: linear-gradient(90deg,#fbbf24,#f472b6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.done-msg { opacity: .9; margin-bottom: 20px; text-align: center; }
.stats { display: flex; gap: 14px; margin: 10px 0 20px; }
.stat {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.1); padding: 16px 20px; border-radius: 18px; min-width: 80px;
}
.stat-num { font-size: 32px; font-weight: 800; color: #fde68a; }
.stat-lbl { font-size: 13px; opacity: .8; margin-top: 4px; }
.feedback { text-align: center; font-size: 17px; margin-bottom: 12px; line-height: 1.5; padding: 0 10px; }
.levelup {
  text-align: center; font-size: 16px; font-weight: 700; margin-bottom: 20px;
  min-height: 24px;
}
.levelup.show {
  background: linear-gradient(135deg,#f59e0b,#ec4899);
  padding: 12px 18px; border-radius: 14px; animation: pop .5s;
}

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -10px; width: 10px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .8; } }
