/*
  Tablita: Spanish vocabulary app built on lotería (Screenery template)
  The page is printed card stock: cream paper, black key lines, flat inks a hair off register, papel picado strung across the top.
  The round sits in the first screen (caller left, tabla right); below it the words list, the rules on a box lid,
  the deck, the level road, the classroom on a blue ground, plans and sign-up, questions, and an ink footer.

  Contents
   1. Tokens
   2. Base and browser surfaces
   3. The printed card (.lc) and its two-pass drawing
   4. Kit: buttons, switch, chips, fields, alerts
   5. Header and papel picado
   6. The round: intro, caller, tabla, beans, status, cantadas
   7. Words list
   8. How a round goes
   9. Deck browser
  10. Level road
  11. Classroom
  12. Plans and sign-up
  13. Questions, footer
  14. Motion
  15. Narrow screens
*/

/* ---------- 1. Tokens ---------- */
:root {
  /* paper and ink */
  --paper: #f3e4c4;
  --paper-2: #fbf3df;
  --paper-3: #ead7af;
  --ink: #1b1512;
  --ink-2: #4b3a2d;

  /* the flat inks of the print run */
  --red: #c8352b;
  --red-deep: #a82b23;
  --rosa: #d6336c;
  --yellow: #f2b632;
  --green: #2d7d46;
  --green-deep: #24653a;
  --lime: #a9c94e;
  --blue: #2b5fa8;
  --blue-deep: #24508e;
  --teal: #3aa6a0;
  --orange: #e8742a;
  --brown: #8a5634;

  /* pale grounds behind the card drawings */
  --gr-cream: #f7ecd2;
  --gr-rose: #f7d5d8;
  --gr-sky: #d3e6ef;
  --gr-mint: #d8ebd3;
  --gr-butter: #f7e3a8;

  /* feedback tints */
  --good: #d8ebd3;
  --bad: #f7d5d8;
  --warn: #f7e3a8;
  --bad-ink: #9a2620;

  /* the colour classes the card art uses */
  --cr: var(--red); --cy: var(--yellow); --cg: var(--green); --cl: var(--lime); --cb: var(--blue);
  --ct: var(--teal); --cp: var(--rosa); --co: var(--orange); --cn: var(--brown); --cw: var(--paper-2); --ck: var(--ink);
  --line: var(--ink);

  /* type */
  --display: 'Ultra', 'Rockwell Extra Bold', serif;
  --text: 'Atkinson Hyperlegible Next', system-ui, sans-serif;

  /* space, radius, depth */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px; --s9: 112px;
  --gutter: clamp(16px, 4vw, 48px);
  --r-card: 6px;
  --r-box: 10px;
  --lift: 0 2px 4px rgb(27 21 18 / .12), 0 10px 24px -8px rgb(27 21 18 / .28);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --page: 1280px;
}

/* ---------- 2. Base and browser surfaces ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font: 400 17px/1.55 var(--text);
  color: var(--ink);
  background-color: var(--paper);
  /* card stock: a little fibre and a few flecks */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .3 0 0 0 0 .18 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  accent-color: var(--red);
  caret-color: var(--red);
  scrollbar-color: var(--ink-2) var(--paper-3);
  overflow-x: clip;
}
::selection { background: var(--yellow); color: var(--ink); }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: .2em; text-decoration-color: var(--rosa); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.04; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(1.9rem, 1.2rem + 2.4vw, 3.1rem); }
p { margin: 0; text-wrap: pretty; }
em { font-style: italic; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: var(--s4); top: -60px; z-index: 50; background: var(--ink); color: var(--paper-2); padding: 10px 14px; border-radius: 6px; }
.skip:focus { top: var(--s3); }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
section { position: relative; }

/* ---------- 3. The printed card ---------- */
/* Outer white margin, a black frame line, a pale ground, the number top left, the name in a band at the bottom. */
.lc {
  --gr: var(--gr-cream);
  container-type: inline-size;
  position: relative;
  display: block;
  aspect-ratio: 5 / 7;
  width: 100%;
  background: var(--paper-2);
  border: 1.5px solid var(--ink);
  border-radius: var(--r-card);
  color: var(--ink);
  overflow: hidden;
}
.lc--rose { --gr: var(--gr-rose); }
.lc--sky { --gr: var(--gr-sky); }
.lc--mint { --gr: var(--gr-mint); }
.lc--butter { --gr: var(--gr-butter); }
.lc::before {
  content: ""; position: absolute; inset: 5%; border: 2px solid var(--ink); border-radius: 3px;
  background:
    radial-gradient(circle at 30% 20%, rgb(255 255 255 / .35), transparent 60%),
    var(--gr);
}
.lc-num {
  position: absolute; z-index: 1; top: 7%; left: 10%;
  font: 400 max(11px, 13cqi)/1 var(--display);
}
.lc-art { position: absolute; z-index: 1; left: 12%; right: 12%; top: 15%; width: 76%; height: auto; aspect-ratio: 1; overflow: visible; }
.lc-name {
  position: absolute; z-index: 1; left: calc(5% + 2px); right: calc(5% + 2px); bottom: calc(5% + 2px); height: 20%;
  display: grid; place-items: center; padding: 0 4%;
  border-top: 2px solid var(--ink);
  background: var(--paper-2);
  font: 800 max(11px, 9cqi)/1 var(--text);
  text-transform: uppercase; letter-spacing: .02em; text-align: center; text-wrap: balance;
  border-radius: 0 0 2px 2px;
}
@container (min-width: 140px) {
  .lc-name { font: 400 7.6cqi/1.05 var(--display); letter-spacing: .01em; }
}

