/* =========================================================================
 * Mobbyt — Ruleta digital (playwheel) · ver004
 * Todo va scopeado bajo .pw-app para no tocar los estilos del portal
 * (cabecera, footer, Bootstrap 3).
 * ========================================================================= */

.pw-app {
  /* ---- Tokens: tema "Aula" (por defecto) ---- */
  --pw-ink: #14161C;
  --pw-slate: #1E222B;
  --pw-line: #2C313D;
  --pw-chalk: #F2F4F8;
  --pw-muted: #8B93A3;
  --pw-amber: #FFB020;
  --pw-mint: #35D0A5;
  --pw-stage: #0E1015;

  --pw-display: "Bricolage Grotesque", system-ui, sans-serif;
  --pw-body: "Inter", system-ui, -apple-system, sans-serif;
  --pw-mono: "JetBrains Mono", ui-monospace, monospace;

  display: grid;
  grid-template-columns: 1fr 340px;
  background: var(--pw-ink);
  color: var(--pw-chalk);
  font-family: var(--pw-body);
  transition: background 400ms ease, color 400ms ease;
}

.pw-app[data-theme="pastel"] {
  --pw-ink: #FBF7F2; --pw-slate: #FFFFFF; --pw-line: #E8DFD4;
  --pw-chalk: #2C2A26; --pw-muted: #8A8377; --pw-amber: #E07A3F;
  --pw-mint: #4FA88A; --pw-stage: #F4EDE4;
}
.pw-app[data-theme="neon"] {
  --pw-ink: #0A0A14; --pw-slate: #12122A; --pw-line: #2A2A55;
  --pw-chalk: #EDEBFF; --pw-muted: #8C8AC0; --pw-amber: #FF3DA6;
  --pw-mint: #3DF5FF; --pw-stage: #06060F;
}
.pw-app[data-theme="contraste"] {
  --pw-ink: #000000; --pw-slate: #111111; --pw-line: #555555;
  --pw-chalk: #FFFFFF; --pw-muted: #BBBBBB; --pw-amber: #FFE600;
  --pw-mint: #00FF95; --pw-stage: #000000;
}

.pw-app *,
.pw-app *::before,
.pw-app *::after { box-sizing: border-box; }

/* --- Escenario ---------------------------------------------------------- */

.pw-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 48px;
  overflow: hidden;
  min-height: 600px;
  /* Color sólido de base (cubre siempre) + halo radial encima (decorativo).
     Antes solo estaba el radial: si el panel estiraba la celda, asomaba el
     fondo claro del body y quedaba un hueco blanco. */
  background-color: var(--pw-stage);
  background-image: radial-gradient(ellipse 68% 55% at 50% 42%, var(--pw-slate) 0%, transparent 72%);
}

.pw-eyebrow {
  font-family: var(--pw-mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--pw-muted);
  margin: 0 0 6px;
}

.pw-title {
  font-family: var(--pw-display);
  font-weight: 800;
  font-size: clamp(26px, 3.4vw, 46px);
  letter-spacing: -.02em;
  line-height: 1.05;
  text-align: center;
  margin: 0 0 20px;
  max-width: 16ch;
  color: var(--pw-chalk);
  border: 0;
  word-break: break-word;
}

.pw-title-edit {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  width: min(100%, 420px);
}
.pw-title-edit[hidden] { display: none; }
.pw-title-edit input {
  flex: 1;
  min-width: 0;
  background: var(--pw-ink);
  color: var(--pw-chalk);
  border: 1px solid var(--pw-line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--pw-body);
  font-size: 15px;
}
.pw-title-edit input:focus {
  outline: none;
  border-color: var(--pw-mint);
}

/* --- Ruleta ------------------------------------------------------------- */

.pw-wheel-wrap {
  position: relative;
  width: min(66vh, 560px);
  aspect-ratio: 1 / 1;
  max-width: 100%;
}

.pw-wheel-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#pwWheel { cursor: pointer; border-radius: 50%; }
#pwFx { pointer-events: none; z-index: 5; }

/* El momento del ganador: el gajo queda iluminado, el nombre crece encima. */
.pw-reveal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}
.pw-reveal.is-on { opacity: 1; }

.pw-reveal-name {
  font-family: var(--pw-display);
  font-weight: 800;
  font-size: clamp(30px, 5.5vw, 72px);
  letter-spacing: -.03em;
  line-height: 1.05;
  color: #fff;
  text-align: center;
  padding: 0 8%;
  word-break: break-word;
  text-shadow: 0 4px 40px rgba(0, 0, 0, .8), 0 2px 8px rgba(0, 0, 0, .9);
  transform: scale(.75);
  transition: transform 520ms cubic-bezier(.16, 1.2, .3, 1);
}
.pw-reveal.is-on .pw-reveal-name { transform: scale(1); }

