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

:root {
  --bg: #12122b;
  --surface: #1d1d42;
  --surface-2: #262658;
  --text: #f2efe9;
  --muted: #9a9ac2;
  --coral: #ff6b5b;
  --gold: #ffc857;
  --border: #33336b;
  --danger: #ff6b5b;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  color-scheme: dark;
}

:root.light {
  --bg: #f7f3ea;
  --surface: #ffffff;
  --surface-2: #f0ece2;
  --text: #1b1b3a;
  --muted: #6b6b85;
  --coral: #e85a4a;
  --gold: #d99b1f;
  --border: #e3ddd0;
  --danger: #e85a4a;
  --shadow: 0 10px 30px rgba(27,27,58,0.10);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

h1, h2, h3, .display {
  font-family: 'Poppins', 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: inherit; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: conic-gradient(var(--coral), var(--gold), var(--coral));
}

.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--coral);
  color: #1b1b3a;
}

.btn-gold {
  background: var(--gold);
  color: #1b1b3a;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

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

input[type="text"], input[type="password"], textarea, select {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
textarea { min-height: 140px; resize: vertical; font-family: 'Inter', monospace; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

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

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

/* ---- Login screen ---- */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card { max-width: 380px; width: 100%; }

/* ---- Admin dashboard ---- */
.wheel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.wheel-card { display: flex; flex-direction: column; gap: 10px; }
.wheel-card .link {
  font-family: 'Inter', monospace;
  font-size: 0.85rem;
  color: var(--coral);
  word-break: break-all;
}
.wheel-card .row { display: flex; gap: 8px; flex-wrap: wrap; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,10,25,0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: 18px;
  max-width: 560px;
  width: 100%;
  padding: 26px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

.pill-toggle { display: flex; gap: 8px; }
.pill-toggle button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.pill-toggle button.active {
  background: var(--coral);
  color: #1b1b3a;
  border-color: var(--coral);
}

.name-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.name-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.name-list li:last-child { border-bottom: none; }
.name-list button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}
.name-list button:hover { color: var(--danger); }

/* ---- Wheel page ---- */
.wheel-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding-top: 10px;
}
.wheel-title-input {
  text-align: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  background: transparent;
  border: none;
  color: var(--text);
  max-width: 90vw;
}
.wheel-stage {
  position: relative;
  width: min(520px, 92vw);
  height: min(520px, 92vw);
}
.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 30px solid var(--gold);
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
  z-index: 5;
}
canvas#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: var(--shadow);
}
.hub {
  position: absolute;
  top: 50%; left: 50%;
  width: 64px; height: 64px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--surface);
  border: 4px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  z-index: 4;
}

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

.winner-banner {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 18px 26px;
  box-shadow: var(--shadow);
}
.winner-banner.show { display: flex; }
.winner-banner .name {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--gold);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

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

@media (max-width: 560px) {
  .wrap { padding: 14px 14px 40px; }
  .modal { padding: 18px; }
}