/* Two passes of one drawing: colour plate nudged off register (x/y on the use), then the key line on top. */
.ln { stroke: var(--line); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.r { fill: var(--cr); } .y { fill: var(--cy); } .g { fill: var(--cg); } .l { fill: var(--cl); } .b { fill: var(--cb); }
.t { fill: var(--ct); } .p { fill: var(--cp); } .o { fill: var(--co); } .n { fill: var(--cn); } .w { fill: var(--cw); } .k { fill: var(--ck); }
.s { fill: none; }
.handle { stroke-width: 5; }
.frame { fill: none; stroke: var(--cr); stroke-width: 5.5; }
.lc-f { --line: transparent; --ck: transparent; mix-blend-mode: multiply; }
.lc-l { --cr: transparent; --cy: transparent; --cg: transparent; --cl: transparent; --cb: transparent; --ct: transparent;
        --cp: transparent; --co: transparent; --cn: transparent; --cw: transparent; }

/* ---------- 4. Kit ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); flex-wrap: wrap;
  min-height: 46px; padding: 9px 16px;
  border: 2px solid var(--ink); border-radius: 7px;
  background: var(--paper-2); color: var(--ink);
  font-weight: 750; font-size: 16px; line-height: 1.1; text-decoration: none; text-align: center;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background-color .2s;
}
.btn small { display: block; width: 100%; font-size: 12.5px; font-weight: 500; opacity: .92; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--lift); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--red { background: var(--red-deep); color: var(--paper-2); flex-direction: column; gap: 2px; }
.btn--ink { background: var(--ink); color: var(--paper-2); }
.btn--paper[aria-pressed="true"] { background: var(--ink); color: var(--paper-2); }
.btn--big { min-height: 56px; font-size: 18px; width: 100%; }
.linkish { border: 0; padding: 0; background: none; font-weight: 750; text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); border: 0; padding: 0; margin: 0; min-width: 0; }
.chips legend { width: 100%; padding: 0; margin-bottom: var(--s2); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 7px 14px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2);
  font-weight: 700; font-size: 15px;
  transition: background-color .2s, color .2s;
}
.chip input:checked + span { background: var(--ink); color: var(--paper-2); }
.chip input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 3px; }
.chip:hover input:not(:checked) + span { background: var(--gr-butter); }

.switch { width: 52px; height: 30px; padding: 3px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-3); flex: none; }
.switch span { display: block; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .25s var(--ease); }
.switch[aria-checked="true"] { background: var(--yellow); }
.switch[aria-checked="true"] span { transform: translateX(22px); }

/* ---------- 5. Header and papel picado ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 2px solid var(--ink); }
.top-in { max-width: var(--page); margin: 0 auto; padding: 10px var(--gutter); display: flex; align-items: center; gap: var(--s5); }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 400 1.5rem/1 var(--display); }
.logo-card { width: 26px; height: 35px; }
.logo-card rect:first-child { fill: var(--paper-2); stroke: var(--ink); stroke-width: 2.4; }
.logo-band { fill: var(--rosa); }
.logo-sun { fill: var(--yellow); stroke: var(--ink); stroke-width: 2; }
.nav { display: flex; gap: var(--s5); margin-left: auto; font-weight: 700; font-size: 15px; }
.nav a { text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { border-bottom-color: var(--rosa); }
.top-cta { min-height: 42px; }

/* A string of cut tissue flags. Each flag sways a little from the string. */
.picado {
  position: relative; z-index: 5; display: flex; gap: 6px; justify-content: center;
  height: 58px; overflow: hidden; pointer-events: none; padding: 0 8px;
  margin-bottom: -36px;
}
.picado::before { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 2px; background: var(--ink); opacity: .75; }
.flag { width: 44px; height: 57px; flex: none; transform-origin: 50% 3px; opacity: .93; }
.flag--p { color: var(--rosa); } .flag--o { color: var(--orange); } .flag--t { color: var(--teal); } .flag--y { color: var(--yellow); }
.flag--g { color: var(--green); } .flag--b { color: var(--blue); } .flag--r { color: var(--red); }

/* ---------- 6. The round ---------- */
.play {
  max-width: var(--page); margin: 0 auto; padding: 64px var(--gutter) var(--s7);
  display: grid; gap: var(--s5) clamp(24px, 4vw, 56px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "intro board" "caller board" "called called";
  align-items: start;
}
.play-intro { grid-area: intro; display: grid; gap: var(--s4); }
.play h1 {
  font-size: clamp(2.3rem, 1.2rem + 3.2vw, 3.7rem);
  max-width: 14ch;
  /* the rosa plate printed a hair off the black */
  text-shadow: .045em .035em 0 rgb(214 51 108 / .55);
}
.lead { max-width: 56ch; font-size: 18px; color: var(--ink-2); }

.caller {
  grid-area: caller;
  background: var(--paper-2);
  border: 2px solid var(--ink); border-radius: var(--r-box);
  box-shadow: inset 0 0 0 5px var(--paper-2), inset 0 0 0 6.5px var(--ink), var(--lift);
  padding: var(--s5);
  display: grid; gap: var(--s4);
}
.caller-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.caller-h { font-size: 1.5rem; }
.call-count { font-size: 14px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.caller-body { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--s5); align-items: center; }
.call-card { perspective: 700px; width: 112px; aspect-ratio: 5 / 7; }
.call-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s var(--ease); }
.call-card.is-up .call-inner { transform: rotateY(180deg); }
.call-back, .call-face { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; }
.call-face { transform: rotateY(180deg); }
.call-text { display: grid; gap: var(--s2); min-width: 0; }
.verse { font-size: clamp(1.15rem, 1rem + .6vw, 1.45rem); font-weight: 650; font-style: italic; line-height: 1.35; }
.verse-en { font-size: 15.5px; color: var(--ink-2); }
.caller-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.caller-actions .btn--red { min-width: 168px; }
.voice-note { font-size: 14px; color: var(--ink-2); }
.feedback {
  font-size: 15.5px; padding: var(--s3) var(--s4); border: 2px dashed var(--ink-2); border-radius: 8px; background: var(--paper);
  min-height: 3.6em;
}
.feedback[data-tone="good"] { background: var(--good); border: 2px solid var(--green-deep); }
.feedback[data-tone="bad"] { background: var(--bad); border: 2px solid var(--bad-ink); }
.feedback[data-tone="warn"] { background: var(--warn); border: 2px solid var(--brown); }

/* The tabla: a red board with its own number, sixteen cards */
.board { grid-area: board; display: grid; gap: var(--s4); }
.tabla-frame {
  position: relative;
  background: var(--red);
  border: 2.5px solid var(--ink); border-radius: 12px;
  padding: 10px 14px 14px;
  box-shadow: var(--lift);
}
.tabla-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 8px; color: var(--paper-2); font: 400 1.15rem/1 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.tabla-no { font-variant-numeric: tabular-nums; margin-right: auto; margin-left: var(--s3); }
.tabla-head { gap: var(--s2); align-items: center; }
.new-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px;
  border: 2px solid var(--ink); border-radius: 6px; background: var(--paper-2); color: var(--ink);
  font: 750 14px/1 var(--text); letter-spacing: 0; text-transform: none;
}
.new-btn .ico { width: 17px; height: 17px; }
.new-btn:hover { background: var(--yellow); }
.tabla { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.cell {
  position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: var(--r-card); background: none;
  transition: transform .2s var(--ease);
}
.cell:hover .lc { box-shadow: 0 0 0 3px var(--yellow); }
.cell:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.cell-bean { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 2; }
.bean { width: 52%; height: auto; transform: rotate(var(--turn)); filter: drop-shadow(0 3px 2px rgb(27 21 18 / .35)); }
.bean-body { fill: var(--brown); stroke: var(--ink); stroke-width: 2; }
.bean-eye { fill: none; stroke: var(--paper-2); stroke-width: 2; stroke-linecap: round; }
.bean-shine { fill: none; stroke: rgb(251 243 223 / .55); stroke-width: 1.8; stroke-linecap: round; }
.cell.is-help .bean-body { fill: #b98a5e; }
.cell.is-marked .lc { filter: saturate(.85); }
.cell.is-line .lc { box-shadow: 0 0 0 4px var(--yellow); }
.tabla.is-won .cell:not(.is-line) .lc { filter: saturate(.25) brightness(.92); }

.win {
  position: relative;
  background: var(--paper-2); border: 2.5px solid var(--ink); border-radius: var(--r-box);
  padding: var(--s4) var(--s5); display: grid; gap: var(--s2);
  box-shadow: 0 -2px 0 var(--paper-2), var(--lift);
}
.win-shout { font: 400 clamp(2rem, 1.4rem + 2vw, 2.8rem)/1 var(--display); color: var(--red-deep); text-shadow: .04em .035em 0 rgb(242 182 50 / .9); }
.win-line { font-weight: 750; }
.win-sum { font-size: 15px; color: var(--ink-2); }
.win-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }

.status { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.stats { display: flex; gap: var(--s4); margin: 0; margin-right: auto; }
.stats div { display: grid; gap: 2px; }
.stats dt { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.stats dt span { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-2); }
.stats dd { margin: 0; font: 400 1.5rem/1 var(--display); font-variant-numeric: tabular-nums; }
.loteria-btn {
  min-height: 52px; padding: 8px 20px; border: 2.5px solid var(--ink); border-radius: 9px;
  background: var(--yellow); color: var(--ink);
  font: 400 1.35rem/1 var(--display);
  transition: transform .2s var(--ease), background-color .2s;
}
.loteria-btn:hover { transform: rotate(-2deg) scale(1.03); }
.loteria-btn.is-ready { background: var(--red-deep); color: var(--paper-2); }

.called-wrap { grid-area: called; display: grid; gap: var(--s3); }
.called-h { font-size: 1.25rem; }
.called-h span { font: 500 15px/1 var(--text); color: var(--ink-2); margin-left: 6px; }
.called { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; min-height: 80px; }
.called li { width: 56px; }
.called:empty::before { content: "None yet. They line up here as the caller draws them."; font-size: 15px; color: var(--ink-2); align-self: center; }
.called .lc-name, .word-card .lc-name { display: none; }
.called .lc-art, .word-card .lc-art { top: 20%; }
.called .lc-num, .word-card .lc-num { display: none; }

/* ---------- 7. Words list ---------- */
.words-sec { max-width: var(--page); margin: 0 auto; padding: var(--s6) var(--gutter) var(--s8); }
.words-sec::before { content: ""; position: absolute; left: var(--gutter); right: var(--gutter); top: 0; border-top: 2px dashed var(--ink-2); }
.words-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.words-top h2 { font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.4rem); }
.words-count { font-weight: 750; font-variant-numeric: tabular-nums; }
.words-empty { max-width: 62ch; color: var(--ink-2); padding: var(--s5); border: 2px dashed var(--ink-2); border-radius: var(--r-box); }
.words { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--r-box); }
.words:empty { display: none; }
.word {
  display: grid; grid-template-columns: 56px minmax(0, 15rem) minmax(0, 1fr); gap: var(--s5); align-items: center;
  padding: var(--s3) var(--s5);
  border-top: 1.5px solid var(--paper-3);
}
.word:first-child { border-top: 0; }
.word-main { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.word-es { font: 400 1.2rem/1.1 var(--display); width: 100%; }
.word-en { width: 100%; color: var(--ink-2); }
.word-tag { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; border: 1.5px solid var(--ink); letter-spacing: .03em; }
.word-tag--m { background: var(--gr-sky); }
.word-tag--f { background: var(--gr-rose); }
.word-tag--review { background: var(--warn); }
.word-ex { display: grid; gap: 2px; font-size: 15.5px; }
.word-ex [lang="es"] { font-weight: 650; font-style: italic; }
.word-ex-en { color: var(--ink-2); }
.word-note { font-size: 14px; color: var(--ink-2); }
.word-note::before { content: "Note: "; font-weight: 800; color: var(--ink); }

/* ---------- 8. How a round goes: the rules inside a yellow box lid ---------- */
.how {
  max-width: var(--page); margin: 0 auto var(--s9); padding: 0 var(--gutter);
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: center;
}
.lid {
  background: var(--yellow);
  border: 2.5px solid var(--ink); border-radius: 14px;
  box-shadow: inset 0 0 0 8px var(--yellow), inset 0 0 0 10px var(--ink), var(--lift);
  padding: clamp(28px, 4vw, 52px);
}
.lid h2 { margin-bottom: var(--s5); }
.rules { margin: 0; padding: 0; list-style: none; counter-reset: rule; display: grid; gap: var(--s4); max-width: 64ch; }
.rules li { counter-increment: rule; position: relative; padding-left: 52px; min-height: 36px; }
.rules li::before {
  content: counter(rule); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--ink); color: var(--yellow); font: 400 1.05rem/1 var(--display);
}
.rules strong { display: block; font-size: 18px; }
.how-fig { margin: 0; display: grid; gap: var(--s4); justify-items: center; text-align: center; }
.how-cards { display: flex; justify-content: center; }
.how-card { width: min(180px, 42vw); display: block; box-shadow: var(--lift); border-radius: var(--r-card); }
.how-card--a { transform: rotate(-5deg); z-index: 1; position: relative; }
.how-card--b { transform: rotate(6deg) translate(-14px, 18px); }
.how-card--a::after {
  content: ""; position: absolute; z-index: 3; left: 50%; top: 46%; width: 46%; aspect-ratio: 40 / 28; transform: translate(-50%, -50%) rotate(-18deg);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 28'%3E%3Cpath d='M6 18C2 10 8 2 18 3c6 .6 8 5 12 4 6-1 9 4 7 10-2 7-10 10-18 9C13 25 8 23 6 18Z' fill='%238a5634' stroke='%231b1512' stroke-width='2'/%3E%3Cpath d='M17 7c3 0 4 2 3 3' fill='none' stroke='%23fbf3df' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 3px 2px rgb(27 21 18 / .35));
}
.how-verse { margin: var(--s4) 0 0; font-size: 1.25rem; font-weight: 650; font-style: italic; max-width: 30ch; }
.how-fig figcaption { max-width: 40ch; color: var(--ink-2); font-size: 15.5px; }

