/* Телефон-контроллер: без зума, скролла и pull-to-refresh */
html {
  height: 100%;
}
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.scr {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  text-align: center;
}
.scr-title {
  font-size: 26px;
  color: var(--gold);
}
.brand {
  line-height: 0;
}
.brand svg {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 0 18px rgba(232, 181, 77, 0.5));
}
.brand-title {
  font-size: 38px;
  color: var(--gold);
  text-shadow: 0 3px 0 var(--red-dark);
}
.gate-hint {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  min-height: 24px;
}
.big-btn {
  font-size: 26px;
  padding: 26px 44px;
  border-radius: 22px;
}

/* имя хозяина вечера под титулом ворот */
.host-line {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--white);
  opacity: 0.85;
  margin-top: -8px;
}

/* ── имя: сначала своё, список тамады — вторым путём ──────────────────── */
.or-line {
  font-size: 15px;
  font-weight: 700;
  opacity: 0.6;
  letter-spacing: 0.03em;
}
.name-list {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.name-btn {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  border: 2px solid rgba(232, 181, 77, 0.4);
  border-radius: 14px;
  padding: 18px 8px;
  font-size: 19px;
  font-weight: 800;
  color: var(--white);
  min-height: 68px;
}
.name-btn:disabled {
  opacity: 0.35;
}
.name-btn small {
  display: block;
  font-size: 12px;
  opacity: 0.7;
  font-weight: 600;
}
.custom-box {
  display: flex;
  gap: 8px;
  width: 100%;
}
.custom-box input {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid rgba(232, 181, 77, 0.4);
  background: rgba(0, 0, 0, 0.3);
  color: var(--white);
  font-size: 18px;
  font-family: inherit;
}

/* ── выбор своей команды ──────────────────────────────────────────────── */
/* Две карточки во весь экран: сторону видно с расстояния вытянутой руки,
   а промахнуться пальцем невозможно — это первое, что делает гость. */
.team-pick {
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
}
.team-card {
  --tc: #888;
  position: relative;
  border: 4px solid var(--tc);
  border-radius: 22px;
  /* сначала простая заливка: Safari до 16.2 не знает color-mix и молча
     выбрасывает следующее правило — карточка обязана остаться цветной */
  background: rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 55%, transparent), color-mix(in srgb, var(--tc) 22%, transparent));
  color: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  box-shadow: 0 0 26px rgba(0, 0, 0, 0.35);
}
.team-card .tc-name {
  font-size: 30px;
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  line-height: 1.1;
}
.team-card .tc-count {
  font-size: 40px;
  font-weight: 900;
  color: var(--gold);
}
.team-card small {
  font-size: 15px;
  font-weight: 700;
  opacity: 0.85;
}
.team-card.mine {
  border-color: var(--gold);
}
.team-card.mine::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 16px;
  font-size: 26px;
  color: var(--gold);
}
/* занятая или запертая сторона: гасим, но не прячем — иначе непонятно,
   куда делась вторая команда */
.team-card.off {
  opacity: 0.32;
  filter: grayscale(0.6);
}

/* ── лобби игрока ─────────────────────────────────────────────────────── */
/* плашка своей команды — цветом той стороны, за которую играешь */
.my-team {
  --tc: transparent;
  font-size: 17px;
  font-weight: 800;
  padding: 7px 18px;
  border-radius: 999px;
  border: 2px solid var(--tc);
  background: rgba(255, 255, 255, 0.07);
  background: color-mix(in srgb, var(--tc) 30%, transparent);
}
.hello {
  font-size: 30px;
  font-weight: 900;
  color: var(--gold);
}
.score-chip {
  font-size: 22px;
  font-weight: 800;
  background: rgba(200, 16, 46, 0.35);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 8px 22px;
}
.wait {
  font-size: 19px;
  opacity: 0.75;
}
.idle-game {
  font-size: 22px;
  font-weight: 800;
  color: var(--white);
}
.wake-note {
  position: absolute;
  bottom: 12px;
  font-size: 14px;
  color: var(--gold);
  opacity: 0.8;
}

/* мини-таблица вечера на экране ожидания */
.mini-wrap {
  width: 100%;
  max-width: 340px;
  margin-top: 6px;
}
.mini-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.mini-board {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mini-board li {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 4px;
}
.mini-board li.me {
  background: rgba(200, 16, 46, 0.4);
  border: 1.5px solid var(--gold);
}
.mini-board li b {
  margin-left: auto;
  color: var(--gold-bright);
}
.my-rank {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--gold);
  opacity: 0.9;
}

/* ── разрешения ───────────────────────────────────────────────────────── */
.perm-emoji {
  font-size: 80px;
}
.perm-why {
  font-size: 19px;
  max-width: 320px;
  opacity: 0.85;
  margin: 0;
}
.perm-deny {
  font-size: 15px;
  max-width: 320px;
}

