:root {
  --bg: #071226;
  --panel: rgba(255, 255, 255, .05);
  --borde: rgba(255, 255, 255, .1);
  --texto: #eaf0f6;
  --suave: #a3b2c2;
  --oro: #5bb0ea;      /* azul claro AMPAR (tema oscuro del ERP) */
  --oro2: #1f6feb;     /* azul del logo */
  --acento: #2e8bff;
  --radio: 20px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--texto);
  background:
    radial-gradient(900px 600px at 10% -10%, rgba(31, 111, 235, .35), transparent 60%),
    radial-gradient(800px 600px at 110% 10%, rgba(21, 102, 156, .3), transparent 60%),
    radial-gradient(700px 500px at 50% 120%, rgba(91, 176, 234, .14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--oro); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; letter-spacing: -.02em; }

.marca { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--oro); }
.marca::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--oro); box-shadow: 0 0 12px var(--oro); }
.vivo::before { background: #22c55e; box-shadow: 0 0 12px #22c55e; animation: pulso 1.6s infinite; }
.vivo { color: #4ade80; }
@keyframes pulso { 50% { opacity: .3; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

/* ---------- Registro ---------- */
.centro { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.tarjeta { width: 100%; max-width: 440px; padding: 36px 28px; }
.tarjeta h1 { font-size: clamp(1.8rem, 6vw, 2.3rem); margin: 12px 0 6px; }
.tarjeta .sub { color: var(--suave); margin: 0 0 28px; }
form { display: grid; gap: 16px; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; color: var(--suave); }
input {
  font: inherit; color: var(--texto);
  padding: 14px 16px; border-radius: 12px;
  background: rgba(0, 0, 0, .25); border: 1px solid var(--borde);
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 4px rgba(46, 139, 255, .3); }
.btn {
  font: inherit; font-weight: 800; letter-spacing: .02em;
  padding: 15px 22px; border: 0; border-radius: 12px; cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #3a8bff, var(--oro2));
  box-shadow: 0 8px 24px rgba(31, 111, 235, .4), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(31, 111, 235, .55), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#msg { min-height: 1.4em; margin: 18px 0 0; font-weight: 600; }
#msg.ok { color: #4ade80; }
#msg.error { color: #fb7185; }
.pie { margin: 22px 0 0; text-align: center; font-size: .95rem; }

/* ---------- Ruleta ---------- */
.escenario { max-width: 1180px; margin: 0 auto; padding: 28px 16px 40px; }
.cabecera { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.cabecera h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin-top: 6px; }
.escenario { max-width: 1440px; }
.rejilla { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; grid-template-areas: 'izq centro der'; gap: 24px; align-items: start; }
.participantes { grid-area: izq; } .zona-ruleta { grid-area: centro; } .lateral { grid-area: der; }
@media (max-width: 1100px) { .rejilla { grid-template-columns: 1fr 1fr; grid-template-areas: 'centro centro' 'izq der'; } }
@media (max-width: 700px) { .rejilla { grid-template-columns: 1fr; grid-template-areas: 'centro' 'izq' 'der'; } }

/* Lista de todos los participantes (izquierda) */
.participantes { padding: 22px; }
.participantes h2 { font-size: 1rem; color: var(--suave); text-transform: uppercase; letter-spacing: .1em; display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.participantes h2 span { font-size: .85rem; color: var(--texto); background: rgba(255, 255, 255, .08); border-radius: 999px; padding: 2px 10px; letter-spacing: 0; }
#todos { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow: auto; }
#todos li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--borde); font-weight: 500; }
#todos li:last-child { border-bottom: 0; }
#todos li.gano::after { content: ''; flex: none; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, .8); }
#todos:empty::after { content: 'Aún no hay registros'; color: var(--suave); font-size: .95rem; }
.zona-ruleta { padding: 24px; display: grid; justify-items: center; gap: 20px; }
canvas#c { width: 100%; max-width: min(620px, calc(100vh - 300px)); min-width: 280px; aspect-ratio: 1; filter: drop-shadow(0 25px 50px rgba(0, 0, 0, .5)); }
#girar { min-width: 220px; font-size: 1.1rem; }

.lateral { padding: 22px; display: grid; gap: 20px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { padding: 16px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid var(--borde); }
.stat b { display: block; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--suave); text-transform: uppercase; letter-spacing: .08em; }
.lateral h2 { font-size: 1rem; color: var(--suave); text-transform: uppercase; letter-spacing: .1em; }
#ganadores { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 420px; overflow: auto; }
#ganadores li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(91, 176, 234, .08); border: 1px solid rgba(91, 176, 234, .22);
  font-weight: 600; animation: entra .4s ease-out;
}
#ganadores li span {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 800;
  color: #fff; background: linear-gradient(180deg, #3a8bff, var(--oro2));
}
#ganadores:empty::after { content: 'Aún no hay ganadores'; color: var(--suave); font-size: .95rem; }
@keyframes entra { from { opacity: 0; transform: translateY(-6px); } }

/* Ventana del ganador */
#modal {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 7, 18, .7); backdrop-filter: blur(6px);
  animation: aparece .3s ease-out;
}
#modal[hidden] { display: none; }
#modal .panel { padding: 40px 32px; text-align: center; max-width: 560px; width: 100%; background: rgba(14, 26, 48, .92); animation: crece .5s cubic-bezier(.2, 1.4, .4, 1); }
#modal p { margin: 0; color: var(--suave); text-transform: uppercase; letter-spacing: .2em; font-weight: 700; font-size: .85rem; }
#modal strong {
  display: block; margin-top: 12px; font-size: clamp(2.2rem, 8vw, 3.8rem); line-height: 1.1; font-weight: 900; word-break: break-word;
  background: linear-gradient(180deg, #ffffff, #bfe0ff 50%, var(--oro)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
@keyframes aparece { from { opacity: 0; } }
@keyframes crece { from { transform: scale(.6); opacity: 0; } }
#confeti { position: fixed; inset: 0; pointer-events: none; z-index: 11; width: 100vw; height: 100vh; }

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

.logo { display: block; height: 46px; width: auto; }
.tarjeta .logo { height: 54px; margin: 0 0 22px; }

/* Diálogo del código */
dialog#dlgCodigo { width: min(420px, calc(100vw - 32px)); padding: 32px 28px; color: var(--texto); background: rgba(14, 26, 48, .97); }
dialog#dlgCodigo::backdrop { background: rgba(5, 10, 22, .7); backdrop-filter: blur(6px); }
dialog#dlgCodigo[open] { animation: crece .35s cubic-bezier(.2, 1.3, .4, 1); }
dialog#dlgCodigo h2 { font-size: 1.6rem; margin: 10px 0 6px; }
dialog#dlgCodigo .sub { color: var(--suave); margin: 0 0 20px; }
dialog#dlgCodigo input { width: 100%; font-size: 1.2rem; letter-spacing: .2em; text-align: center; }
.error { color: #fb7185; font-weight: 600; min-height: 1.4em; margin: 10px 0 6px; }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn.secundario { background: rgba(255, 255, 255, .08); color: var(--texto); box-shadow: none; border: 1px solid var(--borde); }
.btn.secundario:hover:not(:disabled) { background: rgba(255, 255, 255, .14); box-shadow: none; }
/* sin barras de scroll en el diálogo y foco con un solo borde (sin anillo doble) */
dialog#dlgCodigo { overflow: visible; }
dialog#dlgCodigo input:focus { box-shadow: none; border-color: var(--acento); background: rgba(0, 0, 0, .35); }
