/* La Feria de las Tablas · estilos. Noche de feria: azul noche, rojo y
   crema de las casetas, oro de las bombillas. */
:root {
  --noche: #1d1b5e;
  --noche2: #2c2a86;
  --rojo: #e8414a;
  --crema: #fff6e3;
  --oro: #ffc83d;
  --naranja: #ff7a2f;
  --azul: #2f7bff;
  --verde: #1fa863;
  --tinta: #1d2340;
  --sombra: 0 6px 0 rgb(0 0 0 / 22%);
  --alto: 100vh;
}
@supports (height: 100dvh) {
  :root { --alto: 100dvh; }
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--noche);
  color: var(--tinta);
  font-family: "Baloo 2", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
#app { height: var(--alto); position: relative; overflow: hidden; }
.pant {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  overflow-y: auto;
  background-size: cover;
  background-position: center;
}
.pant[hidden] { display: none; }

/* Fondos provisionales (los sustituye arte/fondo-*.webp). */
.fondo-menu {
  background-image:
    radial-gradient(circle at 20% 12%, rgb(255 200 61 / 35%) 0 3px, transparent 4px),
    radial-gradient(circle at 80% 8%, rgb(255 200 61 / 35%) 0 3px, transparent 4px),
    repeating-linear-gradient(100deg, rgb(255 255 255 / 4%) 0 40px, transparent 40px 80px),
    linear-gradient(180deg, #1d1b5e 0%, #3b2a8f 60%, #6a2c7d 100%);
}
.fondo-loteria { background-image: linear-gradient(180deg, #23206e, #4b2c8f); }
.fondo-duelo { background-image: linear-gradient(180deg, #2f7bff 0 50%, #d9530b 50% 100%); }
.fondo-contrarreloj { background-image: linear-gradient(180deg, #102a6b, #1b6f8f); }

/* Piezas: si hay imagen, se ve la imagen; si no, el dibujo provisional. */
.pieza {
  display: inline-grid;
  place-items: center;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  line-height: 1;
}
.pieza.con-arte { font-size: 0 !important; background-color: transparent !important; border: 0 !important; box-shadow: none !important;
  background-size: contain !important; background-repeat: no-repeat !important; background-position: center !important; }

.redondo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--crema);
  background: rgb(255 255 255 / 16%);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex: none;
}
.redondo:focus-visible, .btn:focus-visible, .caseta:focus-visible, .chips button:focus-visible, .carton button:focus-visible, .op:focus-visible, .teclado button:focus-visible {
  outline: 4px solid var(--oro);
  outline-offset: 2px;
}
.arriba-der { align-self: flex-end; }

/* ---------- Menú ---------- */
.logo {
  margin: 0 0 4px;
  font-family: "Lilita One", "Baloo 2", sans-serif;
  font-weight: 400;
  text-align: center;
  line-height: 0.95;
  color: var(--oro);
  text-shadow: 0 4px 0 var(--rojo), 0 7px 0 rgb(0 0 0 / 30%);
  font-size: clamp(38px, 11vw, 56px);
  width: min(100%, 420px);
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.logo span { display: block; }
.logo span + span { font-size: 0.72em; color: #fff; }
.logo.con-arte { background-size: contain; background-repeat: no-repeat; background-position: center; min-height: 170px; }
.logo.con-arte span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.pipo-zona { display: flex; align-items: center; gap: 10px; width: min(100%, 440px); margin: 4px 0 10px; }
.pipo {
  width: 96px;
  height: 96px;
  flex: none;
  background-image: url("../../universo-pop/arte/pipo-principal.webp");
}
.bocadillo {
  margin: 0;
  background: var(--crema);
  border-radius: 18px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.25;
  position: relative;
  box-shadow: var(--sombra);
}
.bocadillo::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  margin-top: -9px;
  border: 9px solid transparent;
  border-left: 0;
  border-right-color: var(--crema);
}

.tablas-sel {
  width: min(100%, 440px);
  background: rgb(255 255 255 / 12%);
  border-radius: 18px;
  padding: 8px 10px 10px;
  margin-bottom: 12px;
}
.sel-titulo { margin: 0 0 6px; color: #fff; font-weight: 800; text-align: center; font-size: 17px; }
.chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chips button {
  min-height: 44px;
  border-radius: 12px;
  border: 2px solid rgb(255 255 255 / 80%);
  background: rgb(255 255 255 / 10%);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
}
.chips button[aria-pressed="true"] { background: var(--oro); border-color: var(--oro); color: var(--tinta); }
.chips .todas { grid-column: span 2; font-size: 16px; }

.casetas { display: grid; gap: 10px; width: min(100%, 440px); padding-bottom: 8px; }
.caseta {
  display: grid;
  grid-template-columns: 74px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  border: 0;
  border-radius: 20px;
  padding: 12px 14px;
  color: #fff;
  box-shadow: var(--sombra);
  position: relative;
  overflow: hidden;
}
.caseta::after {
  /* toldo de rayas */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 10px;
  background: repeating-linear-gradient(90deg, rgb(255 255 255 / 85%) 0 16px, transparent 16px 32px);
}
.caseta .ico { grid-row: span 2; width: 74px; height: 74px; font-size: 44px; border-radius: 16px; background: rgb(255 255 255 / 20%); }
.caseta b { font-family: "Lilita One", "Baloo 2", sans-serif; font-weight: 400; font-size: 24px; line-height: 1.1; padding-top: 6px; }
.caseta small { font-size: 15px; font-weight: 600; line-height: 1.2; opacity: 0.95; }
.c-loteria { background: var(--rojo); }
.c-duelo { background: #2766d9; }
.c-reloj { background: #0f8a6a; }
.caseta:active, .btn:active, .op:active { transform: translateY(3px); box-shadow: 0 3px 0 rgb(0 0 0 / 22%); }

/* ---------- Barras ---------- */
.barra {
  width: min(100%, 480px);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  margin-bottom: 8px;
}
.barra h2 {
  flex: 1;
  margin: 0;
  font-family: "Lilita One", "Baloo 2", sans-serif;
  font-weight: 400;
  font-size: 24px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.chip {
  background: var(--crema);
  color: var(--tinta);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  min-height: 50px;
  font-weight: 800;
  font-size: 18px;
  box-shadow: var(--sombra);
}
.btn.oro { background: var(--oro); color: var(--tinta); }
.btn.crema { background: var(--crema); color: var(--tinta); }
.fila-btn { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Lotería ---------- */
.sorteo {
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: 10px;
}
.bombo { width: 70px; height: 70px; font-size: 52px; }
.bola {
  position: relative;
  justify-self: center;
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
}
.bola-img {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-color: #fff;
  border: 6px solid var(--oro);
  box-shadow: inset -10px -12px 0 rgb(0 0 0 / 8%), var(--sombra);
}
.bola b {
  position: relative;
  font-family: "Lilita One", "Baloo 2", sans-serif;
  font-weight: 400;
  font-size: 34px;
  color: var(--tinta);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bola.sale { animation: sale 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes sale { from { transform: scale(0.2) rotate(-90deg); } to { transform: scale(1) rotate(0); } }
.rival { display: flex; align-items: center; gap: 6px; color: #fff; font-weight: 700; font-size: 15px; }
.mini-pipo { width: 60px; height: 60px; background-image: url("../../universo-pop/arte/pipo-principal.webp"); }
.barrita { width: 80px; height: 14px; border-radius: 7px; background: rgb(255 255 255 / 25%); overflow: hidden; margin-top: 3px; }
.barrita i { display: block; height: 100%; width: 0; background: var(--naranja); transition: width 0.3s; }
.tiempo { width: min(100%, 480px); height: 10px; border-radius: 5px; background: rgb(255 255 255 / 20%); overflow: hidden; margin: 8px 0 10px; }
.tiempo i { display: block; height: 100%; width: 100%; background: var(--oro); transform-origin: left; }

.carton {
  width: min(100%, 460px);
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--crema);
  border-radius: 20px;
  border: 5px solid var(--rojo);
  box-shadow: var(--sombra);
  background-size: cover;
}
.carton.t4 { grid-template-columns: repeat(4, 1fr); }
.carton.t3 { grid-template-columns: repeat(3, 1fr); }
.carton button {
  position: relative;
  aspect-ratio: 1;
  border: 3px solid #e7d6b4;
  border-radius: 14px;
  background: #fff;
  color: var(--tinta);
  font-weight: 800;
  font-size: clamp(24px, 8vw, 38px);
  font-variant-numeric: tabular-nums;
}
.carton button.marcada {
  border-color: var(--rojo);
  color: #fff;
  background: radial-gradient(circle, var(--rojo) 0 56%, #fff 58%);
  animation: ficha 0.25s ease-out;
}
.carton.ficha-arte button.marcada { color: var(--tinta); background: #fff var(--ficha) center / 84% no-repeat; }
@keyframes ficha { from { transform: scale(1.25); } to { transform: scale(1); } }
.carton button.linea { box-shadow: 0 0 0 4px var(--oro); }
.mal, .carton button.mal { animation: tiembla 0.35s; border-color: var(--rojo) !important; }
@keyframes tiembla { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.carton button.perdida { border-color: var(--naranja); border-style: dashed; }
.aviso { min-height: 1.4em; color: #fff; font-weight: 800; text-align: center; font-size: 18px; margin: 8px 0 0; }

/* ---------- Duelo ---------- */
#pDuelo { padding: 0; }
.mitad {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  color: #fff;
  background-size: cover;
}
.m-arriba.girada { transform: rotate(180deg); }
.mitad .quien { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.mitad .quien .avatar { width: 40px; height: 40px; font-size: 30px; }
.mitad .q {
  font-family: "Lilita One", "Baloo 2", sans-serif;
  font-size: clamp(40px, 12vw, 60px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 0 rgb(0 0 0 / 25%);
}
.ops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(100%, 380px); }
.op {
  min-height: 64px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: var(--tinta);
  font-weight: 800;
  font-size: 30px;
  box-shadow: var(--sombra);
  font-variant-numeric: tabular-nums;
}
.op.ok { background: #c9f3db; }
.op:disabled { opacity: 0.5; }
.mitad .estado { min-height: 1.3em; font-weight: 800; font-size: 18px; }
.centro {
  height: 64px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--noche);
  box-shadow: 0 0 0 4px var(--oro);
  z-index: 1;
}
.marcador { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 800; }
.marcador span { font-size: 22px; color: var(--oro); }
.marcador b { font-size: 34px; min-width: 52px; text-align: center; border-radius: 12px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.marcador .azul { background: var(--azul); }
.marcador .naranja { background: var(--naranja); }

/* ---------- Contrarreloj ---------- */
.record { margin: 0; color: #d9f3ff; font-weight: 700; min-height: 1.3em; }
.reloj-ico { width: 30px; height: 30px; font-size: 24px; }
.pregunta {
  font-family: "Lilita One", "Baloo 2", sans-serif;
  color: #fff;
  font-size: clamp(48px, 15vw, 72px);
  margin: 10px 0 4px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 0 rgb(0 0 0 / 25%);
}
.caja {
  min-width: 150px;
  min-height: 66px;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 18px;
  font-size: 42px;
  font-weight: 800;
  box-shadow: var(--sombra);
  font-variant-numeric: tabular-nums;
}
.caja.bien { background: #c9f3db; }
.caja.mal { background: #ffd5d7; }
.era { min-height: 1.4em; color: #ffd1a3; font-weight: 800; font-size: 19px; margin: 8px 0; }
.reloj-centro { margin: auto 0; display: flex; flex-direction: column; align-items: center; }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(100%, 380px); }
.teclado button {
  min-height: 68px;
  border: 0;
  border-radius: 16px;
  background: var(--crema);
  color: var(--tinta);
  font-size: 28px;
  font-weight: 800;
  box-shadow: var(--sombra);
}
.teclado button.otro { background: #ffd9a3; font-size: 22px; }
.teclado button:active { transform: translateY(3px); box-shadow: 0 3px 0 rgb(0 0 0 / 22%); }

/* ---------- Final ---------- */
.fin { width: min(100%, 440px); margin: auto 0; text-align: center; color: #fff; }
.trofeo { width: 150px; height: 150px; font-size: 110px; }
.fin h2 { font-family: "Lilita One", "Baloo 2", sans-serif; font-weight: 400; font-size: 38px; margin: 6px 0; color: var(--oro); text-shadow: 0 3px 0 rgb(0 0 0 / 30%); }
.fin-txt { font-size: 19px; font-weight: 700; margin: 0 0 10px; }
.fin-datos { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.repasar { background: var(--crema); color: var(--tinta); border-radius: 18px; padding: 10px 14px; margin-top: 12px; text-align: left; }
.repasar:empty { display: none; }
.repasar p { margin: 0 0 6px; font-weight: 800; }
.repasar ul { margin: 0; padding-left: 20px; }
.repasar a { color: #b8361f; font-weight: 800; }

/* ---------- Ventanas, avisos, confeti ---------- */
.velo { position: fixed; inset: 0; background: rgb(15 14 50 / 70%); display: grid; place-items: center; padding: 16px; z-index: 5; }
.velo[hidden] { display: none; }
.ventana { background: var(--crema); border-radius: 22px; padding: 18px; width: min(100%, 380px); text-align: center; box-shadow: var(--sombra); }
.ventana h3 { margin: 0 0 6px; font-family: "Lilita One", "Baloo 2", sans-serif; font-weight: 400; font-size: 28px; }
.ventana p { margin: 0 0 10px; font-size: 17px; font-weight: 600; }
.ventana .cuenta { font-family: "Lilita One", "Baloo 2", sans-serif; font-size: 80px; color: var(--rojo); line-height: 1; }
.toast {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
  font-family: "Lilita One", "Baloo 2", sans-serif;
  font-size: 46px;
  color: var(--oro);
  text-shadow: 0 4px 0 var(--rojo), 0 8px 12px rgb(0 0 0 / 40%);
  transition: 0.25s;
  z-index: 6;
  white-space: nowrap;
}
.toast.ver { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#confeti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Revisión de diseño: centrado vertical, tiempo visible, final con acción clara. */
#pLoteria { justify-content: center; }
#rSeg { font-size: 30px; font-variant-numeric: tabular-nums; }
.tiempo.reloj-barra { height: 14px; border-radius: 7px; }
.tiempo.reloj-barra.ultimos i { background: var(--rojo); }
.fin .fila-btn .btn { min-height: 58px; font-size: 20px; }
.fin .fila-btn .btn.oro { flex: 1; max-width: 200px; }

/* Revisión de usabilidad */
.tiempo.reloj-barra.ultimos i { background: var(--rojo); }
.duelo-t { width: min(100%, 380px); margin: 0; height: 8px; }
.ops.bloqueado { opacity: 0.45; filter: grayscale(0.6); }
.mitad .q { text-align: center; }
.era { font-size: 24px; color: #fff; }
.rival small { display: block; font-size: 14px; }
.chips .prisa { grid-column: 1 / -1; font-size: 16px; }

[tabindex="-1"]:focus { outline: none; }
