:root{
  --bg:#7d71c6;
  --tile:#e9e9ee;
  --tileBorder:#cfcfe1;
  --called:#3b2cb7;
  --accent:#2ed1c3;
  --shadow: 0 10px 25px rgba(0,0,0,.18);
  --radius:18px;

  --autoOn:#22c55e;
  --autoOff:#ffffff;

  /* Escala dinámica para quepa siempre en pantalla */
  --scale: 1;
}

*{ box-sizing:border-box; }

/* Desactivar selección de texto en toda la web */
html, body, .screen, .wrap, .card, .board, .side, .btn, .logo, .cell, .lastBox {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* iOS long-press */
}

html, body{
  width:100%;
  height:100%;
  min-height:100dvh;                 /* Evita que la barra de direcciones recorte la vista */
  margin:0;
  padding:0;
  overflow:hidden;                   /* Sin scroll en ninguna dirección */
}

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:var(--bg);
  color:#fff;
}

/* Contenedor pantalla completa */
.screen{
  width:100vw;
  min-height:100dvh;                 /* Asegura altura completa aunque aparezca la barra */
  padding: clamp(6px, 1.2vh, 14px) clamp(4px, 1.2vw, 12px);
  padding-left: max(4px, env(safe-area-inset-left));
  padding-right: max(4px, env(safe-area-inset-right));
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;                   /* Evita scroll en horizontal/vertical */
}

/* Layout fluido, sin forzar 16:9 */
.wrap{
  width: 100%;
  height:auto;
  display:grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: clamp(8px, 1.6vh, 22px);
  padding: clamp(8px, 1.5vh, 16px);
  margin: 0;
  transform: scale(var(--scale));
  transform-origin: top center;
  will-change: transform;
}

/* Ajustes para tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .wrap {
    width: 100%;
    max-width: none;
    max-height: none;
    gap: clamp(8px, 1.6vh, 18px);
    padding: clamp(8px, 1.6vh, 16px);
  }
  
  .board {
    padding: 1vh;
  }
  
  .grid {
    gap: 0.8vh;
  }
  
  .cell {
    font-size: clamp(16px, 2vmin, 30px);
  }
  
  .logo {
    font-size: clamp(40px, 5vmin, 72px);
  }
  
  .big .num {
    font-size: clamp(80px, 10vmin, 140px);
  }
  
  .lastBox {
    height: 6vh;
    min-height: 48px;
    font-size: clamp(24px, 3.5vmin, 48px);
  }
  
  .btn {
    padding: 1vh 1.5vh;
    min-width: 140px;
    font-size: clamp(13px, 1.5vmin, 18px);
  }
}

/* ===== Animaciones ===== */
@keyframes blinkGlow{
  0%, 100% { filter: brightness(1); transform: scale(1); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); }
  50% { filter: brightness(1.35); transform: scale(1.03); box-shadow: 0 0 0 6px rgba(255,255,255,.10), 0 12px 30px rgba(0,0,0,.22); }
}

@keyframes popNumber{
  0% { transform: scale(0.86); opacity: .0; filter: blur(1px); }
  60% { transform: scale(1.06); opacity: 1; filter: blur(0px); }
  100% { transform: scale(1.0); opacity: 1; }
}