/* ---------- 9. Deck browser ---------- */
.deck { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter) var(--s9); }
.deck-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); align-items: end; margin-bottom: var(--s5); }
.deck-top p { max-width: 52ch; color: var(--ink-2); }
.filters { display: flex; flex-wrap: wrap; gap: var(--s4) var(--s6); align-items: end; padding: var(--s4) 0 var(--s5); border-top: 2px solid var(--ink); margin-bottom: var(--s5); }
.deck-count { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.deck-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: var(--s5) var(--s4); }
.flip { position: relative; display: block; width: 100%; aspect-ratio: 5 / 7; padding: 0; border: 0; background: none; perspective: 900px; border-radius: var(--r-card); }
.flip-front, .flip-back { position: absolute; inset: 0; backface-visibility: hidden; transition: transform .6s var(--ease), visibility 0s linear .25s; border-radius: var(--r-card); }
/* the face turned away is also hidden from readers and from hit testing */
.flip-back, .flip[aria-pressed="true"] .flip-front { visibility: hidden; }
.flip[aria-pressed="true"] .flip-back { visibility: visible; }
.flip-front .lc { height: 100%; }
.flip:hover .flip-front { transform: translateY(-3px) rotate(-1deg); }
.flip-back {
  transform: rotateY(180deg);
  background: var(--paper-2); border: 1.5px solid var(--ink);
  box-shadow: inset 0 0 0 6px var(--paper-2), inset 0 0 0 8px var(--ink);
  padding: 16px 16px 14px; text-align: left;
  display: flex; flex-direction: column; gap: 4px; overflow: auto;
}
.flip[aria-pressed="true"] .flip-front { transform: rotateY(-180deg); }
.flip[aria-pressed="true"] .flip-back { transform: rotateY(0); }
.fb-num { font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.fb-es { font: 400 1.2rem/1.05 var(--display); }
.fb-en { font-weight: 700; font-size: 15px; }
.fb-g { align-self: flex-start; font-size: 12px; font-weight: 800; padding: 1px 8px; border: 1.5px solid var(--ink); border-radius: 999px; }
.fb-g--m { background: var(--gr-sky); } .fb-g--f { background: var(--gr-rose); }
.fb-ex { font-size: 14px; font-style: italic; font-weight: 650; line-height: 1.35; margin-top: 2px; }
.fb-ex-en { font-size: 13px; color: var(--ink-2); line-height: 1.38; }
.fb-note { font-size: 12.5px; line-height: 1.4; margin-top: auto; padding-top: 4px; border-top: 1.5px dashed var(--ink-2); }
.deck-empty { display: grid; justify-items: start; gap: var(--s3); padding: var(--s5); border: 2px dashed var(--ink-2); border-radius: var(--r-box); }

/* ---------- 10. Level road ---------- */
.levels { background: var(--green-deep); color: var(--paper-2); padding: var(--s8) var(--gutter); }
.levels > * { max-width: var(--page); margin-inline: auto; }
.levels-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); align-items: end; margin-bottom: var(--s7); }
.levels-top p { max-width: 54ch; }
.road { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s7) var(--s5); }
.stop { position: relative; display: grid; justify-items: start; align-content: start; gap: 6px; }
.stop:nth-child(5) { grid-column: 4; grid-row: 2; }
.stop:nth-child(6) { grid-column: 3; grid-row: 2; }
.stop:nth-child(7) { grid-column: 2; grid-row: 2; }
.stop:nth-child(8) { grid-column: 1; grid-row: 2; }
/* the dashed road between decks */
.stop::before { content: ""; position: absolute; top: 38px; height: 0; border-top: 3px dashed rgb(251 243 223 / .7); z-index: 0; }
.stop:nth-child(-n+3)::before { left: 70px; right: calc(-1 * var(--s5)); }
.stop:nth-child(n+5):nth-child(-n+7)::before { left: calc(-1 * var(--s5) - 100% + 70px); width: calc(100% + var(--s5) - 74px); }
.stop:nth-child(4)::before { left: 28px; top: calc(100% + 8px); height: calc(var(--s7) - 16px); border-top: 0; border-left: 3px dashed rgb(251 243 223 / .7); }
.stop:nth-child(8)::before { display: none; }
.stop-deck { position: relative; z-index: 1; width: 56px; height: 76px; display: grid; place-items: center; }
.stop-deck::before, .stop-deck::after, .stop-deck span {
  position: absolute; inset: 0; border: 2px solid var(--ink); border-radius: 5px; background: var(--paper-2);
}
.stop-deck::before { content: ""; transform: rotate(-7deg) translate(-3px, 2px); }
.stop-deck::after { content: ""; transform: rotate(5deg) translate(3px, 1px); background: var(--gr-butter); }
.stop-deck span { z-index: 1; display: grid; place-items: center; color: var(--ink); font: 400 1.5rem/1 var(--display); }
.stop.is-now .stop-deck span { background: var(--yellow); }
.stop-name { font: 400 1.25rem/1.1 var(--display); margin-top: var(--s2); }
.stop-what { font-size: 15px; max-width: 26ch; }
.stop-tag { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; font-weight: 800; letter-spacing: .03em; padding: 3px 10px; border: 1.5px solid currentColor; border-radius: 999px; }
.stop-tag .ico { width: 15px; height: 15px; }
.stop.is-now .stop-tag { background: var(--yellow); color: var(--ink); border-color: var(--ink); }

