/* Новогоднее демо «Лови снежинки» — единый ночной мир, все цвета заданы явно. */

:root {
  --night-deep: #0a1631;
  --night-hi: #1b3a72;
  --snow: #f4f8ff;
  --ice: #9db4d8;
  --gold: #ffc94d;
  --gold-soft: #ffe3a1;
  --berry: #e5484d;
  --berry-dark: #c73a3f;
  --pine: #2fbf71;
  --line: rgba(244, 248, 255, 0.16);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--night-deep);
  color: var(--snow);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
/* Ночное небо отдельным фиксированным слоем (background-attachment:fixed глючит на iOS) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(120% 90% at 85% -10%, var(--night-hi) 0%, rgba(27, 58, 114, 0) 55%),
    radial-gradient(90% 70% at 10% 110%, #0f2a56 0%, rgba(15, 42, 86, 0) 60%),
    var(--night-deep);
}

#bg-snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ===== Каркас приложения ===== */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ===== Гирлянда ===== */
.garland {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  z-index: 5;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  pointer-events: none;
}
.garland::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -4%;
  right: -4%;
  height: 14px;
  border-bottom: 2px solid rgba(244, 248, 255, 0.22);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.garland i {
  width: 9px;
  height: 13px;
  margin-top: 8px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  animation: twinkle 1.6s ease-in-out infinite;
}
.garland i:nth-child(odd) { margin-top: 12px; }
.garland i:nth-child(4n+1) { background: var(--berry); color: var(--berry); }
.garland i:nth-child(4n+2) { background: var(--gold); color: var(--gold); animation-delay: 0.4s; }
.garland i:nth-child(4n+3) { background: var(--pine); color: var(--pine); animation-delay: 0.8s; }
.garland i:nth-child(4n)   { background: #5aa7ff; color: #5aa7ff; animation-delay: 1.2s; }
@keyframes twinkle {
  0%, 100% { box-shadow: 0 0 7px 1px currentColor; opacity: 1; }
  50% { box-shadow: 0 0 1px 0 currentColor; opacity: 0.5; }
}

/* ===== Экраны ===== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(36px + env(safe-area-inset-top)) 22px calc(14px + env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s 0.35s;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* ===== Кнопки ===== */
.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 17px;
  line-height: 1.2;
  padding: 16px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: scale(0.96); }
.btn-berry {
  background: linear-gradient(180deg, #f2666b, var(--berry) 55%, var(--berry-dark));
  box-shadow: 0 10px 24px rgba(229, 72, 77, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-ghost {
  background: rgba(244, 248, 255, 0.08);
  border: 1.5px solid rgba(244, 248, 255, 0.22);
  color: var(--snow);
}
.btn.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 10px 24px rgba(229, 72, 77, 0.35); }
  50% { transform: scale(1.045); box-shadow: 0 12px 32px rgba(229, 72, 77, 0.55); }
}
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ===== Экран 1: главный ===== */
.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
.badge {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-soft);
  background: rgba(255, 201, 77, 0.1);
  border: 1px solid rgba(255, 201, 77, 0.3);
  border-radius: 999px;
  padding: 8px 16px;
}
.logo-light {
  display: block;
  width: 168px;
  height: auto;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
}
.logo-light-sm {
  width: 116px;
  align-self: center;
  margin-top: 4px;
  opacity: 0.92;
}
.title {
  font-size: clamp(44px, 13vw, 58px);
  line-height: 1.04;
  font-weight: 900;
  letter-spacing: -0.01em;
  text-wrap: balance;
  background: linear-gradient(180deg, #ffffff 15%, var(--gold-soft) 55%, var(--gold) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 201, 77, 0.25));
}
.subtitle {
  color: var(--ice);
  font-size: 16px;
  font-weight: 500;
  max-width: 26ch;
  line-height: 1.45;
  text-wrap: balance;
}
.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}
.foot {
  padding-top: 10px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(157, 180, 216, 0.65);
}

/* ===== Экран 2: поздравление ===== */
#screen-greet { gap: 14px; }
.topbar { display: flex; align-items: center; gap: 12px; }
.btn-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(244, 248, 255, 0.1);
  border: 1px solid var(--line);
  color: var(--snow);
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.topbar-title { font-weight: 800; font-size: 17px; }

