/* Gym Coach: Lucha Libre poster look. Bungee headings, chunky ink outlines, offset shadows, gold mask + hot red. */
:root {
  --ink: #1b2340;
  --muted: #5a6280;
  --bg: #fff6e0;
  --paper: radial-gradient(circle at 15% 10%, #ffe9b0 0 14%, transparent 15%),
    radial-gradient(circle at 92% 30%, #ffd9d0 0 10%, transparent 11%),
    repeating-linear-gradient(135deg, transparent 0 22px, rgb(27 35 64 / 3%) 22px 24px), #fff6e0;
  --card: #ffffff;
  --gold: #ffc72c;
  --red: #e63946;
  --navy: #1b2340;
  --green: #2a9d8f;
  --teal: #1f9fb4;
  --leaf: #6a994e;
  --orange: #f4842d;
  --edge: #1b2340;
  --pop: 4px 4px 0 var(--edge);
  --bar: rgb(255 246 224 / 92%);
  --display: "Bungee", "Impact", system-ui, sans-serif;
  --body: "Rubik", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f4f1e8; --muted: #aab1cc; --bg: #121830; --card: #1e2747; --edge: #05070f; --bar: rgb(18 24 48 / 92%);
    --paper: radial-gradient(circle at 15% 10%, #2a2350 0 14%, transparent 15%),
      repeating-linear-gradient(135deg, transparent 0 22px, rgb(255 255 255 / 3%) 22px 24px), #121830;
  }
}
:root[data-theme="dark"] {
  --ink: #f4f1e8; --muted: #aab1cc; --bg: #121830; --card: #1e2747; --edge: #05070f; --bar: rgb(18 24 48 / 92%);
  --paper: repeating-linear-gradient(135deg, transparent 0 22px, rgb(255 255 255 / 3%) 22px 24px), #121830;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--paper); background-attachment: fixed; color: var(--ink);
  font: 16px/1.45 var(--body);
  padding: 0 max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
main, .foot, .top { max-width: 560px; margin-inline: auto; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 0 10px; background: var(--bar); backdrop-filter: blur(8px);
}
.brand { font: 20px/1 var(--display); letter-spacing: .5px; }
.brand b { color: var(--red); font-weight: 400; }
.langs { display: flex; gap: 6px; }
.langs button {
  min-width: 44px; height: 40px; border: 2.5px solid var(--edge); border-radius: 10px; background: var(--card);
  font: 600 15px/1 var(--body); box-shadow: 2px 2px 0 var(--edge);
}
.langs button.active { background: var(--gold); color: var(--navy); }

/* hub */
.hero { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; margin: 8px 0 4px; }
.mascot svg { display: block; width: 100%; height: auto; }
.mascot-fallback { font-size: 64px; text-align: center; }
.hero .mascot { cursor: pointer; }
.bubble {
  position: relative; background: var(--card); border: 3px solid var(--edge); border-radius: 18px; padding: 12px 14px;
  font-weight: 600; box-shadow: var(--pop); min-height: 3em;
}
.hero .bubble::before {
  content: ""; position: absolute; left: -14px; top: 50%; translate: 0 -50%; border: 8px solid transparent;
  border-right: 12px solid var(--edge);
}
.sec { font: 18px/1 var(--display); margin: 22px 0 10px; letter-spacing: .5px; }
.sec::after { content: ""; display: block; width: 56px; height: 5px; margin-top: 6px; background: var(--red); border-radius: 3px; }
.list { display: grid; gap: 12px; }
.list.grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card {
  display: block; background: var(--card); border: 3px solid var(--edge); border-radius: 16px; padding: 14px;
  box-shadow: var(--pop); transition: transform .12s, box-shadow .12s;
}
a.card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--edge); }
.card h3 { margin: 0; font: 700 18px/1.2 var(--body); }
.card p { margin: 6px 0 0; color: var(--muted); }
.routine { border-left: 10px solid var(--red); }
.routine.c-gold { border-left-color: var(--gold); }
.routine.c-teal { border-left-color: var(--teal); }
.routine.c-green { border-left-color: var(--leaf); }
.routine .sub { margin: 2px 0 0; font-size: 13px; font-style: italic; }
.chip { display: inline-block; padding: 2px 8px; border: 1.5px solid var(--muted); border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); }
.routine .chips { margin-top: 8px; }
.r-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.r-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.ex { border-top: 8px solid var(--gold); }
.pill {
  display: inline-block; padding: 3px 10px; border: 2px solid var(--edge); border-radius: 999px; background: var(--gold);
  color: var(--navy); font: 700 13px/1.3 var(--body); white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 3px solid var(--edge);
  border-radius: 14px; background: var(--card); padding: 10px 16px; font: 700 16px/1 var(--body); box-shadow: 3px 3px 0 var(--edge);
}
.btn.small { padding: 7px 12px; font-size: 14px; box-shadow: 2px 2px 0 var(--edge); }
.btn.go { background: var(--red); color: #fff; }
.btn.big { width: 100%; min-height: 58px; font: 22px/1 var(--display); letter-spacing: .5px; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--edge); }
.history { list-style: none; margin: 0; padding: 6px 14px; }
.history li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 0; border-bottom: 2px dashed rgb(127 127 127 / 25%); }
.history li:last-child { border: 0; }
.history li span:first-child { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.tag { font-size: 13px; font-weight: 700; color: var(--muted); }
.tag.ok { color: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 12px; }
.back { display: inline-block; margin: 10px 0; font-weight: 700; }
.detail h2 { margin: 0 0 8px; font: 24px/1.15 var(--display); }
.detail h3 { margin: 18px 0 6px; font-size: 17px; }
.detail ul { margin: 0; padding-left: 20px; }
.detail li { margin: 4px 0; }
.muted { color: var(--muted); }
.safety { margin-top: 16px; padding: 10px 12px; border: 2.5px solid var(--red); border-radius: 12px; background: rgb(230 57 70 / 10%); }

/* footer */
.foot { text-align: center; padding: 28px 0 24px; color: var(--muted); font-size: 13px; }
.foot p { margin: 6px 0; }
.foot .ver { font: 12px/1 var(--display); letter-spacing: 1px; opacity: .8; }
.install-help { max-width: 320px; margin-inline: auto; }

/* player: full screen over the hub */
body.playing { overflow: hidden; }
body.playing main, body.playing .foot, body.playing .top { display: none; }
.player {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: var(--paper);
  padding: calc(env(safe-area-inset-top) + 8px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 12px) max(16px, env(safe-area-inset-left));
  max-width: 560px; margin-inline: auto;
}
[hidden] { display: none !important; }
.p-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.p-label { text-align: center; font-weight: 700; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 44px; height: 44px; border: 2.5px solid var(--edge); border-radius: 12px; background: var(--card);
  font-size: 18px; box-shadow: 2px 2px 0 var(--edge);
}
.icon-btn.lg { width: 64px; height: 56px; font-size: 24px; }
.icon-btn.off { opacity: .6; }
.progress { height: 10px; margin: 10px 0 4px; border: 2.5px solid var(--edge); border-radius: 999px; background: var(--card); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); transition: width .4s; }
.p-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 0; text-align: center; }
.p-stage > * { flex-shrink: 0; }
.p-stage .mascot { width: min(34vh, 180px); }
.p-stage.intro .mascot { width: min(26vh, 150px); }
.p-stage .bubble { width: 100%; max-width: 420px; font-size: 17px; }
.p-phase {
  font: 26px/1 var(--display); letter-spacing: 1px; color: #fff; background: var(--red); padding: 8px 16px;
  border: 3px solid var(--edge); border-radius: 12px; box-shadow: 3px 3px 0 var(--edge); transform: rotate(-2deg);
}
.kind-rest .p-phase { background: var(--green); }
.kind-prep .p-phase { background: var(--gold); color: var(--navy); }
.p-title { margin: 0; font: 24px/1.15 var(--display); }
.p-title.small { font-size: 18px; }
.p-meta { margin: 0; color: var(--muted); }
.p-list { margin: 0; padding: 0; list-style: none; font-weight: 600; }
.p-hint { margin: 0; color: var(--muted); font-size: 14px; }
.timer { position: relative; width: min(30vh, 190px); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring-bg { stroke: rgb(127 127 127 / 20%); }
.ring-fg { stroke: var(--red); stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.kind-rest .ring-fg { stroke: var(--green); }
.kind-prep .ring-fg { stroke: var(--gold); }
.secs { position: absolute; inset: 0; display: grid; place-items: center; font: clamp(48px, 12vh, 76px)/1 var(--display); }
.reps-target { font: 22px/1 var(--display); }
.reps-target b { font-size: 64px; font-weight: 400; color: var(--red); }
.reps-target.fail { color: var(--red); font-size: 24px; line-height: 1.1; }
.reps-target small { display: block; margin-top: 6px; font: 600 15px/1.2 var(--body); color: var(--muted); }
.weight { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.weight input { width: 80px; padding: 8px; border: 2.5px solid var(--edge); border-radius: 10px; font: 700 18px var(--body); background: var(--card); color: var(--ink); }
.p-stage .btn.big { max-width: 420px; }
.p-controls { display: flex; justify-content: center; gap: 14px; padding-top: 10px; }
.is-paused .timer, .is-paused .secs { opacity: .45; }

/* El Titán: talking and wiggle */
.mascot.talking .titan-mouth { animation: talk .22s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes talk { to { transform: scaleY(.55); } }
.pose-work .titan-body { animation: pump 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom center; }
@keyframes pump { 50% { transform: scale(1.03); } }
.mascot.wiggle { animation: wiggle .5s; }
@keyframes wiggle { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

@media (max-height: 600px) {
  .p-stage .mascot { width: 17vh; }
  .reps-target b { font-size: 48px; }
  .btn.big { min-height: 50px; }
  .p-stage { gap: 6px; }
  .p-stage .bubble { font-size: 15px; padding: 8px 10px; min-height: 0; }
  .p-phase { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* exercise library groups */
.group { margin: 0 0 10px; }
.group summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none;
  padding: 12px 14px; border: 3px solid var(--edge); border-radius: 14px; background: var(--card); font-weight: 700;
  box-shadow: 3px 3px 0 var(--edge);
}
.group summary::-webkit-details-marker { display: none; }
.group summary::after { content: "▾"; transition: rotate .2s; }
.group[open] summary::after { rotate: 180deg; }
.group[open] summary { margin-bottom: 10px; }
.routine .phases { margin-top: 6px; font-size: 13px; }

/* routine groups: emoji, name and the lengths inside, coloured edge per group */
.g-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.g-title small { font-weight: 500; font-size: 12px; color: var(--muted); }
.group.g-red summary, .group.g-gold summary, .group.g-teal summary, .group.g-green summary { border-left-width: 10px; }
.group.g-red summary { border-left-color: var(--red); }
.group.g-gold summary { border-left-color: var(--gold); }
.group.g-teal summary { border-left-color: var(--teal); }
.group.g-green summary { border-left-color: var(--leaf); }
.group summary .g-title { flex: 1; }
.g-emoji { font-size: 26px; line-height: 1; }
