:root {
  --bg: #0b0d14;
  --bg-2: #11141f;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #eef0f6;
  --muted: #8b90a5;
  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --accent-3: #37d5c8;
  --success: #3ddc97;
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 10% -10%, rgba(124, 92, 255, 0.28), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(255, 92, 138, 0.18), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(55, 213, 200, 0.14), transparent 60%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  max-width: 1200px;
  margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.01em; text-decoration: none;
}
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: conic-gradient(var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  box-shadow: 0 0 18px rgba(124, 92, 255, 0.7);
}
.nav-link {
  color: var(--muted); text-decoration: none; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid transparent;
  transition: all .2s;
}
.nav-link:hover { color: var(--text); border-color: var(--panel-border); background: var(--panel); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 28px 60px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; color: #fff;
  padding: 14px 26px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.35);
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s;
  display: inline-flex; align-items: center; gap: 10px;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(124, 92, 255, 0.45); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn.ghost {
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: none; color: var(--text);
}
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); box-shadow: none; }
.btn.danger { background: linear-gradient(135deg, #ff6b6b, #ff3d7f); box-shadow: 0 10px 30px rgba(255, 61, 127, .3); }
.btn.sm { padding: 9px 16px; font-size: 13px; }
.btn.lg { padding: 18px 36px; font-size: 17px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

input[type="text"], select, textarea {
  font: inherit; color: var(--text);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 12px 14px;
  outline: none; transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
input[type="text"]:focus, select:focus, textarea:focus {
  border-color: rgba(124, 92, 255, .8);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, .15);
}
select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b90a5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
select option { background: #171a26; color: var(--text); }
textarea { resize: vertical; min-height: 90px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(14px);
}
.panel h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.01em; }
.panel .sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

/* ---------- Wheel page ---------- */
.wheel-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; align-items: center;
  min-height: calc(100vh - 160px);
}
@media (max-width: 900px) {
  .wheel-layout { grid-template-columns: 1fr; gap: 24px; }
}

.wheel-stage { display: grid; place-items: center; position: relative; }
.wheel-wrap {
  position: relative;
  width: min(80vw, 560px); aspect-ratio: 1 / 1;
}
.wheel-glow {
  position: absolute; inset: -6%; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  filter: blur(40px); opacity: .35; z-index: 0;
  animation: glowspin 12s linear infinite;
}
@keyframes glowspin { to { transform: rotate(360deg); } }
.wheel-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 10px solid rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.06), 0 30px 80px rgba(0,0,0,.5);
  z-index: 2; pointer-events: none;
}
#wheel {
  position: relative; z-index: 1;
  width: 100%; height: 100%; border-radius: 50%; display: block;
  will-change: transform;
}
.hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 15%; aspect-ratio: 1; border-radius: 50%; z-index: 3;
  background: radial-gradient(circle at 30% 30%, #fff, #d8d6ff 40%, #8c7cff 100%);
  box-shadow: 0 10px 30px rgba(0,0,0,.5), inset 0 -4px 10px rgba(0,0,0,.2);
  display: grid; place-items: center;
}
.hub::after {
  content: ""; width: 35%; aspect-ratio: 1; border-radius: 50%;
  background: var(--bg); opacity: .85;
}
.pointer {
  position: absolute; left: 50%; top: -4%; transform: translateX(-50%); z-index: 4;
  width: 9%; aspect-ratio: 1; filter: drop-shadow(0 8px 16px rgba(0,0,0,.55));
  transform-origin: 50% 20%;
}
.pointer svg { width: 100%; height: 100%; display: block; }

.wheel-empty {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; text-align: center;
  color: var(--muted); padding: 40px; font-size: 15px; line-height: 1.5;
}
.wheel-empty a { color: var(--text); }

