:root {
  --bg: #090b18;
  --panel: #12152a;
  --text: #f7f7ff;
  --muted: #9297b8;
  --line: #292e4d;
  --accent: #9c6cff;
  --cyan: #55e4ff;
  --pink: #ff5c91;
  --yellow: #ffd166;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(
      circle at 15% 0%,
      #24204d 0,
      transparent 32%
    ),
    radial-gradient(
      circle at 90% 50%,
      #162a48 0,
      transparent 30%
    ),
    var(--bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
textarea,
select {
  max-width: 100%;
  font: inherit;
}

button {
  min-height: 44px;
  cursor: pointer;
  color: inherit;
  border: 0;
}

input,
textarea,
select {
  font-size: 16px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #55e4ff88;
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 28px);
}

.topbar {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: clamp(12px, 3vw, 48px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 800;
  letter-spacing: -0.7px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    var(--accent),
    var(--cyan)
  );
  box-shadow: 0 0 25px #8c6cff66;
}

.brand-accent {
  color: var(--cyan);
}

nav {
  display: flex;
  flex: 1;
  gap: clamp(14px, 3vw, 28px);
}

nav a {
  padding: 25px 0;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  color: var(--text);
  border-color: var(--cyan);
}

.top-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.ghost-btn,
.icon-btn {
  color: var(--muted);
  background: transparent;
  font-size: 20px;
}

.ghost-btn:hover,
.icon-btn:hover {
  color: var(--text);
}

.outline-btn,
.secondary-btn {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.outline-btn:hover,
.secondary-btn:hover {
  border-color: var(--accent);
  background: rgba(156, 108, 255, 0.13);
}

.main-grid {
  display: grid;
  grid-template-columns:
    minmax(0, 1.35fr)
    minmax(310px, 0.65fr);
  gap: 22px;
  padding: 24px 0 45px;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 22px;
  background:
    linear-gradient(
      145deg,
      rgba(25, 29, 54, 0.9),
      rgba(14, 17, 34, 0.91)
    );
  box-shadow: 0 20px 60px #0004;
}

.picker-panel {
  min-height: 760px;
  padding: clamp(18px, 3vw, 28px);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -1px;
}

h1 {
  font-size: clamp(24px, 4vw, 30px);
}

h2 {
  font-size: 21px;
}

.wheel-stage {
  position: relative;
  display: grid;
  width: min(100%, 570px);
  aspect-ratio: 1;
  margin: clamp(16px, 3vw, 22px) auto 20px;
  place-items: center;
}

.wheel-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 15px 30px #0008);
}

.pointer {
  position: absolute;
  z-index: 2;
  top: -3px;
  width: 0;
  height: 0;
  border-top: 40px solid var(--yellow);
  border-right: 16px solid transparent;
  border-left: 16px solid transparent;
  filter: drop-shadow(0 3px 6px #000);
}

.wheel-centre {
  position: absolute;
  display: grid;
  width: clamp(72px, 16vw, 92px);
  height: clamp(72px, 16vw, 92px);
  place-items: center;
  border: 5px solid #30375b;
  border-radius: 50%;
  background: #11152b;
  box-shadow: 0 0 0 5px #11152b;
  pointer-events: none;
}

.wheel-centre span {
  font-size: clamp(14px, 3vw, 17px);
  font-weight: 900;
}

.wheel-centre small {
  margin-top: -20px;
  color: var(--muted);
  font-size: 12px;
}

.spin-btn {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 14px 18px;
  border-radius: 13px;
  color: white;
  background: linear-gradient(
    100deg,
    #8458ff,
    #b86aff,
    #32d9ed
  );
  box-shadow: 0 10px 30px #9167ff45;
  font-size: 16px;
  font-weight: 800;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    opacity 0.2s;
}

.spin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 35px #9167ff70;
}

.spin-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.spin-btn.small {
  width: auto;
  padding: 12px 22px;
}

.spin-options {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.spin-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.spin-options input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.selection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}

.side-column {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 22px;
}

.names-panel,
.history-panel {
  padding: clamp(17px, 3vw, 24px);
}

.input-row {
  display: flex;
  gap: 8px;
  margin: 20px 0 10px;
}

.input-row input,
textarea,
.saved-wheel-controls input,
.saved-wheel-select,
.winner-count-row select {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #0c1021;
}

.input-row input {
  flex: 1;
}

.input-row input:focus,
textarea:focus,
.saved-wheel-controls input:focus,
.saved-wheel-select:focus,
.winner-count-row select:focus {
  border-color: var(--accent);
}

.add-btn {
  width: 48px;
  flex: 0 0 48px;
  border-radius: 10px;
  background: var(--accent);
  font-size: 25px;
}

.add-btn:hover {
  background: #b48cff;
}

.winner-count-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.winner-count-row select {
  padding: 7px 10px;
}

.names-panel textarea {
  display: block;
  width: 100%;
  min-height: 86px;
  resize: vertical;
}

.secondary-btn.full {
  width: 100%;
  margin-top: 8px;
  color: var(--muted);
}

.file-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.file-actions .secondary-btn {
  width: 100%;
  color: var(--muted);
}

.share-btn {
  margin-top: 8px;
}

