:root {
  --bg: #0b0b0b;
  --ink: #f4f1ea;
  --muted: rgba(244, 241, 234, .62);
  --faint: rgba(244, 241, 234, .12);
  --red: #e3342f;
  --red-deep: #a61c18;
  --yellow: #f5c518;
  --cyan: #3cc6f2;
  --green: #3ccf7a;
  --glass: rgba(16, 16, 16, .55);
  --glass-strong: rgba(14, 14, 14, .72);
  --glass-border: rgba(255, 255, 255, .13);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
  --r: 22px;
  --r-sm: 14px;
  --pad: 28px;
  --gap: 44px;
  --display: 'Bungee', 'Arial Black', Impact, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --jp: 'Noto Serif JP', serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ---------- Fondo póster ---------- */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-panel {
  position: absolute; top: 70px; right: -14vw;
  width: min(78vw, 620px); height: min(92vh, 820px);
  background: var(--red);
  clip-path: polygon(6% 0, 100% 2%, 100% 100%, 0 96%, 3% 52%);
  opacity: .92;
}
.bg-panel::after {
  /* trama de puntos tipo manga */
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(0,0,0,.55) 1.2px, transparent 1.6px);
  background-size: 9px 9px;
  -webkit-mask-image: linear-gradient(200deg, transparent 35%, #000 95%);
  mask-image: linear-gradient(200deg, transparent 35%, #000 95%);
}
.bg-kanji {
  position: absolute; left: -2vw; bottom: 4vh;
  font-family: var(--jp); font-weight: 900;
  writing-mode: vertical-rl;
  font-size: min(42vw, 360px); line-height: 1;
  color: rgba(244, 241, 234, .045);
}
.bg-grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .075;
  mix-blend-mode: overlay;
}

/* ---------- Vidrio ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
}

/* ---------- Íconos de línea ---------- */
.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  border-width: 0 0 1px;
  border-radius: 0;
}
.topbar-logo { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; }
.topbar-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.brand { font-family: var(--display); font-size: 17px; letter-spacing: .02em; line-height: 1; }
.level-chip {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(227, 52, 47, .16);
  border: 1px solid rgba(227, 52, 47, .45);
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 11px 2px 9px;
  font-size: 13px; font-weight: 600;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.level-chip .kj { font-family: var(--jp); font-weight: 900; color: var(--red); font-size: 13px; }

/* Detalle sorpresa: el guante lanza un 1-2 al ganar un logro */
.mascot { position: relative; width: 40px; height: 40px; display: grid; place-items: center; }
.mascot-glove { width: 30px; height: 30px; fill: none; stroke: var(--red); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(-90deg) scaleY(-1); }
.mascot-pow {
  position: absolute; right: 30px; top: -2px;
  font-family: var(--display); font-size: 13px; color: var(--yellow);
  text-shadow: 2px 2px 0 #000;
  opacity: 0; transform: scale(.4) rotate(-12deg);
  pointer-events: none;
}
.mascot.punch .mascot-glove { animation: jab .7s var(--ease); }
.mascot.punch .mascot-pow { animation: pow 1.1s var(--ease); }
@keyframes jab {
  0% { transform: rotate(-90deg) scaleY(-1) translateY(0); }
  18% { transform: rotate(-90deg) scaleY(-1) translateY(12px) scale(1.15); }
  34% { transform: rotate(-90deg) scaleY(-1) translateY(0); }
  52% { transform: rotate(-90deg) scaleY(-1) translateY(14px) scale(1.25); }
  100% { transform: rotate(-90deg) scaleY(-1) translateY(0); }
}
@keyframes pow {
  0%, 40% { opacity: 0; transform: scale(.4) rotate(-12deg); }
  55% { opacity: 1; transform: scale(1.2) rotate(-12deg); }
  85% { opacity: 1; transform: scale(1) rotate(-8deg); }
  100% { opacity: 0; transform: scale(1) rotate(-8deg) translateY(-6px); }
}

/* ---------- Layout ---------- */
main {
  position: relative; z-index: 1;
  max-width: 640px; margin: 0 auto;
  padding: 36px 20px calc(130px + env(safe-area-inset-bottom));
}
.view { display: none; }
.view.active { display: block; animation: viewIn .45s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.section { margin-top: var(--gap); }
.hero { padding: 8px 4px 0; }
.hero h1 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(30px, 8vw, 44px); line-height: 1.08;
  margin: 16px 0 14px; letter-spacing: -.005em;
  text-shadow: 3px 3px 0 rgba(0,0,0,.6);
}
.tag-red {
  display: inline-block;
  font-family: var(--display); font-size: 14px;
  color: var(--red); letter-spacing: .04em;
}
.muted { color: var(--muted); margin: 0; }
.hero .muted, .plan-summary { color: rgba(244, 241, 234, .82); text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  margin: 0 4px 18px; color: var(--ink);
}
.h2 .i { color: var(--red); }
.h2 .count { color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.card { border-radius: var(--r); padding: var(--pad); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px;
  border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: 16px; letter-spacing: .02em;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--red); color: #fff;
  box-shadow: 0 8px 24px rgba(227, 52, 47, .35), inset 0 -3px 0 rgba(0,0,0,.2);
  font-family: var(--display); font-weight: 400; letter-spacing: .04em;
}
.btn-primary:hover { background: #ec4540; }
.btn-ghost { background: rgba(255,255,255,.06); border-color: var(--glass-border); }
.btn-ghost:hover { background: rgba(255,255,255,.11); }
.btn-danger-ghost { background: transparent; border-color: rgba(227,52,47,.4); color: #ff8a86; margin-top: 18px; width: 100%; }
.btn-big { min-height: 62px; font-size: 18px; }
.btn-wide { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 26px; }
.btn-row .btn { flex: 1 1 160px; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }

/* ---------- Presets ---------- */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.preset {
  position: relative; text-align: left;
  border-radius: var(--r-sm); padding: 20px 18px 18px;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .2s var(--ease), border-color .2s, background .2s;
}
.preset:hover { transform: translateY(-2px); }
.preset.selected { border-color: var(--red); background: rgba(227, 52, 47, .16); }
.preset img { width: 38px; height: 38px; margin-bottom: 6px; }
.preset b { font-size: 17px; }
.preset small { color: var(--muted); font-size: 14px; }
.preset .del {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.08); display: grid; place-items: center;
}
.preset .del .i { width: 15px; height: 15px; }

/* ---------- Steppers ---------- */
.steppers { display: flex; flex-direction: column; gap: 6px; }
.stepper {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--faint);
}
.stepper:last-child { border-bottom: 0; }
.stepper-label { display: flex; align-items: center; gap: 12px; font-weight: 600; min-width: 0; white-space: nowrap; }
.stepper-label .i { color: var(--muted); }
.stepper-ctrl { display: flex; align-items: center; gap: 10px; flex: none; }
.step-btn {
  width: 46px; height: 46px; border-radius: 13px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.06);
  display: grid; place-items: center;
  transition: background .15s, transform .12s;
}
.step-btn:active { transform: scale(.92); background: rgba(227,52,47,.3); }
.step-val { font-family: var(--display); font-size: 21px; min-width: 76px; text-align: center; }
.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 18px; padding-top: 20px; border-top: 1px dashed var(--faint);
}
.total-row strong { font-family: var(--display); font-weight: 400; font-size: 22px; color: var(--yellow); }