.video-card {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: radial-gradient(140% 100% at 50% -20%, #24457f 0%, #16294f 55%, #0f1d3c 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 18px;
}
.vc-santa {
  font-size: 96px;
  line-height: 1;
  animation: float 3.2s ease-in-out infinite;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35));
  transition: font-size 0.4s ease;
}
.video-card.playing .vc-santa { font-size: 54px; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.vc-play {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  background: rgba(229, 72, 77, 0.95);
  color: #ffffff;
  font-size: 26px;
  padding-left: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
  touch-action: manipulation;
}
.vc-play:active { transform: translateX(-50%) scale(0.94); }
.video-card.playing .vc-play { display: none; }
.vc-text { max-width: 95%; text-align: center; }
.vc-text p {
  font-size: 18.5px;
  font-weight: 700;
  line-height: 1.5;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.video-card.typing .vc-text p:last-child::after {
  content: "▍";
  color: var(--gold);
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.vc-snow i {
  position: absolute;
  top: -10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(244, 248, 255, 0.8);
  animation: vcfall linear infinite;
}
.vc-snow i:nth-child(1)  { left: 6%;  animation-duration: 5.2s; }
.vc-snow i:nth-child(2)  { left: 16%; animation-duration: 6.4s; animation-delay: 1.1s; }
.vc-snow i:nth-child(3)  { left: 26%; animation-duration: 4.8s; animation-delay: 2.3s; }
.vc-snow i:nth-child(4)  { left: 37%; animation-duration: 6.9s; animation-delay: 0.6s; }
.vc-snow i:nth-child(5)  { left: 47%; animation-duration: 5.6s; animation-delay: 3.1s; }
.vc-snow i:nth-child(6)  { left: 58%; animation-duration: 4.6s; animation-delay: 1.7s; }
.vc-snow i:nth-child(7)  { left: 67%; animation-duration: 6.2s; animation-delay: 2.8s; }
.vc-snow i:nth-child(8)  { left: 77%; animation-duration: 5.0s; animation-delay: 0.3s; }
.vc-snow i:nth-child(9)  { left: 86%; animation-duration: 6.6s; animation-delay: 1.9s; }
.vc-snow i:nth-child(10) { left: 94%; animation-duration: 4.9s; animation-delay: 3.6s; }
@keyframes vcfall { to { transform: translateY(640px); } }

.caption {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ice);
  background: rgba(255, 201, 77, 0.07);
  border: 1px solid rgba(255, 201, 77, 0.22);
  border-radius: 12px;
  padding: 10px 12px;
}
#btn-greet-play { width: 100%; }

/* ===== Экран 3: игра ===== */
#screen-game { padding-left: 0; padding-right: 0; padding-bottom: env(safe-area-inset-bottom); }
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 8px;
}
.hud-score {
  font-size: 20px;
  font-weight: 900;
  min-width: 86px;
  font-variant-numeric: tabular-nums;
}
.hud-combo {
  flex: 1;
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--gold);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.hud-combo.on { opacity: 1; transform: scale(1); }
.hud-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(244, 248, 255, 0.1);
  border: 1px solid var(--line);
  color: var(--snow);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.timebar {
  height: 6px;
  margin: 0 16px;
  border-radius: 99px;
  background: rgba(244, 248, 255, 0.12);
  overflow: hidden;
}
.timebar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pine), var(--gold));
  transform-origin: left;
  will-change: transform;
  transition: background 0.3s ease;
}
.timebar-fill.low { background: linear-gradient(90deg, var(--berry), #ff8a5c); }

.game-stage { position: relative; flex: 1; min-height: 0; margin-top: 8px; }
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
#screen-game.frenzy .game-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 70px 12px rgba(255, 201, 77, 0.35);
  animation: frenzy-glow 0.6s ease-in-out infinite;
}
@keyframes frenzy-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ===== Оверлеи и панели ===== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 22, 49, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.25s ease, visibility 0s;
}
.overlay.clear { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s ease, visibility 0s 0.25s; }
.panel {
  width: 100%;
  max-width: 320px;
  background: linear-gradient(180deg, #1b3565, #122548);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 26px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}
.panel h2 { font-size: 26px; font-weight: 900; text-wrap: balance; }
.legend { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.legend span {
  background: rgba(244, 248, 255, 0.09);
  border: 1px solid rgba(244, 248, 255, 0.15);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 700;
}
.hint { color: var(--ice); font-size: 14px; font-weight: 500; line-height: 1.45; }
.count {
  font-size: 110px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 8px 40px rgba(255, 201, 77, 0.45);
  animation: countpop 0.7s ease both;
}
@keyframes countpop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.end-score {
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.end-sub { color: var(--ice); font-size: 14px; font-weight: 500; margin-top: -8px; }
.end-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* ===== Десктоп: телефонная рамка по центру ночного неба ===== */
@media (min-width: 600px) {
  body { display: flex; align-items: center; justify-content: center; }
  #app {
    width: 400px;
    height: min(94dvh, 840px);
    border-radius: 44px;
    border: 1px solid rgba(244, 248, 255, 0.14);
    background:
      radial-gradient(120% 60% at 50% -10%, #16305e 0%, rgba(22, 48, 94, 0) 60%),
      linear-gradient(180deg, #0e1e42, var(--night-deep));
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
