/* Archivo variable (Google Fonts, OFL), alojada en el repo: peso 100-900 y ancho 62-125 */
@font-face {
  font-family: 'Archivo';
  src: url('fonts/archivo-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --rubber: #121212;
  --rubber-2: #1a1a1a;
  --rubber-3: #222221;
  --line: #2f2f2d;
  --chalk: #eeebe4;
  --chalk-2: #cbc7be;
  --chalk-3: #9c988f;

  --red: #cf2a2e;
  --blue: #1d55c4;
  --yellow: #f1c21b;
  --green: #1e7a3e;
  --white: #ece8df;
  --steel: #8f989f;
  --ink-dark: #141414;
  --ink-light: #fff6ee;

  --lit: #ffffff;
  --nolift: #ff3b30;

  --top-h: 47px;
  --rail-w: 62px;
  --gutter: 18px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --flecks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Ccircle cx='45.3' cy='21.1' r='0.6' fill='%233a3a3a'/%3E%3Ccircle cx='115.0' cy='13.2' r='1.1' fill='%233a3a3a'/%3E%3Ccircle cx='127.4' cy='30.1' r='0.6' fill='%23353535'/%3E%3Ccircle cx='58.5' cy='33.7' r='1.1' fill='%23353535'/%3E%3Ccircle cx='8.3' cy='79.2' r='0.7' fill='%232f4d3a'/%3E%3Ccircle cx='132.7' cy='80.8' r='1.0' fill='%233a3a3a'/%3E%3Ccircle cx='136.7' cy='6.5' r='0.7' fill='%23553331'/%3E%3Ccircle cx='58.7' cy='75.7' r='1.1' fill='%23553331'/%3E%3Ccircle cx='78.4' cy='95.5' r='0.6' fill='%232f4d3a'/%3E%3Ccircle cx='80.0' cy='26.3' r='0.6' fill='%232f4d3a'/%3E%3Ccircle cx='99.7' cy='79.0' r='1.1' fill='%23304463'/%3E%3Ccircle cx='69.5' cy='74.4' r='0.8' fill='%23353535'/%3E%3Ccircle cx='82.0' cy='63.4' r='0.8' fill='%23304463'/%3E%3Ccircle cx='111.2' cy='97.9' r='0.7' fill='%233a3a3a'/%3E%3Ccircle cx='80.4' cy='73.5' r='0.8' fill='%23353535'/%3E%3Ccircle cx='40.3' cy='137.2' r='0.6' fill='%232f4d3a'/%3E%3Ccircle cx='58.5' cy='106.0' r='0.7' fill='%23353535'/%3E%3Ccircle cx='59.0' cy='134.7' r='0.6' fill='%232f4d3a'/%3E%3Ccircle cx='80.2' cy='122.6' r='0.8' fill='%23553331'/%3E%3Ccircle cx='97.3' cy='83.2' r='1.1' fill='%23353535'/%3E%3Ccircle cx='9.6' cy='13.1' r='0.8' fill='%23353535'/%3E%3Ccircle cx='97.6' cy='9.1' r='0.8' fill='%232f4d3a'/%3E%3Ccircle cx='139.0' cy='115.1' r='0.8' fill='%23353535'/%3E%3Ccircle cx='124.2' cy='48.6' r='1.0' fill='%23553331'/%3E%3Ccircle cx='23.5' cy='16.4' r='0.6' fill='%23304463'/%3E%3Ccircle cx='107.6' cy='18.1' r='0.7' fill='%23353535'/%3E%3Ccircle cx='54.7' cy='122.0' r='0.6' fill='%23304463'/%3E%3Ccircle cx='62.9' cy='76.9' r='0.7' fill='%23353535'/%3E%3Ccircle cx='121.0' cy='39.0' r='1.0' fill='%23553331'/%3E%3Ccircle cx='95.6' cy='53.3' r='0.7' fill='%23304463'/%3E%3Ccircle cx='11.6' cy='21.2' r='0.7' fill='%233a3a3a'/%3E%3Ccircle cx='67.9' cy='82.5' r='0.8' fill='%23553331'/%3E%3Ccircle cx='0.6' cy='58.7' r='0.8' fill='%232f4d3a'/%3E%3Ccircle cx='79.3' cy='133.4' r='1.1' fill='%232f4d3a'/%3E%3Ccircle cx='91.7' cy='103.6' r='1.0' fill='%232f4d3a'/%3E%3Ccircle cx='54.9' cy='55.9' r='0.6' fill='%23353535'/%3E%3Ccircle cx='88.8' cy='8.7' r='0.6' fill='%23304463'/%3E%3Ccircle cx='61.7' cy='15.4' r='1.1' fill='%233a3a3a'/%3E%3Ccircle cx='14.3' cy='79.3' r='1.1' fill='%233a3a3a'/%3E%3Ccircle cx='132.9' cy='85.9' r='0.6' fill='%23304463'/%3E%3Ccircle cx='86.0' cy='20.8' r='0.8' fill='%23553331'/%3E%3Ccircle cx='84.3' cy='66.4' r='0.6' fill='%23353535'/%3E%3Ccircle cx='139.0' cy='65.2' r='1.0' fill='%23553331'/%3E%3Ccircle cx='12.0' cy='14.3' r='0.8' fill='%23553331'/%3E%3Ccircle cx='67.0' cy='96.9' r='1.1' fill='%233a3a3a'/%3E%3Ccircle cx='28.7' cy='133.3' r='0.8' fill='%23304463'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--rubber);
  color: var(--chalk);
  font-family: 'Archivo', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--yellow); color: var(--ink-dark); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--chalk); outline-offset: 3px; }