.saved-wheel-controls {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.saved-wheel-controls input {
  flex: 1;
}

.saved-wheel-controls .secondary-btn {
  white-space: nowrap;
  color: var(--muted);
}

.saved-wheel-select {
  width: 100%;
  margin-top: 8px;
}

.saved-wheel-actions {
  margin-top: 8px;
}

.saved-wheel-actions .secondary-btn {
  width: 100%;
  color: var(--muted);
}

.name-list {
  display: grid;
  max-height: 310px;
  gap: 7px;
  margin-top: 18px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.name-item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  transition:
    border-color 0.2s,
    opacity 0.2s;
}

.name-item span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-selected {
  border-color: var(--cyan);
  opacity: 0.6;
}

.remove-name {
  min-width: 44px;
  color: var(--muted);
  background: none;
  font-size: 18px;
}

.remove-name:hover {
  color: var(--pink);
}

.count-badge {
  margin-left: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  color: #bb9cff;
  background: #29214c;
  font-size: 11px;
}

.text-btn {
  min-height: 36px;
  padding: 6px 8px;
  color: var(--muted);
  background: none;
  font-size: 12px;
}

.text-btn:hover {
  color: var(--pink);
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.history-entry {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--cyan);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
}

.history-entry span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-entry small,
.muted {
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 8;
  right: 16px;
  bottom: 20px;
  left: 16px;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: auto;
  padding: 11px 18px;
  border-radius: 10px;
  opacity: 0;
  color: #11152b;
  background: #f7f7ff;
  font-weight: 700;
  pointer-events: none;
  text-align: center;
  transform: translateY(20px);
  transition:
    opacity 0.25s,
    transform 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  z-index: 7;
  inset: 0;
  display: none;
  padding: 16px;
  place-items: center;
  background: #050611b8;
  backdrop-filter: blur(8px);
}

.modal-backdrop.show {
  display: grid;
}

.winner-modal {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 45px 24px 24px;
  border: 1px solid #8068de;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(145deg, #25204d, #11152c);
  box-shadow: 0 20px 90px #000b;
  animation: winner-pop 0.35s ease-out;
}

.winner-modal h2 {
  margin: 8px 0;
  overflow-wrap: anywhere;
  color: var(--yellow);
  font-size: clamp(34px, 10vw, 52px);
}

.winner-message {
  color: var(--muted);
}

.confetti {
  color: var(--cyan);
  font-size: 27px;
  letter-spacing: 12px;
  animation: confetti-float 1.4s ease-in-out infinite;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  min-width: 44px;
  color: var(--muted);
  background: none;
  font-size: 28px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

.modal-actions > * {
  flex: 1;
}

.modal-actions .secondary-btn {
  color: var(--text);
}

.share-link-fallback {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  padding: 16px;
  place-items: center;
  background: #050611cc;
  backdrop-filter: blur(8px);
}

.share-link-card {
  width: min(600px, 100%);
  padding: 22px;
  border: 1px solid var(--accent);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 20px 70px #000b;
}

.share-link-card h3 {
  margin: 0 0 8px;
}

.share-link-card p {
  color: var(--muted);
}

.share-link-card input {
  width: 100%;
  min-height: 46px;
  margin: 8px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #0c1021;
  font-size: 12px;
}

body.light {
  --bg: #eef1ff;
  --panel: #ffffff;
  --text: #15172b;
  --muted: #656b88;
  --line: #dce0f0;
  background: linear-gradient(
    135deg,
    #e8ecff,
    #f8f9ff
  );
}

body.light .topbar {
  border-color: #dce0f0;
}

body.light .input-row input,
body.light textarea,
body.light .saved-wheel-controls input,
body.light .saved-wheel-select,
body.light .winner-count-row select,
body.light .share-link-card input {
  background: #f7f8ff;
}

body.light .name-item,
body.light .history-entry {
  background: #f5f6ff;
}

@keyframes winner-pop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes confetti-float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 64px;
    gap: 10px;
  }

  nav {
    display: none;
  }

  .top-actions {
    margin-left: auto;
  }

  .top-actions .outline-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .main-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-top: 16px;
  }

  .picker-panel {
    min-height: 0;
  }

  .wheel-stage {
    width: min(100%, 520px);
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 0 10px;
  }

  .brand {
    font-size: 18px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .top-actions {
    gap: 4px;
  }

  .top-actions .ghost-btn {
    min-width: 38px;
    padding: 4px;
  }

  .top-actions .outline-btn {
    padding: 7px 8px;
    font-size: 11px;
  }

  .picker-panel,
  .names-panel,
  .history-panel {
    padding: 15px;
    border-radius: 17px;
  }

  .wheel-stage {
    width: 100%;
    margin-top: 16px;
  }

  .spin-options {
    display: grid;
    justify-content: start;
    gap: 8px;
  }

  .spin-options label {
    min-height: 32px;
  }

  .selection-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .winner-count-row {
    align-items: stretch;
    flex-direction: column;
  }

  .winner-count-row select {
    width: 100%;
  }

  .input-row {
    align-items: stretch;
  }

  .input-row input {
    width: 100%;
  }

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

  .saved-wheel-controls {
    display: grid;
  }

  .saved-wheel-controls .secondary-btn {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column;
  }

  .spin-btn.small {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}