:root {
  --bg-start: #eef7ff;
  --bg-end: #ffe8fb;
  --card: #ffffff;
  --text: #2a2f45;
  --muted: #67728f;
  --primary: #6c5ce7;
  --primary-2: #8b7bff;
  --accent: #ff4d9a;
  --good: #00b894;
  --shadow: 0 10px 30px rgba(63, 71, 115, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.app {
  width: min(1000px, 92vw);
  margin: 2.25rem auto;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  align-items: start;
  position: relative;
  z-index: 20;
}

.card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.25rem;
}

.panel-draw {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.panel-input {
  grid-column: 1;
  grid-row: 1;
}

.panel-preview {
  grid-column: 1;
  grid-row: 2;
  margin-top: -0.4rem;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 0.8rem;
}

.subtitle {
  color: var(--muted);
  margin: 0.45rem 0 1rem;
}

.label {
  display: inline-block;
  margin-bottom: 0.45rem;
  font-weight: 600;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 2px solid #e3e7f3;
  border-radius: 12px;
  padding: 0.75rem;
  font: inherit;
  min-height: 180px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.12);
}

.hint {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.input-actions {
  margin-top: 0.65rem;
}

.share-card {
  margin-top: 0.85rem;
  border-radius: 12px;
  background: #f8fbff;
  border: 1px solid #e7eeff;
  padding: 0.7rem 0.85rem;
}

.share-actions {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.share-link-input {
  width: 100%;
  border: 1px solid #dbe3fb;
  background: #fff;
  border-radius: 10px;
  padding: 0.52rem 0.58rem;
  font: inherit;
  color: var(--text);
}

.share-status {
  margin: 0.5rem 0 0;
}

.style-select {
  width: 100%;
  border: 2px solid #e3e7f3;
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.65rem;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

.style-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.12);
}

.roulette-wrapper {
  position: relative;
  border: 2px dashed #dfd9ff;
  border-radius: 16px;
  background: linear-gradient(180deg, #faf8ff, #f5f8ff);
  min-height: 220px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.pointer {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  height: 0;
  border-top: 3px solid rgba(255, 77, 154, 0.34);
}

.roulette-display {
  padding: 1.25rem;
  text-align: center;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.3px;
  transition: transform 140ms ease, color 140ms ease;
  max-width: 95%;
  word-break: break-word;
}

.roulette-display.spinning {
  color: #4f4a90;
}

.roulette-display.winner-pop {
  color: var(--accent);
  animation: pop 700ms cubic-bezier(0.16, 1.2, 0.36, 1);
  text-shadow: 0 6px 20px rgba(255, 77, 154, 0.35);
}

body[data-draw-style="neon"] .roulette-wrapper {
  border: 2px solid #2ce6ff;
  background: radial-gradient(circle at 50% 20%, #1d2b64, #0f1231 70%);
  box-shadow: inset 0 0 30px rgba(44, 230, 255, 0.18), 0 0 28px rgba(44, 230, 255, 0.2);
}

body[data-draw-style="neon"] .pointer {
  border-top-color: rgba(255, 255, 255, 0.4);
}

body[data-draw-style="neon"] .roulette-display {
  color: #e9f9ff;
  text-shadow: 0 0 18px rgba(44, 230, 255, 0.7);
}

body[data-draw-style="sunset"] .roulette-wrapper {
  border: 0;
  background: linear-gradient(135deg, #ff9a44, #ff6a88 55%, #7b5cff);
  box-shadow: inset 0 -25px 35px rgba(0, 0, 0, 0.12);
}

body[data-draw-style="sunset"] .pointer {
  border-top-color: rgba(255, 255, 255, 0.32);
}

body[data-draw-style="sunset"] .roulette-display {
  color: #ffffff;
  text-shadow: 0 8px 24px rgba(51, 22, 83, 0.35);
}

body[data-draw-style="minimal"] .roulette-wrapper {
  border: 1px solid #dde2ef;
  background: #ffffff;
  box-shadow: none;
}

body[data-draw-style="minimal"] .pointer {
  border-top-color: rgba(82, 95, 127, 0.22);
}

body[data-draw-style="minimal"] .roulette-display {
  color: #2f3750;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: none;
}

@keyframes pop {
  0% {
    transform: scale(0.7) rotate(-3deg);
    opacity: 0.35;
  }
  45% {
    transform: scale(1.22) rotate(1deg);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

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

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.btn.secondary {
  color: #fff;
  background: linear-gradient(135deg, #f98b2f, #ff5f6d);
}

.btn.tertiary {
  color: #ffffff;
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
}

.result-card {
  margin-top: 1rem;
  border-radius: 12px;
  background: #f7f9ff;
  border: 1px solid #e9edff;
  padding: 0.7rem 0.85rem;
}

.result-label {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 0.2rem;
}

.last-result {
  color: var(--good);
  font-size: 1.06rem;
}

.history-card {
  margin-top: 0.75rem;
  border-radius: 12px;
  background: #f8fbff;
  border: 1px solid #e7eeff;
  padding: 0.7rem 0.85rem;
}

.history-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 0.35rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.7rem;
  background: #ffffff;
  border: 1px solid #edf1ff;
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
}

.history-date {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.history-name {
  color: #3a3172;
  font-weight: 700;
  text-align: right;
  word-break: break-word;
}

.name-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 2rem;
}

.chip {
  background: #f2edff;
  color: #4f447e;
  border: 1px solid #dfd6ff;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel-draw {
    grid-column: auto;
    grid-row: auto;
  }

  .panel-input,
  .panel-preview {
    grid-column: auto;
    grid-row: auto;
  }

  .panel-preview {
    margin-top: 0;
  }

  .app {
    margin: 1.1rem auto 1.5rem;
  }

  .roulette-wrapper {
    min-height: 160px;
  }

  .roulette-display {
    font-size: clamp(1.6rem, 8vw, 2.4rem);
  }
}
