/* ═══════════════════════════════════════════════════════════
   ТЕАТР: ОСТАТЬСЯ В ЖИВЫХ — общие стили
   Шрифт: Montserrat (кириллица). Палитра: глубокий фиолетовый + золото.
   ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/montserrat-cyrillic.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/montserrat-latin.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --gold: #eac86b;
  --gold-light: #f6dd96;
  --gold-dim: #b39852;
  --velvet: #7a1530;
  --velvet-dark: #3d0a1c;
  --velvet-light: #a02050;
  --bg: #160a26;
  --bg2: #241239;
  --paper: #f4eefc;      /* основной текст */
  --ink: #241536;        /* текст на золоте */
  --dim: #cbbadd;        /* второстепенный текст */
  --green: #5ee0a0;
  --red: #ff7b6e;
  --blue: #8fb8ff;
  --font-ui: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  --font-display: 'Montserrat', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(ellipse 130% 100% at 50% 0%, #2e1a4d 0%, transparent 60%),
    linear-gradient(180deg, #1b0d30 0%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.04em;
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  border-radius: 10px;
}

/* ── золотые кнопки ── */
.btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--ink);
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-dim));
  border: 1px solid #8a7334;
  box-shadow: 0 3px 0 #6e5a26, 0 6px 14px rgba(0,0,0,.5);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #6e5a26; }