p, h1, h2, h3, ol, ul { margin: 0; padding: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barra fija: fila de repeticiones + filtros ---------- */
.top {
  position: fixed; z-index: 10; top: 0; left: 0; right: 0;
  padding: env(safe-area-inset-top) 0 0;
  background: var(--rubber);
  border-bottom: 1px solid var(--line);
}
.rack {
  display: flex; align-items: center; gap: 14px;
  height: 46px; padding: 0 var(--gutter);
}
.pips {
  list-style: none; display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px;
  flex: 1; min-width: 0;
}
.pip {
  height: 14px; border-radius: 2px;
  background: var(--rubber-3);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6);
  transition: background-color .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
.pip.is-done { background: #4a4844; box-shadow: none; }
.pip.is-cur { background: var(--chalk-3); box-shadow: 0 0 0 1px var(--chalk-3); }
.pip.is-ok { background: var(--lit); box-shadow: none; }
.pip.is-no { background: var(--nolift); box-shadow: none; }
.meta {
  display: flex; gap: 12px; flex: none;
  font-size: 11px; font-weight: 600; font-stretch: 112%;
  letter-spacing: .12em; text-transform: uppercase; color: var(--chalk-3);
  font-variant-numeric: tabular-nums;
}
.meta b { color: var(--chalk); font-weight: 800; }

.focus-on {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 8px 0 10px; border-radius: 4px;
  background: var(--chalk); color: var(--ink-dark); border: 0;
  font-size: 11px; font-weight: 800; font-stretch: 108%; letter-spacing: .08em; text-transform: uppercase;
}
.focus-on[hidden] { display: none; }
.focus-on i { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.focus-on svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------- Feed ---------- */
#feed {
  position: fixed; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  touch-action: manipulation;
}
#feed::-webkit-scrollbar { display: none; }

.card {
  --plate: var(--red); --on-plate: var(--ink-light);
  position: relative;
  height: 100vh; height: 100dvh;
  scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column;
  padding-top: calc(var(--top-h) + env(safe-area-inset-top));
  background: var(--rubber) var(--flecks);
  overflow: hidden;
}
.card[data-plate="red"] { --plate: var(--red); --on-plate: var(--ink-light); }
.card[data-plate="blue"] { --plate: var(--blue); --on-plate: var(--ink-light); }
.card[data-plate="yellow"] { --plate: var(--yellow); --on-plate: var(--ink-dark); }
.card[data-plate="green"] { --plate: var(--green); --on-plate: var(--ink-light); }
.card[data-plate="white"] { --plate: var(--white); --on-plate: var(--ink-dark); }
.card[data-plate="steel"] { --plate: var(--steel); --on-plate: var(--ink-dark); }

/* El disco: banda de pintura plana con el borde inferior en arco */
.plate {
  position: relative; flex: none;
  background: var(--plate); color: var(--on-plate);
  padding: 16px var(--gutter) 26px;
  border-radius: 0 0 50% 50% / 0 0 22px 22px;
}
.tag { display: flex; justify-content: flex-end; margin-bottom: -4px; }
.sub {
  display: inline-block; margin-left: 4px; padding: 1px 7px; vertical-align: 2px;
  border: 1.5px solid currentColor; border-radius: 3px;
  font-size: 12px; font-weight: 700; font-stretch: 104%; letter-spacing: .02em; white-space: nowrap;
}
.badge {
  padding: 3px 7px 2px; border-radius: 3px;
  background: var(--on-plate); color: var(--plate);
  letter-spacing: .1em; font-size: 10px;
}
.stamp {
  margin: 12px 0 6px;
  font-size: 84px; font-weight: 900; font-stretch: 75%;
  line-height: .88; letter-spacing: -.01em;
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: normal; hyphens: none;
}
.stamp.is-strike { text-decoration: line-through; text-decoration-thickness: .09em; }
.stamp-q {
  margin: 12px 0 4px;
  font-size: 27px; font-weight: 800; font-stretch: 88%;
  line-height: 1.12; letter-spacing: -.005em;
  text-wrap: balance;
}
.gloss { font-size: 18px; line-height: 1.35; font-weight: 500; }
.gloss s { opacity: .75; }

/* Caja de luces de juez */
.lights {
  display: inline-flex; gap: 7px; padding: 6px 8px;
  background: var(--ink-dark); border-radius: 12px;
}
.light {
  width: 12px; height: 12px; border-radius: 50%;
  background: #2c2c2b; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .8);
  transition: background-color .18s, box-shadow .18s;
}
.light.is-white { background: var(--lit); box-shadow: 0 0 10px 2px rgba(255, 255, 255, .75); }
.light.is-red { background: var(--nolift); box-shadow: 0 0 10px 2px rgba(255, 59, 48, .8); }
.light.is-flat { background: var(--chalk); box-shadow: none; }

/* ---------- Suelo (cuerpo de la tarjeta) ---------- */
.body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px calc(var(--rail-w) + 6px) calc(28px + env(safe-area-inset-bottom)) var(--gutter);
  overflow-y: auto; scrollbar-width: none;
}
.body::-webkit-scrollbar { display: none; }
.card:not(:has(.rail)) .body { padding-right: var(--gutter); }
/* Repeticiones y revelados: el contenido baja a la zona del pulgar */
.card[data-kind="pick"] .body > :first-child,
.card[data-kind="upgrade"] .body > :first-child { margin-top: auto; }
.card[data-kind="syn"] .stamp { font-size: 60px; margin-top: 8px; }
.nw { white-space: nowrap; }
.stamp .blank { display: inline-block; width: 1.3em; height: .1em; margin-left: .06em; background: currentColor; vertical-align: .02em; }
.label {
  display: block; margin-bottom: 7px;
  font-size: 11px; font-weight: 700; font-stretch: 112%;
  letter-spacing: .14em; text-transform: uppercase; color: var(--chalk-3);
}
.pattern {
  padding: 11px 13px;
  background: var(--rubber-2); border: 1px solid var(--line); border-radius: 4px;
  font-size: 17px; font-weight: 600; font-stretch: 90%; line-height: 1.35;
  color: var(--chalk);
}
.pattern i { font-style: normal; color: var(--chalk-3); }
.ex { font-size: 21px; line-height: 1.38; font-weight: 450; color: var(--chalk-2); }
.ex-sm { font-size: 18px; }
mark {
  background: none; color: var(--lit); font-weight: 700;
  text-decoration: underline; text-decoration-color: var(--plate);
  text-decoration-thickness: 3px; text-underline-offset: 4px;
  text-decoration-skip-ink: none;
}
.why p { font-size: 16px; line-height: 1.5; color: var(--chalk-2); max-width: 62ch; }
.note { font-size: 15px; line-height: 1.45; color: var(--chalk-3); }

/* Lista de alternativas (sinónimos) */
.alts { list-style: none; display: grid; gap: 14px; }
.alt { display: grid; gap: 2px; padding-left: 12px; border-left: 1px solid var(--line); }
.alt b { font-size: 20px; font-weight: 800; font-stretch: 92%; color: var(--chalk); line-height: 1.2; }
.alt small { font-size: 13px; color: var(--chalk-3); }
.alt span { font-size: 15px; line-height: 1.4; color: var(--chalk-2); }
.alt span mark { text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* Escala: discos apilados de mayor a menor */
.stack { list-style: none; display: grid; gap: 6px; }
.stack li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  width: var(--w); min-width: 62%;
  padding: 9px 12px; border-radius: 4px;
  background: var(--plate); color: var(--on-plate);
}
.stack b { font-size: 17px; font-weight: 800; font-stretch: 90%; }
.stack small { font-size: 12px; font-weight: 600; opacity: .85; text-align: right; }

/* Debate */
.sides { display: grid; gap: 14px; }
.side p { font-size: 17px; line-height: 1.42; color: var(--chalk-2); }

/* ---------- Repeticiones (quiz) ---------- */
.q { font-size: 22px; line-height: 1.42; font-weight: 500; color: var(--chalk); }
.gap {
  display: inline-block; min-width: 3.4em; height: 1.05em; vertical-align: -.12em;
  border-bottom: 3px solid var(--plate);
}
.gap.is-filled { min-width: 0; height: auto; border: 0; vertical-align: baseline; }
.opts { display: grid; gap: 9px; }
.opt {
  display: flex; align-items: center; min-height: 54px;
  padding: 12px 15px; text-align: left;
  background: var(--rubber-2); border: 1px solid var(--line); border-radius: 4px;
  font-size: 18px; font-weight: 650; font-stretch: 94%; line-height: 1.3;
  transition: background-color .2s var(--ease-out), color .2s, border-color .2s, box-shadow .3s, opacity .2s;
}
.opt.is-sentence { font-size: 16px; font-weight: 500; font-stretch: 100%; line-height: 1.4; }
.opt.is-punct { font-size: 24px; font-weight: 800; letter-spacing: .04em; white-space: pre; }
.opt:active { background: var(--rubber-3); }
.opt.is-right {
  background: var(--lit); border-color: var(--lit); color: var(--ink-dark);
  box-shadow: 0 0 22px rgba(255, 255, 255, .28);
}
.opt.is-wrong { border-color: var(--nolift); color: var(--chalk-3); text-decoration: line-through; text-decoration-color: var(--nolift); }
.opt.is-dim { opacity: .38; }
.opt:disabled { cursor: default; }

.reveal {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 20px;
  background: var(--plate); color: var(--on-plate);
  border: 0; border-radius: 4px;
  font-size: 15px; font-weight: 800; font-stretch: 108%; letter-spacing: .08em; text-transform: uppercase;
}
.reveal:active { filter: brightness(.92); }

/* La hoja que se pega encima de las opciones: plana, la superposición es la única profundidad */
.paste {
  display: none;
  position: absolute; z-index: 1; left: 0; right: 0; bottom: 0;
  max-height: 68%; overflow-y: auto; scrollbar-width: none;
  padding: 18px calc(var(--rail-w) + 6px) calc(26px + env(safe-area-inset-bottom)) var(--gutter);
  background: var(--rubber-3);
  border-top: 3px solid var(--plate);
}
.paste::-webkit-scrollbar { display: none; }
.paste > * + * { margin-top: 14px; }
.paste .answer { font-size: 20px; line-height: 1.4; font-weight: 600; color: var(--lit); }
.is-done .paste { display: block; animation: paste .5s var(--ease-out) .6s both; }
.card[data-kind="upgrade"].is-done .paste, .card[data-kind="debate"].is-done .paste { animation-delay: 0s; }
@keyframes paste { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- Riel de acciones ---------- */
.rail {
  position: absolute; z-index: 2; right: 8px; bottom: calc(22px + env(safe-area-inset-bottom));
  display: grid; gap: 12px; justify-items: center;
}
.act {
  display: grid; justify-items: center; gap: 3px;
  background: none; border: 0; padding: 0; color: var(--chalk);
}
.act span.ring {
  width: 46px; height: 46px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--rubber-2); border: 1px solid var(--line);
  transition: transform .25s var(--ease-out), background-color .2s;
}
.act:active span.ring { transform: scale(.9); }
.act svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.act small { font-size: 10px; font-weight: 700; font-stretch: 108%; letter-spacing: .08em; text-transform: uppercase; color: var(--chalk-3); }
.act[aria-pressed="true"] svg { fill: var(--chalk); }
.act[aria-pressed="true"] span.ring { background: var(--rubber-3); }

/* ---------- Tarjetas especiales ---------- */
.steps { list-style: none; display: grid; gap: 16px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: start; font-size: 17px; line-height: 1.42; color: var(--chalk-2); }
.steps .lights { margin-top: 3px; justify-self: start; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.legend li { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--chalk-2); }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
.note b { color: var(--chalk); }
.steps svg { width: 26px; height: 26px; fill: none; stroke: var(--chalk); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.steps b { color: var(--chalk); }
.tally { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.tally i { height: 34px; border-radius: 3px; background: var(--rubber-3); box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.tally i.is-ok { background: var(--lit); box-shadow: none; }
.tally i.is-no { background: var(--nolift); box-shadow: none; }
.tally i.is-done { background: #4a4844; box-shadow: none; }
.big-num { font-size: 64px; font-weight: 900; font-stretch: 75%; line-height: .9; color: var(--chalk); font-variant-numeric: tabular-nums; }
.stat-row { display: flex; gap: 28px; }
.focus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pad {
  display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px;
  background: var(--rubber-2); border: 1px solid var(--line); border-radius: 4px;
  font-size: 14px; font-weight: 650; font-stretch: 94%; text-align: left; color: var(--chalk);
}
.pad i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
.pad small { margin-left: auto; font-size: 12px; color: var(--chalk-3); font-variant-numeric: tabular-nums; }
.pad[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--ink-dark); }
.pad[aria-pressed="true"] small { color: var(--ink-dark); }
.stat-row .label { margin: 6px 0 0; }

.hint {
  position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--chalk-3);
  animation: nudge 1.8s var(--ease-out) .8s 3;
}
.hint svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 40% { transform: translate(-50%, -6px); } }

/* Nube de tiza al guardar con doble toque */
.chalk { position: fixed; z-index: 20; pointer-events: none; width: 0; height: 0; }
.chalk i {
  position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%;
  background: rgba(238, 235, 228, .9); filter: blur(1.5px);
  animation: puff .7s var(--ease-out) forwards;
}
@keyframes puff {
  from { transform: translate(0, 0) scale(.6); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(1.8); opacity: 0; }
}

.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0;
  padding: 11px 16px; border-radius: 4px;
  background: var(--chalk); color: var(--ink-dark);
  font-size: 14px; font-weight: 700; white-space: nowrap;
  transition: opacity .25s, transform .35s var(--ease-out);
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Pantallas bajas: comprime sin perder la jerarquía */
@media (max-height: 720px) {
  .stamp { font-size: 56px; }
  .card[data-kind="syn"] .stamp { font-size: 46px; }
  .plate { padding-bottom: 20px; }
  .stamp-q { font-size: 23px; }
  .ex { font-size: 19px; }
  .q { font-size: 20px; }
  .opt { min-height: 48px; padding: 10px 13px; font-size: 17px; }
  .body { gap: 14px; padding-top: 16px; }
  .gloss { font-size: 16px; }
  .alts { gap: 10px; }
  .alt span { font-size: 14px; }
}

/* Escritorio: no es el objetivo, se centra como un móvil */
@media (min-width: 600px) {
  body { background: #0b0b0b; }
  #feed, .top { left: 50%; right: auto; width: 440px; transform: translateX(-50%); }
  #feed { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #feed { scroll-behavior: auto; }
}
