/* Villa Perlitas · Tómbola — visual line taken from "Instrucciones de juego" PDF */
:root {
  --ink: #1b2266;          /* body text navy */
  --royal: #2531a5;        /* headings, filled cells */
  --royal-dark: #1a2484;
  --sky: #93caf1;          /* header band */
  --sky-2: #b9dff8;
  --page: #dcedfb;         /* page background */
  --panel: #eef6fd;        /* inner panels */
  --line: #8cc8ef;         /* divider lines, empty cell border */
  --border: #c3e1f6;       /* card borders */
  --gold: #f3c24f;
  --gold-soft: #fff6de;
  --gold-line: #ebc66a;
  --white: #ffffff;
  --serif: "Fraunces", "Georgia", "Times New Roman", serif;
  --sans: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --r-card: 26px;
  --gap: clamp(10px, 1.2vw, 22px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--sky) 0, var(--sky-2) 14vh, var(--page) 30vh, var(--page) 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- snowflakes & sparkles background ---------- */
.snow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.snow svg { position: absolute; opacity: .28; }
.snow .spark { position: absolute; color: #ffffff; opacity: .9; font-size: 14px; }

/* ---------- header ---------- */
.top {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1.2vh 2.2vw 0.6vh;
  height: 17vh;
}
.logo { height: 15.5vh; width: auto; justify-self: start; filter: drop-shadow(0 2px 0 rgba(255,255,255,.35)); }
.title { text-align: center; }
.title h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(36px, 7vh, 96px);
  letter-spacing: .06em;
  line-height: 1;
  color: var(--white);
  text-shadow: 3px 4px 0 #4d63c9, 0 0 1px #4d63c9;
}
.divider {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: .9vh 0 .3vh;
}
.divider span { display: block; width: clamp(80px, 13vw, 260px); height: 2px; background: var(--white); border-radius: 2px; }
.divider i { font-style: normal; color: var(--royal); font-size: clamp(16px, 2.4vh, 28px); line-height: 1; position: relative; }
.divider i::before, .divider i::after {
  content: ""; position: absolute; top: 50%; width: 5px; height: 5px; border-radius: 50%;
  background: var(--white); transform: translateY(-50%);
}
.divider i::before { left: -10px; } .divider i::after { right: -10px; }
.subtitle {
  margin: 0;
  font-family: var(--serif); font-style: italic; font-weight: 800;
  font-size: clamp(20px, 3.6vh, 48px);
  color: var(--white);
  text-shadow: 2px 3px 0 #4d63c9;
  line-height: 1.05;
}
.top-stats { justify-self: end; display: flex; flex-direction: column; gap: 1vh; align-items: flex-end; }
.pill {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: .7vh 1.4vw;
  font-size: clamp(13px, 2vh, 24px);
  font-weight: 500;
  box-shadow: 0 2px 0 rgba(37,49,165,.08);
}
.pill strong { font-family: var(--serif); font-weight: 800; color: var(--royal); font-size: 1.2em; }

/* ---------- layout ---------- */
.layout {
  position: relative; z-index: 1;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 2.05fr 0.95fr;
  grid-template-rows: 1fr auto;
  gap: var(--gap);
  padding: 0 2.2vw 2vh;
}
.board-card { grid-column: 1 / -1; }

/* Double-frame card like the PDF panels */
.card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--r-card);
  position: relative;
  padding: 1.6vh 1.4vw;
  min-height: 0;
  box-shadow: 0 0 0 6px rgba(255,255,255,.55), 0 10px 30px rgba(37,49,165,.08);
}
.card::before {
  content: ""; position: absolute; inset: 6px; border-radius: calc(var(--r-card) - 6px);
  border: 1.5px solid var(--border); pointer-events: none;
}

/* Section title: —— ✦ Title ✦ —— */
.section-title {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 1.2vh;
  font-family: var(--serif); font-style: italic; font-weight: 800;
  font-size: clamp(16px, 2.6vh, 34px);
  color: var(--royal);
  white-space: nowrap;
}
.section-title::before, .section-title::after {
  content: ""; flex: 1; height: 2px; background: var(--line); border-radius: 2px;
}
.section-title span::before, .section-title span::after { content: "✦"; font-style: normal; font-size: .62em; margin: 0 .6em; vertical-align: .2em; }

