:root {
  --bg: #0a0a0f;
  --bg-panel: #12121a;
  --bg-elevated: #1a1a26;
  --gold: #c9a227;
  --gold-dim: #8a7020;
  --gold-glow: rgba(201, 162, 39, 0.35);
  --violet: #7b5cff;
  --violet-dim: #5a42c4;
  --violet-glow: rgba(123, 92, 255, 0.4);
  --cream: #f5f0e6;
  --cream-muted: #b8b0a0;
  --danger: #e85d5d;
  --border: rgba(201, 162, 39, 0.22);
  --radius: 10px;
  --font-display: "Cinzel", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-body);
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(123, 92, 255, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(201, 162, 39, 0.08), transparent 50%),
    var(--bg);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  color: var(--gold);
  font-size: 1.25rem;
  text-shadow: 0 0 12px var(--gold-glow);
}

.header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--cream);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 0;
  min-height: 0;
}

.sidebar {
  padding: 1rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  background: rgba(18, 18, 26, 0.65);
  transition: transform 0.28s ease, opacity 0.28s ease, width 0.28s ease, padding 0.28s ease, border 0.28s ease;
}

.app.overlay-mode .sidebar {
  transform: translateX(-110%);
  opacity: 0;
  pointer-events: none;
  width: 0;
  padding: 0;
  border: none;
  overflow: hidden;
}

.app.overlay-mode .main {
  grid-template-columns: 1fr;
}

.app.overlay-mode .header h1 {
  opacity: 0.85;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.hint {
  margin: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--cream-muted);
  line-height: 1.4;
}

.stat {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.875rem;
  color: var(--cream-muted);
}

.stat strong {
  color: var(--gold);
  font-size: 1.05rem;
}

.upload-row,
.add-row,
.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.add-row {
  margin-bottom: 0.75rem;
}

.add-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.field-label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.8rem;
  color: var(--cream-muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--cream-muted);
  cursor: pointer;
  margin: 0.5rem 0;
  user-select: none;
}

.toggle-row input {
  accent-color: var(--violet);
  width: 1rem;
  height: 1rem;
}

input[type="text"],
.select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
.select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px var(--violet-glow);
}

.select {
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #0a0a0f;
  border-color: var(--gold);
  box-shadow: 0 0 20px var(--gold-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 28px var(--gold-glow);
}

.btn-secondary {
  background: rgba(123, 92, 255, 0.2);
  color: var(--cream);
  border-color: var(--violet);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(123, 92, 255, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--cream-muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--cream);
  border-color: var(--gold-dim);
}

.btn-ghost.danger:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-spin {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.85rem 2.5rem;
  min-width: 160px;
}

.file-label {
  cursor: pointer;
}

.name-list,
.prize-list,
.winners-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--bg);
}

.name-list li,
.prize-list li,
.winners-log li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.name-list li:last-child,
.prize-list li:last-child,
.winners-log li:last-child {
  border-bottom: none;
}

.name-list .name-text,
.prize-list .prize-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.icon-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--cream-muted);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--danger);
  background: rgba(232, 93, 93, 0.12);
}

.prize-list .edit-btn:hover {
  color: var(--gold);
  background: rgba(201, 162, 39, 0.12);
}

.winners-log {
  max-height: 140px;
  margin-bottom: 0.5rem;
}

.winners-log .meta {
  color: var(--cream-muted);
  font-size: 0.7rem;
}

.winners-log .empty {
  padding: 0.75rem;
  color: var(--cream-muted);
  font-size: 0.8rem;
  justify-content: center;
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  min-height: calc(100vh - 64px);
  overflow: hidden;
}

.wheel-wrap {
  position: relative;
  width: min(92vw, 520px);
  aspect-ratio: 1;
}

#wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow:
    0 0 0 4px var(--gold-dim),
    0 0 0 8px rgba(123, 92, 255, 0.35),
    0 0 48px var(--violet-glow),
    inset 0 0 40px rgba(0, 0, 0, 0.4);
  background: var(--bg-elevated);
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 28px solid var(--gold);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

.pointer::after {
  content: "";
  position: absolute;
  top: -28px;
  left: -6px;
  width: 12px;
  height: 12px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--gold-glow);
}

.win-flash {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.55), rgba(123, 92, 255, 0.25) 45%, transparent 70%);
  animation: cosmic-flash 1.2s ease-out forwards;
}

@keyframes cosmic-flash {
  0% { opacity: 0; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.15); }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
  z-index: 6;
}

.result-banner {
  margin-top: 1.5rem;
  text-align: center;
  padding: 1.25rem 2rem;
  border-radius: 12px;
  border: 1px solid var(--gold);
  background: linear-gradient(160deg, rgba(123, 92, 255, 0.25), rgba(18, 18, 26, 0.95));
  box-shadow: 0 0 40px var(--gold-glow), 0 0 60px var(--violet-glow);
  animation: banner-in 0.45s ease-out;
  z-index: 6;
  max-width: 90vw;
}

@keyframes banner-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-label {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.result-name {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 700;
  color: var(--cream);
  text-shadow: 0 0 24px var(--violet-glow);
  word-break: break-word;
}

.result-prize {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  color: var(--gold);
}

.result-prize:empty {
  display: none;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

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

  .sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .app.overlay-mode .sidebar {
    display: none;
  }

  .stage {
    min-height: auto;
    padding-bottom: 2rem;
  }
}

::-webkit-scrollbar {
  width: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
  border: 1px solid var(--border);
}
