/* ============================================================
   Wheel of Names — Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* ---------- Tokens ---------- */
:root {
  --bg: #120d30;
  --primary: #f7c948;
  --pink: #ff6b9d;
  --teal: #4dd9ac;
  --purple: #8b5cf6;
  --blue: #38bdf8;
  --orange: #f97316;
  --card: rgba(255, 255, 255, 0.06);
  --bdr: rgba(255, 255, 255, 0.11);
  --muted: rgba(255, 255, 255, 0.5);
  --radius: 20px;
  --trans: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  font-size: 16px;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Background ---------- */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 10% 20%, rgba(139, 92, 246, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse at 88% 78%, rgba(56, 189, 248, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(77, 217, 172, 0.07) 0%, transparent 65%);
}

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

/* ---------- Back Button ---------- */
.back-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--bdr);
  color: var(--muted);
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  backdrop-filter: blur(10px);
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ---------- Page ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 1060px;
  margin: 0 auto;
  padding: 72px 24px 60px;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 40px;
}

.header-icon {
  font-size: 3rem;
  line-height: 1;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 6px 18px rgba(247, 201, 72, 0.4));
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }

  50% {
    transform: translateY(-10px) rotate(4deg);
  }
}

.app-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--orange), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}

.app-sub {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
  align-items: start;
}

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

.wheel-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
}

.wheel-pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  color: var(--primary);
  filter: drop-shadow(0 0 8px rgba(247, 201, 72, 0.8));
  z-index: 5;
  animation: pointer-pulse 1.5s ease-in-out infinite;
  line-height: 1;
}

@keyframes pointer-pulse {

  0%,
  100% {
    filter: drop-shadow(0 0 6px rgba(247, 201, 72, 0.5));
  }

  50% {
    filter: drop-shadow(0 0 18px rgba(247, 201, 72, 1));
  }
}

#wheel-canvas {
  width: 100%;
  height: auto;
  border-radius: 50%;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.06),
    0 0 0 12px rgba(255, 255, 255, 0.03),
    0 24px 60px rgba(0, 0, 0, 0.5);
  display: block;
}

/* ---------- Spin Button ---------- */
.spin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 48px;
  border-radius: 99px;
  border: none;
  background: linear-gradient(135deg, var(--primary), #f59e0b);
  color: #1a1040;
  font-family: 'Nunito', sans-serif;
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 28px rgba(247, 201, 72, 0.4);
  transition: transform var(--trans), box-shadow var(--trans);
  letter-spacing: 1px;
}

.spin-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 36px rgba(247, 201, 72, 0.6);
}

.spin-btn:active {
  transform: scale(0.97);
}

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

/* ---------- Names Panel ---------- */
.names-panel {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.names-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 1rem;
  font-weight: 900;
}

.name-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 10px;
  border-radius: 99px;
}

/* ---------- Add Name Row ---------- */
.add-name-row {
  display: flex;
  gap: 8px;
}

.name-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  outline: none;
  transition: border-color 0.25s, background 0.25s;
}

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

.name-input:focus {
  border-color: var(--purple);
  background: rgba(139, 92, 246, 0.10);
}

.btn-add {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform var(--trans);
  flex-shrink: 0;
}

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

.btn-add:active {
  transform: scale(0.95);
}

/* ---------- Name List ---------- */
.name-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

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

.name-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
}

.name-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  animation: slideIn 0.3s var(--trans) both;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }

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

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

