:root {
  --bg-plane: #07060d;
  --bg-1: #140d29;
  --bg-2: #271a4d;
  --bg-3: #1a1230;
  --gold: #f0b429;
  --gold-soft: #ffd76a;
  --violet: #7c5cff;
  --violet-soft: #9985ff;
  --cyan: #22e0c9;
  --pink: #ff3d81;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-strong: rgba(255, 255, 255, 0.22);
  --text-main: #f7f6fc;
  --text-dim: #ada7cf;
  --text-muted: #8983ad;
  --danger: #ff5c7a;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-card: 0 14px 44px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  --font-display: 'Baloo 2', sans-serif;
  --font-body: 'Poppins', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--text-main);
  background: var(--bg-plane);
  overflow-x: hidden;
}

.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.bg-orbs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.8;
  animation: drift 22s ease-in-out infinite alternate;
}
.bg-orbs span:nth-child(1) {
  width: 500px; height: 500px;
  top: -120px; left: -80px;
  background: radial-gradient(circle, var(--violet), transparent 68%);
}
.bg-orbs span:nth-child(2) {
  width: 440px; height: 440px;
  top: 5%; right: -100px;
  background: radial-gradient(circle, var(--pink), transparent 68%);
  animation-delay: -7s;
}
.bg-orbs span:nth-child(3) {
  width: 560px; height: 560px;
  bottom: -240px; left: 15%;
  background: radial-gradient(circle, var(--gold), transparent 70%);
  opacity: 0.55;
  animation-delay: -14s;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, 50px) scale(1.12); }
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  position: relative;
}

.app-header {
  text-align: center;
  margin-bottom: 34px;
  animation: rise-in 0.6s ease both;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border-strong);
  color: var(--gold-soft);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  margin: 0;
  background: linear-gradient(90deg, var(--gold-soft), var(--pink) 55%, var(--violet-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(240, 180, 41, 0.25));
  letter-spacing: 1px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-top: 8px;
  font-weight: 500;
}

.layout {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 28px;
  align-items: start;
}

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

.wheel-section {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  background: linear-gradient(175deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 40px 20px 36px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-card);
  animation: rise-in 0.6s ease both;
  animation-delay: 0.05s;
  overflow: hidden;
}

.wheel-section::before {
  content: '';
  position: absolute;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 70%;
  background: radial-gradient(ellipse at center, rgba(124, 92, 255, 0.35), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.wheel-wrap {
  position: relative;
  z-index: 1;
  width: min(540px, 80vw);
  height: min(540px, 80vw);
  display: flex;
  align-items: center;
  justify-content: center;
}

#wheel-canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.5),
    0 0 0 9px #1a1330,
    0 0 0 13px var(--gold),
    0 0 0 15px rgba(240, 180, 41, 0.35),
    0 25px 70px rgba(0, 0, 0, 0.55),
    0 0 50px rgba(124, 92, 255, 0.3);
  transform: rotate(0deg);
}

.pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 34px solid var(--gold-soft);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 10px rgba(255, 215, 106, 0.7));
  z-index: 5;
}
.pointer::after {
  content: '';
  position: absolute;
  top: -34px;
  left: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--gold));
  box-shadow: 0 0 8px rgba(255, 215, 106, 0.8);
}

.wheel-hub {
  position: absolute;
  width: 21%;
  height: 21%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff8e6, var(--gold) 55%, #9a6b0a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(0.7rem, 1.6vw, 1rem);
  color: #4a2f00;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.35),
    0 0 0 6px rgba(0, 0, 0, 0.25),
    0 6px 20px rgba(0, 0, 0, 0.5);
  z-index: 4;
  pointer-events: none;
  letter-spacing: 0.5px;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
  color: var(--text-main);
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none !important; animation: none !important; }

.btn-spin {
  position: relative;
  z-index: 1;
  padding: 17px 46px;
  font-size: 1.15rem;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--gold), var(--pink) 60%, var(--violet));
  box-shadow: 0 8px 28px rgba(240, 180, 41, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  color: #1a1024;
}
.btn-spin:hover:not(:disabled) { box-shadow: 0 10px 34px rgba(255, 61, 129, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.2) inset; }

#spin-btn:not(:disabled) { animation: pulse-glow 2.6s ease-in-out infinite; }
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 8px 28px rgba(240, 180, 41, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15) inset; }
  50% { box-shadow: 0 8px 40px rgba(240, 180, 41, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.25) inset; }
}

