/* ============================================
   Lucky Wheel - Premium Dark UI
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg-primary: #071224;
  --bg-secondary: rgba(255, 255, 255, 0.04);
  --bg-card: rgba(255, 255, 255, 0.06);
  --border: rgba(96, 165, 250, 0.2);
  --border-hover: rgba(96, 165, 250, 0.5);
  --accent: #60a5fa;
  --accent-bright: #bfdbfe;
  --accent-dark: #2563eb;
  --text-primary: #f0f9ff;
  --text-secondary: rgba(240, 249, 255, 0.6);
  --text-muted: rgba(240, 249, 255, 0.35);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow-glow: 0 0 30px rgba(96, 165, 250, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37, 99, 235, 0.35), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(14, 165, 233, 0.2), transparent);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.5s ease;
}

body.has-bg-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body.has-bg-image::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 0;
}

body>* {
  position: relative;
  z-index: 1;
}

/* ---- Header ---- */
header {
  text-align: center;
  padding: 40px 400px 24px 32px;
}

header h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  background: linear-gradient(135deg, #bfdbfe, #60a5fa, #38bdf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

header p {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 400;
}

/* ---- Layout ---- */
.app-layout {
  display: block;
  padding: 0 400px 40px 32px;
}

@media (max-width: 900px) {
  .app-layout {
    padding: 0 16px 40px;
  }
}

/* ---- Wheel Section ---- */
.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.wheel-wrapper {
  position: relative;
  width: 100%;
  max-width: min(900px, calc(100vw - 460px));
  aspect-ratio: 1;
  margin: 0 auto;
  filter: drop-shadow(0 0 40px rgba(96, 165, 250, 0.35));
  transition: filter var(--transition);
}

.wheel-wrapper.spinning {
  filter: drop-shadow(0 0 60px rgba(96, 165, 250, 0.6));
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- Spin Button ---- */
.spin-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 48px;
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 24px rgba(37, 99, 235, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  letter-spacing: 0.3px;
  overflow: hidden;
}

.spin-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.spin-btn:hover:not(:disabled)::before {
  opacity: 1;
}

.spin-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.spin-btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.spin-btn .btn-icon {
  font-size: 22px;
}

/* Progress bar for multi-spin */
.spin-progress {
  width: 100%;
  max-width: min(900px, calc(100vw - 460px));
  margin: 0 auto;
  display: none;
}

.spin-progress.visible {
  display: block;
}

.spin-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.spin-progress-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.spin-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  border-radius: 999px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ---- Results Area ---- */
.results-section {
  width: 100%;
  max-width: min(900px, calc(100vw - 460px));
  margin: 0 auto;
}

.results-section h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}

.result-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-bright);
  animation: chipIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chipIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }

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

.results-empty {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  right: 0;
  top: 0;
  width: 380px;
  height: 100vh;
  overflow-y: auto;
  padding: 16px;
  background: rgba(7, 18, 36, 0.88);
  backdrop-filter: blur(16px);
  border-left: 1px solid rgba(96, 165, 250, 0.15);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(96, 165, 250, 0.25) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(96, 165, 250, 0.25);
  border-radius: 999px;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 1px solid rgba(96, 165, 250, 0.15);
    padding: 16px;
  }
}

/* ---- Card ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
  transition: border-color var(--transition);
}

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

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Form Controls ---- */
.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-label span {
  color: var(--accent-bright);
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: grab;
  transition: box-shadow var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px rgba(167, 139, 250, 0.4), 0 2px 8px rgba(0, 0, 0, 0.4);
}

input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--transition);
}

input[type="number"]:focus {
  border-color: var(--accent);
}

/* ---- Upload Button ---- */
.upload-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  background: rgba(167, 139, 250, 0.08);
}

.upload-btn .icon {
  font-size: 18px;
}

.bg-filename {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-clear-bg {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  background: transparent;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  display: none;
}

.btn-clear-bg.visible {
  display: block;
}

.btn-clear-bg:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: var(--danger);
}

/* ---- Prize List ---- */
.prize-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.prize-input-row input[type="text"] {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--transition);
}

.prize-input-row input[type="text"]:focus {
  border-color: var(--accent);
}

.prize-input-row input[type="text"]::placeholder {
  color: var(--text-muted);
}

.btn-add {
  padding: 10px 16px;
  background: linear-gradient(135deg, #2563eb, #0284c7);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 18px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  line-height: 1;
}

.btn-add:hover {
  transform: scale(1.08);
}

.prize-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

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

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

.prize-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.prize-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: slideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideIn {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.prize-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.prize-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-remove:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.08);
}

