:root {
  --brand-dark: #4c1d95;
  --brand: #6d28d9;
  --brand-mid: #7c3aed;
  --cocoa-dark: #4a1e0d;
  --cocoa: #6b2d16;
  --caramel: #f59e0b;
  --caramel-light: #fef3c7;
  --cream: #fff8f0;
  --bg: #f5f3ff;
  --card: #ffffff;
  --text: #1f1635;
  --muted: #6b6380;
  --border: #e5dff5;
  --success-bg: #dcfce7;
  --success: #16a34a;
  --fail-bg: #fee2e2;
  --fail: #dc2626;
  --shadow: 0 8px 24px rgba(76, 29, 149, 0.09);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 100;
}

.loading-logo {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--brand-mid), var(--brand-dark));
  display: grid;
  place-items: center;
  font-size: 42px;
  box-shadow: 0 12px 30px rgba(76, 29, 149, 0.28);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid #ddd6fe;
  border-top-color: var(--brand);
  animation: spinLoader 0.85s linear infinite;
}

.loading-text {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

@keyframes spinLoader {
  to {
    transform: rotate(360deg);
  }
}

/* Shell & Header */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 94px;
  position: relative;
}

.top-header {
  background: linear-gradient(155deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
  color: #fff;
  padding: 16px 16px 34px;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  font-size: 24px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.prize-pill {
  background: #fff;
  color: var(--brand-dark);
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  white-space: nowrap;
}

.main-content {
  padding: 0 14px;
  margin-top: -20px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-panel.active {
  display: flex;
}

/* Wheel Stage */
.wheel-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
}

.wheel-pointer {
  position: relative;
  z-index: 6;
  width: 38px;
  height: 42px;
  margin-bottom: -22px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 4px 6px rgba(31, 22, 53, 0.35));
  display: flex;
  justify-content: center;
  padding-top: 9px;
}

.wheel-pointer-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--brand);
}

