/* ============================================
   Wheel — Design System v3.0
   Premium Dark UI + Vibrant Accents
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

/* ── Tokens ───────────────────────────────── */
:root {
  --bg-base: #0c0c10;
  --bg-surface: #16161d;
  --bg-elevated: #1e1e28;
  --bg-hover: #26263a;

  --border-dim: rgba(255, 255, 255, 0.06);
  --border-mid: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(16, 185, 129, 0.4);

  --text-primary: #f8f8fc;
  --text-secondary: #a0a0b8;
  --text-muted: #5a5a72;

  --accent: #10b981;
  --accent-hover: #059669;
  --accent-glow: rgba(16, 185, 129, 0.25);
  --accent-violet: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-blue: #3b82f6;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xl: 24px;
  --transition: 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

::-webkit-scrollbar {
  display: none;
}

* {
  scrollbar-width: none;
}

/* ── Subtle animated bg ───────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 20% 0%, rgba(16, 185, 129, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse 100% 60% at 85% 100%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

/* ── App Layout ───────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ── Header ───────────────────────────────── */
.app-header {
  padding: 20px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dim);
  backdrop-filter: blur(16px);
  background: rgba(12, 12, 16, 0.85);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent), #059669);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 24px var(--accent-glow);
}

.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.spin-counter {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  padding: 6px 16px;
  border-radius: 100px;
}

/* ── Main Grid ────────────────────────────── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 460px;
  gap: 48px;
  max-width: 1460px;
  width: 100%;
  margin: 0 auto;
  padding: 48px;
  align-items: start;
}

/* ── Wheel Area ───────────────────────────── */
.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  padding-top: 16px;
}

.wheel-container {
  position: relative;
  width: min(580px, 90vw);
  aspect-ratio: 1;
}

.wheel-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 16px 48px rgba(0, 0, 0, 0.5));
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Pointer arrow */
.wheel-pointer {
  position: absolute;
  top: 50%;
  right: -20px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
  border-right: 36px solid #fff;
  filter: drop-shadow(-4px 0 8px rgba(0, 0, 0, 0.5));
  z-index: 10;
}

/* Center SPIN button */
.wheel-center-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #059669);
  border: 4px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 10;
  transition: all var(--transition);
  box-shadow: 0 8px 32px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.wheel-center-btn:hover:not(:disabled) {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 12px 48px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.wheel-center-btn:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.95);
}

.wheel-center-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-elevated);
  box-shadow: none;
}

/* ── Result Display ───────────────────────── */
.result-display {
  width: min(580px, 90vw);
  min-height: 100px;
  padding: 28px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 300ms ease;
}

.result-display.has-result {
  border-color: var(--border-accent);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), var(--bg-surface));
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.08);
}

.result-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: all 300ms ease;
}

.result-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.result-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* ── Sidebar ──────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 300ms ease;
}

.panel:hover {
  border-color: var(--border-mid);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.badge {
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--border-accent);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 14px;
}

/* ── Add Form ─────────────────────────────── */
.add-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-swatch {
  width: 0;
  height: 0;
  overflow: hidden;
  position: absolute;
}

.text-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 500;
  outline: none;
  transition: all var(--transition);
}

.text-input::placeholder {
  color: var(--text-muted);
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #059669);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-mid);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
}

/* ── Entries List ─────────────────────────── */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: none;
}

.entries-list::-webkit-scrollbar {
  display: none;
}

.entry-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.entry-item:hover {
  border-color: var(--border-mid);
  background: var(--bg-hover);
}

.entry-item.highlighted {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.08);
}

.entry-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.entry-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-name-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  outline: none;
}

.entry-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.entry-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.entry-item:hover .entry-actions {
  opacity: 1;
}

/* ── History ──────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: none;
}
.history-list::-webkit-scrollbar {
  display: none;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.history-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.history-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Settings ─────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-dim);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-label svg {
  color: var(--text-muted);
}

/* Toggle */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #3f3f46;
  border-radius: 24px;
  cursor: pointer;
  transition: background 250ms ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toggle input:checked+.toggle-slider {
  background: var(--accent);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(20px);
}

/* ── Empty State ──────────────────────────── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

/* ── Presets ───────────────────────────────── */
.quick-presets {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: 100px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}

.preset-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(16, 185, 129, 0.06);
}

/* ── Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  padding: 36px;
  width: min(520px, 90vw);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.6);
}

/* ── Winner Banner ────────────────────────── */
.winner-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: var(--bg-surface);
  border: 2px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 56px 64px;
  text-align: center;
  z-index: 2001;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.8), 0 0 80px var(--accent-glow);
  opacity: 0;
  pointer-events: none;
  transition: all 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 90vw;
}

.winner-banner.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: all;
}

.winner-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 16px;
}

.winner-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 42px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 32px;
}

/* ── Confetti ─────────────────────────────── */
.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: fixed;
  top: -10px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
  pointer-events: none;
}

@keyframes confetti-fall {
  0% {
    top: -10px;
    transform: rotate(0deg) translateX(0);
    opacity: 1;
  }

  100% {
    top: 110vh;
    transform: rotate(720deg) translateX(var(--drift, 0px));
    opacity: 0;
  }
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 24px;
    gap: 32px;
  }

  .app-header {
    padding: 16px 24px;
  }

  .wheel-container {
    width: min(440px, 90vw);
  }
}

@media (max-width: 480px) {
  .wheel-container {
    width: min(340px, 95vw);
  }

  .panel {
    padding: 20px;
  }

  .winner-banner {
    padding: 40px 32px;
  }

  .winner-name {
    font-size: 32px;
  }
}