/* ---------- mini bingo grid (figures) ---------- */
.bingo-head {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  font-family: var(--serif); font-weight: 900; color: var(--royal);
  text-align: center; font-size: 12px; margin-bottom: 4px;
}
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.grid5 .cell {
  aspect-ratio: 1; border-radius: 22%;
  border: 2px solid var(--line); background: var(--white);
  transition: background .35s, border-color .35s, transform .35s;
}
.grid5 .cell.on { background: var(--royal); border-color: var(--royal); }
.grid5.editor .cell { cursor: pointer; }
.grid5.editor .cell:hover { border-color: var(--royal); }

/* Big figure in the main screen */
.figure-card { display: flex; flex-direction: column; }
.figure-display {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--panel); border: 2px solid var(--border); border-radius: 18px;
  padding: 1.6vh 1vw;
  transition: border-color .2s, transform .2s;
}
.figure-display:hover { border-color: var(--line); }
.bingo-head.big, .grid5.big { width: min(100%, 24vh); }
.figure-card.has-prize .bingo-head.big, .figure-card.has-prize .grid5.big { width: min(100%, 17vh); }
.figure-card.has-prize .figure-name { margin-top: .8vh; font-size: clamp(20px, 3.6vh, 48px); }
.bingo-head.big { font-size: clamp(14px, 2.6vh, 34px); gap: .9vh; margin-bottom: .6vh; }
.grid5.big { gap: .9vh; }
.grid5.big .cell { border-width: 3px; }
.figure-name {
  margin: 1.4vh 0 .3vh;
  font-family: var(--serif); font-style: italic; font-weight: 800;
  font-size: clamp(22px, 4.4vh, 58px); color: var(--royal); line-height: 1.05; text-align: center;
}
.figure-desc { margin: 0; font-size: clamp(13px, 2vh, 24px); text-align: center; }
.prize {
  margin-top: 1.2vh;
  background: var(--gold-soft); border: 2px solid var(--gold-line); border-radius: 16px;
  padding: 1vh 1vw; text-align: center;
  display: flex; flex-direction: column; gap: .2vh;
}
.prize-label { font-size: clamp(11px, 1.6vh, 18px); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.prize-name { font-family: var(--serif); font-weight: 800; font-size: clamp(16px, 3vh, 38px); color: var(--royal); line-height: 1.1; }

/* ---------- drum + current ball ---------- */
.drum-card { display: flex; flex-direction: column; }
.drum-stage {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1vw; align-items: center;
}
.drum-wrap { height: 100%; min-height: 0; position: relative; }
#drum { position: absolute; inset: 0; width: 100%; height: 100%; }

.current { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 0; }
.ball {
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffffff 0 18%, #eef6fd 45%, #b9dcf5 85%, #93c3ea 100%);
  box-shadow: inset -6px -10px 18px rgba(37,49,165,.18), 0 10px 24px rgba(27,34,102,.22);
  display: grid; place-items: center;
  position: relative;
}
.ball-inner {
  width: 68%; aspect-ratio: 1; border-radius: 50%;
  background: var(--white);
  border: .7vh solid var(--royal);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
}
.ball.big { width: min(30vh, 100%); aspect-ratio: 1; }
.ball.big .ball-letter { font-family: var(--serif); font-weight: 900; font-size: 4.2vh; color: var(--royal); }
.ball.big .ball-number { font-family: var(--serif); font-weight: 900; font-size: 9.5vh; color: var(--ink); letter-spacing: -.02em; }
.ball.big.empty .ball-number { color: var(--line); }
.ball.pop { animation: pop .7s cubic-bezier(.2, 1.4, .4, 1); }
.ball.big.latest::after {
  content: ""; position: absolute; inset: -1.2vh; border-radius: 50%;
  border: .5vh solid var(--gold); opacity: 0;
  animation: ring 1.6s ease-out .3s 2;
}
@keyframes pop { 0% { transform: scale(.2) rotate(-200deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes ring { 0% { opacity: .9; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.25); } }

.current-caption {
  margin: 1.4vh 0 1vh; font-family: var(--serif); font-style: italic; font-weight: 800;
  font-size: clamp(16px, 3vh, 38px); color: var(--royal); text-align: center;
}
.recent-wrap { display: flex; flex-direction: column; align-items: center; gap: .6vh; }
.recent-label { font-size: clamp(11px, 1.5vh, 17px); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }
.recent { display: flex; gap: .7vw; min-height: 6.4vh; }
.ball.small { width: 6.4vh; height: 6.4vh; }
.ball.small .ball-inner { border-width: .35vh; width: 78%; }
.ball.small .ball-letter { font-family: var(--serif); font-weight: 900; font-size: 1.3vh; color: var(--royal); }
.ball.small .ball-number { font-family: var(--serif); font-weight: 900; font-size: 2.3vh; }

/* ---------- controls ---------- */
.controls-card { display: flex; flex-direction: column; gap: 1.1vh; }
.btn-draw {
  flex: 1; min-height: 9vh;
  border: none; border-radius: 20px;
  background: linear-gradient(180deg, #3442c4, var(--royal) 55%, var(--royal-dark));
  color: var(--white);
  box-shadow: 0 6px 0 #141c6b, 0 12px 24px rgba(37,49,165,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5vh;
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.btn-draw:hover { filter: brightness(1.08); }
.btn-draw:active { transform: translateY(4px); box-shadow: 0 2px 0 #141c6b, 0 6px 14px rgba(37,49,165,.3); }
.btn-draw:disabled { filter: grayscale(.4) brightness(.95); cursor: default; }
.btn-draw-main { font-family: var(--serif); font-style: italic; font-weight: 800; font-size: clamp(18px, 3.6vh, 44px); }
.btn-draw-hint { font-size: clamp(10px, 1.4vh, 16px); opacity: .8; letter-spacing: .08em; text-transform: uppercase; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6vw; }
.btn {
  border: 2px solid var(--border); background: var(--panel);
  border-radius: 14px; padding: 1.1vh .6vw;
  font-weight: 600; font-size: clamp(12px, 1.7vh, 20px); color: var(--royal);
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--line); background: #e3f0fc; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--royal); border-color: var(--royal); color: var(--white); }
.btn.primary:hover { background: #3341c0; }
.btn.ghost { background: var(--white); }
.hint { margin: 0; font-size: clamp(11px, 1.5vh, 17px); text-align: center; opacity: .8; line-height: 1.35; }

/* ---------- board ---------- */
.board-card { padding-bottom: 1.8vh; }
.board { display: grid; grid-template-rows: repeat(5, 1fr); gap: .7vh; }
.board-row { display: grid; grid-template-columns: 5.2vh repeat(15, 1fr); gap: .45vw; }
.board-letter {
  display: grid; place-items: center;
  background: var(--royal); color: var(--white); border-radius: 10px;
  font-family: var(--serif); font-weight: 900; font-size: 2.8vh; height: 4.4vh;
}
.board-num {
  display: grid; place-items: center; height: 4.4vh;
  border: 2px solid var(--line); border-radius: 10px; background: var(--white);
  font-weight: 700; font-size: 2.2vh; color: #9cc3e2;
  transition: background .4s, color .4s, border-color .4s, transform .4s;
}
.board-num.on { background: var(--royal); border-color: var(--royal); color: var(--white); }
.board-num.last { background: var(--gold); border-color: #d9a52a; color: var(--ink); transform: scale(1.12); box-shadow: 0 4px 12px rgba(217,165,42,.5); }

/* ---------- modal ---------- */
.modal, .announce {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(27,34,102,.42); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 3vh;
}
.modal-box {
  width: min(1100px, 96vw); max-height: 94vh; overflow: auto;
  padding: 2.6vh 2.2vw;
}
.modal-box.small { width: min(560px, 92vw); }
.modal-lead { text-align: center; margin: 0 0 1.6vh; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 auto 1.8vh; max-width: 520px; font-weight: 600; font-size: 15px; }
.field em { font-weight: 400; opacity: .7; }
.field input {
  font: inherit; font-weight: 500; color: var(--ink);
  border: 2px solid var(--border); border-radius: 12px; padding: 10px 14px; background: var(--panel);
  outline: none;
}
.field input:focus { border-color: var(--royal); background: var(--white); }

.figure-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.fig-opt {
  background: var(--panel); border: 2px solid var(--border); border-radius: 18px;
  padding: 14px 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.fig-opt:hover { border-color: var(--line); transform: translateY(-2px); }
.fig-opt.selected { border-color: var(--royal); box-shadow: 0 0 0 3px rgba(37,49,165,.18); background: var(--white); }
.fig-opt.selected::after {
  content: "✓"; position: absolute; top: 8px; right: 10px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--royal); color: var(--white);
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.fig-opt .bingo-head, .fig-opt .grid5 { width: 92px; }
.fig-opt .bingo-head { font-size: 11px; letter-spacing: .1em; }
.fig-opt .grid5 { gap: 3px; }
.fig-opt .grid5 .cell { border-width: 1.5px; border-radius: 4px; }
.fig-opt h4 { margin: 6px 0 0; font-family: var(--serif); font-style: italic; font-weight: 800; font-size: 19px; color: var(--royal); }
.fig-opt p { margin: 0; font-size: 13px; text-align: center; line-height: 1.3; }

.sub-options { margin-top: 2vh; background: var(--panel); border: 2px solid var(--border); border-radius: 18px; padding: 14px 18px; }
.sub-title { margin: 0 0 10px; text-align: center; font-family: var(--serif); font-style: italic; font-weight: 800; font-size: 19px; color: var(--royal); }
.letters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.letter-btn {
  width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--border); background: var(--white);
  font-family: var(--serif); font-weight: 900; font-size: 22px; color: var(--royal);
}
.letter-btn:hover { border-color: var(--line); }
.letter-btn.selected { background: var(--royal); color: var(--white); border-color: var(--royal); }
.custom-editor { display: flex; gap: 28px; align-items: center; justify-content: center; flex-wrap: wrap; }
.custom-editor .bingo-head, .custom-editor .grid5 { width: 200px; }
.custom-editor .bingo-head { font-size: 18px; }
.custom-editor .field { margin: 0; min-width: 260px; }

.modal-actions { display: flex; justify-content: center; gap: 14px; margin-top: 2.4vh; }
.modal-actions .btn { padding: 12px 28px; font-size: 16px; }

/* ---------- announcement ---------- */
.announce { cursor: pointer; }
.announce-box {
  display: flex; flex-direction: column; align-items: center;
  padding: 4vh 5vw; animation: rise .5s cubic-bezier(.2, 1.3, .4, 1);
}
.announce-kicker { margin: 0; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; font-size: 2.2vh; }
.announce-prize { margin: .6vh 0 2vh; font-family: var(--serif); font-weight: 800; font-size: 4.2vh; color: var(--royal); text-align: center; }
.announce-prize:empty { display: none; }
.bingo-head.huge, .grid5.huge { width: 38vh; }
.bingo-head.huge { font-size: 4vh; gap: 1.2vh; margin-bottom: 1vh; }
.grid5.huge { gap: 1.2vh; }
.grid5.huge .cell { border-width: 4px; }
.announce-name { margin: 2.4vh 0 .4vh; font-family: var(--serif); font-style: italic; font-weight: 800; font-size: 7.5vh; color: var(--royal); line-height: 1; text-align: center; }
.announce-desc { margin: 0; font-size: 2.6vh; text-align: center; }
@keyframes rise { 0% { transform: translateY(30px) scale(.92); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---------- smaller screens (laptop of the operator) ---------- */
@media (max-aspect-ratio: 4/3) {
  body { overflow: auto; }
  html, body { height: auto; min-height: 100%; }
  .top { height: auto; }
  .layout { flex: none; grid-template-columns: 1fr 1fr; grid-template-rows: none; grid-auto-rows: auto; }
  .ball.big { width: min(22vh, 100%); }
  .figure-display, .btn-draw { flex: none; }
  .bingo-head.big, .grid5.big,
  .figure-card.has-prize .bingo-head.big, .figure-card.has-prize .grid5.big { width: min(100%, 20vh); }
  .drum-card { grid-column: 1 / -1; min-height: 46vh; grid-row: 1; }
  .figure-card { grid-row: 2; }
  .controls-card { grid-row: 2; }
  .figure-options { grid-template-columns: repeat(3, 1fr); }
}
