/* Общая палитра и «бутылочный» движок. Используется и на ТВ, и на телефоне. */

:root {
  /* Единицы «процент от логического экрана». На телефоне совпадают с vh/vw,
     на повёрнутом телевизоре tv.css меняет их местами — см. .frame */
  --h: 1vh;
  --w: 1vw;

  --bg: #0b1220;
  --bg-2: #101c33;
  --ink: #f5f7fb;
  --ink-dim: #93a3bd;
  --br-green: #1fae5a;
  --br-yellow: #f7d117;
  --br-blue: #2f6fe0;
  --danger: #ff4d4d;
  --radius: 22px;
  --font: 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  position: relative; /* конфетти позиционируются относительно контейнера */
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(31, 174, 90, 0.18), transparent 60%),
    radial-gradient(1000px 600px at 105% 110%, rgba(47, 111, 224, 0.2), transparent 60%),
    var(--bg);
}

.hidden {
  display: none !important;
}

.nowrap {
  white-space: nowrap;
}

/* ── Сцена с бутылками ───────────────────────────────────────────────────── */

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  --slot-w: 33.333%;
}

.slot-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 33.333%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border-radius: 18px;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 5; /* тап-зоны поверх бутылок */
}

.stage.pickable .slot-hit:active {
  background: rgba(255, 255, 255, 0.09);
}

.stage:not(.pickable) .slot-hit {
  pointer-events: none;
}

.piece {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 33.333%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--swap-ms, 420ms) cubic-bezier(0.42, 0, 0.3, 1);
  will-change: transform;
}

.piece.lifted {
  z-index: 3;
}

/* По умолчанию размер задаёт ширина слота — это случай узкого телефона,
   где бутылка упирается в ширину, а не в высоту. На ТВ сцена низкая и широкая,
   там tv.css переключает бутылку на высоту (см. `.tv .bottle-wrap`).
   Одним правилом это не выразить: aspect-ratio не умеет ужиматься сразу
   по обеим осям, как object-fit: contain. */
.bottle-wrap {
  position: relative;
  width: 76%;
  aspect-ratio: 60 / 160;
}

.bottle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45));
}

.cover {
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -2%;
  height: 112%;
  border-radius: 14px 14px 8px 8px;
  background: linear-gradient(170deg, #c9975c 0%, #a9743d 45%, #8c5c2c 100%);
  border: 3px solid rgba(0, 0, 0, 0.28);
  box-shadow:
    inset 0 -14px 24px rgba(0, 0, 0, 0.32),
    0 14px 22px rgba(0, 0, 0, 0.45);
  transform: translateY(-118%);
  opacity: 0;
  transition:
    transform var(--cover-ms, 600ms) cubic-bezier(0.5, 0, 0.3, 1),
    opacity 0.18s linear;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover::after {
  content: '';
  width: 44%;
  height: 44%;
  border-radius: 50%;
  border: 4px dashed rgba(0, 0, 0, 0.22);
}

.piece.covered .cover {
  transform: translateY(0);
  opacity: 1;
}

/* Подсветка после ответа */
.piece .bottle-wrap::before {
  content: '';
  position: absolute;
  inset: -8% -14%;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

/* «Вот эту и следи» — пульсирует цветом самой бутылки, пока она открыта */
.piece.watch .bottle-wrap::before {
  opacity: 1;
  animation: watch-pulse 0.9s ease-in-out infinite;
}

@keyframes watch-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 4px var(--glow, #fff),
      0 0 34px 8px var(--glow, #fff);
  }
  50% {
    box-shadow:
      0 0 0 8px var(--glow, #fff),
      0 0 64px 20px var(--glow, #fff);
  }
}

.piece.right .bottle-wrap::before {
  opacity: 1;
  box-shadow:
    0 0 0 6px rgba(37, 184, 98, 0.9),
    0 0 60px 18px rgba(37, 184, 98, 0.55);
}

.piece.wrong .bottle-wrap::before {
  opacity: 1;
  box-shadow:
    0 0 0 6px rgba(255, 77, 77, 0.9),
    0 0 50px 14px rgba(255, 77, 77, 0.45);
}

.piece.target .bottle-wrap::before {
  opacity: 1;
  box-shadow:
    0 0 0 6px rgba(247, 209, 23, 0.95),
    0 0 60px 18px rgba(247, 209, 23, 0.5);
}

.piece.right .bottle-wrap {
  animation: pop 0.45s ease;
}

@keyframes pop {
  40% {
    transform: scale(1.12);
  }
}

/* ── Точки результатов раундов ───────────────────────────────────────────── */

.dots {
  display: flex;
  gap: 0.5em;
}

.dot {
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 0.14em solid rgba(255, 255, 255, 0.28);
}

.dot.ok {
  background: var(--br-green);
  border-color: #6df2a5;
}

.dot.bad {
  background: var(--danger);
  border-color: #ff9d9d;
}

/* ── Конфетти ────────────────────────────────────────────────────────────── */

/* absolute, а не fixed: на повёрнутом телевизоре fixed привязался бы к окну,
   и конфетти сыпались бы вбок */
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.confetti i {
  position: absolute;
  top: calc(-8 * var(--h));
  width: calc(0.9 * var(--w));
  height: calc(1.8 * var(--w));
  min-width: 6px;
  min-height: 12px;
  border-radius: 2px;
  animation: fall linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(calc(118 * var(--h))) rotate(720deg);
  }
}