/* --- Botones ------------------------------------------------------------ */

.pw-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 24px;
}

.pw-btn {
  font-family: var(--pw-body);
  border: 0;
  cursor: pointer;
  transition: transform 120ms ease, filter 160ms ease, color 160ms ease, border-color 160ms ease;
}
.pw-btn:active { transform: translateY(1px) scale(.98); }
.pw-btn:focus-visible { outline: 3px solid var(--pw-mint); outline-offset: 3px; }

.pw-btn-spin {
  background: var(--pw-amber);
  color: #14161C;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .02em;
  padding: 15px 42px;
  border-radius: 999px;
  box-shadow: 0 8px 30px -8px var(--pw-amber);
  min-height: 52px;
}
.pw-btn-spin:hover { filter: brightness(1.08); }
.pw-btn-spin:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }

.pw-btn-ghost {
  background: transparent;
  color: var(--pw-muted);
  border: 1px solid var(--pw-line);
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 14px;
  min-height: 48px;
}
.pw-btn-ghost:hover { color: var(--pw-chalk); border-color: var(--pw-muted); }

.pw-btn-block { display: block; width: 100%; margin-bottom: 8px; }

.pw-hint {
  font-family: var(--pw-mono);
  font-size: 11px;
  color: var(--pw-muted);
  margin-top: 14px;
}
.pw-hint kbd {
  font-family: var(--pw-mono);
  font-size: 10px;
  background: var(--pw-slate);
  border: 1px solid var(--pw-line);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--pw-chalk);
  box-shadow: none;
}

/* Anuncio para lectores de pantalla */
.pw-live {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --- Panel -------------------------------------------------------------- */

.pw-panel {
  background: var(--pw-slate);
  border-left: 1px solid var(--pw-line);
  padding: 26px 22px;
}

.pw-section { margin-bottom: 30px; }
.pw-section:last-child { margin-bottom: 0; }

.pw-panel h2 {
  font-family: var(--pw-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--pw-muted);
  margin: 0 0 12px;
  border: 0;
  padding: 0;
}

.pw-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.pw-chip {
  background: transparent;
  border: 1px solid var(--pw-line);
  color: var(--pw-muted);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: 140ms all;
}
.pw-chip:hover { border-color: var(--pw-muted); color: var(--pw-chalk); }
.pw-chip.is-on {
  background: var(--pw-chalk);
  color: var(--pw-ink);
  border-color: var(--pw-chalk);
  font-weight: 500;
}

#pwList {
  width: 100%;
  height: 190px;
  min-height: 120px;
  max-height: 420px;
  resize: vertical;
  background: var(--pw-ink);
  color: var(--pw-chalk);
  border: 1px solid var(--pw-line);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--pw-body);
  font-size: 14px;
  line-height: 1.7;
}
#pwList:focus { outline: none; border-color: var(--pw-mint); }

.pw-count {
  display: block;
  font-family: var(--pw-mono);
  font-size: 11px;
  color: var(--pw-muted);
  margin-top: 6px;
}

.pw-toggles { display: flex; flex-direction: column; gap: 8px; }

.pw-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--pw-ink);
  border: 1px solid var(--pw-line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--pw-chalk);
  cursor: pointer;
  transition: border-color 140ms ease;
}
.pw-toggle:hover { border-color: var(--pw-muted); }
.pw-toggle small {
  display: block;
  color: var(--pw-muted);
  font-size: 12px;
  margin-top: 2px;
}

.pw-pill {
  flex-shrink: 0;
  font-family: var(--pw-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--pw-line);
  color: var(--pw-muted);
}
.pw-toggle[aria-pressed="true"] .pw-pill {
  background: var(--pw-mint);
  color: var(--pw-ink);
  font-weight: 700;
}

.pw-themes { display: flex; gap: 8px; }
.pw-swatch {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
}
.pw-swatch[aria-pressed="true"] { border-color: var(--pw-chalk); }

.pw-history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.pw-history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--pw-line);
  color: var(--pw-chalk);
}
.pw-history li span {
  font-family: var(--pw-mono);
  font-size: 11px;
  color: var(--pw-muted);
}
.pw-history:empty::after {
  content: attr(data-empty);
  color: var(--pw-muted);
  font-size: 13px;
}

.pw-note {
  font-size: 12px;
  color: var(--pw-muted);
  line-height: 1.6;
  border-left: 2px solid var(--pw-amber);
  padding-left: 12px;
  margin-top: 12px;
}