/* ---------- 11. Classroom ---------- */
.salon {
  background: var(--blue-deep); color: var(--paper-2);
  padding: var(--s8) max(var(--gutter), calc((100% - var(--page)) / 2 + var(--gutter)));
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: var(--s6) clamp(24px, 4vw, 64px);
  grid-template-areas: "copy fig" "calc fig";
  align-items: start;
}
.salon .projector { align-self: center; }
.salon-copy { grid-area: copy; display: grid; gap: var(--s4); }
.salon-copy > p { max-width: 54ch; font-size: 18px; }
.salon-list { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: var(--s3); max-width: 56ch; }
.salon-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s3); }
.salon-list .ico { color: var(--yellow); margin-top: 2px; stroke-width: 2.4; }
.projector { grid-area: fig; margin: 0; display: grid; gap: var(--s3); }
.screen {
  display: grid; grid-template-columns: 30% minmax(0, 1fr); gap: var(--s4); align-items: center;
  aspect-ratio: 16 / 9; padding: 6%;
  background: var(--paper-2); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: 0 0 0 10px rgb(251 243 223 / .08), 0 20px 50px -20px rgb(0 0 0 / .6);
}
.screen-card { display: block; }
.screen-verse { font-weight: 700; font-style: italic; font-size: clamp(15px, 1.4vw, 21px); line-height: 1.38; }
.desks { display: flex; justify-content: space-between; gap: 8px; padding: 0 4%; }
.desks span {
  width: 17%; aspect-ratio: 4 / 5; border: 2px solid var(--ink); border-radius: 4px;
  background:
    linear-gradient(var(--ink) 0 0) 50% 0 / 1.5px 100% no-repeat,
    linear-gradient(90deg, var(--ink) 0 0) 0 50% / 100% 1.5px no-repeat,
    var(--red);
  transform: rotate(calc(var(--d, 0) * 1deg));
}
.desks span:nth-child(1) { --d: -6; } .desks span:nth-child(2) { --d: 4; } .desks span:nth-child(4) { --d: -3; } .desks span:nth-child(5) { --d: 7; }
.calc {
  grid-area: calc;
  background: var(--paper-2); color: var(--ink); border: 2.5px solid var(--ink); border-radius: var(--r-box);
  padding: var(--s5); display: grid; gap: var(--s3);
}
.calc h3 { font-size: 1.4rem; }
.calc-label { font-weight: 750; }
.calc-label output { font: 400 1.3rem/1 var(--display); font-variant-numeric: tabular-nums; }
.calc input[type="range"] { width: 100%; height: 30px; accent-color: var(--red-deep); }
.calc-total { font-weight: 700; }
.calc-total span { font: 400 2.6rem/1 var(--display); font-variant-numeric: tabular-nums; margin-right: 6px; }
.calc-sum { font-size: 15.5px; }
.calc-small { font-size: 14px; color: var(--ink-2); }
.calc .btn { justify-self: start; }

