:root {
  --bg-1: #fff5e6;
  --bg-2: #ffe2f0;
  --ink: #1a1230;
  --ink-soft: #5b4a7a;
  --ink-mute: #8d80a8;
  --line: #efe3f3;
  --card: #ffffff;
  --accent: #ff3d8b;
  --accent-2: #ffb02e;
  --accent-3: #6ee7b7;
  --accent-4: #5b8def;
  --accent-5: #c084fc;

  /* Wheel palette — bright, candy */
  --w1: #ff3d8b;
  --w2: #ffb02e;
  --w3: #5b8def;
  --w4: #6ee7b7;
  --w5: #c084fc;
  --w6: #ff7a5c;
  --w7: #4cc9f0;
  --w8: #f9c74f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 90% -10%, #ffd6e8 0%, transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, #ffe7c2 0%, transparent 55%),
    radial-gradient(900px 600px at 50% 50%, #f3e8ff 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
}

/* ---------- App layout ---------- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
  padding: 28px;
  max-width: 1480px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: conic-gradient(from 30deg, var(--w1), var(--w2), var(--w3), var(--w4), var(--w5), var(--w1));
  box-shadow:
    inset 0 0 0 4px #fff,
    0 8px 22px rgba(255, 61, 139, 0.35);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 38%;
  background: var(--ink);
  border-radius: 50%;
}

.brand h1 {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 24px;
  margin: 0;
  letter-spacing: -0.01em;
}
.brand .tag {
  font-size: 12px;
  color: var(--ink-mute);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ---------- User list ---------- */
.panel {
  background: var(--card);
  border-radius: 28px;
  padding: 22px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 30px 60px -30px rgba(91, 35, 110, 0.25),
    0 8px 20px -10px rgba(91, 35, 110, 0.1);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  position: sticky;
  top: 28px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.panel-head h2 {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 20px;
  margin: 0;
}
.panel-head .count {
  font-size: 13px;
  color: var(--ink-mute);
  font-weight: 600;
}

.list-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.list-actions .pill {
  flex: 1;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  background: #f6eef9;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s;
}
.list-actions .pill:hover { background: #ecdcf3; color: var(--ink); }

.user-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
  scrollbar-width: thin;
}
.user-list::-webkit-scrollbar { width: 8px; }
.user-list::-webkit-scrollbar-thumb { background: #ecdcf3; border-radius: 4px; }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  transition: background 0.12s;
  cursor: pointer;
  user-select: none;
}
.user-row:hover { background: #faf3fb; }
.user-row:focus-visible { outline: 2px solid var(--accent-5); outline-offset: 2px; }
.user-row.unchecked .name { color: var(--ink-mute); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.user-row.unchecked .swatch { opacity: 0.25; filter: saturate(0.3); }

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,0.06);
  transition: opacity 0.15s, filter 0.15s;
}

.name-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: inherit;
  padding: 4px 0;
  min-width: 0;
}
.name-input:focus { outline: none; }

.name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Custom checkbox */
.checkbox {
  --size: 22px;
  width: var(--size);
  height: var(--size);
  border-radius: 7px;
  flex: none;
  position: relative;
  background: #fff;
  box-shadow: inset 0 0 0 2px #e4d2ec;
  transition: all 0.15s;
}
.checkbox:hover { box-shadow: inset 0 0 0 2px var(--ink-soft); }
.checkbox.checked {
  background: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
}
.checkbox.checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.row-del {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-mute);
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
  font-size: 14px;
}
.user-row:hover .row-del { opacity: 1; }
.row-del:hover { background: #ffe3ec; color: var(--accent); }

.add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.add-row input {
  flex: 1;
  border: none;
  background: #f7eff9;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.add-row input::placeholder { color: var(--ink-mute); font-weight: 500; }
.add-row input:focus { outline: 2px solid var(--accent-5); outline-offset: 1px; background: #fff; }
.add-row input:disabled { opacity: 0.4; cursor: not-allowed; }

.add-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 600;
  transition: transform 0.12s, background 0.12s;
}
.add-btn:hover { background: var(--accent); transform: rotate(90deg); }
.add-btn:disabled { background: #d9cee0; cursor: not-allowed; transform: none; }

/* ---------- Stage ---------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 20px;
  min-height: calc(100vh - 56px);
}

.wheel-wrap {
  position: relative;
  width: min(640px, 70vh);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.wheel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 30px 60px rgba(91, 35, 110, 0.25));
}

/* Pointer arrow on the right edge, pointing left into the wheel */
.pointer {
  position: absolute;
  top: 50%;
  right: -4px;
  transform: translateY(-50%);
  width: 70px;
  height: 56px;
  z-index: 3;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.18));
}

/* Center hub button */
.hub {
  position: absolute;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(160deg, #fff, #f4eaff);
  box-shadow:
    0 0 0 6px #fff,
    0 0 0 8px rgba(26, 18, 48, 0.12),
    0 14px 30px rgba(91, 35, 110, 0.35);
  display: grid;
  place-items: center;
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: clamp(14px, 2vw, 20px);
  color: var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
  z-index: 2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hub:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow:
    0 0 0 6px #fff,
    0 0 0 8px var(--accent),
    0 14px 30px rgba(255, 61, 139, 0.5);
}
.hub:disabled {
  cursor: not-allowed;
  color: var(--ink-mute);
}
.hub.spinning {
  color: var(--ink-mute);
}

/* Floating bottom action row */
.actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  background: #fff;
  color: var(--ink);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 12px 30px -10px rgba(91, 35, 110, 0.25),
    0 0 0 1px rgba(26, 18, 48, 0.06);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 18px 36px -10px rgba(91, 35, 110, 0.35),
    0 0 0 1px rgba(26, 18, 48, 0.08);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: var(--ink);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent);
}

/* Empty state */
.empty {
  text-align: center;
  color: var(--ink-mute);
  font-weight: 600;
  font-size: 15px;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

/* ---------- Winner overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 48, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: grid;
  place-items: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.overlay-card {
  text-align: center;
  padding: 50px 70px;
  border-radius: 36px;
  background:
    radial-gradient(circle at 30% 0%, rgba(255, 176, 46, 0.25), transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(192, 132, 252, 0.3), transparent 60%),
    #fff;
  box-shadow:
    0 50px 100px -20px rgba(0,0,0,0.4),
    0 0 0 8px rgba(255,255,255,0.1);
  max-width: 92vw;
  transform: scale(0.85) translateY(20px);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.overlay.show .overlay-card { transform: scale(1) translateY(0); }

.overlay-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 18px;
}

.overlay-name {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: clamp(48px, 12vw, 140px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0;
  background: linear-gradient(135deg, var(--w1) 0%, var(--w5) 50%, var(--w3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  word-break: break-word;
  max-width: 14ch;
}

.overlay-sub {
  margin-top: 18px;
  font-size: 16px;
  color: var(--ink-mute);
  font-weight: 600;
}

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

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 49;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.3);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
  .panel {
    position: static;
    height: auto;
    max-height: 50vh;
  }
  .wheel-wrap {
    width: min(92vw, 520px);
  }
}