.btn-small { padding: 9px 18px; font-size: 0.88rem; }

.btn-gold {
  background: linear-gradient(120deg, var(--gold-soft), var(--gold));
  color: #241a00;
  box-shadow: 0 4px 16px rgba(240, 180, 41, 0.3);
}
.btn-gold:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(240, 180, 41, 0.45); }

.btn-outline {
  background: var(--glass);
  border: 1px solid var(--glass-border-strong);
  color: var(--text-main);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); }

.btn-danger {
  background: rgba(255, 92, 122, 0.14);
  border: 1px solid rgba(255, 92, 122, 0.4);
  color: #ffb3c1;
}
.btn-danger:hover { background: rgba(255, 92, 122, 0.26); }

.hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
  position: relative;
  z-index: 1;
}

.side-panel {
  background: linear-gradient(175deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 480px;
  animation: rise-in 0.6s ease both;
  animation-delay: 0.1s;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.25);
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 6px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all .2s ease;
  white-space: nowrap;
}
.tab-btn:hover:not(.active) { color: var(--text-main); }

.tab-btn.active {
  background: linear-gradient(120deg, var(--gold-soft), var(--pink));
  color: #1a1024;
  box-shadow: 0 4px 16px rgba(240, 180, 41, 0.35);
}

.tab-panel { display: none; flex-direction: column; gap: 16px; }
.tab-panel.active { display: flex; animation: fade-in 0.3s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.add-form { display: flex; gap: 8px; }
.add-form input {
  flex: 1;
  min-width: 0;
}

input[type="text"], textarea {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.92rem;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.15);
}

.bulk-add summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.bulk-add summary:hover { color: var(--text-main); }
.bulk-add textarea { margin-bottom: 8px; resize: vertical; }

.participant-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.participant-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px 8px 8px;
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.participant-list li:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--glass-border-strong);
}

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

.p-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset, 0 2px 6px rgba(0, 0, 0, 0.35);
}

.participant-list li.eliminated {
  opacity: 0.5;
}
.participant-list li.eliminated .p-name { text-decoration: line-through; }

.participant-list li button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 8px;
  flex-shrink: 0;
}
.participant-list li button:hover { color: var(--danger); background: rgba(255, 92, 122, 0.14); }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
}

.history-list li {
  background: linear-gradient(120deg, rgba(240, 180, 41, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
}

.history-list .h-name { font-weight: 600; }
.history-list .h-meta { display: block; color: var(--text-dim); font-size: 0.75rem; margin-top: 2px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--gold); flex-shrink: 0; }

.divider {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 6px 0;
}

.tab-panel h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-main);
}

.telegram-status { font-size: 0.82rem; min-height: 18px; }
.telegram-status.ok { color: var(--cyan); }
.telegram-status.err { color: var(--danger); }

.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 44px;
}

/* Winner modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 12, 0.82);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal-card {
  position: relative;
  background: linear-gradient(165deg, #1a1330, #241a4d);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg);
  padding: 34px 26px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.65), 0 0 70px rgba(240, 180, 41, 0.2);
  max-height: 90vh;
  overflow-y: auto;
  animation: pop-in 0.4s cubic-bezier(0.17, 0.89, 0.32, 1.28);
}

@keyframes pop-in {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-main);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.16); }

.modal-trophy {
  font-size: 3.2rem;
  filter: drop-shadow(0 0 20px rgba(240, 180, 41, 0.6));
}
.modal-label { color: var(--text-dim); letter-spacing: 3px; font-size: 0.75rem; margin: 6px 0; text-transform: uppercase; }
.winner-name {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  margin: 4px 0 10px;
  background: linear-gradient(90deg, var(--gold-soft), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.winner-greeting { color: var(--text-main); font-size: 0.95rem; margin-bottom: 18px; }

#result-card-canvas { display: none; }
.result-card-preview {
  width: auto;
  max-width: 100%;
  max-height: 38vh;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.modal-actions .btn { flex: 1; min-width: 140px; }

.send-status { margin-top: 12px; font-size: 0.85rem; min-height: 18px; }
.send-status.ok { color: var(--cyan); }
.send-status.err { color: var(--danger); }

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(20, 14, 36, 0.95);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  max-width: 300px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.25s ease;
}
.toast.err { border-color: rgba(255, 92, 122, 0.5); }
.toast.ok { border-color: rgba(34, 224, 201, 0.5); }

@keyframes toast-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