/* ---------- 12. Plans and sign-up ---------- */
.join { max-width: var(--page); margin: 0 auto; padding: var(--s9) var(--gutter); }
.join > h2 { margin-bottom: var(--s6); }
.signup { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: start; }
.plans { border: 0; margin: 0; padding: 0; display: grid; gap: var(--s3); min-width: 0; }
.billing-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; font-weight: 750; margin-bottom: var(--s2); }
.billing-save { font-size: 14px; font-weight: 800; padding: 2px 10px; border-radius: 999px; background: var(--gr-butter); border: 1.5px solid var(--ink); }
.plan { position: relative; display: block; cursor: pointer; }
.plan input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.plan-in {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s4); align-items: baseline;
  padding: var(--s4) var(--s5); padding-right: 76px;
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--r-box);
  transition: background-color .2s, box-shadow .2s var(--ease);
}
.plan-name { font: 400 1.45rem/1.1 var(--display); }
.plan-price { font-size: 15px; text-align: right; }
.plan-price b { font: 400 1.45rem/1 var(--display); font-variant-numeric: tabular-nums; }
.plan-list { grid-column: 1 / -1; font-size: 15px; color: var(--ink-2); max-width: 54ch; }
/* the chosen plan gets a bean on it, like a card on the tabla */
.plan-in::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 42px; aspect-ratio: 40 / 28; transform: translateY(-50%) rotate(-14deg) scale(.4);
  opacity: 0; transition: opacity .2s, transform .35s var(--ease);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 28'%3E%3Cpath d='M6 18C2 10 8 2 18 3c6 .6 8 5 12 4 6-1 9 4 7 10-2 7-10 10-18 9C13 25 8 23 6 18Z' fill='%238a5634' stroke='%231b1512' stroke-width='2'/%3E%3Cpath d='M17 7c3 0 4 2 3 3' fill='none' stroke='%23fbf3df' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.plan-in::before { content: ""; position: absolute; right: 18px; top: 50%; width: 42px; height: 42px; transform: translateY(-50%); border: 2px dashed var(--ink-2); border-radius: 50%; }