/* ---------- Planes ---------- */
.field { margin-bottom: 26px; }
.label { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 12px; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 10px; }
.seg button, .chip {
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.05);
  font-weight: 600; font-size: 15px;
  transition: background .2s, border-color .2s, color .2s;
}
.seg button.active, .chip.active { background: var(--ink); color: #111; border-color: var(--ink); }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.plan-head .h2 { margin-bottom: 0; }
.plan-summary { margin: 0 4px 22px; }
.blocks { display: flex; flex-direction: column; gap: 18px; margin-bottom: 28px; }
.block { border-radius: var(--r); padding: 24px var(--pad); }
.block-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.block-head img { width: 40px; height: 40px; }
.block-head b { font-size: 18px; display: block; line-height: 1.2; }
.block-head small { color: var(--muted); font-size: 14px; }
.block ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.block li { display: flex; gap: 14px; align-items: baseline; }
.block li .n { font-family: var(--display); font-size: 13px; color: var(--red); min-width: 30px; }
.block li .t { flex: 1; }
.block li .d { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.block .note { margin: 16px 0 0; font-size: 14px; color: var(--yellow); }
.tips { display: flex; flex-direction: column; gap: 20px; }
.tip { display: flex; flex-direction: column; gap: 4px; }
.tip b { font-size: 16px; }
.tip span { color: var(--muted); font-size: 15px; }

/* ---------- Logros ---------- */
.level-card { display: flex; gap: 26px; align-items: center; padding: 30px var(--pad); }
.level-card .emblem { width: 128px; height: 128px; flex: none; filter: drop-shadow(0 8px 18px rgba(0,0,0,.5)); }
.level-info { flex: 1; min-width: 0; }
.level-info small { color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; }
.level-info h2 { font-family: var(--display); font-weight: 400; font-size: 23px; line-height: 1.15; margin: 6px 0 16px; }
.xpbar { height: 12px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red-deep), var(--red), #ff7a5c); border-radius: inherit; transition: width .9s var(--ease); }
.xp-text { margin-top: 10px; font-size: 14px; color: var(--muted); }
.ladder { display: flex; flex-direction: column; border-radius: var(--r); padding: 8px var(--pad); background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
.rung { display: flex; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--faint); }
.rung:last-child { border-bottom: 0; }
.rung > svg:first-child { width: 58px; height: auto; flex: none; }
.rung div { flex: 1; min-width: 0; }
.rung b { display: block; font-size: 16px; line-height: 1.3; }
.rung small { color: var(--muted); font-size: 14px; }
.rung > .i { color: var(--muted); }
.rung.locked > svg:first-child { filter: grayscale(1) brightness(.5); }
.rung.locked b { color: var(--muted); font-weight: 600; }
.rung.current b { color: var(--red); }
.rung.current small { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat { border-radius: var(--r-sm); padding: 20px 22px; }
.stat b { display: block; font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.stat span .i { width: 16px; height: 16px; }
.chips { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.medals { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 24px 8px; }
.medal-btn {
  background: none; border: 0; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  border-radius: var(--r-sm); transition: transform .2s var(--ease);
}
.medal-btn:hover { transform: translateY(-3px); }
.medal-btn svg { width: 74px; height: 74px; }
.medal-btn span { font-size: 13px; line-height: 1.3; font-weight: 600; }
.medal-btn.locked span { color: var(--muted); font-weight: 500; }
.medal-btn .mini-prog { width: 54px; height: 4px; border-radius: 9px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: -4px; }
.medal-btn .mini-prog i { display: block; height: 100%; background: var(--muted); }
.history { padding: 10px var(--pad); }
.h-item { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--faint); }
.h-item:last-child { border-bottom: 0; }
.h-item img { width: 34px; height: 34px; }
.h-item div { flex: 1; min-width: 0; }
.h-item b { display: block; font-size: 16px; }
.h-item small { color: var(--muted); font-size: 14px; }
.h-item .xp { font-family: var(--display); font-size: 14px; color: var(--yellow); white-space: nowrap; }
.h-item .xp.partial { color: var(--muted); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* ---------- Ajustes ---------- */
.row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--faint); }
.row:last-of-type { border-bottom: 0; }
.row > span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.row small { color: var(--muted); font-size: 14px; }
.row input[type=range] { flex: 2; accent-color: var(--red); height: 30px; }
.vol-val { min-width: 48px; text-align: right; font-family: var(--display); font-weight: 400; font-size: 15px; }
.switch {
  appearance: none; -webkit-appearance: none;
  width: 54px; height: 32px; border-radius: 99px; flex: none;
  background: rgba(255,255,255,.14); position: relative; cursor: pointer;
  transition: background .25s;
}
.switch::after {
  content: ''; position: absolute; top: 4px; left: 4px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  transition: transform .25s var(--ease);
}
.switch:checked { background: var(--red); }
.switch:checked::after { transform: translateX(22px); }
.test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.donate p { margin: 0 0 22px; }
.donate a.btn { text-decoration: none; }
.donate .copy-link { margin-top: 12px; }
.donate small { display: block; text-align: center; margin-top: 12px; font-size: 14px; }
.res-donate {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 18px; color: var(--muted); font-size: 14px; text-decoration: none;
}
.res-donate:hover { color: var(--ink); }
.res-donate .i { width: 16px; height: 16px; color: var(--red); }
.test-grid .btn { padding: 0 12px; white-space: nowrap; }

/* ---------- Barra de pestañas ---------- */
.tabbar {
  position: fixed; z-index: 20;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(calc(100% - 28px), 520px);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px; border-radius: 24px;
  background: var(--glass-strong);
}
.tab {
  border: 0; background: none; border-radius: 17px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 4px; font-size: 12px; font-weight: 600; color: var(--muted);
  transition: color .2s, background .2s;
}
.tab .i { width: 22px; height: 22px; }
.tab.active { color: #fff; background: var(--red); }

/* ---------- Pantalla de entrenamiento ---------- */
.workout {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  padding: calc(22px + env(safe-area-inset-top)) 22px calc(26px + env(safe-area-inset-bottom));
  background: var(--red); color: #fff;
  transition: background .5s ease;
  overflow: hidden;
}
.workout::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(0,0,0,.28) 1.2px, transparent 1.7px);
  background-size: 10px 10px;
  -webkit-mask-image: linear-gradient(180deg, transparent 40%, #000);
  mask-image: linear-gradient(180deg, transparent 40%, #000);
}
.workout::after {
  /* pulso blanco de los últimos 10 s */
  content: ''; position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none;
}
.workout.flash::after { animation: flash .6s ease-out; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
.workout.ph-prep { background: var(--yellow); color: #111; }
.workout.ph-rest { background: #0e1a22; color: var(--ink); }
.workout.ph-rest .wo-time { color: var(--cyan); }
.workout.ph-work.final .wo-time { color: #fff; text-shadow: 0 0 40px rgba(255,255,255,.5), 5px 5px 0 #000; }
.wo-kanji {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  writing-mode: vertical-rl; font-family: var(--jp); font-weight: 900;
  font-size: min(22vh, 30vw); line-height: 1; opacity: .13; pointer-events: none;
}
.wo-top { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; letter-spacing: .06em; text-transform: uppercase; }
.wo-round { font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: .02em; }
.wo-center { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px; }
.wo-phase { font-family: var(--display); font-size: clamp(26px, 7vw, 44px); letter-spacing: .04em; }
.wo-time {
  font-family: var(--display); line-height: 1;
  font-size: clamp(96px, 30vw, 300px);
  text-shadow: 5px 5px 0 rgba(0,0,0,.55);
  display: flex; justify-content: center;
}
.ph-prep .wo-time { text-shadow: 5px 5px 0 rgba(0,0,0,.18); }
.wo-time .dg { display: inline-block; width: .8em; text-align: center; }
.wo-time .cl { display: inline-block; width: .38em; text-align: center; }
.wo-task { font-size: clamp(22px, 5.4vw, 32px); font-weight: 700; line-height: 1.25; max-width: 18em; margin-top: 10px; }
.wo-next { opacity: .75; font-size: 16px; margin-top: 6px; }
.wo-progress { position: relative; display: flex; gap: 4px; margin: 18px 0 26px; height: 8px; }
.wo-progress i { flex: 1; border-radius: 9px; background: rgba(0,0,0,.25); }
.ph-rest .wo-progress i { background: rgba(255,255,255,.12); }
.wo-progress i.done { background: currentColor; opacity: .9; }
.wo-progress i.now { background: currentColor; opacity: .45; }
.wo-controls { position: relative; display: flex; justify-content: center; align-items: center; gap: 28px; }
.wo-btn {
  width: 70px; height: 70px; border-radius: 50%;
  border: 2px solid currentColor; background: rgba(0,0,0,.18); color: inherit;
  display: grid; place-items: center;
  transition: transform .12s;
}
.wo-btn:active { transform: scale(.92); }
.wo-btn .i { width: 28px; height: 28px; }
.wo-main { width: 104px; height: 104px; background: #111; color: #fff; border-color: #111; }
.ph-rest .wo-main { background: var(--cyan); color: #0e1a22; border-color: var(--cyan); }
.wo-main .i { width: 40px; height: 40px; stroke-width: 2.4; }
.wo-paused {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--display); font-size: 64px; letter-spacing: .06em;
  background: rgba(0,0,0,.55); color: #fff; pointer-events: none;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}

/* ---------- Resultado ---------- */
.result {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 20px;
  background: rgba(0,0,0,.6);
  animation: fadeIn .3s ease;
  overflow-y: auto;
}
.result-inner {
  width: min(100%, 460px); border-radius: 28px; padding: 40px 30px 30px;
  text-align: center; background: var(--glass-strong);
  animation: popIn .5s var(--ease);
}
.result-inner h2 { font-family: var(--display); font-weight: 400; font-size: 30px; margin: 18px 0 8px; }
.check-draw { width: 92px; height: 92px; fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.check-draw circle { stroke: var(--green); stroke-dasharray: 145; stroke-dashoffset: 145; animation: draw .7s .1s var(--ease) forwards; }
.check-draw path { stroke: var(--ink); stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .45s .65s var(--ease) forwards; }
.result.partial .check-draw circle { stroke: var(--yellow); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 28px 0; }
.res-stats div { background: rgba(255,255,255,.05); border-radius: var(--r-sm); padding: 16px 6px; }
.res-stats b { display: block; font-family: var(--display); font-weight: 400; font-size: 22px; }
.res-stats span { font-size: 13px; color: var(--muted); }
.res-ach { display: flex; flex-direction: column; gap: 12px; margin-bottom: 26px; text-align: left; }
.res-ach:empty { display: none; }
.res-ach .ra { display: flex; align-items: center; gap: 14px; background: rgba(245,197,24,.08); border: 1px solid rgba(245,197,24,.25); padding: 10px 14px; border-radius: var(--r-sm); }
.res-ach .ra svg { width: 46px; height: 46px; flex: none; }
.res-ach .ra small { display: block; color: var(--muted); font-size: 13px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(14px); } }

/* ---------- Hoja modal ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease;
}
.sheet {
  width: min(100%, 480px);
  border-radius: 28px 28px 0 0;
  padding: 34px 28px calc(28px + env(safe-area-inset-bottom));
  background: var(--glass-strong);
  animation: sheetUp .4s var(--ease);
  text-align: center;
}
@media (min-width: 640px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 28px; padding-bottom: 28px; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { font-family: var(--display); font-weight: 400; font-size: 24px; margin: 14px 0 10px; line-height: 1.15; }
.sheet p { color: var(--muted); margin: 0 0 8px; }
.sheet .big-medal { width: 120px; height: 120px; }
.sheet .tier { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.sheet .prog { margin: 18px auto 0; max-width: 260px; }
.sheet .btn-row { margin-top: 28px; }
.sheet input[type=text] {
  width: 100%; margin-top: 18px; min-height: 54px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--glass-border); background: rgba(255,255,255,.07);
  font-size: 17px;
}
.sheet input[type=text]:focus { outline: 2px solid var(--red); border-color: transparent; }

/* ---------- Avisos (toasts) ---------- */
.toasts {
  position: fixed; z-index: 100;
  top: calc(14px + env(safe-area-inset-top)); right: 14px;
  width: min(380px, calc(100% - 28px));
  display: flex; flex-direction: column; gap: 12px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px 18px; border-radius: 18px;
  background: rgba(22, 22, 22, .78);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  animation: toastIn .5s var(--ease);
}
.toast.out { animation: toastOut .35s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(110%); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(110%); } }
.toast .ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.toast .ico svg.i { width: 20px; height: 20px; }
.toast .ico svg.medal { width: 36px; height: 36px; }
.toast b { display: block; font-size: 15px; line-height: 1.3; }
.toast small { display: block; color: var(--muted); font-size: 14px; line-height: 1.35; margin-top: 2px; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: bar linear forwards; }
@keyframes bar { to { transform: scaleX(0); } }
.toast.success .ico { background: rgba(60, 207, 122, .16); color: var(--green); }
.toast.success .bar { background: var(--green); }
.toast.warn .ico { background: rgba(245, 197, 24, .16); color: var(--yellow); }
.toast.warn .bar { background: var(--yellow); }
.toast.error .ico { background: rgba(227, 52, 47, .18); color: #ff6b66; }
.toast.error .bar { background: var(--red); }
.toast.info .ico { background: rgba(60, 198, 242, .16); color: var(--cyan); }
.toast.info .bar { background: var(--cyan); }
.toast.ach .ico { background: none; }
.toast.ach .bar { background: var(--yellow); }

.confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; width: 100%; height: 100%; }

@media (max-width: 420px) {
  :root { --pad: 22px; --gap: 40px; }
  .level-card { flex-direction: column; text-align: center; }
  .stepper { gap: 10px; }
  .stepper-label { gap: 9px; font-size: 16px; }
  .stepper-ctrl { gap: 6px; }
  .step-val { min-width: 62px; font-size: 18px; }
  .step-btn { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