/* ── игра ─────────────────────────────────────────────────────────────── */
.game-scr {
  padding: 0;
  gap: 0;
  justify-content: stretch;
}
.g-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.g-top {
  padding: 10px 14px calc(10px);
  font-size: 17px;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--gold);
  z-index: 2;
}
.g-main {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* большая игровая кнопка */
.mega {
  /* ВАЖНО: none, а не наследуемый manipulation. При manipulation браузер
     считает вертикальный свайп началом прокрутки, отменяет указатель
     через pointercancel — и рывок «на себя» в эр эңиш не доходил
     до сервера ни на одном телефоне. */
  touch-action: none;
  position: absolute;
  inset: 8px;
  border-radius: 26px;
  border: 3px solid var(--gold);
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 42px;
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  overflow: hidden;
  color: var(--white);
}
.mega .fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  opacity: 0.85;
  transition: height 0.09s linear;
}
.mega .label,
.mega .sub {
  position: relative;
  z-index: 2;
  pointer-events: none;
}
.mega .sub {
  font-size: 20px;
  font-weight: 800;
  opacity: 0.9;
}
.mega.hit {
  filter: brightness(1.35);
}
.mega.gold-mega {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #3a1a00;
}
.mega.dim {
  filter: grayscale(0.7) brightness(0.6);
}
/* отстаёшь по темпу — кнопка тревожно светится, но остаётся активной */

/* эр эңиш: полоса крена */
.mega.boosted {
  box-shadow: inset 0 0 70px rgba(255, 255, 255, 0.6);
  border-color: #fff;
}
.mega.shout-ready {
  border-color: #39ff88;
  box-shadow: inset 0 0 70px rgba(57, 255, 136, 0.35), 0 0 30px rgba(57, 255, 136, 0.5);
}

/* эр эңиш */
.hearts {
  font-size: 26px;
  letter-spacing: 4px;
}

/* лук */
.mega .label.bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  font-size: 24px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.bow-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bow-wrap svg {
  width: 70%;
  max-height: 70%;
}

/* ── отсчёт / прочее ──────────────────────────────────────────────────── */
.cd {
  position: fixed;
  inset: 0;
  background: rgba(26, 3, 8, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.cd span {
  font-size: 40vh;
  font-weight: 900;
  color: var(--gold);
  animation: pop 0.35s;
}
.conn {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  padding: 6px;
  text-align: center;
  z-index: 200;
}
.my-place {
  font-size: 46px;
  font-weight: 900;
  color: var(--gold);
}
.res-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 420px;
  overflow-y: auto;
}
.res-list li {
  display: flex;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 6px;
}
.res-list li.me {
  border: 2px solid var(--gold);
}
.res-list .pts {
  margin-left: auto;
  color: var(--gold-bright);
}

/* переключатель языка на воротах: маленький, не спорит с главной кнопкой */
.lang-btn {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  min-width: 46px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 2px solid rgba(232, 181, 77, 0.5);
  background: rgba(255, 255, 255, 0.07);
  color: var(--gold);
  font: inherit;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.5px;
}

/* ── эр эңиш: «повод» соперника, который оттягиваешь на себя ──────────── */

/* ── выбор фигурки ─────────────────────────────────────────────────────── */
/* Двадцать штук должны помещаться на экран телефона без прокрутки к кнопке:
   четыре в ряд, сетка прокручивается сама. */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px;
}
.hero-cell {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 4px 2px;
  line-height: 0;
  touch-action: manipulation;
}
.hero-cell canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
}
.hero-cell.mine {
  border-color: var(--gold);
  background: rgba(200, 16, 46, 0.35);
  box-shadow: 0 0 18px rgba(232, 181, 77, 0.35);
}
/* своя фигурка в лобби */
.my-hero {
  background: transparent;
  border: 2px solid rgba(232, 181, 77, 0.45);
  border-radius: 18px;
  padding: 4px 10px;
  line-height: 0;
}
.my-hero canvas {
  width: 68px;
  height: 84px;
}
.my-hero.hidden {
  display: none;
}

/* ── код на вход ───────────────────────────────────────────────────────── */
/* По QR заходит весь зал, а играют двенадцать: код отсекает случайных. */
.code-lock {
  font-size: 64px;
  line-height: 1;
}
.code-input {
  width: 72vw;
  max-width: 320px;
  padding: 16px;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 14px;
  text-align: center;
  font-family: inherit;
  color: var(--gold-bright);
  background: rgba(0, 0, 0, 0.35);
  border: 3px solid var(--gold);
  border-radius: 18px;
}
.code-input::placeholder {
  color: rgba(232, 181, 77, 0.35);
  letter-spacing: 14px;
}
.code-err {
  min-height: 24px;
  font-weight: 800;
  color: #ffb3c0;
  text-align: center;
}
/* отказ видно без чтения — поле дёргается */
.code-input.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(6px); }
  30%, 50%, 70% { transform: translateX(-10px); }
  40%, 60% { transform: translateX(10px); }
}