.plan input:checked + .plan-in { background: var(--gr-butter); box-shadow: inset 0 0 0 2px var(--ink); }
.plan input:checked + .plan-in::after { opacity: 1; transform: translateY(-50%) rotate(-14deg) scale(1); }
.plan input:focus-visible + .plan-in { outline: 3px solid var(--blue); outline-offset: 3px; }
.plan:hover .plan-in { box-shadow: var(--lift); }

.fields {
  display: grid; gap: var(--s4);
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--r-box);
  box-shadow: inset 0 0 0 5px var(--paper-2), inset 0 0 0 6.5px var(--ink);
  padding: clamp(20px, 3vw, 32px);
}
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > label, .field legend { font-weight: 750; font-size: 15px; padding: 0; }
.hint { font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.field input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 2px solid var(--ink); border-radius: 7px; background: #fffaf0;
}
.field input::placeholder { color: #7a6656; }
.field input:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
.field input[aria-invalid="true"] { border-color: var(--bad-ink); background: var(--bad); }
.msg { font-size: 14px; font-weight: 700; color: var(--bad-ink); }
.level { display: flex; flex-wrap: wrap; gap: var(--s2); }
.level legend { width: 100%; margin-bottom: 6px; }
.pass { position: relative; }
.pass input { padding-right: 96px; }
.pass-btn { position: absolute; right: 5px; top: 5px; bottom: 5px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 0; border-radius: 5px; background: var(--paper-3); font-weight: 750; font-size: 14px; }
.salon-fields { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s3); align-items: start; }
.check { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s3); align-items: start; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; }
.summary { font-size: 15px; font-weight: 650; padding: var(--s3) var(--s4); background: var(--paper); border-radius: 7px; border: 1.5px solid var(--paper-3); }
.alert { font-size: 15px; font-weight: 650; padding: var(--s3) var(--s4); border-radius: 7px; background: var(--bad); border: 2px solid var(--bad-ink); color: var(--ink); }
.spin { display: none; width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgb(251 243 223 / .35); border-top-color: var(--paper-2); }
.is-loading .spin { display: inline-block; animation: spin .8s linear infinite; }
#submit { flex-direction: row; gap: 10px; }
#submit.is-loading:disabled { opacity: 1; cursor: progress; }
.signup[aria-busy="true"] .fields { opacity: .92; }

