:root {
  --accent-1: #7928CA;
  --accent-2: #FF0080;
  --accent-grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text: #f0f0f8;
  --text-muted: rgba(240, 240, 248, 0.5);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Poppins', sans-serif;
  background: #060614;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Animated background orbs ── */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.35;
  animation: orbDrift 15s ease-in-out infinite alternate;
}

.orb-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, #7928CA 0%, transparent 70%);
  top: -250px; left: -150px;
  animation-duration: 18s;
}

.orb-2 {
  width: 550px; height: 550px;
  background: radial-gradient(circle, #FF0080 0%, transparent 70%);
  bottom: -180px; right: -120px;
  animation-delay: -6s;
  animation-duration: 14s;
}

.orb-3 {
  width: 450px; height: 450px;
  background: radial-gradient(circle, #0055ff 0%, transparent 70%);
  top: 40%; left: 45%;
  transform: translate(-50%, -50%);
  animation-delay: -12s;
  animation-duration: 20s;
  opacity: 0.2;
}

@keyframes orbDrift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 40px) scale(1.15); }
}

/* ── App layout ── */
.app {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.5rem 0;
  gap: 1.25rem;
}

/* ── Header ── */
.app-header {
  text-align: center;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: clamp(2.4rem, 5vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 0 40px rgba(255, 255, 255, 0.15);
}

.title-accent {
  background: linear-gradient(135deg, #f7971e 0%, #ffd200 50%, #ffb347 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Main 3-column grid ── */
.app-main {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  gap: 2rem;
  width: 100%;
  max-width: 1400px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

/* ── Shared panel (glass card) ── */
.panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Side columns (stacked panels) ── */
.panel-left-col,
.panel-right-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 0;
  overflow-y: auto;
  padding-top: 3rem;
}

.panel-left-col {
  padding-top: 5rem;
}

/* Input group */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.name-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-2);
  opacity: 0.8;
}

textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

textarea::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

textarea:focus {
  border-color: rgba(121, 40, 202, 0.6);
  background: rgba(255, 255, 255, 0.08);
}

/* ── Center column ── */
.wheel-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 0;
}

.wheel-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-glow {
  position: absolute;
  inset: -5%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(121, 40, 202, 0.25) 0%, transparent 70%);
  animation: glowPulse 3s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes glowPulse {
  from { transform: scale(0.95); opacity: 0.6; }
  to   { transform: scale(1.05); opacity: 1; }
}

.wheel-wrapper {
  position: relative;
  aspect-ratio: 1 / 1;
  /* scale with viewport, max out at canvas native size */
  width: min(600px, calc(100vh - 260px));
  filter: drop-shadow(0 0 30px rgba(121, 40, 202, 0.5))
          drop-shadow(0 0 60px rgba(255, 0, 128, 0.2));
}

/* Pointer -- needle only, no ball */
.pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.pointer-needle {
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 42px solid #fff;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

#wheel {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Spin button ── */
#spin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem 2rem;
  width: 100%;
  max-width: 320px;
  background: var(--accent-grad);
  border: none;
  border-radius: var(--radius-lg);
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 4px 30px rgba(255, 0, 128, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  position: relative;
  overflow: hidden;
}

#spin-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}

#spin-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 40px rgba(255, 0, 128, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
}

#spin-btn:active:not(:disabled) {
  transform: scale(0.98);
}

#spin-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.space-hint {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.04em;
  text-align: center;
  margin-top: -0.75rem;
}

/* ── Winner banner (fixed overlay, always centered on screen) ── */
.winner-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 5, 30, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 215, 0, 0.45);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2.5rem;
  text-align: center;
  min-width: 220px;
  max-width: 340px;
  z-index: 100;
  animation: winnerPop 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  box-shadow: 0 0 80px rgba(255, 215, 0, 0.15), 0 12px 40px rgba(0, 0, 0, 0.7);
}

.winner-banner.hidden {
  display: none;
}

.winner-crown {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 0.3rem;
  animation: crownBounce 1s ease-in-out infinite alternate;
}

@keyframes crownBounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-4px); }
}

.winner-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 215, 0, 0.7);
  margin-bottom: 0.3rem;
}

.winner-name {
  font-size: 1.55rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #FFD700, #FFA500, #FF6B35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  word-break: break-word;
}

@keyframes winnerPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}


.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Clear history button ── */
.clear-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.clear-btn:hover {
  background: rgba(255, 0, 128, 0.15);
  border-color: rgba(255, 0, 128, 0.35);
  color: var(--accent-2);
}

/* ── History list ── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

.empty-state {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem 0;
  font-style: italic;
}

/* ── History item ── */
.history-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.history-round {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 20px;
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toggle-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.toggle-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.toggle-label {
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-label input {
  display: none;
}

.toggle-slider {
  display: block;
  width: 48px;
  height: 27px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  position: relative;
  transition: background 0.3s;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 21px;
  height: 21px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.toggle-label input:checked + .toggle-slider {
  background: var(--accent-grad);
  border-color: transparent;
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(21px);
}

/* ── Setting group (speed pills) ── */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.speed-pills {
  display: flex;
  gap: 0.4rem;
}

.speed-pill {
  flex: 1;
  padding: 0.5rem 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-align: center;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
}

.speed-pill:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.speed-pill.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px rgba(255, 0, 128, 0.35);
}

/* ── Reset button ── */
.reset-btn {
  width: 100%;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.reset-btn:hover {
  background: rgba(121, 40, 202, 0.2);
  border-color: rgba(121, 40, 202, 0.4);
  color: #c4a0ff;
}

.reset-btn.hidden {
  display: none;
}

/* ── Footer ── */
.app-footer {
  width: 100%;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.5rem 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.footer-logo {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.footer-tagline {
  font-size: 0.78rem;
  color: rgba(240, 240, 248, 0.35);
  font-style: italic;
}

.footer-copy {
  font-size: 0.65rem;
  color: rgba(240, 240, 248, 0.25);
}

/* ── Responsive (mobile) ── */
@media (max-width: 900px) {
  html, body {
    height: auto;
    overflow: auto;
  }

  .app {
    flex: none;
    min-height: 0;
    overflow: visible;
    padding: 1.25rem 1rem 1rem;
    gap: 1.25rem;
  }

  .app-main {
    grid-template-columns: 1fr;
    align-items: start;
    flex: none;
    min-height: 0;
    gap: 1.25rem;
  }

  /* Order: wheel → right col (participants + history) → left col (settings) */
  .app-main > .wheel-center  { order: 1; }
  .app-main > .panel-right-col { order: 2; }
  .app-main > .panel-left-col  { order: 3; }

  .panel-left-col,
  .panel-right-col {
    width: 100%;
    overflow-y: visible;
    padding-top: 0;
  }

  .wheel-center {
    width: 100%;
    min-height: 0;
    gap: 1rem;
  }

  .wheel-wrapper {
    width: min(90vw, 400px);
  }

  .app-header h1 {
    font-size: clamp(1.8rem, 7vw, 2.8rem);
  }

  .app-main {
    grid-template-columns: 1fr;
  }

  #spin-btn {
    max-width: 100%;
  }

  .toggle-row {
    padding: 0.75rem 0.85rem;
  }

  .app-footer {
    margin-top: 1rem;
  }
}
