:root {
  --bg: #0a0c0b;
  --bg-2: #101412;
  --surface: #141917;
  --surface-2: #1b211e;
  --line: #262e2a;
  --text: #f1f5ef;
  --muted: #8d978f;
  --lime: #4df0ff;
  --lime-ink: #00161a;
  --mint: #b8ff6a;
  --orange: #8b7bff;
  --red: #ff3b4e;
  --voice: #4df0ff;
  --breath: #8b7bff;
  --sil: #39423d;
  --radius: 22px;
  --display: "Unbounded", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }

.bg-glow {
  position: fixed;
  inset: -20vh -20vw auto;
  height: 80vh;
  background:
    radial-gradient(40% 50% at 30% 30%, rgba(77, 240, 255, 0.14), transparent 70%),
    radial-gradient(35% 45% at 75% 20%, rgba(139, 123, 255, 0.12), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
  transition: background 1s ease;
}
body[data-heat="hot"] .bg-glow {
  background:
    radial-gradient(40% 50% at 30% 30%, rgba(255, 59, 78, 0.18), transparent 70%),
    radial-gradient(35% 45% at 75% 20%, rgba(139, 123, 255, 0.2), transparent 70%);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  max-width: 560px;
  margin: 0 auto;
  background: linear-gradient(var(--bg) 60%, transparent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-mark { display: flex; align-items: center; gap: 2px; height: 22px; }
.brand-mark i {
  display: block;
  width: 3.5px;
  border-radius: 3px;
  background: var(--lime);
  animation: breathe 1.6s ease-in-out infinite;
}
.brand-mark i:nth-child(1) { height: 8px; animation-delay: 0s; }
.brand-mark i:nth-child(2) { height: 16px; animation-delay: 0.12s; }
.brand-mark i:nth-child(3) { height: 22px; animation-delay: 0.24s; background: var(--orange); }
.brand-mark i:nth-child(4) { height: 14px; animation-delay: 0.36s; }
.brand-mark i:nth-child(5) { height: 7px; animation-delay: 0.48s; }
@keyframes breathe { 50% { transform: scaleY(0.45); } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.chip:hover { border-color: #3a4540; color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 10px var(--orange); }
.chip.is-ok .dot { background: var(--lime); box-shadow: 0 0 10px var(--lime); }
.chip.is-ok { color: var(--text); }

/* ---------- Layout ---------- */
main {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px calc(40px + var(--safe-b));
}
.screen { display: none; }
.screen.is-active { display: block; animation: enter 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--lime);
  margin-bottom: 12px;
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding-top: 18px; }
.hero-title {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(32px, 9.5vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.035em;
}
.hero-title em {
  font-style: normal;
  background: linear-gradient(90deg, var(--lime), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { margin: 16px auto 0; max-width: 38ch; color: var(--muted); font-size: 17px; }
.hero-orb { width: min(300px, 80vw); aspect-ratio: 1; margin: 12px auto 8px; }
.hero-orb canvas, .rec-stage canvas { width: 100%; height: 100%; display: block; }
.hint { margin-top: 14px; color: var(--muted); font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .chip:focus-visible, .link:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }
.btn-xl { width: 100%; padding: 19px 26px; font-size: 18px; font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; }
.btn-primary {
  background: var(--lime);
  color: var(--lime-ink);
  box-shadow: 0 10px 40px -10px rgba(77, 240, 255, 0.55), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.btn-primary:hover { box-shadow: 0 14px 50px -8px rgba(77, 240, 255, 0.7), inset 0 -3px 0 rgba(0, 0, 0, 0.15); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--line); width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); width: 100%; }
.btn-ghost:hover { color: var(--text); }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Challenge banner ---------- */
.challenge {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-top: 6px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(139, 123, 255, 0.2), rgba(255, 59, 78, 0.12));
  border: 1px solid rgba(139, 123, 255, 0.45);
}
.challenge-score {
  flex: none;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--orange);
  color: #1a0700;
  font-family: var(--display);
  font-weight: 900;
  font-size: 24px;
}
.challenge-title { font-weight: 700; }
.challenge-sub { color: var(--muted); font-size: 14px; }

/* ---------- Cards ---------- */
.card {
  margin-top: 28px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.card h2, .section-title { font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--bg-2); border-radius: 14px; padding: 12px; text-align: center; }
.stat-num { display: block; font-family: var(--display); font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); }
.spark { width: 100%; height: 70px; margin-top: 14px; overflow: visible; }

.btn-sm { padding: 11px 14px; font-size: 14px; }
.backup-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.storage-status { margin-top: 12px; font-size: 13px; color: var(--muted); }
.storage-status.ok { color: var(--lime); }
.install { display: flex; gap: 14px; align-items: flex-start; border-color: rgba(77, 240, 255, 0.35); background: linear-gradient(140deg, rgba(77, 240, 255, 0.08), var(--surface) 60%); }
.install-icon img { display: block; border-radius: 12px; }
.install-body { flex: 1; min-width: 0; }
.install-body p { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.install-body .btn { width: auto; }
.ios-steps { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.ios-steps b { color: var(--text); }
.foot p + p { margin-top: 10px; }

/* ---------- Atletas ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.avatar {
  --c: var(--lime);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--c);
  color: #0a0c0b;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.athlete-chip { padding: 4px 12px 4px 4px; max-width: 52vw; }
.athlete-chip .chip-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 15px; color: var(--muted); }
.who b { color: var(--text); }
.who .link { font-size: 15px; color: var(--lime); }

.coach-promo { display: grid; gap: 14px; border-color: rgba(139, 123, 255, 0.35); background: linear-gradient(140deg, rgba(139, 123, 255, 0.1), var(--surface) 60%); }
.coach-promo .eyebrow { color: var(--orange); margin-bottom: 6px; }
.coach-promo p:not(.eyebrow) { color: var(--muted); font-size: 15px; margin-top: 6px; }

.screen-sub { margin-top: 10px; color: var(--muted); }
.screen-note { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }
#screen-team { padding-top: 24px; }

.add-athlete { display: flex; gap: 8px; margin-top: 24px; }
.add-athlete input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.add-athlete input:focus { outline: 2px solid var(--lime); outline-offset: 1px; }
.add-athlete .btn { flex: none; }

.athletes { list-style: none; padding: 0; margin: 14px 0 16px; display: grid; gap: 10px; }
.athlete { padding: 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.athlete.is-active { border-color: rgba(77, 240, 255, 0.5); }
.athlete-main { display: flex; align-items: center; gap: 12px; }
.athlete-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.athlete-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.athlete-info span { font-size: 13px; color: var(--muted); }
.athlete-info .cal-ok { color: var(--lime); font-style: normal; }
.athlete-main .btn { width: auto; flex: none; }
.icon-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: 18px; line-height: 1; }
.athlete-more { display: none; gap: 8px; margin-top: 12px; grid-template-columns: repeat(3, 1fr); }
.athlete.open .athlete-more { display: grid; }
.athlete-more .btn { width: 100%; padding: 10px 8px; font-size: 13px; }
.btn-danger { background: rgba(255, 59, 78, 0.12); color: #ff9aa5; border: 1px solid rgba(255, 59, 78, 0.35); }

.ranking-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: pos; }
.ranking-list li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; background: var(--bg-2); counter-increment: pos; }
.ranking-list li::before { content: counter(pos); width: 22px; text-align: center; font-family: var(--display); font-weight: 900; color: var(--muted); }
.ranking-list li:nth-child(1)::before { content: "🥇"; }
.ranking-list li:nth-child(2)::before { content: "🥈"; }
.ranking-list li:nth-child(3)::before { content: "🥉"; }
.ranking-list .avatar { width: 32px; height: 32px; font-size: 11px; }
.rank-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.rank-score { font-family: var(--display); font-weight: 900; font-size: 22px; }

.picker-wrap { margin-bottom: 20px; }
.picker-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.picker { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.picker::-webkit-scrollbar { display: none; }
.pick {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.pick .avatar { width: 30px; height: 30px; font-size: 10px; }
.pick[aria-checked="true"] { border-color: var(--lime); color: var(--text); background: var(--surface-2); box-shadow: 0 0 0 1px var(--lime) inset; }

.result-who { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; margin-bottom: 4px; }
.result-who:empty { display: none; }
.result-who .avatar { width: 28px; height: 28px; font-size: 10px; }

/* ---------- Diversión ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.icon-top { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-top .snd-off { display: none; }
.icon-top.is-muted { color: var(--muted); }
.icon-top.is-muted .snd-on { display: none; }
.icon-top.is-muted .snd-off { display: inline; }
.athlete-chip { max-width: 42vw; }
@media (max-width: 360px) { .brand-name { display: none; } }

.btn-duel { margin-top: 10px; }

.phrase-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.phrase-tools .btn { width: auto; }
.phrase-count { font-size: 13px; color: var(--muted); }
.phrase.swap { animation: swap 0.35s ease; }
@keyframes swap { 0% { opacity: 0; transform: translateX(14px); } 100% { opacity: 1; transform: none; } }

.compare {
  margin: 18px auto 0;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: 18px;
  background: linear-gradient(120deg, rgba(77, 240, 255, 0.12), rgba(139, 123, 255, 0.12));
  border: 1px dashed rgba(77, 240, 255, 0.4);
}
.compare span { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.compare b { display: block; margin-top: 2px; font-family: var(--display); font-size: 20px; line-height: 1.25; letter-spacing: -0.02em; }
.data-roast { margin: 14px auto 0; max-width: 40ch; color: #c3ccc5; font-size: 15px; font-style: italic; }
.data-roast:empty { display: none; }
.cheat-note { margin: 12px auto 0; display: inline-block; padding: 6px 12px; border-radius: 999px; background: rgba(255, 59, 78, 0.14); border: 1px solid rgba(255, 59, 78, 0.4); color: #ffb3bb; font-size: 13px; font-weight: 600; }
body[data-cheat="1"] .gauge-num .score { text-decoration: line-through; text-decoration-thickness: 6px; text-decoration-color: var(--red); }

.medal-banner { margin: 16px auto 0; display: grid; gap: 8px; max-width: 420px; }
.medal-new {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: 16px;
  background: linear-gradient(120deg, rgba(255, 177, 44, 0.2), rgba(139, 123, 255, 0.12));
  border: 1px solid rgba(255, 177, 44, 0.5);
  animation: medalIn 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.medal-new:nth-child(2) { animation-delay: 0.15s; }
.medal-new:nth-child(3) { animation-delay: 0.3s; }
@keyframes medalIn { from { opacity: 0; transform: scale(0.7) translateY(10px); } }
.medal-new .mi { font-size: 30px; }
.medal-new small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #ffd27a; }
.medal-new b { font-size: 16px; }

.medal-count { font-family: var(--display); font-weight: 700; color: var(--lime); }
.medal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.medal {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 14px;
  background: var(--bg-2); border: 1px solid var(--line); font-size: 24px; cursor: pointer;
  transition: transform 0.15s;
}
.medal:active { transform: scale(0.92); }
.medal.locked { filter: grayscale(1); opacity: 0.28; }
.medal.sel { border-color: var(--lime); }
.medal-desc { margin-top: 12px; font-size: 14px; color: var(--muted); min-height: 1.5em; }
.medal-desc b { color: var(--text); }

/* Pantalla para ordenador */
.phone-emoji { font-size: 72px; line-height: 1; margin-bottom: 16px; }
.qr-box { margin-top: 24px; padding: 14px; border-radius: 22px; background: #fff; box-shadow: 0 20px 60px -20px rgba(77, 240, 255, 0.45); }
.qr-box img { display: block; width: 220px; height: 220px; }
.qr-url { margin-top: 14px; font-family: var(--display); font-weight: 700; color: var(--lime); }
#screen-desktop .prep-actions { max-width: 360px; justify-items: center; }
body[data-screen="desktop"] .top-actions { display: none; }

/* Funcionalidades */
.features { margin-top: 44px; }
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.feature {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  font: inherit; color: inherit;
}
button.feature { cursor: pointer; transition: border-color 0.2s, transform 0.15s; }
button.feature:hover { border-color: rgba(77, 240, 255, 0.5); }
button.feature:active { transform: scale(0.97); }
button.feature b::after { content: "\00a0→"; color: var(--lime); }
.feature i { font-style: normal; font-size: 26px; line-height: 1; margin-bottom: 4px; }
.feature b { font-size: 15px; line-height: 1.25; }
.feature span { font-size: 13px; color: var(--muted); line-height: 1.4; }

/* Compartir la app */
.share-app { display: grid; gap: 12px; text-align: left; border-color: rgba(77, 240, 255, 0.35); }
.share-app-emoji { font-size: 40px; line-height: 1; }
.share-app h2 { font-size: 18px; }
.share-app p { color: var(--muted); margin-top: 4px; }
.share-app .btn { justify-self: start; width: auto; }
.science-more { margin-top: 14px; width: auto; }

/* Pantalla de ciencia */
#screen-science { padding-top: 24px; }
.science-screen .card p { color: #c3ccc5; margin-top: 10px; }
.sci-list { margin: 12px 0 0; padding-left: 18px; display: grid; gap: 8px; color: #c3ccc5; }
.sci-list b { color: var(--text); }
.refs { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 12px; font-size: 14px; color: #c3ccc5; }
.refs a { color: var(--lime); font-weight: 600; white-space: nowrap; }
.limits { border-color: rgba(255, 177, 44, 0.4); }

/* ¿Ha acertado? */
.feedback { text-align: left; }
.feedback-q { color: var(--muted); font-size: 14px; margin-top: 4px; }
.rpe { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.rpe-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-2);
  cursor: pointer; transition: transform 0.15s, border-color 0.2s, opacity 0.2s;
}
.rpe-btn i { font-style: normal; font-size: 24px; line-height: 1; }
.rpe-btn span { font-size: 11px; font-weight: 600; color: var(--muted); }
.rpe-btn:active { transform: scale(0.94); }
.rpe.done .rpe-btn { opacity: 0.35; cursor: default; }
.rpe.done .rpe-btn.sel { opacity: 1; border-color: var(--lime); background: var(--surface-2); }
.feedback-thanks { margin-top: 12px; font-weight: 600; }

/* Duelo */
.center { text-align: center; }
.duel-form { display: grid; gap: 10px; margin-top: 24px; }
.duel-player { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.duel-player input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; font-weight: 600; padding: 8px 4px; }
.duel-player input:focus { outline: none; }
.duel-player:focus-within { border-color: var(--lime); }
.duel-tag { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-family: var(--display); font-weight: 900; color: #0a0c0b; }
.duel-tag.p1 { background: var(--lime); }
.duel-tag.p2 { background: var(--orange); }
.vs { text-align: center; font-family: var(--display); font-weight: 900; font-size: 20px; color: var(--muted); letter-spacing: 0.05em; }
.screen-center.is-active { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 40px; }
.screen-center .prep-actions { width: 100%; }
.secret { font-size: 84px; line-height: 1; margin-bottom: 18px; animation: wobble 2s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(-8deg) scale(1.05); } }

#screen-duel, #screen-duel-result { padding-top: 24px; }
.duel-board { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 34px; }
.duel-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 26px 8px 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line);
  transition: transform 0.5s cubic-bezier(0.2, 1.4, 0.4, 1), border-color 0.3s, opacity 0.3s;
}
.duel-card .crown { position: absolute; top: -22px; font-size: 34px; opacity: 0; transform: translateY(10px) scale(0.5); transition: all 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
.duel-card.win { border-color: var(--lime); transform: scale(1.05); box-shadow: 0 10px 40px -12px rgba(77, 240, 255, 0.5); }
.duel-card.win .crown { opacity: 1; transform: none; }
.duel-card.lose { opacity: 0.7; }
.duel-card.dq .duel-score { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 4px; }
.duel-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-score { font-family: var(--display); font-weight: 900; font-size: clamp(44px, 14vw, 64px); line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.duel-tier { font-size: 12px; color: var(--muted); text-align: center; min-height: 2.6em; }
#duelHeadline { margin-top: 26px; }

/* ---------- How ---------- */
.how { margin-top: 44px; }
.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.step-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--lime);
  color: var(--lime-ink);
  font-family: var(--display);
  font-weight: 900;
}
.steps h3 { font-size: 16px; margin-bottom: 2px; }
.steps p { color: var(--muted); font-size: 15px; }

.science p { color: #c3ccc5; margin-top: 10px; }
.science p:first-of-type { margin-top: 12px; }
.signals { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.signals li { background: var(--bg-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.signals b { font-size: 14px; }
.signals span { font-size: 12px; color: var(--muted); }
.privacy { font-size: 14px; color: var(--muted) !important; }
.foot { margin-top: 36px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Prep ---------- */
.screen-title { font-family: var(--display); font-size: clamp(26px, 7vw, 34px); font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; }
#screen-prep, #screen-calibrated { padding-top: 24px; }
.phrase {
  margin: 22px 0 0;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--lime);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.tips { margin: 20px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; color: var(--muted); }
.tips li::before { content: "→ "; color: var(--lime); font-weight: 700; }
.prep-actions { display: grid; gap: 8px; margin-top: 28px; }
.error ol { margin: 6px 0 4px; padding-left: 20px; }
.error li { margin: 3px 0; }
.error b { color: #fff; }
.err-sub { margin-top: 10px; font-weight: 700; font-size: 14px; color: #ffd9dd; }
.error .btn { margin-top: 12px; width: auto; }
.err-retry { display: flex; }
.err-code { margin-top: 10px; font-size: 12px; opacity: 0.6; }
.tips b { color: var(--text); }
.error { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: rgba(255, 59, 78, 0.12); border: 1px solid rgba(255, 59, 78, 0.4); color: #ffc2c8; }

/* ---------- Record ---------- */
.screen-record.is-active { display: flex; flex-direction: column; align-items: center; text-align: center; }
.rec-stage { position: relative; width: min(340px, 86vw); aspect-ratio: 1; margin-top: 4px; }
.rec-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.countdown {
  font-family: var(--display);
  font-weight: 900;
  font-size: 110px;
  line-height: 1;
  color: var(--lime);
  text-shadow: 0 0 40px rgba(77, 240, 255, 0.5);
}
.countdown.pop { animation: pop 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(0.9); opacity: 0.85; } }
.rec-time { font-family: var(--display); font-size: 54px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.rec-status { margin-top: 4px; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px; }
.rec-status.live::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); animation: blink 1s infinite; vertical-align: 1px; }
@keyframes blink { 50% { opacity: 0.3; } }
.phrase-live { text-align: left; width: 100%; margin-bottom: 14px; font-size: 22px; }

/* ---------- Analyze ---------- */
.screen-analyze.is-active { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; gap: 28px; }
.scanner { display: flex; gap: 7px; align-items: center; height: 90px; }
.scanner span { width: 10px; border-radius: 6px; background: var(--lime); animation: scan 0.9s ease-in-out infinite; }
.scanner span:nth-child(odd) { background: var(--orange); }
.scanner span:nth-child(1) { animation-delay: 0s; }
.scanner span:nth-child(2) { animation-delay: 0.08s; }
.scanner span:nth-child(3) { animation-delay: 0.16s; }
.scanner span:nth-child(4) { animation-delay: 0.24s; }
.scanner span:nth-child(5) { animation-delay: 0.32s; }
.scanner span:nth-child(6) { animation-delay: 0.4s; }
.scanner span:nth-child(7) { animation-delay: 0.48s; }
@keyframes scan { 0%, 100% { height: 14px; } 50% { height: 86px; } }
.analyze-line { font-family: var(--display); font-weight: 700; font-size: 18px; text-align: center; min-height: 2.6em; max-width: 26ch; }

/* ---------- Result ---------- */
#screen-result { text-align: center; padding-top: 8px; }
.gauge-wrap { position: relative; width: min(340px, 88vw); margin: 0 auto; }
.gauge { width: 100%; display: block; overflow: visible; }
.gauge-track, .gauge-fill { fill: none; stroke-width: 16; stroke-linecap: round; }
.gauge-track { stroke: var(--surface-2); }
.gauge-fill { stroke: url(#gaugeGrad); stroke-dasharray: 314.16; stroke-dashoffset: 314.16; }
.gauge-needle { fill: #fff; filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.7)); }
.gauge-num { position: absolute; left: 0; right: 0; bottom: 4px; display: flex; align-items: baseline; justify-content: center; gap: 4px; }
.score { font-family: var(--display); font-size: clamp(68px, 22vw, 96px); font-weight: 900; line-height: 0.9; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.score-of { font-family: var(--display); color: var(--muted); font-size: 18px; font-weight: 700; }
.tier { margin-top: 18px; font-family: var(--display); font-weight: 900; font-size: clamp(26px, 8vw, 36px); letter-spacing: -0.03em; line-height: 1.05; }
.tier-line { margin-top: 8px; color: #c3ccc5; font-size: 17px; }
.delta { margin-top: 12px; display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 14px; font-weight: 600; }
.warn { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 177, 44, 0.1); border: 1px solid rgba(255, 177, 44, 0.35); color: #ffd99b; font-size: 14px; }

.xray { text-align: left; }
.xray canvas { width: 100%; height: 110px; display: block; }
.xray-note { margin-top: 10px; font-size: 13px; color: var(--muted); }
.xray-note:empty { display: none; }
#doneBtn { margin-bottom: 4px; }
#doneBtn:disabled { opacity: 0.35; box-shadow: none; cursor: default; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.lg-voice { background: var(--voice); }
.lg-breath { background: var(--breath); }
.lg-sil { background: var(--sil); }

.metrics { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.metric { padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.metric-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.metric-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.metric-val { margin-top: 4px; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.metric-val small { font-family: var(--body); font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.metric-bar { margin-top: 10px; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.metric-bar i { display: block; height: 100%; width: 0; border-radius: 6px; transition: width 1.1s cubic-bezier(0.2, 0.8, 0.2, 1); }
.metric-note { margin-top: 6px; font-size: 12px; color: var(--muted); }

.result-actions { display: grid; gap: 10px; margin-top: 28px; }

/* ---------- Calibrated ---------- */
#screen-calibrated { text-align: center; }
.big-check svg { width: 88px; height: 88px; margin: 10px auto 18px; display: block; }
.big-check circle { fill: none; stroke: var(--lime); stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.7s ease forwards; }
.big-check path { fill: none; stroke: var(--lime); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.4s 0.55s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translate(-50%, 30px);
  opacity: 0;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 15px;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  main { padding-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ================= Pulmómetro ================= */
.seconds-wrap { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 8px 0 4px; }
.seconds { font-family: var(--display); font-weight: 900; font-size: clamp(88px, 28vw, 140px); line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; color: var(--lime); }
.seconds-unit { font-family: var(--display); font-weight: 700; font-size: 34px; color: var(--muted); }
#screen-result .tier, #screen-result .tier-line { text-align: center; }

.scale { margin: 40px 0 6px; }
.scale-track { position: relative; height: 14px; border-radius: 99px; background: linear-gradient(90deg, #9aa6ff22, #4df0ff22 40%, #f2e93a22 70%, #ffb12c22); border: 1px solid var(--line); }
.scale-band { position: absolute; top: -1px; bottom: -1px; left: 33.33%; width: 11.11%; background: rgba(255, 255, 255, 0.14); border-left: 1px dashed rgba(255,255,255,.35); border-right: 1px dashed rgba(255,255,255,.35); }
.scale-you, .scale-best { position: absolute; top: 50%; width: 22px; height: 22px; margin-left: -11px; margin-top: -11px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px var(--bg), 0 0 18px var(--lime); }
.scale-you.bad { background: var(--red); box-shadow: 0 0 0 4px var(--bg), 0 0 18px var(--red); }
.scale-best { width: 4px; margin-left: -2px; height: 26px; margin-top: -13px; border-radius: 2px; background: var(--muted); box-shadow: none; }
.scale-you span, .scale-best span { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 700; color: var(--text); white-space: nowrap; }
.scale-best span { color: var(--muted); bottom: 30px; }
.scale-labels { position: relative; height: 18px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.scale-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.scale-labels span:nth-child(1) { left: 0; transform: none; }
.scale-labels span:nth-child(2) { left: 22.2%; }
.scale-labels span:nth-child(3) { left: 38.9%; top: 16px; color: var(--text); }
.scale-labels span:nth-child(4) { left: 66.7%; }
.scale-labels span:nth-child(5) { right: 0; left: auto; transform: none; }
.scale + .data-roast { margin-top: 26px; }

.aaa-demo { font-family: var(--display); font-weight: 900; font-size: clamp(36px, 12vw, 60px); color: var(--lime); margin: 14px 0 6px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; }
.aaa-demo span { display: inline-block; opacity: 0.85; background: linear-gradient(90deg, var(--lime), var(--orange) 70%, transparent); -webkit-background-clip: text; background-clip: text; color: transparent; animation: aaa 2.6s ease-in-out infinite; }
@keyframes aaa { 0% { clip-path: inset(0 100% 0 0); } 70%, 100% { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .aaa-demo span { animation: none; } }

.rec-who { text-align: center; font-weight: 700; color: var(--lime); margin-bottom: 6px; }
.rec-record { text-align: center; color: var(--muted); font-weight: 600; margin: 4px 0 14px; min-height: 1.5em; }
.screen-record .countdown { font-size: clamp(64px, 22vw, 110px); }
.family { border-color: rgba(139, 123, 255, 0.35); }
.family .eyebrow { margin-bottom: 4px; }
a.btn { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
