:root {
  color: #18233f;
  background: #f7f1dc;
  font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 209, 102, 0.42), transparent 24rem),
    radial-gradient(circle at 88% 18%, rgba(78, 205, 196, 0.3), transparent 22rem),
    linear-gradient(135deg, #fff7df 0%, #f7f1dc 44%, #dff6ff 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  width: min(100% - 1rem, 1280px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.25rem) 0 clamp(1rem, 2vw, 1.5rem);
  place-items: center;
}

.admin-toggle {
  position: fixed;
  z-index: 12;
  top: 1rem;
  right: 1rem;
  min-height: 46px;
  padding: 0.65rem 0.95rem;
  border: 3px solid #25314f;
  border-radius: 8px;
  background: #b8f2e6;
  color: #18233f;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 4px 4px 0 #25314f;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.admin-toggle:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #25314f;
}

.spinner-stage {
  display: grid;
  justify-items: center;
  gap: clamp(0.75rem, 1.6vh, 1rem);
  width: 100%;
  min-height: calc(100vh - 2rem);
  padding: 0;
}

.title-group {
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: #e14d5f;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Fredoka", "Nunito", sans-serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 4.5rem);
  line-height: 0.94;
}

h2 {
  font-size: 1.7rem;
  line-height: 1;
}

.wheel-wrap {
  position: relative;
  width: min(92vw, 76vh, 780px);
  aspect-ratio: 1;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 18px 0 rgba(37, 49, 79, 0.18));
}

.pointer {
  position: absolute;
  z-index: 3;
  top: -4px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 24px solid transparent;
  border-right: 24px solid transparent;
  border-top: 54px solid #25314f;
  transform: translateX(-50%);
}

.pointer::after {
  position: absolute;
  top: -50px;
  left: -14px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 34px solid #ff6b6b;
  content: "";
}

.wheel-center {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  width: 25%;
  min-width: 82px;
  aspect-ratio: 1;
  place-items: center;
  border: 6px solid #25314f;
  border-radius: 50%;
  background: #fff8e8;
  color: #25314f;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(1.1rem, 3vw, 1.7rem);
  font-weight: 700;
  transform: translate(-50%, -50%);
}

.spin-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.primary-button,
.secondary-button,
.mini-button,
.icon-button {
  border: 3px solid #25314f;
  border-radius: 8px;
  color: #18233f;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 4px 4px 0 #25314f;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.mini-button:hover,
.icon-button:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #25314f;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.2rem;
  background: #ffd166;
  font-size: 1.1rem;
}

.names-panel {
  position: fixed;
  z-index: 15;
  top: 0;
  right: 0;
  width: min(92vw, 430px);
  height: 100vh;
  overflow: auto;
  padding: 1rem;
  border-left: 4px solid #25314f;
  background: #ffffff;
  box-shadow: -10px 0 0 rgba(37, 49, 79, 0.22);
  transform: translateX(calc(100% + 14px));
  transition: transform 220ms ease;
}

.names-panel.is-open {
  transform: translateX(0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(24, 35, 63, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.count-pill {
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem;
  border: 2px solid #25314f;
  border-radius: 999px;
  background: #b8f2e6;
  font-size: 0.9rem;
  font-weight: 800;
}

.drawer-close {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #ff6b6b;
  color: #25314f;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
}

.add-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 3px solid #25314f;
  border-radius: 8px;
  background: #fff8e8;
  color: #18233f;
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 0.85rem;
}

textarea {
  min-height: 7rem;
  padding: 0.75rem 0.85rem;
  resize: vertical;
}

input:focus,
textarea:focus {
  box-shadow: 0 0 0 4px rgba(90, 169, 230, 0.26);
}

.icon-button,
.secondary-button,
.mini-button {
  background: #7bd88f;
}

.icon-button {
  min-width: 48px;
  min-height: 48px;
  font-size: 2rem;
  line-height: 1;
}

.secondary-button {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 0.8rem;
}

.quick-actions,
.backup-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 1rem 0;
}

.backup-actions {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 1rem;
}

.mini-button {
  min-height: 42px;
  padding: 0.45rem 0.35rem;
  font-size: 0.87rem;
}

.mini-button.danger {
  background: #ff9aa7;
}

.import-button {
  display: grid;
  place-items: center;
  text-align: center;
}

#importRosterInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.name-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 0.55rem;
  align-items: center;
  min-height: 54px;
  padding: 0.45rem 0.45rem 0.45rem 0.65rem;
  border: 3px solid #25314f;
  border-radius: 8px;
  background: #f7fbff;
}

.switch-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 0.65rem;
  align-items: center;
  min-width: 0;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  border: 3px solid #25314f;
  border-radius: 999px;
  background: #d6dbe7;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 2px #25314f;
  content: "";
  transition: transform 160ms ease;
}

.switch-row input:checked + .switch {
  background: #7bd88f;
}

.switch-row input:checked + .switch::after {
  transform: translateX(20px);
}

.student-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.03rem;
  font-weight: 800;
}

.remove-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #ff6b6b;
  color: #25314f;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.winner-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(24, 35, 63, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.winner-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

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

.confetti-piece {
  position: absolute;
  top: -18px;
  width: 12px;
  height: 18px;
  border: 2px solid rgba(37, 49, 79, 0.22);
  border-radius: 3px;
  background: var(--confetti-color);
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.35, 1);
  animation-fill-mode: forwards;
}

.confetti-piece:nth-child(3n) {
  width: 18px;
  height: 10px;
}

.confetti-piece:nth-child(4n) {
  border-radius: 999px;
}

.winner-card {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  width: min(92vw, 520px);
  padding: clamp(1.4rem, 5vw, 2.3rem);
  border: 5px solid #25314f;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.4), transparent 42%),
    linear-gradient(225deg, rgba(78, 205, 196, 0.32), transparent 44%),
    #fff8e8;
  box-shadow: 12px 12px 0 #25314f;
  text-align: center;
  transform: translateY(18px) scale(0.96);
  transition: transform 220ms ease;
}

.winner-eyebrow {
  color: #25314f;
}

.winner-modal.is-open .winner-card {
  transform: translateY(0) scale(1);
}

.winner-card h2 {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.7rem 0.9rem;
  border: 4px dashed #25314f;
  border-radius: 8px;
  background: #ffffff;
  color: #e14d5f;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(2rem, 12vw, 5rem);
  font-weight: 700;
  line-height: 1;
  overflow-wrap: anywhere;
}

.modal-button {
  min-width: min(100%, 190px);
  margin-top: 1.2rem;
  justify-content: center;
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -40px, 0) rotate(0deg);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0.92;
    transform: translate3d(var(--confetti-drift), 110vh, 0) rotate(var(--confetti-spin));
  }
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100% - 0.75rem, 1280px);
  }

  .wheel-wrap {
    width: min(94vw, 68vh, 720px);
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 0.5rem, 1280px);
    padding: 0.5rem 0 1rem;
  }

  .names-panel {
    width: min(94vw, 430px);
  }

  .wheel-wrap {
    width: min(94vw, 58vh, 620px);
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .backup-actions {
    grid-template-columns: 1fr;
  }
}
