:root {
  --bg: #0e1220;
  --bg-soft: #171d33;
  --line: #2a3252;
  --text: #eef1fb;
  --muted: #939bc0;
  --gold-1: #ffe9a8;
  --gold-2: #e8b53c;
  --gold-3: #a9761a;
  --accent: #6f8cff;
  --radius: 16px;
  --ring: 0 0 0 3px rgba(111, 140, 255, 0.35);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- общие анимации ---------- */

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes pop-in {
  0%   { opacity: 0; transform: scale(0.92); }
  60%  { opacity: 1; transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes pulse-once {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); color: var(--gold-1); }
  100% { transform: scale(1); }
}

/* уважаем системную настройку «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  display: flex;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  background: radial-gradient(60% 60% at 50% 20%, rgba(111, 140, 255, 0.28), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  padding: 40px 20px 64px;
  animation: rise-in 0.45s var(--ease) both;
}

.head { text-align: center; margin-bottom: 28px; }

h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
  justify-content: space-between;
}


.field { display: flex; flex-direction: column; gap: 8px; flex: 1 1 320px; }
.field-label { font-size: 13px; color: var(--muted); }

/* ---------- свой выпадающий список ---------- */

.select { position: relative; }

.select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101529;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease),
    background 0.25s var(--ease);
}
.select-trigger:hover { border-color: #3a4570; }
.select-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.select.open .select-trigger { border-color: var(--accent); }

.select-arrow {
  width: 14px;
  flex: none;
  margin-right: 6px; /* стрелка чуть левее края */
  color: var(--muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}
.select.open .select-arrow { transform: rotate(180deg); color: var(--gold-2); }

.select-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  padding: 6px;
  background: #101529;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  animation: drop 0.2s var(--ease) both;
  transform-origin: top center;
}
.select-menu[hidden] { display: none; }
.select-menu.closing { animation: drop-out 0.16s var(--ease) both; }

@keyframes drop-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-6px) scale(0.985); }
}

.select-list {
  max-height: 250px;
  overflow-y: auto;
  margin: 0;
  padding: 0 14px 0 0;
  list-style: none;
  scrollbar-width: none; /* родной скроллбар прячем, рисуем свой */
}
.select-list::-webkit-scrollbar { width: 0; height: 0; display: none; }

@keyframes drop {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.select-list li {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.select-list li:hover,
.select-list li.active { background: #1b2340; }
.select-list li[aria-selected="true"] { color: var(--gold-1); }

/* свой скроллбар — выглядит одинаково во всех браузерах */
.select-scroll {
  position: absolute;
  top: 8px;
  bottom: 8px;
  right: 7px;
  width: 6px;
  border-radius: 4px;
  background: #0b1020;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.select-scroll[hidden] { display: none; }

.select-thumb {
  position: absolute;
  left: 0;
  width: 6px;
  min-height: 28px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3));
  cursor: grab;
  transition: filter 0.2s ease;
}
.select-thumb:hover { filter: brightness(1.15); }
.select-thumb.dragging { cursor: grabbing; filter: brightness(1.2); }

.pool-info { font-size: 14px; color: var(--muted); padding-bottom: 10px; }
.pool-info b { color: var(--text); display: inline-block; }
.pool-info b.changed { animation: pulse-once 0.45s var(--ease); }

/* ---------- подсказка ---------- */

.hint {
  margin: 18px 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
}
.hint-error { color: #ff8a8a; }
.hint.hint-swap { animation: rise-in 0.28s var(--ease); }

/* ---------- результат ---------- */

.result[hidden] { display: none; }
.result { animation: rise-in 0.35s var(--ease) both; }

.result {
  margin-top: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.result.win {
  border-color: var(--gold-2);
  box-shadow: 0 0 0 1px rgba(232, 181, 60, 0.3), 0 12px 34px rgba(232, 181, 60, 0.12);
}
.result-label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.result-name { font-size: 28px; font-weight: 700; margin-top: 8px; word-break: break-word; }
.result-name.pop { animation: pop-in 0.4s var(--ease); }

/* ---------- списки ---------- */

h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 32px 0 12px; }
.muted { color: var(--muted); font-weight: 400; }


.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history li {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.history li span { color: var(--muted); white-space: nowrap; }
.history li {
  flex-direction: column;
  gap: 4px;
  animation: rise-in 0.3s var(--ease) both;
}
.history { animation: fade-in 0.3s var(--ease) both; }
.history-top { display: flex; justify-content: space-between; gap: 12px; }
.history-note { font-size: 12px; color: var(--muted); }
.history-empty { color: var(--muted); align-items: center; }

.people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.people li {
  animation: rise-in 0.3s var(--ease) both;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease),
    background 0.2s var(--ease), opacity 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.people li.birthday {
  border-color: var(--gold-2);
  color: var(--gold-1);
  background: rgba(232, 181, 60, 0.1);
}
.people li.winner {
  border-color: var(--accent);
  color: #cdd8ff;
}

.people-hint { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }

/* ---------- история ---------- */

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

.ghost-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }
.ghost-btn[hidden] { display: none; }

.history[hidden] { display: none; }

.history-block[hidden] { display: none; }
.history-block { animation: rise-in 0.4s var(--ease) both; }

.people li[role="button"] { cursor: pointer; }
.people li[role="button"]:hover { border-color: #3a4570; }
.people li[role="button"]:focus-visible { outline: none; box-shadow: var(--ring); }

.people li.excluded {
  color: var(--muted);
  opacity: 0.55;
  text-decoration: line-through;
  border-style: dashed;
}
.people li.excluded:hover { opacity: 0.8; }

.excluded-note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--gold-1);
  animation: rise-in 0.28s var(--ease) both;
}
.excluded-note[hidden] { display: none; }

@media (max-width: 560px) {
  h1 { font-size: 32px; }
}
