:root {
  --bg: #0d1530;
  --bg2: #16204a;
  --card: #1b2654;
  --line: #2c3a72;
  --text: #f4f6ff;
  --muted: #a7b0d6;
  --accent: #e8336b;
  --good: #22c38e;
  --warn: #ffb020;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  display: inline-block; font: 600 0.75em ui-monospace, monospace; padding: 0.15em 0.45em;
  border: 1px solid #4a5aa0; border-bottom-width: 2px; border-radius: 6px; background: #24306a; color: #dfe4ff;
}

/* ---------------- HOME ---------------- */
#home { max-width: 1280px; margin: 0 auto; padding: 32px 24px 64px; }
.home-head h1 { font-size: clamp(32px, 5vw, 56px); margin: 0; letter-spacing: -0.02em; }
.home-head .sub { color: var(--accent); font-weight: 700; font-size: 20px; margin: 6px 0 0; color: #ff6b97; }

.setup { display: flex; flex-wrap: wrap; gap: 16px 40px; margin: 28px 0 8px; padding: 18px 22px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; }
.setting { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.setting-label { font-weight: 700; }
.setting-hint { color: var(--muted); }
.seg { display: inline-flex; background: #0b1128; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 10px 18px; border-radius: 9px; font-weight: 700; font-size: 18px; color: var(--muted); }
.seg button.on { background: #ff6b97; color: #fff; }
.seg button:hover:not(.on) { background: #1f2a5c; color: #fff; }

.last-done { font-size: 18px; margin: 18px 4px; color: var(--muted); }
.last-done b { color: var(--text); }

.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.day {
  position: relative; background: var(--card); border: 2px solid var(--line); border-top: 8px solid var(--c);
  border-radius: 18px; padding: 20px; display: flex; flex-direction: column;
}
.day.suggested { border-color: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); }
.up-next { position: absolute; top: -16px; right: 16px; background: var(--c); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .08em; padding: 5px 12px; border-radius: 99px; }
.day-num { color: var(--c); font-weight: 900; letter-spacing: .08em; font-size: 15px; filter: brightness(1.25); }
.day h3 { font-size: 24px; margin: 4px 0 4px; line-height: 1.15; }
.focus { color: var(--muted); margin: 0 0 12px; }
.move-list { list-style: none; counter-reset: mv; padding: 0; margin: 0 0 16px; flex: 1; }
.move-list li {
  counter-increment: mv; display: grid; grid-template-columns: 30px 1fr auto; grid-template-areas: "n name reps" "n db link";
  gap: 0 8px; padding: 9px 0; border-top: 1px solid var(--line); align-items: baseline;
}
.move-list li::before { content: counter(mv); grid-area: n; font-weight: 900; color: var(--c); filter: brightness(1.25); font-size: 18px; }
.mv-name { grid-area: name; font-weight: 700; }
.mv-reps { grid-area: reps; color: #ff8fb0; font-weight: 700; font-size: 14px; text-align: right; }
.mv-db { grid-area: db; color: var(--muted); font-size: 13px; }
.link { grid-area: link; background: none; border: 0; padding: 0; color: #7f8bc4; font-size: 12px; text-decoration: underline; text-align: right; }
.link:hover { color: #fff; }
.day-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.start-btn {
  background: var(--c); border: 0; border-radius: 12px; padding: 14px 18px; font-size: 18px; font-weight: 800; color: #fff;
  display: inline-flex; gap: 10px; align-items: center;
}
.start-btn:hover { filter: brightness(1.12); }
.start-btn kbd { background: rgba(0,0,0,.2); border-color: rgba(255,255,255,.35); color: #fff; }

.keys-card, .rules { margin-top: 24px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; }
.keys-card h2, .rules h2 { margin: 0 0 12px; font-size: 20px; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 20px; font-size: 17px; }
.rules ul { margin: 0; padding-left: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 24px; }

/* ---------------- SESSION ---------------- */
#session { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: #0a1027; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); font-size: 20px; }
.icon-btn:hover { background: #2a2050; }
.topinfo { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tday { font-weight: 800; font-size: 20px; }
.pill { background: var(--bg2); border: 1px solid var(--line); padding: 5px 12px; border-radius: 99px; font-weight: 700; }
.progress { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.dot { width: 22px; height: 10px; border-radius: 99px; background: #2a376b; }
.dot.done { background: var(--good); }
.dot.now { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }

.stage { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr); gap: 24px; padding: 20px; min-height: 0; }
.video-wrap { min-height: 0; display: flex; align-items: center; justify-content: center; container-type: size; }
.video-box { position: relative; background: #000; border-radius: 18px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.video-box.tall { height: min(100cqh, calc(100cqw * 16 / 9)); aspect-ratio: 9 / 16; }
.video-box.wide { width: min(100cqw, calc(100cqh * 16 / 9)); aspect-ratio: 16 / 9; }
.video-box iframe, #player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.shield { position: absolute; inset: 0; cursor: pointer; }
.resting .video-box { outline: 4px dashed rgba(255,255,255,.25); outline-offset: -4px; }
.paused-badge {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(5,8,20,.6); font-size: 44px; font-weight: 900; letter-spacing: .1em; pointer-events: none;
}
.paused-badge small { font-size: 18px; letter-spacing: 0; font-weight: 600; color: var(--muted); margin-top: 6px; }
.video-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 22px; background: #000; padding: 20px; line-height: 1.6; }

.panel { display: flex; flex-direction: column; justify-content: center; min-height: 0; overflow: auto; padding-right: 8px; }
.phase { text-transform: uppercase; font-weight: 900; letter-spacing: .12em; color: var(--accent); filter: brightness(1.25); font-size: 20px; }
.resting .phase { color: var(--warn); filter: none; }
.ex-name { font-size: clamp(34px, 4.4vw, 64px); line-height: 1.02; margin: 6px 0 10px; letter-spacing: -0.02em; }
.ex-reps { font-size: clamp(28px, 3.4vw, 48px); font-weight: 900; color: #ff6b97; }
.resting .ex-name, .resting .ex-reps { opacity: .75; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.badge { background: var(--bg2); border: 1px solid var(--line); padding: 6px 12px; border-radius: 99px; font-weight: 700; color: #8fe3d8; }
.badge.db { background: #fff; color: #0d1530; border-color: #fff; }
.big-timer { font-size: clamp(80px, 11vw, 160px); font-weight: 900; line-height: 1; margin: 10px 0 0; font-variant-numeric: tabular-nums; color: var(--warn); }
.big-timer.warn { color: #ff4d6d; animation: pulse 1s infinite; }
.side-label { font-size: 24px; font-weight: 800; margin-top: 6px; }
.cues { list-style: none; padding: 0; margin: 16px 0 0; font-size: clamp(18px, 1.7vw, 24px); }
.cues li { padding: 7px 0 7px 34px; position: relative; }
.cues li::before { content: "✓"; position: absolute; left: 0; color: var(--good); font-weight: 900; }
.tip { margin-top: 10px; display: inline-block; align-self: flex-start; background: #12352c; color: #8ff0c6; border: 1px solid #1f6b52; padding: 8px 14px; border-radius: 99px; font-weight: 700; }
.elapsed { margin-top: 18px; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { opacity: .55; } }

.controls { display: flex; gap: 12px; padding: 14px 20px 18px; background: #0a1027; border-top: 1px solid var(--line); justify-content: center; flex-wrap: wrap; }
.ctl {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 130px; padding: 12px 20px;
  border-radius: 16px; border: 2px solid var(--line); background: var(--bg2); font-weight: 800; font-size: 18px;
}
.ctl .ic { font-size: 26px; line-height: 1; }
.ctl:hover { border-color: #5a6bc0; }
.ctl.primary { background: var(--good); border-color: var(--good); color: #062b1e; min-width: 240px; font-size: 22px; }
.ctl.primary kbd { background: rgba(255,255,255,.35); color: #062b1e; border-color: rgba(0,0,0,.25); }
.ctl.small { min-width: 110px; font-size: 15px; opacity: .9; }
.is-paused #pauseBtn { background: var(--warn); border-color: var(--warn); color: #2b1a00; }

.flash {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); background: var(--warn); color: #2b1a00;
  font-size: 48px; font-weight: 900; padding: 20px 40px; border-radius: 20px; z-index: 50; animation: fade 1.6s forwards; pointer-events: none;
}
@keyframes fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---------------- DONE ---------------- */
#done { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.done-card { text-align: center; max-width: 640px; }
.trophy { font-size: 110px; }
.done-card h1 { font-size: 56px; margin: 8px 0; }
.done-card p { font-size: 22px; }
.big-btn { margin-top: 18px; background: var(--good); color: #062b1e; border: 0; border-radius: 16px; padding: 18px 30px; font-size: 22px; font-weight: 800; display: inline-flex; gap: 12px; align-items: center; }

/* ---------------- narrow screens ---------------- */
@media (max-width: 900px) {
  #session { height: auto; min-height: 100vh; overflow: visible; }
  .stage { grid-template-columns: 1fr; }
  .video-wrap { height: 60vh; }
  .ctl { min-width: 0; flex: 1 1 30%; }
  .ctl.primary { flex-basis: 100%; }
}