.controls { display: flex; flex-direction: column; gap: 18px; }
.controls h1 { margin: 0; font-size: 34px; letter-spacing: -0.03em; line-height: 1.1; }
.controls h1 span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.controls p.lead { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.stats { display: flex; gap: 12px; }
.stat {
  flex: 1; padding: 14px 16px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--panel-border);
}
.stat b { display: block; font-size: 24px; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hint { font-size: 13px; color: var(--muted); min-height: 18px; }
.hint.warn { color: #ffb86b; }

/* ---------- Winner overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; text-align: center;
  background: rgba(8, 9, 15, .82);
  backdrop-filter: blur(16px);
  opacity: 0; pointer-events: none; transition: opacity .4s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay .eyebrow {
  font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); margin-bottom: 18px;
}
.overlay .prize {
  font-size: clamp(18px, 3vw, 28px); color: var(--text); opacity: .8; margin: 0 0 8px; font-weight: 500;
}
.overlay .winner {
  font-size: clamp(48px, 10vw, 120px); font-weight: 800; letter-spacing: -0.04em; line-height: 1; margin: 0;
  background: linear-gradient(90deg, #fff, #d9d1ff 40%, #ffb3c9);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.overlay .trophy { font-size: clamp(50px, 9vw, 110px); margin-bottom: 10px; }
.overlay-content > * { opacity: 0; transform: translateY(20px); }

/* ---------- Mascot ----------
   Fixed to the lower-left on both the wheel page and the winner screen: z-index sits
   above the overlay (50) and below the "Go back" button (200). The wrapper is driven
   only by GSAP (slide-in, win punch); the img carries the CSS idle motion, so the two
   transforms never fight over one element. pointer-events: none so it can never block
   the wheel or a button underneath it. */
.mascot {
  position: fixed; left: 24px; bottom: 12px; z-index: 120;
  width: clamp(240px, 34vmin, 400px); /* projector / TV: plenty of corner room */
  pointer-events: none;
}
/* Shorter displays (laptops): the wheel's lower-left arc runs through the corner,
   so size the mascot to the room that's actually there rather than cover a name. */
@media (max-height: 999px) { .mascot { width: clamp(150px, 22vh, 220px); } }
.mascot img {
  width: 100%; height: auto; display: block;
  filter: drop-shadow(0 16px 34px rgba(0, 0, 0, .5));
  transform-origin: 50% 90%; /* pivot near the feet so it rocks like it's sitting */
  animation: mascot-roar 2.6s ease-in-out infinite;
}
@media (max-width: 900px) { .mascot { width: clamp(130px, 24vw, 190px); left: 12px; bottom: 8px; } }
@media (max-width: 560px) { .mascot { display: none; } } /* no room next to stacked controls */
@keyframes mascot-roar {
  0%, 100% { transform: translateY(0) rotate(-3deg) scale(1); }
  30%      { transform: translateY(-14px) rotate(2.5deg) scale(1.03); }
  55%      { transform: translateY(-4px) rotate(-1deg) scale(1.01); }
  75%      { transform: translateY(-10px) rotate(3deg) scale(1.02); }
}
@media (prefers-reduced-motion: reduce) {
  .mascot img { animation: none; }
}

.fab {
  position: fixed; right: 28px; bottom: 28px; z-index: 200;
  opacity: 0; pointer-events: none; transform: translateY(20px); transition: all .3s;
}
.fab.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ---------- Admin page ---------- */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-head { display: flex; align-items: end; justify-content: space-between; margin: 10px 0 24px; flex-wrap: wrap; gap: 14px; }
.admin-head h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
.admin-head p { margin: 4px 0 0; color: var(--muted); }
.form-row { display: flex; gap: 10px; align-items: end; margin-bottom: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 160px; }
.form-row .btn { flex: 0 0 auto; height: 46px; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(255,255,255,.03); border: 1px solid var(--panel-border);
  transition: background .2s;
}
.item:hover { background: rgba(255,255,255,.06); }
.item .swatch { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.item .name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--muted); font-size: 13px; }
.item.done { opacity: .5; }
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 4px 9px; border-radius: 999px;
  background: rgba(124, 92, 255, .18); color: #c8bbff; border: 1px solid rgba(124, 92, 255, .35);
}
.badge.random { background: rgba(55, 213, 200, .14); color: #9ff0e8; border-color: rgba(55, 213, 200, .35); }
.badge.won { background: rgba(61, 220, 151, .14); color: #a6f5d0; border-color: rgba(61, 220, 151, .35); }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 16px;
  transition: all .15s;
}
.icon-btn:hover { background: rgba(255, 107, 107, .15); color: var(--danger); }
.empty { color: var(--muted); font-size: 14px; padding: 18px; text-align: center; border: 1px dashed var(--panel-border); border-radius: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.count { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 8px; }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1b1e2c; border: 1px solid var(--panel-border); padding: 12px 18px; border-radius: 12px;
  font-size: 14px; opacity: 0; transition: all .25s; z-index: 100; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Admin lock screen ---------- */
.lock {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px;
  background: inherit;
}
.lock.hidden { display: none; }
.lock-card {
  width: min(100%, 380px);
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 32px 28px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.lock-card h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.lock-card p { margin: 0 0 6px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.lock-card .field { text-align: left; }
.lock-icon {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 6px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(124,92,255,.35), rgba(255,92,138,.25));
  border: 1px solid rgba(255,255,255,.1); color: #fff;
}
.lock-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.lock-back { color: var(--muted); font-size: 13px; text-decoration: none; }
.lock-back:hover { color: var(--text); }
.shake { animation: shake .4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}
button.nav-link { background: transparent; font: inherit; cursor: pointer; }

/* ---------- Spin settings ---------- */
.duration-row { display: flex; align-items: center; gap: 24px; margin-bottom: 14px; }
.duration-slider { flex: 1; }
.duration-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; letter-spacing: .04em; text-transform: uppercase; }
.duration-value { text-align: center; min-width: 90px; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--panel-border); }
.duration-value b { display: block; font-size: 30px; letter-spacing: -0.03em; line-height: 1; }
.duration-value span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.presets .btn.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; outline: none;
  background: linear-gradient(90deg, var(--accent-3), var(--accent), var(--accent-2));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.5), 0 0 0 4px rgba(124,92,255,.25); transition: transform .15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.5), 0 0 0 4px rgba(124,92,255,.25);
}
@media (max-width: 600px) { .duration-row { flex-direction: column; align-items: stretch; } }

/* Autosave toggle in the admin header */
.actions .btn.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }

/* Event status toggle */
.event-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.event-state { color: var(--muted); font-size: 14px; font-weight: 500; }
.event-state.live { color: #4ade80; }

/* Storage durability status in admin */
.note.ok { color: #4ade80; }
.note.warn { color: #ffb86b; }