.wheel-bezel {
  position: relative;
  width: min(86vw, 344px);
  height: min(86vw, 344px);
  border-radius: 50%;
  padding: 13px;
  background: linear-gradient(145deg, #8b5cf6, #4c1d95);
  box-shadow: 0 18px 40px rgba(76, 29, 149, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.25);
  display: grid;
  place-items: center;
}

.wheel-lights {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.wheel-bulb {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fde68a;
  box-shadow: 0 0 8px #fbbf24;
  transform: translate(-50%, -50%);
  animation: bulbPulse 1.4s ease-in-out infinite;
}

.wheel-bulb.alt {
  animation-delay: 0.7s;
  background: #fff;
}

@keyframes bulbPulse {
  0%, 100% {
    opacity: 0.45;
    transform: translate(-50%, -50%) scale(0.85);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  background: var(--cream);
}

.spin-center-btn {
  position: absolute;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(180deg, #7c3aed 0%, #4c1d95 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(31, 22, 53, 0.38);
  transition: transform 0.14s ease;
  z-index: 5;
}

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

.spin-center-btn:disabled {
  opacity: 0.82;
  cursor: not-allowed;
}

.spin-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
}

.spin-count {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.05;
}

.tap-hint {
  position: absolute;
  right: 12px;
  bottom: 42px;
  background: #fff;
  color: var(--brand-dark);
  border: 2px solid var(--brand-mid);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(76, 29, 149, 0.22);
  animation: bounceHint 1.2s ease-in-out infinite;
  z-index: 6;
}

@keyframes bounceHint {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 17px;
  font-weight: 900;
  color: var(--brand-dark);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-mid), var(--brand-dark));
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(76, 29, 149, 0.24);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: #ede9fe;
  color: var(--text);
  border: none;
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-full {
  width: 100%;
}

.mini-btn {
  border: none;
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
  background: #ede9fe;
  color: var(--brand-dark);
  cursor: pointer;
}

.mini-btn.ok {
  background: var(--success-bg);
  color: var(--success);
}

.mini-btn.bad {
  background: var(--fail-bg);
  color: var(--fail);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
}

.card-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-row-between .card-title {
  margin: 0;
}

.muted-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.muted-desc {
  margin: -4px 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.count-pill {
  background: #ede9fe;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 800;
}

/* Referral Tab */
.referral-hero-card {
  background: linear-gradient(155deg, var(--brand-mid), var(--brand-dark));
  color: #fff;
  border-radius: 22px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.card-heading-light {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
}

.ref-link-box {
  background: rgba(0, 0, 0, 0.22);
  border: 1.5px dashed rgba(255, 255, 255, 0.45);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  word-break: break-all;
}

.ref-link-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #fff;
}

.ref-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-white {
  background: #fff;
  color: var(--brand-dark);
  border: none;
  border-radius: 14px;
  padding: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.btn-glass {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 14px;
  padding: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.ref-hint {
  margin: 12px 0 0;
  font-size: 13px;
  opacity: 0.92;
  line-height: 1.4;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #ede9fe;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--caramel), var(--brand-mid));
  transition: width 0.35s ease;
}

.progress-numbers {
  margin-top: 8px;
  font-size: 14px;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 14px 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.friend-row,
.leader-row,
.history-row,
.admin-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f8f7ff;
  border-radius: 14px;
  padding: 11px 12px;
}

.admin-item-card {
  flex-direction: column;
  align-items: stretch;
}

.admin-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.inline-search-row input,
.claim-form input,
.claim-form textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1.5px solid var(--border);
  background: #faf9ff;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.inline-search-row input:focus,
.claim-form input:focus,
.claim-form textarea:focus {
  border-color: var(--brand-mid);
  background: #fff;
}

.friend-name {
  font-weight: 700;
  font-size: 14px;
}

.status-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
}

.status-chip.ok {
  background: var(--success-bg);
  color: var(--success);
}

.status-chip.wait {
  background: var(--caramel-light);
  color: #b45309;
}

.status-chip.bad {
  background: var(--fail-bg);
  color: var(--fail);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leader-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
}

.leader-rank {
  width: 24px;
  text-align: center;
  font-weight: 800;
}

.leader-count {
  font-weight: 800;
  color: var(--brand-dark);
  font-size: 14px;
}

/* Gifts Tab */
.gifts-hero-card {
  background: linear-gradient(155deg, var(--brand-mid), var(--brand-dark));
  color: #fff;
  border-radius: 22px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.gifts-hero-label {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
}

.gifts-hero-amount {
  margin: 6px 0 10px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.4px;
}

.gifts-pill-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.gift-mini-pill {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.gifts-hero-sub {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.88;
}

.rules-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.rule-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}

.rule-icon.ok {
  background: var(--success-bg);
  color: var(--success);
}

.rule-icon.fail {
  background: var(--fail-bg);
  color: var(--fail);
}

.claim-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.segmented-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #ede9fe;
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 12px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.seg-btn.active {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  width: min(calc(100% - 24px), 456px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-radius: 22px;
  padding: 6px;
  display: flex;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(31, 22, 53, 0.16);
  z-index: 20;
}

.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 16px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--brand-mid), var(--brand-dark));
  color: #fff;
}

.nav-icon {
  font-size: 18px;
}

.nav-text {
  font-size: 12px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 42, 0.58);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}

.modal-sheet {
  width: 100%;
  max-width: 450px;
  background: #fff;
  border-radius: 26px;
  padding: 22px 18px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.channel-hero-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 10px;
  border-radius: 18px;
  background: #ede9fe;
  display: grid;
  place-items: center;
  font-size: 30px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.modal-subtitle {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  max-height: 45vh;
  overflow-y: auto;
}

.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f8f7ff;
  border-radius: 16px;
  padding: 10px 12px;
}

.channel-row.missing {
  border: 1.5px solid var(--fail);
  background: #fef2f2;
}

.channel-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.channel-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #ede9fe;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.channel-name {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-sub {
  font-size: 12px;
  color: var(--muted);
}

.channel-join-btn {
  background: var(--brand-mid);
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.inline-error {
  color: var(--fail);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 10px;
}

/* Win & Claim Modals */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 61;
}

.win-card {
  position: relative;
  z-index: 62;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 26px;
  padding: 26px 20px 20px;
  text-align: center;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  margin-bottom: 12px;
}

.win-rays {
  position: absolute;
  inset: -40%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(124, 58, 237, 0.08) 0deg 15deg,
    transparent 15deg 30deg
  );
  animation: spinLoader 18s linear infinite;
  pointer-events: none;
}

.win-content {
  position: relative;
  z-index: 2;
}

.win-kicker {
  margin: 0 0 8px;
  color: var(--brand-mid);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
}

.win-emoji {
  font-size: 54px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.win-title {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 900;
  color: var(--brand-dark);
}

.win-desc {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.win-actions {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 10px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  background: rgba(31, 22, 53, 0.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 90;
  max-width: 90vw;
  text-align: center;
}
