/* ------------------------------------------------------------------
   Wheelson — stage lighting on ink, brass hardware.
   The wheel is the only loud thing on the page; everything around it
   stays flat and quiet so the spin is the event.
   ------------------------------------------------------------------ */

:root {
  --ink: #0e1020;
  --bg: #0e1020;
  --surface: #171a30;
  --surface-2: #20243f;
  --text: #f4f1ea;
  --muted: #8d92b5;
  --coral: #ff5d54;
  --gold: #e8b04b;
  --mint: #54d6a8;
  --border: #2a2f4f;
  --danger: #ff5d54;
  --ring: rgba(232, 176, 75, 0.55);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  --spotlight: radial-gradient(circle at 50% 42%, rgba(232,176,75,0.16), rgba(255,93,84,0.07) 38%, transparent 68%);
  --on-accent: #14162a;
  color-scheme: dark;
}

:root.light {
  --ink: #181a2e;
  --bg: #faf6ee;
  --surface: #ffffff;
  --surface-2: #f2ede2;
  --text: #181a2e;
  --muted: #666c8c;
  --coral: #d94a41;
  --gold: #b3801d;
  --mint: #1f9c72;
  --border: #e4dccc;
  --danger: #d94a41;
  --ring: rgba(179, 128, 29, 0.5);
  --shadow: 0 18px 40px rgba(24, 26, 46, 0.12);
  --shadow-sm: 0 2px 8px rgba(24, 26, 46, 0.08);
  --spotlight: radial-gradient(circle at 50% 42%, rgba(179,128,29,0.14), rgba(217,74,65,0.06) 38%, transparent 66%);
  --on-accent: #fffaf0;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* A single faint light source behind everything, fixed to the viewport. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--spotlight);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

h1, h2, h3, .display {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.12;
  margin: 0;
}
h2 { font-size: 1.45rem; }
h3 { font-size: 1.05rem; font-weight: 600; }

a { color: var(--coral); }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 8px;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 22px 64px;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 26px;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  align-self: center;
  background: conic-gradient(var(--gold) 0deg 60deg, var(--surface-2) 60deg 120deg, var(--coral) 120deg 180deg, var(--surface-2) 180deg 240deg, var(--gold) 240deg 300deg, var(--coral) 300deg 360deg);
  box-shadow: 0 0 0 2px var(--border);
}

/* ---- Buttons ---- */
.btn {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 0.94rem;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 17px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--coral); color: var(--on-accent); }
.btn-primary:hover { background: var(--coral); filter: brightness(1.08); }

.btn-gold { background: var(--gold); color: var(--on-accent); }
.btn-gold:hover { background: var(--gold); filter: brightness(1.08); }

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--on-accent); }

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
}

/* ---- Forms ---- */
input[type="text"], input[type="password"], textarea, select {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 100%;
  transition: border-color 0.14s ease;
}
input:hover, textarea:hover, select:hover { border-color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.86rem; color: var(--muted); font-weight: 500; }

.error-text { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; margin: 0 0 8px; }
.muted { color: var(--muted); }

/* ---- Surfaces ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card { max-width: 380px; width: 100%; box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 4px; }

/* ---- Admin dashboard ---- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 28px 0 4px;
}
.count-chip {
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  white-space: nowrap;
}

.wheel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

/* The left stripe carries each wheel's own pointer colour, so the grid is
   scannable at a glance rather than decorated. */
.wheel-card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding-left: 22px;
  position: relative;
  overflow: hidden;
}
.wheel-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--stripe, var(--gold));
}
.wheel-card h3 { display: flex; align-items: center; gap: 7px; }
.wheel-card .link {
  font-size: 0.85rem;
  color: var(--coral);
  word-break: break-all;
}
.wheel-card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.wheel-card .row .btn { padding: 8px 13px; font-size: 0.88rem; }

.meter {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  background: var(--stripe, var(--gold));
}
.card-meta { font-size: 0.85rem; color: var(--muted); }

/* ---- Modals ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 9, 20, 0.66);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 580px;
  width: 100%;
  padding: 26px;
  box-shadow: var(--shadow);
}
.modal-wide { max-width: 840px; }
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 24px;
  align-items: start;
}
.field-grid .field-span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .field-grid { grid-template-columns: 1fr; }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.modal-head h3 { font-size: 1.25rem; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 700; }

.pill-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  flex-wrap: wrap;
}
.pill-toggle button {
  flex: 1 1 auto;
  min-width: 72px;
  padding: 9px 10px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.14s ease, color 0.14s ease;
}
.pill-toggle button:hover { color: var(--text); }
.pill-toggle button.active {
  background: var(--coral);
  color: var(--on-accent);
}

.name-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.name-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.name-list li:last-child { border-bottom: none; }
.name-list button {
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 3px 8px;
  line-height: 1.2;
}
.name-list button:hover { color: var(--text); border-color: var(--border); }
.name-list button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---- Toasts ---- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--mint);
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease;
}
.toast.warn { border-left-color: var(--gold); }
.toast.error { border-left-color: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---- Wheel page ---- */
.wheel-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 6px;
}
.wheel-title-input {
  text-align: center;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  letter-spacing: -0.01em;
  background: transparent;
  border: none;
  color: var(--text);
  max-width: 90vw;
  margin: 0;
}