@keyframes bump{
  0% { transform: translateY(0); }
  40% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

@keyframes flashCell{
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes modalIn{
  0% { transform: translateY(10px) scale(.98); opacity:0; }
  100% { transform: translateY(0) scale(1); opacity:1; }
}

/* Board */
.board{
  background:rgba(255,255,255,.15);
  border-radius:var(--radius);
  padding:1.4vh;
  box-shadow: var(--shadow);
  overflow:hidden;
  height:100%;
}

.grid{
  height:100%;
  display:grid;
  grid-template-columns: repeat(10, 1fr);
  gap:1.1vh;
  grid-auto-rows: 1fr;
}

.cell{
  position:relative;
  background:var(--tile);
  border:2px solid var(--tileBorder);
  border-radius:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  color:#fff;
  user-select:none;
  overflow:hidden;
  aspect-ratio: 1 / 1;
    font-size: clamp(18px, 2.2vmin, 36px);
  transform: translateZ(0);
}

.cell::before{
  content:"";
  position:absolute;
  inset:12%;
  border-radius:10px;
  background: radial-gradient(circle, rgba(0,0,0,.18) 1px, transparent 2px) 0 0/10px 10px;
  opacity:.25;
  pointer-events:none;
}

.cell .n{
  position:relative;
  z-index:1;
  text-shadow: 0 2px 0 rgba(0,0,0,.12);
}

.cell.called{
  background:var(--called);
  border-color:rgba(255,255,255,.25);
  color:#fff;
}

/* Celda recién salida (flash corto) */
.cell.flash{ animation: flashCell 420ms ease-out 1; }

/* Último número: parpadea continuamente */
.cell.latest{ animation: blinkGlow 1.05s ease-in-out infinite; }

/* Side panel */
.side{
  display:flex;
  flex-direction:column;
  gap:2vh;
  height:100%;
}

.card{
  background:rgba(255,255,255,.15);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  padding:1.6vh;
}

.brand{
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:1vh;
  padding:2vh 1.6vh;
}

.logo{
  font-weight:1000;
  line-height:1;
  letter-spacing:1px;
  text-transform:uppercase;
  text-shadow: 0 10px 20px rgba(0,0,0,.25);
  font-size: clamp(48px, 6vmin, 90px);
}
.logo .b{ color:#33c3ff; } 
.logo .i{ color:#2ed1c3; } 
.logo .n{ color:#a78bfa; } 
.logo .g{ color:#fbbf24; }  
.logo .o{ color:#ff4fc3; }  


.big{
  background:rgba(255,255,255,.18);
  border-radius:var(--radius);
  padding:2vh;
  display:flex;
  align-items:center;
  justify-content:center;
  height:32%;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.12);
  overflow:hidden;
}

.big .num{
  font-weight:1000;
  color:#fff;
  text-shadow: 0 10px 22px rgba(0,0,0,.25);
  font-size: clamp(120px, 15vmin, 220px);
}

.big .num.pop{ animation: popNumber 420ms ease-out 1; }

.sectionTitle{
  font-weight:900;
  letter-spacing:1px;
  opacity:.95;
  text-transform:uppercase;
  margin-bottom:1vh;
  font-size: clamp(14px, 1.4vmin, 18px);
}

.lastRow{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:1vh;
}

.lastBox{
  background:var(--called);
  border-radius:14px;
  height:8.5vh;
  min-height:68px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:1000;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.10);
  font-size: clamp(28px, 4vmin, 56px);
}
.lastBox.bump{ animation: bump 280ms ease-out 1; }

.smallNote{
  font-size: clamp(11px, 1.1vmin, 14px);
  opacity:.9;
  margin-top:1vh;
  line-height:1.3;
}

/* Buttons */
.btnRow{
  display:flex;
  gap:1vh;
  flex-wrap:wrap;
}

.btn{
  border:0;
  border-radius:14px;
  padding: 1.2vh 2vh;
  font-weight:900;
  cursor:pointer;
  background:#fff;
  color:#2b2b2b;
  box-shadow: 0 10px 18px rgba(0,0,0,.18);
  flex:1;
  min-width: 160px;
  font-size: clamp(14px, 1.6vmin, 20px);
  transition: transform .06s ease, background-color .18s ease, color .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.btn.primary{ background:var(--accent); color:#fff; }
.btn.danger{ background:#ff5a7a; color:#fff; }
.btn:active{ transform: translateY(1px); }

/* Botón deshabilitado */
.btn:disabled{
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.btn:disabled:active{
  transform: translateY(0);
}

/* Auto button color states */
.btn.auto{
  background: var(--autoOff);
  color:#2b2b2b;
}
.btn.auto.on{
  background: var(--autoOn);
  color:#fff;
  box-shadow: 0 12px 22px rgba(0,0,0,.20);
}

/* Auto controls */
.autoRow{
  margin-top:1.2vh;
  display:flex;
  align-items:center;
  gap:1vh;
  background:rgba(0,0,0,.10);
  padding:1.1vh 1.2vh;
  border-radius:14px;
}
.autoLabel{
  font-weight:900;
  font-size: clamp(12px, 1.2vmin, 16px);
  opacity:.95;
}
.slider-container {
  display: flex;
  align-items: center;
  gap: 0.8vh;
  flex: 1;
}
.slider-hint {
  font-size: clamp(10px, 1vmin, 13px);
  opacity: 0.7;
  font-weight: 600;
  white-space: nowrap;
}
.autoRow input[type="range"]{ flex:1; }
.autoValue{
  min-width:52px;
  text-align:right;
  font-weight:1000;
  font-size: clamp(12px, 1.2vmin, 16px);
}

/* ===== Modal confirm ===== */
.overlay{
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 45, .55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 3vh;
  z-index: 9999;
  backdrop-filter: blur(6px);
}

.overlay.hidden{
  display:none;
}

.modal{
  width: min(560px, 92vw);
  animation: modalIn 180ms ease-out 1;
}

.modalCard{
  background: rgba(255,255,255,.16);
  border-radius: var(--radius);
  box-shadow: 0 20px 55px rgba(0,0,0,.30);
  padding: 18px;
  border: 1px solid rgba(255,255,255,.16);
}

.modalTitle{
  text-align: center;
  font-weight:1000;
  font-size: 22px;
  letter-spacing: .3px;
  margin-bottom: 10px;
}

.modalText{
  opacity: .95;
  line-height: 1.35;
  margin-bottom: 16px;
  text-align: center;
}

.modalActions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.creditsText{
  font-size: clamp(11px, 1.1vmin, 14px);
  opacity:.9;
  line-height:1.3;
}
.creditsText a{
  color: #fff;
  text-decoration: underline;
}

/* Tablets en orientación vertical */
@media (max-width: 1024px) and (orientation: portrait) {
  .wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    width: 100%;
    max-width: none;
    max-height: none;
    gap: clamp(10px, 2vh, 18px);
    padding: clamp(10px, 2vh, 18px);
  }
  
  .side {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5vh;
  }
  
  .side .card {
    flex: 1 1 calc(50% - 0.75vh);
    min-width: 200px;
  }
  
  .brand {
    padding: 1vh;
  }
  
  .big {
    height: auto;
    padding: 1.5vh;
  }
}

/* Responsive (si pantalla muy pequeña) */
@media (max-width: 768px){
  .wrap{ 
    grid-template-columns: 1fr; 
    padding: 1vh;
  }
  .big{ height:auto; }
}

/* Botón Pantalla Completa */
.fullscreen-btn {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 10000;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.fullscreen-btn:active {
  transform: scale(0.95);
}

.fs-icon {
  width: 24px;
  height: 24px;
  color: #fff;
}

.fs-contract {
  display: none;
}

body.fullscreen .fs-expand {
  display: none;
}

body.fullscreen .fs-contract {
  display: block;
}

/* Celebration overlay */
.celebration {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 25%, rgba(46,209,195,0.14), transparent 38%),
    radial-gradient(circle at 70% 30%, rgba(255,90,122,0.12), transparent 40%),
    radial-gradient(circle at 50% 70%, rgba(51,195,255,0.14), transparent 42%),
    rgba(0,0,0,0.68);
  backdrop-filter: blur(6px) saturate(120%);
  pointer-events: none;
  z-index: 12000;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.celebration.hidden {
  display: none;
}

.celebration.show {
  opacity: 1;
  transform: scale(1);
}

.celebration-content {
  text-align: center;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.5));
  position: relative;
  z-index: 2;
}


.confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.confetti span {
  position: absolute;
  width: 12px;
  height: 28px;
  background: #fbbf24;
  border-radius: 6px;
  opacity: 0;
  animation: confetti-fall 1.8s ease-out forwards;
}

.confetti span:nth-child(1)  { left: 4%;  background:#2ed1c3; animation-delay: 0s;    }
.confetti span:nth-child(2)  { left: 10%; background:#ff5a7a; animation-delay: 0.04s; }
.confetti span:nth-child(3)  { left: 16%; background:#33c3ff; animation-delay: 0.08s; }
.confetti span:nth-child(4)  { left: 22%; background:#a78bfa; animation-delay: 0.12s; }
.confetti span:nth-child(5)  { left: 28%; background:#fbbf24; animation-delay: 0.16s; }
.confetti span:nth-child(6)  { left: 34%; background:#ff4fc3; animation-delay: 0.2s;  }
.confetti span:nth-child(7)  { left: 40%; background:#2ed1c3; animation-delay: 0.06s; }
.confetti span:nth-child(8)  { left: 46%; background:#ff5a7a; animation-delay: 0.1s;  }
.confetti span:nth-child(9)  { left: 52%; background:#33c3ff; animation-delay: 0.14s; }
.confetti span:nth-child(10) { left: 58%; background:#a78bfa; animation-delay: 0.18s; }
.confetti span:nth-child(11) { left: 64%; background:#fbbf24; animation-delay: 0.22s; }
.confetti span:nth-child(12) { left: 70%; background:#ff4fc3; animation-delay: 0.26s; }
.confetti span:nth-child(13) { left: 76%; background:#2ed1c3; animation-delay: 0.05s; }
.confetti span:nth-child(14) { left: 82%; background:#ff5a7a; animation-delay: 0.09s; }
.confetti span:nth-child(15) { left: 88%; background:#33c3ff; animation-delay: 0.13s; }
.confetti span:nth-child(16) { left: 94%; background:#a78bfa; animation-delay: 0.17s; }
.confetti span:nth-child(17) { left: 6%;  background:#fbbf24; animation-delay: 0.21s; }
.confetti span:nth-child(18) { left: 26%; background:#ff4fc3; animation-delay: 0.25s; }
.confetti span:nth-child(19) { left: 46%; background:#2ed1c3; animation-delay: 0.29s; }
.confetti span:nth-child(20) { left: 66%; background:#ff5a7a; animation-delay: 0.33s; }
.confetti span:nth-child(21) { left: 74%; background:#33c3ff; animation-delay: 0.3s;  }
.confetti span:nth-child(22) { left: 84%; background:#a78bfa; animation-delay: 0.27s; }
.confetti span:nth-child(23) { left: 14%; background:#fbbf24; animation-delay: 0.24s; }
.confetti span:nth-child(24) { left: 54%; background:#ff4fc3; animation-delay: 0.31s; }

@keyframes confetti-fall {
  0% { transform: translateY(-30vh) rotate(-20deg) scale(0.9); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(110vh) rotate(220deg) scale(1); opacity: 0; }
}

.celebration-word {
  display: inline-flex;
  gap: clamp(4px, 1vmin, 10px);
  font-weight: 1000;
  font-size: clamp(52px, 8vmin, 120px);
  letter-spacing: 2px;
  text-shadow: 0 4px 14px rgba(0,0,0,0.28);
  -webkit-text-stroke: 1px rgba(0,0,0,0.3);
}

.celebration-letter {
  display: inline-block;
  color: var(--color, #fff);
  animation: celebration-pop 0.9s ease forwards;
  animation-delay: var(--delay, 0s);
  transform-origin: center;
  text-shadow: 0 0 8px rgba(255,255,255,0.18);
}

@keyframes celebration-pop {
  0% { opacity: 0; transform: translateY(16px) scale(0.85) rotate(-6deg); }
  50% { opacity: 1; transform: translateY(-6px) scale(1.08) rotate(2deg); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px){
  .celebration-word { font-size: clamp(42px, 10vmin, 90px); }
}

/* Tipografía más grande en pantallas amplias */
@media (min-width: 1280px) and (min-height: 720px) {
  .cell { font-size: clamp(22px, 1.8vw, 54px); }
  .logo { font-size: clamp(56px, 4.5vw, 120px); }
  .big .num { font-size: clamp(120px, 8vw, 260px); }
  .sectionTitle { font-size: clamp(19px, 1vw, 25px); }
  .lastBox { font-size: clamp(32px, 2.8vw, 80px); }
  .btn { font-size: clamp(16px, 1.2vw, 24px); }
  .smallNote { font-size: clamp(13px, 0.9vw, 18px); }
  .autoLabel, .autoValue { font-size: clamp(16px, 1.1vw, 22px); }
  .creditsText { font-size: clamp(14px, 1vw, 20px); }
}