.name-text {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.name-remove {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.name-remove:hover {
  color: var(--pink);
  background: rgba(255, 107, 157, 0.12);
}

.name-list-empty {
  text-align: center;
  padding: 24px 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- Panel Actions ---------- */
.panel-actions {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  flex: 1;
  padding: 9px 0;
  border-radius: 12px;
  border: none;
  background: rgba(255, 107, 157, 0.12);
  border: 1px solid rgba(255, 107, 157, 0.2);
  color: var(--pink);
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, transform var(--trans);
}

.btn-secondary:hover {
  background: rgba(255, 107, 157, 0.22);
  transform: scale(1.03);
}

.btn-ghost {
  flex: 1;
  padding: 9px 0;
  border-radius: 12px;
  border: 1px solid var(--bdr);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ---------- Winner Modal ---------- */
.winner-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 6, 30, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

.winner-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.winner-card {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  backdrop-filter: blur(24px);
  padding: 40px 36px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  from {
    transform: scale(0.6);
    opacity: 0;
  }

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

.winner-trophy {
  font-size: 72px;
  line-height: 1;
  animation: bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes bounce {
  from {
    transform: scale(0) translateY(-20px);
  }

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

.winner-label {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 700;
}

.winner-name {
  font-size: 2.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.winner-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .wheel-wrap {
    max-width: 340px;
    margin: 0 auto;
  }

  .spin-btn {
    padding: 14px 36px;
    font-size: 1.1rem;
  }

  .app-header {
    gap: 12px;
  }

  .header-icon {
    font-size: 2.2rem;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 64px 16px 48px;
  }

  .wheel-wrap {
    max-width: 290px;
  }

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

  .CodeMirror {
    font-size: 0.8rem !important;
  }

  .CodeMirror-scroll {
    max-height: 34vh;
  }
}

/* ---------- View Code Button ---------- */
.btn-view-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 99px;
  border: none;
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  transition: transform var(--trans), box-shadow var(--trans);
}

.btn-view-code:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(139, 92, 246, 0.6);
}

.btn-view-code:active {
  transform: scale(0.97);
}

/* ---------- FAB Code Button ---------- */
.fab-code {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.fab-code-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(139, 92, 246, 0.5);
  transition: var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab-code-btn:hover {
  transform: scale(1.12) rotate(-5deg);
}

.fab-code-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
}

/* ---------- Shared Button Utils ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 50px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  cursor: pointer;
  transition: var(--trans);
}

.btn:active {
  transform: scale(0.95);
}

.btn-md {
  padding: 11px 24px;
  font-size: 1rem;
}

.btn-accent {
  background: linear-gradient(135deg, var(--teal), #15b888);
  color: #1a1040;
}

.btn-ghost-ed {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ---------- Code Editor Overlay ---------- */
.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 6, 30, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}

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

.editor-panel {
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  background: #0f0a24;
  border-top: 2px solid var(--purple);
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
  overflow: hidden;
}

.editor-overlay.open .editor-panel {
  transform: translateY(0);
}

.editor-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 800;
}

.editor-title-icon {
  font-size: 1.4rem;
}

.editor-badge {
  background: rgba(139, 92, 246, 0.25);
  border: 1px solid var(--purple);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--purple);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.editor-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  transition: background 0.2s, color 0.2s;
}

.editor-close-btn:hover {
  background: rgba(255, 107, 157, 0.15);
  color: var(--pink);
}

/* CodeMirror overrides */
.CodeMirror {
  font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
  font-size: 0.88rem !important;
  line-height: 1.65 !important;
  background: #0f0a24 !important;
  color: #e2d9f3 !important;
  height: auto !important;
  min-height: 200px;
  max-height: 42vh;
}

.CodeMirror-scroll {
  max-height: 42vh;
}

.CodeMirror-gutters {
  background: #0f0a24 !important;
  border-right: 1px solid rgba(255, 255, 255, 0.07) !important;
}

.CodeMirror-linenumber {
  color: rgba(255, 255, 255, 0.25) !important;
}

.CodeMirror-cursor {
  border-left-color: var(--primary) !important;
}

/* Console */
.console-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--clr-muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.console-wrap {
  padding: 10px 20px 4px;
  flex-shrink: 0;
}

.console-output {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--teal);
  min-height: 73px;
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.console-output.error {
  color: var(--pink);
}

/* Editor actions bar */
.editor-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  background: #0b0820;
  flex-wrap: wrap;
}