.wheel-stage {
  position: relative;
  width: min(720px, 92vw);
  height: min(720px, 92vw);
  flex-shrink: 0;
  margin: 0 auto;
}

/* Brass bezel: a machined ring that sits just outside the canvas. */
.wheel-stage::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, #6a5222, var(--gold), #fff2cf, var(--gold), #6a5222, var(--gold), #6a5222);
  z-index: -1;
  filter: saturate(0.9);
}
:root.light .wheel-stage::after { filter: saturate(0.85) brightness(1.05); }

canvas#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  box-shadow: 0 24px 60px rgba(0,0,0,0.42), inset 0 0 0 6px var(--surface);
}
:root.light canvas#wheelCanvas { box-shadow: 0 18px 44px rgba(24,26,46,0.18), inset 0 0 0 6px #fff; }

.pointer {
  position: absolute;
  z-index: 5;
  width: 0;
  height: 0;
  filter: drop-shadow(0 3px 7px rgba(0,0,0,0.5));
}
.pointer.top {
  top: -20px; left: 50%;
  transform: translateX(-50%);
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-top: 34px solid var(--pointer-color, var(--gold));
}
.pointer.bottom {
  bottom: -20px; left: 50%;
  transform: translateX(-50%);
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-bottom: 34px solid var(--pointer-color, var(--gold));
}
.pointer.left {
  left: -20px; top: 50%;
  transform: translateY(-50%);
  border-top: 17px solid transparent;
  border-bottom: 17px solid transparent;
  border-left: 34px solid var(--pointer-color, var(--gold));
}
.pointer.right {
  right: -20px; top: 50%;
  transform: translateY(-50%);
  border-top: 17px solid transparent;
  border-bottom: 17px solid transparent;
  border-right: 34px solid var(--pointer-color, var(--gold));
}

/* The hub is the one control on the page: a pressed brass disc. */
.hub {
  position: absolute;
  top: 50%; left: 50%;
  width: 124px; height: 124px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, var(--surface-2), var(--surface) 70%);
  border: 6px solid var(--gold);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  z-index: 4;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 8px 22px rgba(0,0,0,0.4);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.hub:hover { transform: translate(-50%, -50%) scale(1.06); box-shadow: 0 12px 30px rgba(0,0,0,0.5); }
.hub:active { transform: translate(-50%, -50%) scale(0.96); }
.hub .hub-count {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: 2.6rem;
  color: var(--gold);
  line-height: 1;
}

.spin-hint { text-align: center; font-size: 0.88rem; margin: 0; }

.controls-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }

/* ---- Winner ---- */
.winner-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 20, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.winner-modal-backdrop.show { display: flex; }
.winner-modal {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 22px;
  padding: 34px 30px;
  text-align: center;
  max-width: 430px;
  width: 100%;
  box-shadow: 0 0 0 1px rgba(232,176,75,0.18), var(--shadow);
  animation: winnerPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes winnerPop {
  0% { transform: scale(0.72); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.winner-modal .label { color: var(--muted); font-size: 0.92rem; }
.winner-modal .name {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  letter-spacing: -0.01em;
  color: var(--gold);
  margin: 8px 0 22px;
  word-break: break-word;
}
.winner-modal .controls-row { justify-content: center; }

.winner-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 6;
  text-align: center;
  padding: 20px;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: clamp(1.6rem, 6vw, 3rem);
  color: #fffaf0;
  text-shadow: 0 2px 18px rgba(0,0,0,0.7), 0 0 34px var(--pointer-color, var(--gold));
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.winner-reveal.show { opacity: 1; transform: scale(1); }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 44px 22px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: transparent;
  box-shadow: none;
}
.empty-state h2 { color: var(--text); margin-bottom: 6px; }

.theme-toggle-floating {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

.wheel-logos {
  position: fixed;
  left: 6vw;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 26px;
  align-items: center;
  z-index: 8;
}
.wheel-logos img {
  max-width: 140px;
  max-height: 140px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

footer.hint { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 30px; }

/* ---- Responsive ---- */
@media (max-width: 1080px) {
  .wheel-logos { left: 2vw; }
  .wheel-logos img { max-width: 96px; max-height: 96px; }
}

@media (max-width: 900px) {
  .wheel-logos {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: center;
    margin-bottom: 2px;
  }
  .wheel-logos img { max-width: 64px; max-height: 64px; }
}

@media (max-width: 620px) {
  .wrap { padding: 12px 14px 44px; }
  .modal { padding: 18px; border-radius: 16px; }
  .modal-backdrop { padding: 16px 10px 40px; }
  .wheel-stage { width: min(560px, 90vw); height: min(560px, 90vw); }
  .hub { width: 92px; height: 92px; border-width: 5px; }
  .hub .hub-count { font-size: 2rem; }
  .wheel-grid { grid-template-columns: 1fr; }
  .btn { padding: 11px 16px; }
  .pill-toggle button { min-width: 0; flex: 1 1 40%; }
  .theme-toggle-floating { top: 10px; right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .winner-reveal { transition: opacity 0.001ms; }
}