.pw-ad {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
}
.pw-ad-bottom { padding: 24px 15px; }

/* --- Modo proyector ----------------------------------------------------- */

.pw-app.is-projector {
  position: fixed;
  inset: 0;
  z-index: 9999;
  grid-template-columns: 1fr;
  height: 100vh;
  /* Permite scroll si el contenido no entra, en vez de cortarlo. */
  overflow-y: auto;
}
.pw-app.is-projector .pw-panel { display: none; }
.pw-app.is-projector .pw-stage {
  min-height: 100vh;
  height: auto;
  /* Empuja el contenido desde arriba con aire para que el título de dos
     líneas no toque el borde superior. */
  justify-content: flex-start;
  padding-top: clamp(24px, 5vh, 64px);
  padding-bottom: clamp(24px, 5vh, 64px);
}
.pw-app.is-projector .pw-title { font-size: clamp(30px, 4vw, 60px); }
.pw-app.is-projector .pw-wheel-wrap { width: min(68vh, 720px); }

/* En proyector no se muestran anuncios (AdSense no sirve en fullscreen y
   además reservaba un hueco vacío). */
.pw-app.is-projector .pw-ad { display: none; }
body.pw-locked { overflow: hidden; }
body.pw-locked .pw-ad-bottom,
body.pw-locked .pw-content { display: none; }


/* --- Responsive --------------------------------------------------------- */

@media (max-width: 991px) {
  .pw-app { grid-template-columns: 1fr; }
  .pw-stage { padding: 24px 16px 28px; }
  .pw-wheel-wrap { width: min(88vw, 460px); }
  .pw-panel { border-left: 0; border-top: 1px solid var(--pw-line); }
  .pw-hint { display: none; }
  .pw-btn-spin { padding: 17px 52px; font-size: 17px; min-height: 56px; }
}

@media (max-width: 480px) {
  .pw-title { font-size: 24px; }
  .pw-actions .pw-btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .pw-app *,
  .pw-app *::before,
  .pw-app *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* =========================================================================
 * Bloque de contenido SEO (fuera del escenario: legible, fondo claro)
 * ========================================================================= */

.pw-stage-lead {
  font-family: var(--pw-body);
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--pw-muted);
  max-width: 46ch;
  text-align: center;
  margin: -8px 0 22px;
  line-height: 1.5;
}

.pw-content {
  background: #FBFBFD;
  color: #23262D;
  padding: 64px 20px 72px;
  border-top: 1px solid #ECEDF1;
}
.pw-content-inner {
  max-width: 760px;
  margin: 0 auto;
}

.pw-article .pw-lead {
  font-family: var(--pw-body);
  font-size: 20px;
  line-height: 1.6;
  color: #33373F;
  margin: 0 0 36px;
}
.pw-article h2 {
  font-family: var(--pw-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -.01em;
  color: #16181D;
  margin: 40px 0 12px;
  border: 0;
  padding: 0;
}
.pw-article p {
  font-size: 16px;
  line-height: 1.75;
  color: #3A3E47;
  margin: 0 0 16px;
}
.pw-article em { font-style: normal; font-weight: 600; color: #16181D; }
.pw-article strong { color: #16181D; }

/* FAQ */
.pw-faq { margin: 8px 0 0; }
.pw-faq dt {
  font-family: var(--pw-body);
  font-weight: 600;
  font-size: 17px;
  color: #16181D;
  margin: 22px 0 6px;
}
.pw-faq dd {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: #3A3E47;
}

/* Enlazado interno */
.pw-related {
  max-width: 760px;
  margin: 56px auto 0;
  padding-top: 40px;
  border-top: 1px solid #ECEDF1;
}
.pw-related h2 {
  font-family: var(--pw-mono);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #8A8F9A;
  margin: 0 0 18px;
}
.pw-related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.pw-related a {
  display: block;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid #E7E8EE;
  border-radius: 12px;
  text-decoration: none;
  transition: border-color 140ms ease, transform 140ms ease;
}
.pw-related a:hover {
  border-color: #C9CBD4;
  transform: translateY(-2px);
}
.pw-related-title {
  display: block;
  font-family: var(--pw-display);
  font-weight: 700;
  font-size: 17px;
  color: #16181D;
  margin-bottom: 4px;
}
.pw-related-lead {
  display: block;
  font-size: 13px;
  line-height: 1.5;
  color: #6A6F7A;
}

@media (max-width: 600px) {
  .pw-content { padding: 44px 18px 52px; }
  .pw-article h2 { font-size: 22px; }
  .pw-article .pw-lead { font-size: 18px; }
}

/* =========================================================================
 * Modo equipos: selector + tarjetas de resultado
 * ========================================================================= */

.pw-team-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--pw-ink);
  border: 1px solid var(--pw-line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--pw-chalk);
}
.pw-team-count[hidden] { display: none; }

.pw-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pw-stepper button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--pw-line);
  background: var(--pw-slate);
  color: var(--pw-chalk);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 140ms ease;
}
.pw-stepper button:hover:not(:disabled) { border-color: var(--pw-muted); }
.pw-stepper button:disabled { opacity: .4; cursor: not-allowed; }
.pw-stepper output {
  min-width: 28px;
  text-align: center;
  font-family: var(--pw-mono);
  font-size: 16px;
  font-weight: 500;
}