.btn:disabled { filter: grayscale(.7) brightness(.6); cursor: default; }
.btn.secondary {
  background: linear-gradient(180deg, #332051, #1e1034);
  color: var(--gold-light);
  border: 1px solid #54407e;
  box-shadow: 0 3px 0 #120a20, 0 6px 14px rgba(0,0,0,.5);
  text-shadow: none;
}
.btn.danger {
  background: linear-gradient(180deg, #b03048, #6d1230);
  color: #ffeef2;
  border-color: #571026;
  box-shadow: 0 3px 0 #420c1e, 0 6px 14px rgba(0,0,0,.5);
  text-shadow: none;
}

input, select {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  font-family: var(--font-ui);
  color: var(--paper);
  background: #241239;
  border: 1px solid #4d3678;
  border-radius: 10px;
  outline: none;
}
input:focus { border-color: var(--gold); }
input::placeholder { color: #9d8abb; }

.card {
  background: linear-gradient(180deg, #2b1a47, #1e1034);
  border: 1px solid #4d3678;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}

.gold-title {
  font-family: var(--font-display);
  color: var(--gold-light);
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(234,200,107,.3);
}

.hidden { display: none !important; }

/* ── полоски показателей Р/Б/П ── */
.stats-bar { display: flex; gap: 8px; }
.stat-chip {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  background: #241239;
  border: 1px solid #4d3678;
  font-size: .9rem;
  color: var(--dim);
}
.stat-chip b {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  margin-top: 2px;
  color: var(--paper);
}
.stat-chip.low b { color: var(--red); animation: pulse 1s infinite; }

@keyframes pulse { 50% { opacity: .45; } }

/* ── эффекты +/− ── */
.eff { display: inline-block; padding: 2px 8px; border-radius: 8px; margin: 2px; font-size: .95em; font-weight: 700; }
.eff.plus { color: var(--green); }
.eff.minus { color: var(--red); }
.eff.zero { color: #a28fc0; font-weight: 400; }

/* ── таймер-кольцо ── */
.timer-wrap { display: flex; align-items: center; justify-content: center; gap: 14px; }
.timer-ring {
  --p: 1;
  width: 84px; height: 84px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 360deg), #332051 0deg);
  flex: none;
}
.timer-ring > div {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem; color: var(--gold-light);
}
.timer-ring.urgent { background: conic-gradient(var(--red) calc(var(--p) * 360deg), #332051 0deg); }
.timer-ring.urgent > div { color: var(--red); animation: pulse 1s infinite; }
.timer-ring.paused > div::after { content: ' ⏸'; font-size: .8rem; }

/* ═════════════ СЦЕНА (проектор) ═════════════ */
.stage-body { overflow: hidden; height: 100vh; background: #0d0518; }

.stage {
  position: relative;
  width: 100vw; height: 100vh;
  background:
    radial-gradient(ellipse 120% 90% at 50% 110%, #3d2263 0%, transparent 60%),
    linear-gradient(180deg, #0d0518 0%, #1e1034 100%);
  overflow: hidden;
}

/* рама-просцениум */
.proscenium {
  position: absolute; inset: 0;
  border: min(2.2vw, 26px) solid transparent;
  border-image: linear-gradient(135deg, #b39852, #f6dd96 25%, #8a7334 50%, #f6dd96 75%, #b39852) 1;
  pointer-events: none;
  z-index: 40;
}
.proscenium::before {
  content: '';
  position: absolute; inset: calc(min(2.2vw, 26px) * -1);
  box-shadow: inset 0 0 60px 20px rgba(0,0,0,.8);
}

/* сцена (контент при открытых кулисах) */
.on-stage {
  position: absolute; inset: min(3vw, 40px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 5;
  text-align: center;
  padding: 20px;
  overflow: hidden;
}

/* ── кулисы: винный бархат с золотым кантом ── */
.curtain {
  position: absolute; top: 0; bottom: 0; width: 51.5%;
  z-index: 20;
  background:
    repeating-linear-gradient(90deg,
      #2c0715 0px, #571026 12px, #7a1530 26px, #96204a 34px, #6d1230 44px, #2c0715 58px);
  transition: transform 1.6s cubic-bezier(.7, 0, .2, 1);
  box-shadow: 0 0 60px rgba(0,0,0,.7);
}
.curtain::before { /* золотая бахрома снизу */
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 26px;
  background:
    radial-gradient(circle at 10px -4px, transparent 14px, var(--gold) 15px, var(--gold) 17px, transparent 18px);
  background-size: 20px 26px;
  background-color: var(--velvet-dark);
  border-top: 3px solid var(--gold-dim);
}
.curtain::after { /* верхняя тень-драпировка */
  content: '';
  position: absolute; left: 0; right: 0; top: 0; height: 70px;
  background: linear-gradient(180deg, rgba(0,0,0,.8), transparent);
}
.curtain.left  { left: 0;  border-right: 4px solid var(--gold-dim); }
.curtain.right { right: 0; border-left: 4px solid var(--gold-dim); }
.curtains-open .curtain.left  { transform: translateX(-103%); }
.curtains-open .curtain.right { transform: translateX(103%); }

/* лёгкое «дыхание» закрытых кулис */
@keyframes sway {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(1.005); }
}
.stage:not(.curtains-open) .curtain { animation: sway 7s ease-in-out infinite; transform-origin: top center; }

/* проекция на кулисах */
.projection {
  position: absolute; inset: 0;
  z-index: 25;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 0 8vw;
  pointer-events: none;
  opacity: 0;
  transition: opacity .8s;
}
.projection.visible { opacity: 1; pointer-events: auto; }
.projection::before { /* луч проектора */
  content: '';
  position: absolute; inset: -10%;
  background: radial-gradient(ellipse 55% 45% at 50% 45%, rgba(255, 244, 200, .22) 0%, rgba(255,244,200,.06) 55%, transparent 75%);
  animation: flicker 4s infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: .82; }
  94% { opacity: 1; }
  96% { opacity: .9; }
  97% { opacity: 1; }
}
.projection > * { position: relative; }

/* верхний валанс */
.valance {
  position: absolute; top: 0; left: 0; right: 0;
  height: min(9vh, 84px);
  z-index: 30;
  background:
    repeating-linear-gradient(90deg, #2c0715 0 20px, #7a1530 20px 55px, #4a0d20 55px 75px);
  border-bottom: 5px solid var(--gold-dim);
  border-radius: 0 0 50% 50% / 0 0 26px 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}

/* типографика сцены */
.scene-kicker {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .35em;
  font-size: clamp(.85rem, 1.6vw, 1.3rem);
  font-weight: 700;
  margin-bottom: 1.2vh;
}
.scene-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.7rem, 4.2vw, 3.6rem);
  color: #ffe9b8;
  text-shadow: 0 0 30px rgba(234,200,107,.45), 0 3px 6px rgba(0,0,0,.85);
  line-height: 1.15;
}
.scene-text {
  font-size: clamp(1.05rem, 2.4vw, 2rem);
  color: #f2e9ff;
  line-height: 1.4;
  text-shadow: 0 2px 4px rgba(0,0,0,.85);
}

/* варианты ответов на проекции */
.proj-options { display: flex; flex-direction: column; gap: 1.4vh; margin-top: 2.5vh; width: 100%; max-width: 1100px; }
.proj-option {
  display: flex; align-items: flex-start; gap: 14px;
  background: rgba(10,4,24,.66);
  border: 1px solid rgba(234,200,107,.55);
  border-radius: 12px;
  padding: 1.2vh 1.6vw;
  text-align: left;
  font-size: clamp(1rem, 2vw, 1.7rem);
  color: #f6efff;
}
.proj-option .letter {
  flex: none;
  width: 1.7em; height: 1.7em;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
}

/* большой код сессии */
.big-code {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(4rem, 14vw, 11rem);
  letter-spacing: .18em;
  color: #ffe9b8;
  text-shadow: 0 0 40px rgba(234,200,107,.55);
  margin: 1vh 0;
}

.qr-frame {
  background: var(--paper);
  padding: 12px;
  border-radius: 14px;
  border: 4px solid var(--gold);
  box-shadow: 0 0 40px rgba(234,200,107,.35);
}
.qr-frame img { display: block; width: clamp(140px, 20vh, 240px); height: auto; }

/* афиша команд в лобби */
.playbill {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin-top: 1.5vh; max-width: 1200px;
}
.playbill .team-tag {
  background: linear-gradient(180deg, #332051, #1e1034);
  border: 1px solid var(--gold-dim);
  color: var(--gold-light);
  border-radius: 999px;
  padding: .5em 1.1em;
  font-size: clamp(.95rem, 1.8vw, 1.4rem);
  animation: fadeSlideIn .5s backwards;
}
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(14px); } }

/* табло результатов на сцене */
.scoreboard {
  width: 100%; max-width: 1250px;
  border-collapse: collapse;
  font-size: clamp(.95rem, 2vw, 1.65rem);
}
.scoreboard th, .scoreboard td { padding: .55em .7em; border-bottom: 1px solid rgba(234,200,107,.25); }
.scoreboard th {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .72em;
  font-weight: 700;
}
.scoreboard tr.out td { opacity: .45; }
.scoreboard tr.winner td { color: #ffe9b8; }
.scoreboard td.num {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
}
.scoreboard .place { color: var(--gold); font-weight: 700; }

/* витрина театров на сцене (представление и выбор) */
.theater-show {
  display: flex; gap: 2.5vw; justify-content: center; flex-wrap: wrap;
  margin: 1vh 0 2vh;
}
.theater-show-card {
  background: rgba(10,4,24,.62);
  border: 2px solid rgba(234,200,107,.55);
  border-radius: 18px;
  padding: 2.2vh 2.2vw;
  min-width: clamp(180px, 22vw, 320px);
  animation: fadeSlideIn .6s backwards;
}
.theater-show-card:nth-child(2) { animation-delay: .15s; }
.theater-show-card:nth-child(3) { animation-delay: .3s; }
.theater-show-emoji { font-size: clamp(2.6rem, 6vw, 4.5rem); }
.theater-show-name {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: clamp(1.1rem, 2.4vw, 1.9rem);
  color: var(--gold-light);
  margin-top: .6vh;
}

/* молния катаклизма */
.storm { animation: stormFlash 1.1s infinite; }
@keyframes stormFlash {
  0%, 100% { filter: none; }
  8% { filter: brightness(2.2) saturate(.2); }
  14% { filter: none; }
  20% { filter: brightness(1.7) saturate(.3); }
  28% { filter: none; }
}
.cataclysm-badge {
  display: inline-block;
  background: linear-gradient(180deg, #a02050, #571026);
  border: 2px solid var(--gold);
  color: #ffe9a8;
  border-radius: 999px;
  padding: .35em 1.2em;
  font-size: clamp(1rem, 2vw, 1.6rem);
  font-weight: 800;
  letter-spacing: .25em;
  text-transform: uppercase;
  margin-bottom: 1.5vh;
  animation: pulse 1.2s infinite;
}

/* конфетти */
.confetti {
  position: absolute; top: -12px;
  z-index: 35;
  animation: confettiFall linear forwards;
  pointer-events: none;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .9; }
}

/* прогресс «ответили N из M» */
.answered-line {
  margin-top: 2vh;
  font-size: clamp(1rem, 2vw, 1.6rem);
  color: var(--gold-light);
  letter-spacing: .1em;
  font-weight: 700;
}

/* ── мобильные экраны (игрок / админ) ── */
.page {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 16px 40px;
  display: flex; flex-direction: column; gap: 14px;
}
.page.wide { max-width: 900px; }

.page-head {
  text-align: center;
  padding: 12px 0 4px;
}
.page-head .logo { font-size: 2rem; }
.page-head h1 {
  font-size: 1.4rem;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.code-input {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: .4em;
}

.theater-cards { display: flex; flex-direction: column; gap: 10px; }
.theater-card {
  text-align: left;
  background: linear-gradient(180deg, #2b1a47, #1e1034);
  border: 2px solid #4d3678;
  color: var(--paper);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color .15s, transform .08s;
}
.theater-card:active { transform: scale(.98); }
.theater-card.selected { border-color: var(--gold); box-shadow: 0 0 18px rgba(234,200,107,.3); }
.theater-card .tname {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--gold-light);
}
.theater-card .tstats { margin-top: 6px; font-size: .92rem; color: var(--dim); }

.answer-buttons { display: flex; flex-direction: column; gap: 12px; }
.answer-btn {
  display: flex; align-items: center; gap: 14px;
  text-align: left;
  padding: 16px;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--paper);
  background: linear-gradient(180deg, #332051, #1e1034);
  border: 2px solid #54407e;
  border-radius: 14px;
  transition: border-color .15s, transform .08s, background .2s;
}
.answer-btn:active { transform: scale(.98); }
.answer-btn .letter {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #41266b;
  color: var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
}
.answer-btn.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, #4d3577, #2b1a47);
  box-shadow: 0 0 20px rgba(234,200,107,.35);
}
.answer-btn.selected .letter { background: var(--gold); color: var(--ink); font-weight: 800; }

.result-delta {
  text-align: center;
  font-size: 1.2rem;
  padding: 14px;
  border-radius: 12px;
  background: #241239;
  border: 1px solid #4d3678;
}

.banner-out {
  background: linear-gradient(180deg, #571026, #33081a);
  border: 2px solid var(--red);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  color: #ffe3ec;
}
.banner-out h2 { color: #ffb3c2; margin-bottom: 6px; }

.note { color: var(--dim); font-size: .92rem; text-align: center; }

.admin-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 760px) { .admin-grid { grid-template-columns: 1fr 1fr; } }

.admin-team-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #352258;
  font-size: .95rem;
}
.admin-team-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.on { background: var(--green); }
.dot.off { background: #666; }
.admin-team-row .answered-mark { color: var(--green); font-weight: 700; }
.admin-team-row .kick {
  margin-left: auto;
  background: none; color: #8f7ab8;
  font-size: 1.1rem; padding: 2px 8px;
}
.admin-team-row .kick:hover { color: var(--red); }
.admin-team-row.out { opacity: .5; }

.ctrl-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ctrl-row .btn { flex: 1; min-width: 140px; width: auto; }

.phase-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: #332051;
  border: 1px solid var(--gold-dim);
  color: var(--gold-light);
  font-size: .9rem;
  letter-spacing: .08em;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: #4a1030;
  color: #ffe3ec;
  border: 1px solid var(--red);
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 100;
  animation: fadeSlideIn .25s;
  max-width: 90vw;
  text-align: center;
}

/* большой таймер на сцене (правый верхний угол) */
#big-timer {
  position: absolute;
  top: calc(min(9vh, 84px) + 16px);
  right: 3vw;
  z-index: 45;
}
#big-timer .timer-ring { width: 120px; height: 120px; }
#big-timer .timer-ring > div { width: 96px; height: 96px; font-size: 2.1rem; background: #160a26; }

/* оверлей ввода кода на проекторе */
.screen-join {
  position: absolute; inset: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,3,18,.88);
}
.screen-join .card { width: min(420px, 90vw); }

/* табло ответов (и на проекции, и на сцене) */
.proj-dist { display: flex; gap: 2vw; justify-content: center; margin: 2vh 0; flex-wrap: wrap; }
.proj-dist .dist-box {
  min-width: clamp(120px, 16vw, 240px);
  background: rgba(10,4,24,.62);
  border: 1px solid rgba(234,200,107,.55);
  border-radius: 14px;
  padding: 1.4vh 1.2vw;
}
.proj-dist .dist-box .letter {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 3.4vw, 2.8rem);
  color: #ffe9b8;
}
.proj-dist .dist-box .cnt { font-size: clamp(1rem, 1.8vw, 1.4rem); color: #f2e9ff; }

.mini-table {
  width: 100%; max-width: 1100px;
  border-collapse: collapse;
  font-size: clamp(.85rem, 1.7vw, 1.35rem);
  background: rgba(10,4,24,.4);
  border-radius: 12px;
  overflow: hidden;
}
.mini-table th, .mini-table td { padding: .35em .5em; border-bottom: 1px solid rgba(234,200,107,.2); }
.mini-table th {
  color: var(--gold);
  font-size: .8em;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
}
.mini-table tr.out td { opacity: .4; }
.mini-table .delta-cell { white-space: nowrap; }
