:root {
  --wheel-text: #334155;
  --wheel-text-muted: #64748b;
  --wheel-accent: #6366f1;
  --wheel-accent-hover: #4f46e5;
  --wheel-accent-soft: rgba(99, 102, 241, 0.1);
  --wheel-accent-border: rgba(99, 102, 241, 0.22);
  --wheel-surface: #ffffff;
  --wheel-surface-elevated: rgba(255, 255, 255, 0.72);
  --wheel-border: rgba(148, 163, 184, 0.2);
  --wheel-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --wheel-shadow-soft: 0 8px 32px rgba(99, 102, 241, 0.08);
  --wheel-radius: 1rem;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(165deg, #f1f5f9 0%, #eef2f7 35%, #f8fafc 100%);
  color: var(--wheel-text);
  min-height: 100vh;
}

body.wheel-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* —— Encabezado compacto —— */
.wheel-top-bar {
  flex-shrink: 0;
  z-index: 1030;
  background: var(--wheel-surface-elevated);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--wheel-border);
}

.wheel-top-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  padding: 0.3rem 0.65rem;
  max-width: 1400px;
  margin: 0 auto;
}

.wheel-brand {
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 0.8125rem;
  color: var(--wheel-accent);
  max-width: min(11rem, 42vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

@media (min-width: 576px) {
  .wheel-brand {
    font-size: 0.875rem;
    max-width: 13rem;
  }
}

.wheel-top-divider {
  width: 1px;
  height: 1.1rem;
  background: var(--wheel-border);
  align-self: center;
}

.wheel-top-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

@media (max-width: 575.98px) {
  .wheel-top-controls {
    width: 100%;
    justify-content: flex-start;
  }
}

.wheel-label-lista {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--wheel-text-muted);
}

.wheel-select-lista {
  min-width: 7rem;
  max-width: min(14rem, 46vw);
  border-color: var(--wheel-border);
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.wheel-btn-header {
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--wheel-border);
  background: var(--wheel-surface);
  color: var(--wheel-text);
}

.wheel-btn-header:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--wheel-text);
}

.wheel-btn-header-primary {
  background: var(--wheel-accent-soft);
  border-color: var(--wheel-accent-border);
  color: var(--wheel-accent);
}

.wheel-btn-header-primary:hover {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--wheel-accent-hover);
}

/* —— Cuerpo: ruleta + panel lateral —— */
.wheel-view-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.5rem 0.65rem 0.65rem;
  overflow: auto;
}

.wheel-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: center;
  justify-items: center;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
}

@media (min-width: 992px) {
  .wheel-layout {
    grid-template-columns: 1fr min(17.5rem, 28vw);
    gap: 1rem 1.25rem;
    align-items: center;
    justify-items: stretch;
  }

  .wheel-col-wheel {
    justify-self: center;
    width: 100%;
    max-width: min(100%, calc(100vh - 5.25rem), calc(100vw - 17rem));
  }

  .wheel-col-actions {
    justify-self: stretch;
    align-self: center;
  }

  .wheel-view-main {
    overflow: hidden;
  }
}

.wheel-col-wheel {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 0;
}

.wheel-col-actions {
  width: 100%;
  max-width: 22rem;
}

/* Tamaño ruleta: cabe en altura de ventana sin scroll (aprox.) */
.wheel-stage {
  position: relative;
  width: min(100%, 76vmin, calc(100vh - 8.75rem), calc(100dvh - 8.75rem), 700px);
  aspect-ratio: 1 / 1;
  max-height: min(76vmin, calc(100vh - 8.75rem), calc(100dvh - 8.75rem), 700px);
  margin: 0 auto;
}

@media (min-width: 992px) {
  .wheel-stage {
    width: min(100%, calc(100vh - 5.25rem), calc(100dvh - 5.25rem), 640px);
    max-height: min(calc(100vh - 5.25rem), calc(100dvh - 5.25rem), 640px);
  }
}

.wheel-canvas-wrap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: var(--wheel-shadow-soft);
  background: var(--wheel-surface);
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

#wheelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.wheel-pointer {
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-left: 26px solid #a8b4c9;
  filter: drop-shadow(1px 1px 2px rgba(15, 23, 42, 0.12));
  z-index: 2;
}

.wheel-pointer::after {
  content: "";
  position: absolute;
  left: -28px;
  top: -12px;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 22px solid #cbd5e1;
}

/* Panel de acciones */
.wheel-panel {
  background: var(--wheel-surface);
  border: 1px solid var(--wheel-border);
  border-radius: var(--wheel-radius);
  box-shadow: var(--wheel-shadow);
  padding: 1rem 1.1rem;
  width: 100%;
}

.btn-spin {
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(180deg, #818cf8 0%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-spin:hover {
  background: linear-gradient(180deg, #8b93f9 0%, #4f46e5 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-spin:active {
  transform: translateY(0);
}

.result-banner {
  min-height: 2.75rem;
  border-radius: 0.65rem;
  background: var(--wheel-accent-soft);
  border: 1px solid var(--wheel-accent-border);
  padding: 0.65rem 0.85rem;
  text-align: center;
}

.result-banner-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--wheel-text-muted);
  margin-bottom: 0.2rem;
}

.result-banner-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--wheel-accent);
  line-height: 1.25;
  word-break: break-word;
}

.wheel-btn-soft {
  border-radius: 0.5rem;
  border: 1px solid var(--wheel-border);
  background: #f8fafc;
  color: var(--wheel-text);
  font-size: 0.8125rem;
}

.wheel-btn-soft:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--wheel-text);
}

.wheel-btn-soft:disabled {
  opacity: 0.55;
}

.wheel-sound-switch {
  padding-top: 0.25rem;
  border-top: 1px solid var(--wheel-border);
}

.wheel-sound-switch .form-check-label {
  font-size: 0.8125rem;
  color: var(--wheel-text-muted);
  line-height: 1.35;
}

.wheel-sound-switch .form-check-input {
  width: 2.1rem;
  height: 1.05rem;
  margin-top: 0.15rem;
  background-color: #e2e8f0;
  border-color: #cbd5e1;
}

.wheel-sound-switch .form-check-input:checked {
  background-color: var(--wheel-accent);
  border-color: var(--wheel-accent);
}

.wheel-sound-select {
  font-size: 0.8125rem;
  border-color: var(--wheel-border);
  border-radius: 0.5rem;
}

.card-soft {
  border: none;
  border-radius: var(--wheel-radius);
  box-shadow: var(--wheel-shadow);
}

.footer-hint {
  font-size: 0.85rem;
  color: var(--wheel-text-muted);
}

.table-students td {
  vertical-align: middle;
}

@media (max-width: 991.98px) {
  .wheel-col-actions {
    max-width: min(22rem, 100%);
  }

  /* Más espacio para panel apilado (girar → sonido) sin tanto scroll */
  .wheel-stage {
    width: min(100%, 66vmin, calc(100dvh - 15.25rem), 560px);
    max-height: min(66vmin, calc(100dvh - 15.25rem), 560px);
  }
}

@media (max-width: 576px) {
  .wheel-pointer {
    border-left-width: 20px;
    border-top-width: 12px;
    border-bottom-width: 12px;
    left: -2px;
  }
}