/* Resultado del reparto */
.pw-teams-result {
  width: 100%;
  max-width: 640px;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.pw-teams-result[hidden] { display: none; }

.pw-teams-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.pw-team-card {
  background: var(--pw-slate);
  border: 1px solid var(--pw-line);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
}
.pw-team-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--pw-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--pw-chalk);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--pw-line);
}
.pw-team-card h3 span {
  font-family: var(--pw-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--pw-ink);
  background: var(--pw-mint);
  border-radius: 999px;
  padding: 2px 8px;
}
.pw-team-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pw-team-card li {
  font-size: 14px;
  color: var(--pw-chalk);
  padding: 3px 0;
}

/* En modo equipos, dejamos ver la ruleta girar pero el foco es el reparto */
.pw-teams-result:not([hidden]) ~ * { /* nada */ }

/* Selector de modo de reparto (todos de una / de a uno) */
.pw-team-mode {
  margin-top: 8px;
}
.pw-team-mode[hidden] { display: none; }
.pw-team-mode > span {
  display: block;
  font-size: 13px;
  color: var(--pw-muted);
  margin-bottom: 6px;
}
.pw-seg {
  display: flex;
  gap: 4px;
  background: var(--pw-ink);
  border: 1px solid var(--pw-line);
  border-radius: 10px;
  padding: 4px;
}
.pw-seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--pw-muted);
  padding: 9px 8px;
  border-radius: 7px;
  font-size: 13px;
  font-family: var(--pw-body);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.pw-seg button.is-on {
  background: var(--pw-mint);
  color: var(--pw-ink);
  font-weight: 600;
}

/* Estado activo de la tarjeta y animación de la nueva incorporación */
.pw-team-card { transition: border-color 200ms ease; }
.pw-team-card.is-active { border-color: var(--pw-mint); }
.pw-team-card li.is-new {
  animation: pw-slidein 450ms cubic-bezier(.16, 1.2, .3, 1) both;
}
@keyframes pw-slidein {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================================
 * Juice y refinamiento de interfaz (ver007)
 * ========================================================================= */

/* Botón de ícono cuadrado (mute) */
.pw-btn-icon {
  background: transparent;
  color: var(--pw-muted);
  border: 1px solid var(--pw-line);
  border-radius: 999px;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pw-btn-icon:hover { color: var(--pw-chalk); border-color: var(--pw-muted); }
.pw-btn-icon .pw-ico-muted { display: none; }
.pw-btn-icon.is-muted { color: var(--pw-amber); border-color: var(--pw-amber); }
.pw-btn-icon.is-muted .pw-ico-sound { display: none; }
.pw-btn-icon.is-muted .pw-ico-muted { display: block; }

.pw-btn-ghost svg { color: currentColor; }

/* La ruleta invita a que le hagan clic: leve realce al pasar el mouse */
#pwWheel {
  transition: filter 200ms ease, transform 200ms ease;
}
.pw-wheel-wrap:hover #pwWheel {
  filter: drop-shadow(0 0 24px rgba(255, 176, 32, 0.18));
}
.pw-wheel-wrap:active #pwWheel {
  transform: scale(0.992);
}

/* El botón Girar respira suavemente cuando está listo (no mientras gira) */
@keyframes pw-ready {
  0%, 100% { box-shadow: 0 8px 30px -8px var(--pw-amber); }
  50%      { box-shadow: 0 8px 38px -6px var(--pw-amber); }
}
.pw-btn-spin:not(:disabled):not(:hover) {
  animation: pw-ready 2.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .pw-btn-spin { animation: none; }
  #pwWheel { transition: none; }
}

/* Responsividad: en pantallas bajas el escenario no fuerza 600px */
@media (max-height: 720px) {
  .pw-stage { min-height: auto; }
}
@media (max-width: 991px) {
  .pw-stage { min-height: auto; }
}