.done {
  display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: var(--s6); align-items: center;
  max-width: 780px; padding: clamp(20px, 4vw, 40px);
  background: var(--gr-mint); border: 2.5px solid var(--ink); border-radius: 14px;
  box-shadow: inset 0 0 0 7px var(--gr-mint), inset 0 0 0 9px var(--ink), var(--lift);
}
.done:focus { outline: none; }
.done-card { display: block; transform: rotate(-4deg); }
.done-title { font: 400 clamp(1.8rem, 1.3rem + 1.6vw, 2.6rem)/1.05 var(--display); margin-bottom: var(--s3); }
.done-dl { margin: 0 0 var(--s3); display: grid; gap: 4px; }
.done-dl div { display: flex; gap: var(--s3); }
.done-dl dt { font-weight: 800; min-width: 4.5em; }
.done-dl dd { margin: 0; overflow-wrap: anywhere; }
.done-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }

/* ---------- 13. Questions, footer ---------- */
.faq { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter) var(--s9); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: var(--s6); align-items: start; }
.faq h2 { position: sticky; top: 96px; }
.faq-list { border-top: 2px solid var(--ink); }
.faq details { border-bottom: 2px solid var(--ink); }
.faq summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: var(--s4); align-items: center;
  padding: var(--s4) 0; font-weight: 800; font-size: 18px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; flex: none; width: 28px; height: 28px; border: 2px solid var(--ink); border-radius: 50%;
  background: linear-gradient(var(--ink) 0 0) center / 12px 2px no-repeat, linear-gradient(var(--ink) 0 0) center / 2px 12px no-repeat, var(--paper-2);
  transition: transform .3s var(--ease);
}
.faq details[open] summary::after { transform: rotate(45deg); background-color: var(--yellow); }
.faq details p { padding: 0 0 var(--s5); max-width: 64ch; color: var(--ink-2); }