.prize-empty-msg {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
  font-style: italic;
}

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

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

.modal {
  background: linear-gradient(135deg, #0d1e3d, #071224);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 24px;
  padding: 48px 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.7), 0 0 40px rgba(96, 165, 250, 0.2);
  transform: scale(0.85);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-emoji {
  font-size: 64px;
  margin-bottom: 16px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-result {
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 800;
  color: var(--accent-bright);
  margin-bottom: 20px;
  line-height: 1.2;
}

.modal-close {
  padding: 12px 36px;
  background: linear-gradient(135deg, #2563eb, #0284c7);
  border: none;
  border-radius: 50px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  margin-top: 20px;
}

.modal-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.6);
}

/* ---- Confetti ---- */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 2.5s ease-out forwards;
  pointer-events: none;
  z-index: 1000;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ---- Mode Toggle ---- */
.mode-toggle {
  display: flex;
  gap: 8px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}

.mode-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.mode-btn.active {
  background: rgba(96, 165, 250, 0.15);
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.2);
}

/* When condolence mode is active, color in gray-blue */
#modeCondolence.active {
  background: rgba(100, 116, 139, 0.2);
  border-color: #94a3b8;
  color: #cbd5e1;
  box-shadow: 0 0 12px rgba(148, 163, 184, 0.2);
}

/* ---- Custom Checkbox ---- */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.checkbox-label:hover {
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
}

.checkbox-label input[type="checkbox"]:checked~.checkbox-custom {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  border-color: #2563eb;
}


.checkbox-label input[type="checkbox"]:checked~.checkbox-custom::after {
  content: '✓';
  font-size: 11px;
  color: white;
  font-weight: 800;
}

/* ---- Condolence Modal Variant ---- */
.modal.modal-condolence {
  background: linear-gradient(135deg, #1a1f2e, #0f1520);
  border-color: rgba(148, 163, 184, 0.35);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(100, 116, 139, 0.15);
}

.modal.modal-condolence .modal-result {
  color: #94a3b8;
}

.modal.modal-condolence .modal-close {
  background: linear-gradient(135deg, #334155, #1e293b);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.modal.modal-condolence .modal-close:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
}

/* ---- Smoke Effect (Condolence) ---- */
.smoke-piece {
  position: fixed;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(148, 163, 184, 0.6), rgba(71, 85, 105, 0.1));
  pointer-events: none;
  z-index: 1000;
  animation: smokeRise var(--dur, 3s) ease-out forwards;
}

@keyframes smokeRise {
  0% {
    transform: translateY(0) scale(1);
    opacity: var(--op, 0.4);
    filter: blur(4px);
  }

  50% {
    transform: translateY(-40vh) translateX(20px) scale(2.5);
    opacity: calc(var(--op, 0.4) * 0.6);
    filter: blur(12px);
  }

  100% {
    transform: translateY(-80vh) translateX(-10px) scale(4);
    opacity: 0;
    filter: blur(20px);
  }
}

/* ---- Bulk Import Section ---- */
.bulk-section {
  margin-top: 12px;
}

.bulk-toggle-btn {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-secondary);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  text-align: left;
}

.bulk-toggle-btn:hover,
.bulk-toggle-btn.active {
  border-color: var(--accent);
  color: var(--accent-bright);
  background: rgba(96, 165, 250, 0.06);
}

.bulk-area {
  margin-top: 10px;
}

.bulk-area textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
  line-height: 1.6;
}

.bulk-area textarea:focus {
  border-color: var(--accent);
}

.bulk-area textarea::placeholder {
  color: var(--text-muted);
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.bulk-hint {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.btn-bulk-add,
.btn-bulk-replace {
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}

.btn-bulk-add {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: white;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}

.btn-bulk-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.btn-bulk-replace {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.btn-bulk-replace:hover {
  background: rgba(251, 191, 36, 0.2);
}

/* ---- Modal Checkbox Label ---- */
.modal-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-secondary);
  transition: color var(--transition);
  margin-bottom: 4px;
}

.modal-checkbox-label:hover {
  color: var(--text-primary);
}

.modal-checkbox-label input[type="checkbox"] {
  display: none;
}

.modal-checkbox-label .checkbox-custom {
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(96, 165, 250, 0.4);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-checkbox-label input[type="checkbox"]:checked~.checkbox-custom {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  border-color: #2563eb;
}

.modal-checkbox-label input[type="checkbox"]:checked~.checkbox-custom::after {
  content: '✓';
  font-size: 11px;
  color: white;
  font-weight: 800;
}