/* Loter-IA — classic Lotería colors on paper. */
:root {
  --paper: #fbf6ec;
  --ink: #1f1a17;
  --muted: #6b6158;
  --line: #e2d7c5;
  --red: #c62d2d;
  --red-dark: #a32222;
  --blue: #2f6db5;
  --green: #2f8a57;
  --display: "Anton", "Arial Black", Impact, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}

.top {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 16px 0;
}

.brand {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--red); }

/* Start */
.start { padding: 26px 0 8px; }

h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.05;
  letter-spacing: .01em;
  margin: 0 0 10px;
}

.intro { font-size: 18px; color: var(--muted); margin: 0 0 22px; max-width: 560px; }

.start-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 6px 6px 0 var(--ink);
  max-width: 820px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.topic-field { flex: 1 1 280px; }
.field label { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }

input, select {
  font: inherit;
  font-size: 18px;
  padding: 11px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 50px;
}
input:focus, select:focus { outline: none; border-color: var(--blue); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  min-height: 50px;
}

.primary {
  background: var(--red);
  color: #fff;
  border: 2px solid var(--ink);
  padding: 0 22px;
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: .03em;
}
.primary:hover { background: var(--red-dark); }
.primary:disabled { opacity: .6; cursor: progress; }
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; }
.status { min-height: 24px; margin: 0; font-weight: 600; color: var(--muted); }
.retry { min-height: 40px; font-size: 16px; }
.retry[hidden] { display: none; }
#deck-status { margin-top: 10px; }
.status.error { color: var(--red); }

/* Deck */
.deck { margin-top: 18px; }
.deck-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  margin-bottom: 16px;
}
.deck-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.boards-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.boards-form label {
  align-self: center;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.boards-form input { width: 92px; }
.secondary {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 0 18px;
  font-family: var(--display);
  font-size: 19px;
  letter-spacing: .03em;
}
.secondary:hover { background: var(--paper); }
#deck-status:empty { display: none; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.deck-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 32px;
  letter-spacing: .01em;
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.card {
  background: #fff;
  border: 1px solid #d9cfbf;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
}

.art {
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background: var(--card-color, #f5c842);
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}
.art img { width: 80%; height: auto; }
.art.no-picture {
  padding: 10px;
  text-align: center;
  font-family: var(--display);
  font-size: 20px;
  text-transform: uppercase;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.name {
  margin: 0;
  padding: 8px 2px 2px;
  text-align: center;
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.regen {
  width: 100%;
  min-height: 36px;
  margin-top: 8px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
}
.regen:hover { border-color: var(--ink); }
.note { margin: 4px 0 0; min-height: 0; font-size: 12px; color: var(--muted); text-align: center; }
.note:empty { display: none; }

.card.is-loading .art { opacity: .35; }
.card.is-loading .regen { cursor: progress; opacity: .6; }
.card.is-new { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.94); opacity: .4; } }

.placeholder .art { animation: pulse 1.2s ease-in-out infinite; }
.placeholder:nth-child(4n + 2) .art { animation-delay: .15s; }
.placeholder:nth-child(4n + 3) .art { animation-delay: .3s; }
.placeholder:nth-child(4n) .art { animation-delay: .45s; }
@keyframes pulse { 50% { opacity: .35; } }

/* Caller: one card per screen, snapped as the teacher swipes or scrolls. */
body.calling { overflow: hidden; }
.caller { position: fixed; inset: 0; z-index: 10; background: var(--paper); }
.caller[hidden] { display: none; }
.caller-back { position: absolute; top: 14px; left: 14px; z-index: 1; min-height: 44px; font-size: 17px; }
.feed {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.feed:focus { outline: none; }
.slide {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
  padding: 70px 16px 40px;
}
.big-card {
  /* As wide as the screen allows while the 4:5 picture and the name still fit its height. */
  width: min(88vw, calc((100dvh - 220px) * .8));
  background: #fff;
  border: 1px solid #d9cfbf;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .16);
}
.big-card .art { border-radius: 8px 8px 0 0; }
.big-card .name { font-size: clamp(26px, 6vw, 54px); padding-top: 12px; }
.caller-hint {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.end-message {
  margin: 0;
  max-width: 14ch;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(36px, 8vw, 72px);
  line-height: 1.1;
}

.credit {
  padding: 18px 16px 22px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.credit a { color: inherit; }

@media (max-width: 560px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .start-form { box-shadow: 4px 4px 0 var(--ink); }
  .start-form .primary { width: 100%; }
  .field { flex: 1 1 100%; }
  .deck-actions, .boards-form { width: 100%; }
  .boards-form .primary, .secondary { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .placeholder .art { animation: none; opacity: .6; }
  .card.is-new { animation: none; }
}
