/* ==========================================================================
   Жеребьёвка — демо v2. Тёмный cinematic UI: прожекторы, стекло, золото.
   ========================================================================== */

:root {
  --bg-0: #04050c;
  --bg-1: #0a0e20;
  --card: rgba(20, 26, 52, 0.55);
  --card-solid: #141a34;
  --line: rgba(255, 255, 255, 0.09);
  --line-bright: rgba(255, 255, 255, 0.18);
  --text: #f4f6fd;
  --text-dim: #8d95b4;
  --gold: #f5c542;
  --gold-2: #ffdf7e;
  --green: #3ddc84;
  --red: #ff5470;
  --font-body: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 70%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* виньетка */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 90% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 1;
}
body > * { position: relative; z-index: 2; }

.font-display { font-family: var(--font-display); }

/* ---------------- Прожекторы ---------------- */

.spotlights {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  filter: blur(60px);
}
.spotlights::before, .spotlights::after {
  content: "";
  position: absolute;
  width: 55vw; height: 55vw;
  border-radius: 50%;
  opacity: 0.16;
}
.spotlights::before {
  background: radial-gradient(circle, #3b4fd8 0%, transparent 65%);
  top: -8%; left: 4%;
  animation: spotA 26s ease-in-out infinite alternate;
}
.spotlights::after {
  background: radial-gradient(circle, #8a5cf5 0%, transparent 65%);
  bottom: -12%; right: 0%;
  animation: spotB 32s ease-in-out infinite alternate;
}
@keyframes spotA { from { transform: translate(0, 0) scale(1); } to { transform: translate(18vw, 10vh) scale(1.25); } }
@keyframes spotB { from { transform: translate(0, 0) scale(1.2); } to { transform: translate(-16vw, -8vh) scale(0.9); } }

/* режим «как в эфире»: ?bg=black */
body.bg-black { background: #000; }
body.bg-black::after { display: none; }
body.bg-black .spotlights { display: none; }

/* ---------------- Общее ---------------- */

.glass {
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 24px 70px rgba(0, 0, 0, 0.5);
}

.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #0c0f1e;
  user-select: none;
  flex-shrink: 0;
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.22), inset 0 4px 10px rgba(255, 255, 255, 0.35);
  position: relative;
  overflow: hidden;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-xl { width: 140px; height: 140px; font-size: 48px; }
.avatar-md { width: 52px; height: 52px; font-size: 19px; }
.avatar-sm { width: 44px; height: 44px; font-size: 16px; }

.btn {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 800;
  padding: 14px 26px;
  border-radius: 14px;
  border: 1px solid var(--line-bright);
  background: var(--card-solid);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn:hover:not(:disabled) { background: #1c2447; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.32; cursor: not-allowed; }
.btn-sm { padding: 9px 16px; font-size: 14px; border-radius: 10px; }

.btn-primary { background: var(--green); border-color: var(--green); color: #06220f; }
.btn-primary:hover:not(:disabled) { background: #59e79b; }
.btn-accent {
  background: linear-gradient(180deg, var(--gold-2) 0%, var(--gold) 100%);
  border-color: var(--gold);
  color: #241c02;
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger { background: transparent; border-color: rgba(255, 84, 112, 0.5); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 84, 112, 0.12); }

.conn-dot {
  position: fixed;
  right: 14px; bottom: 14px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px rgba(255, 84, 112, 0.7);
  transition: background 0.3s, box-shadow 0.3s;
  z-index: 50;
}
.conn-dot.online { background: var(--green); box-shadow: 0 0 10px rgba(61, 220, 132, 0.7); }

.disclaimer {
  padding: 12px 28px 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  opacity: 0.8;
}

@keyframes softPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ==========================================================================
   Лаунчер
   ========================================================================== */

.launcher {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
}
.launcher-brand {
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 56px);
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #fff 15%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.launcher-sub { color: var(--text-dim); font-size: 16px; margin-bottom: 22px; }

.launcher-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 320px));
  gap: 18px;
}
.launcher-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 22px;
  text-align: left;
  transition: transform 0.18s, border-color 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(14px);
}
a.launcher-card:hover {
  transform: translateY(-4px);
  border-color: rgba(245, 197, 66, 0.5);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.launcher-card-icon { font-size: 26px; color: var(--gold); margin-bottom: 12px; }
.launcher-card-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.launcher-card-desc { font-size: 13.5px; color: var(--text-dim); line-height: 1.55; }
.launcher-card-desc code { color: var(--gold); font-size: 12px; }
.launcher-preview-link { color: var(--gold); text-decoration: underline; }
.launcher-preview-link:hover { color: var(--gold-2); }

.launcher-slots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.launcher-slots a {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line-bright);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  transition: background 0.15s, border-color 0.15s;
}
.launcher-slots a:hover { background: rgba(245, 197, 66, 0.15); border-color: var(--gold); }

.launcher-status { margin-top: 26px; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Планшет
   ========================================================================== */

.tablet {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.tablet-card {
  width: min(660px, 96vw);
  min-height: min(600px, 88vh);
  border-radius: 30px;
  padding: 46px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  transition: border-color 0.4s, box-shadow 0.4s;
}
.tablet-card.on-stage {
  border-color: rgba(245, 197, 66, 0.75);
  box-shadow: 0 0 70px rgba(245, 197, 66, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.tablet-name { font-size: 30px; font-weight: 700; }

.tablet-stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.tablet-wait { font-size: 19px; color: var(--text-dim); animation: softPulse 2.6s ease-in-out infinite; }

.btn-ready {
  font-family: var(--font-display);
  width: min(270px, 64vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: clamp(30px, 8vw, 42px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #06220f;
  background: radial-gradient(circle at 32% 26%, #7df3b2 0%, var(--green) 55%, #17a057 100%);
  box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.5), 0 24px 70px rgba(61, 220, 132, 0.3);
  animation: readyGlow 1.8s ease-in-out infinite;
  transition: transform 0.1s;
  position: relative;
  overflow: hidden;
}
.btn-ready:active { transform: scale(0.94); }
.btn-ready .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: scale(0);
  animation: ripple 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes ripple { to { transform: scale(3.2); opacity: 0; } }
@keyframes readyGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.45), 0 24px 70px rgba(61, 220, 132, 0.3); }
  50%      { box-shadow: 0 0 0 26px rgba(61, 220, 132, 0), 0 24px 70px rgba(61, 220, 132, 0.3); }
}

.tablet-pressed-check {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: rgba(61, 220, 132, 0.13);
  border: 2px solid var(--green);
  color: var(--green);
  font-size: 40px;
  display: flex; align-items: center; justify-content: center;
  animation: popIn 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.tablet-pressed-text { font-size: 21px; font-weight: 700; }
.tablet-pressed-progress { font-size: 16px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.tablet-shuffling { font-family: var(--font-display); font-size: 20px; color: var(--gold); animation: softPulse 1.1s ease-in-out infinite; }

.tablet-number-cap { font-size: 17px; color: var(--text-dim); letter-spacing: 0.16em; text-transform: uppercase; }
.tablet-number {
  font-family: var(--font-display);
  font-size: clamp(120px, 34vw, 190px);
  line-height: 1;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 80px rgba(245, 197, 66, 0.45);
  animation: popIn 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.tablet-onstage-cap {
  font-family: var(--font-display);
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.08em;
  animation: softPulse 1.2s ease-in-out infinite;
}
.tablet-done { font-size: 17px; color: var(--text-dim); }
.preview-badge {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 6px 16px;
  border: 1px dashed var(--line-bright);
  border-radius: 999px;
}
.preview-exit {
  font-size: 13.5px;
  color: var(--text-dim);
  text-decoration: underline;
}
.preview-exit:hover { color: var(--text); }

.tablet-next {
  font-size: 19px;
  font-weight: 800;
  color: var(--gold);
  padding: 10px 22px;
  border: 1px solid rgba(245, 197, 66, 0.5);
  border-radius: 999px;
  background: rgba(245, 197, 66, 0.1);
  animation: softPulse 1.4s ease-in-out infinite;
}

@keyframes popIn {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ==========================================================================
   Ведущий
   ========================================================================== */

.host {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 26px 34px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.host-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.host-title { font-size: 24px; font-weight: 700; }
.host-sub { font-size: 14px; color: var(--text-dim); margin-top: 7px; }
.phase-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.04em;
}
.phase-badge.idle       { background: rgba(141, 149, 180, 0.15); color: var(--text-dim); }
.phase-badge.collecting { background: rgba(61, 220, 132, 0.14);  color: var(--green); }
.phase-badge.shuffling  { background: rgba(245, 197, 66, 0.15);  color: var(--gold); }
.phase-badge.revealed   { background: rgba(245, 197, 66, 0.24);  color: var(--gold-2); }

.host-progress { text-align: right; }
.host-progress-num { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; }
.host-progress-cap { font-size: 12.5px; color: var(--text-dim); }

.host-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

.host-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  backdrop-filter: blur(10px);
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.host-cell-name { font-size: 14.5px; font-weight: 800; text-align: center; }
.host-cell-status { font-size: 12px; color: var(--text-dim); }
.host-cell.pressed {
  border-color: rgba(61, 220, 132, 0.55);
  background: rgba(61, 220, 132, 0.07);
  box-shadow: 0 0 22px rgba(61, 220, 132, 0.12);
}
.host-cell.pressed .host-cell-status { color: var(--green); font-weight: 800; }
.host-cell-order { font-size: 12.5px; color: var(--gold); font-weight: 800; }

.host-controls { display: flex; gap: 12px; flex-wrap: wrap; }

.host-run { border-radius: 18px; padding: 18px 20px; }
.host-run-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.host-run-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.host-run-controls { display: flex; gap: 8px; }

.host-run-list { display: flex; flex-direction: column; gap: 6px; }
.host-run-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.2s;
  font-size: 14.5px;
}
.host-run-item:hover { background: rgba(255, 255, 255, 0.05); }
.host-run-item .run-pos { font-weight: 900; color: var(--text-dim); min-width: 26px; font-variant-numeric: tabular-nums; }
.host-run-item .run-name { font-weight: 700; flex: 1; }
.host-run-item .run-mark { font-size: 12px; color: var(--text-dim); }
.host-run-item.done { opacity: 0.45; }
.host-run-item.done .run-mark { color: var(--green); }
.host-run-item.current {
  border-color: rgba(245, 197, 66, 0.65);
  background: rgba(245, 197, 66, 0.1);
}
.host-run-item.current .run-pos { color: var(--gold); }
.host-run-item.current .run-mark { color: var(--gold); font-weight: 800; }

.host-tech { font-size: 11.5px; color: var(--text-dim); opacity: 0.7; font-variant-numeric: tabular-nums; word-break: break-all; }

/* ==========================================================================
   Эфир
   ========================================================================== */

body[data-view="board"] { overflow: hidden; }

.board-stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

/* idle */
.board-idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
}
.board-idle.visible { opacity: 1; }
.board-idle-title {
  font-size: clamp(52px, 8.5vw, 130px);
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #fff 15%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: softPulse 4.5s ease-in-out infinite;
  text-align: center;
  padding: 0 4vw;
}
.board-idle-sub {
  font-size: clamp(15px, 1.7vw, 24px);
  color: var(--text-dim);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

/* shuffle */
.board-shuffle {
  position: absolute;
  inset: 5% 5%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.board-shuffle.visible { opacity: 1; }

.shuffle-card {
  position: absolute;
  width: 17%;
  height: 40%;
  border-radius: 18px;
  background: linear-gradient(180deg, #1d2650 0%, var(--card-solid) 100%);
  border: 1px solid var(--line-bright);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45), 0 0 24px rgba(90, 110, 240, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: left 0.34s cubic-bezier(0.5, 0, 0.25, 1.25), top 0.34s cubic-bezier(0.5, 0, 0.25, 1.25), transform 0.34s;
  animation: cardFlicker 0.85s ease-in-out infinite;
  will-change: left, top, transform;
}
.shuffle-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12) 0%, transparent 38%);
  pointer-events: none;
}
.shuffle-card-name {
  font-family: var(--font-display);
  font-size: clamp(12px, 1.4vw, 21px);
  font-weight: 700;
  text-align: center;
  padding: 0 8px;
}
@keyframes cardFlicker {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.6); }
}

/* вспышка при переходе к результату */
.board-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 235, 170, 0.95) 0%, rgba(245, 197, 66, 0.35) 45%, transparent 75%);
  opacity: 0;
  z-index: 5;
}
.board-flash.go { animation: flash 0.7s ease-out forwards; }
@keyframes flash {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

/* reveal: одна колонка 1..10 */
.board-reveal {
  position: absolute;
  inset: 3.5% 14%;
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.9vh;
}
.board-reveal.visible { display: flex; }

.reveal-row {
  display: flex;
  align-items: center;
  gap: 1.6vw;
  background: rgba(20, 26, 52, 0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.5vh 1.8vw;
  height: 8vh;
  opacity: 0;
  transform: translateX(-46px);
  transition:
    opacity 0.5s ease,
    transform 0.55s cubic-bezier(0.18, 1.1, 0.32, 1),
    border-color 0.35s, box-shadow 0.35s, background 0.35s, filter 0.35s;
}
.reveal-row.shown { opacity: 1; transform: translateX(0); }

.reveal-pos {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.8vh, 42px);
  font-weight: 900;
  min-width: 2em;
  text-align: center;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  position: relative;
}
.reveal-name {
  font-size: clamp(16px, 3.4vh, 40px);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.reveal-badge {
  font-family: var(--font-display);
  font-size: clamp(10px, 1.4vh, 16px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold);
  white-space: nowrap;
}
.reveal-check { color: var(--green); font-size: clamp(14px, 2.2vh, 26px); }

/* «сейчас выступает» */
.board-reveal.has-current .reveal-row:not(.current) { filter: brightness(0.55) saturate(0.7); }
.reveal-row.done .reveal-name { color: var(--text-dim); }
.reveal-row.current {
  opacity: 1;
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(245, 197, 66, 0.28) 0%, rgba(30, 36, 66, 0.85) 70%);
  box-shadow: 0 0 44px rgba(245, 197, 66, 0.3);
  transform: scale(1.045);
  animation: currentPulse 1.6s ease-in-out infinite;
  z-index: 2;
}
.reveal-row.current .reveal-pos { color: var(--gold-2); }
@keyframes currentPulse {
  0%, 100% { box-shadow: 0 0 44px rgba(245, 197, 66, 0.3); }
  50%      { box-shadow: 0 0 64px rgba(245, 197, 66, 0.5); }
}

/* ---------------- Адаптив ---------------- */

@media (max-width: 920px) {
  .launcher-cards { grid-template-columns: 1fr; width: min(420px, 92vw); }
  .host-grid { grid-template-columns: repeat(2, 1fr); }
  .board-reveal { inset: 3% 5%; }
  .shuffle-card { width: 28%; height: 24%; }
}