.foot { background: var(--ink); color: var(--paper-2); position: relative; }
.picado--foot { margin: 0; padding-top: 0; height: 60px; }
.picado--foot::before { background: var(--paper-2); opacity: .5; }
.foot-in { max-width: var(--page); margin: 0 auto; padding: var(--s6) var(--gutter) var(--s7); display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--s6); }
.foot .logo-card rect:first-child { stroke: var(--paper-2); }
.foot-brand { display: grid; gap: var(--s3); align-content: start; }
.foot-brand p { max-width: 44ch; color: #e0d3b8; font-size: 15.5px; }
.foot-nav { display: grid; gap: 4px; align-content: start; }
.foot-nav a { text-decoration: none; padding: 5px 0; font-weight: 650; }
.foot-nav a:hover { text-decoration: underline; }
.foot-contact { display: grid; gap: var(--s2); align-content: start; font-size: 15.5px; }
.foot-small { color: #d7c9ad; font-size: 14px; display: flex; flex-wrap: wrap; gap: var(--s3); }
.foot :focus-visible { outline-color: var(--yellow); }

/* ---------- 14. Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) {
  /* signature: the bean drops onto the card and settles with a small bounce */
  @keyframes bean-drop {
    0% { transform: translateY(-70%) rotate(calc(var(--turn) - 40deg)) scale(1.35); opacity: 0; }
    55% { transform: translateY(4%) rotate(calc(var(--turn) + 6deg)) scale(.96); opacity: 1; }
    78% { transform: translateY(-5%) rotate(calc(var(--turn) - 2deg)) scale(1.02); }
    100% { transform: rotate(var(--turn)); }
  }
  .bean { animation: bean-drop .6s var(--ease) both; }
  @keyframes sway { 0%, 100% { transform: rotate(-2.2deg); } 50% { transform: rotate(2.2deg); } }
  .flag { animation: sway 5.5s ease-in-out infinite; animation-delay: calc(var(--i) * -.37s); }
  @keyframes ready { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06) rotate(-2deg); } }
  .loteria-btn.is-ready { animation: ready 1.1s ease-in-out infinite; }
  @keyframes win-in { from { transform: translateY(16px); opacity: 0; } }
  .win:not([hidden]) { animation: win-in .5s var(--ease); }
}
@media (prefers-reduced-motion: reduce) {
  .call-inner, .flip-front, .flip-back { transition: none; }
}

/* ---------- 15. Narrow screens ---------- */
@media (max-width: 1100px) {
  .nav { gap: var(--s4); font-size: 14px; }
  .nav a:nth-child(n+5) { display: none; }
}
@media (max-width: 960px) {
  .play { grid-template-columns: minmax(0, 1fr); grid-template-areas: "intro" "caller" "board" "called"; }
  .board { max-width: 560px; width: 100%; justify-self: center; }
  .play h1 { max-width: 18ch; }
  .how, .salon, .signup, .faq { grid-template-columns: minmax(0, 1fr); }
  .salon { grid-template-areas: "copy" "fig" "calc"; }
  .faq h2 { position: static; }
  .deck-top, .levels-top { grid-template-columns: minmax(0, 1fr); }
  .road { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stop:nth-child(n) { grid-column: auto; grid-row: auto; }
  .stop::before { display: none; }
  .foot-in { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .foot-brand { grid-column: 1 / -1; }
  .word { grid-template-columns: 56px minmax(0, 1fr); }
  .word-ex { grid-column: 2; }
}
@media (max-width: 720px) {
  .nav { display: none; }
  .top-cta { margin-left: auto; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .play { padding-top: 56px; gap: var(--s4); }
  .lead { font-size: 16.5px; }
  .caller { padding: var(--s4); }
  .caller-body { grid-template-columns: 76px minmax(0, 1fr); gap: var(--s4); }
  .call-card { width: 76px; }
  .caller-actions .btn--red { min-width: 0; flex: 1 1 100%; }
  .caller-actions .btn--paper { flex: 1 1 0; }
  .tabla-frame { padding: 8px 8px 10px; }
  .tabla { gap: 5px; }
  .stats { gap: var(--s3); }
  .status { gap: var(--s3); }
  .loteria-btn { flex: 1 1 auto; }
  .win { padding: var(--s3) var(--s4); }
  .word { padding: var(--s3); gap: var(--s3); grid-template-columns: 48px minmax(0, 1fr); }
  .word-card { width: 48px; }
  .deck-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s3); }
  .deck-count { margin-left: 0; width: 100%; }
  .flip-back { padding: 12px 12px 10px; }
  .road { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
  .stop { grid-template-columns: 64px minmax(0, 1fr); column-gap: var(--s4); justify-items: start; }
  .stop > :not(.stop-deck) { grid-column: 2; }
  .stop-deck { grid-row: 1 / span 3; }
  .stop-name { margin-top: 0; }
  .plan-in { grid-template-columns: minmax(0, 1fr); padding-right: 68px; }
  .plan-price { text-align: left; }
  .salon-fields { grid-template-columns: minmax(0, 1fr); }
  .done { grid-template-columns: minmax(0, 1fr); }
  .done-card { width: 120px; }
  .foot-in { grid-template-columns: minmax(0, 1fr); }
  .how-card { width: min(150px, 40vw); }
  .flag { width: 36px; height: 47px; }
  .picado { height: 50px; margin-bottom: -30px; }
}
@media (min-width: 961px) and (max-width: 1180px) {
  .play h1 { font-size: 2.55rem; max-width: none; }
}
