:root {
  --indigo: #201761;
  --deep: #120c3d;
  --snow: #f6f4ff;
  --muted: rgba(246, 244, 255, .72);
  --warm: #ffd36b;           /* золото — только лампочки и цифры счёта */
  --red: #e8323f;
  --red-dark: #8a1420;
  --green: #2fa35f;
  --line: rgba(255, 255, 255, .14);
  --card: rgba(30, 20, 92, .62);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  overflow: hidden;
  background: var(--indigo);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 600px) {
  body { background: radial-gradient(circle at 50% 15%, #2b2174, #0c0a24 70%); }
  #app {
    width: 420px;
    height: min(880px, calc(100% - 40px));
    border-radius: 32px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .08);
  }
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- экраны ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: screenIn .35s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.screen.dim { background: linear-gradient(180deg, rgba(18, 12, 61, .55), rgba(18, 12, 61, .3) 45%, rgba(18, 12, 61, .72)); }
.screen.dim-strong { background: linear-gradient(180deg, rgba(18, 12, 61, .35), rgba(18, 12, 61, .55) 40%, rgba(18, 12, 61, .85)); }

.wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto 0;
}

/* Цветной логотип как на сайте — на светлой табличке со снегом, иначе чёрные контуры теряются на фиолетовом */
.logo-plate {
  width: 172px;
  margin: 14px 0 8px;
  padding: 12px 14px 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf8, #f4ecdc);
  box-shadow: 0 5px 0 #cfc0a3, 0 16px 34px rgba(8, 4, 40, .5), 0 0 40px rgba(255, 220, 170, .18);
}
.logo-plate img { display: block; width: 100%; }
.logo-plate.small { width: 136px; padding: 9px 11px 8px; margin: 8px 0 18px; }

/* Снежная шапка сверху (кнопки, счёт, табличка) */
.snow { position: relative; }
.snow::before {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: -8px;
  height: 17px;
  pointer-events: none;
  background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 18" preserveAspectRatio="none"%3E%3Cpath fill="%23fff" d="M0 11C0 6 4 5 9 6 13 2 20 2 25 5 31 1 39 2 44 6 50 3 57 3 62 6 69 1 78 2 83 6 89 3 96 3 101 6 107 2 116 2 121 6 127 3 134 3 139 6 146 1 155 2 160 6 166 3 173 3 178 6 184 3 193 4 196 7 199 8 200 10 200 12 198 14 193 13 190 13 188 17 184 17 181 17 180 13 150 13 148 16 144 16 141 16 140 13 104 13 102 15 99 15 96 15 95 13 62 13 60 17 56 17 53 17 52 13 24 13 22 15 19 15 16 15 15 13 5 13 1 13 0 11Z"/%3E%3C/svg%3E') 0 0 / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 1.5px rgba(40, 20, 110, .3));
}
/* Гирлянда: провод SVG + лампочки (строится в buildGarlands) */
.garland {
  position: absolute;
  left: 8px;
  right: 8px;
  top: -12px;
  height: 24px;
  pointer-events: none;
  z-index: 2;
}
.garland svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.garland i {
  position: absolute;
  top: 12px;
  width: 9px;
  height: 13px;
  margin-left: -4.5px;
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .85) 0 1.5px, rgba(255, 255, 255, 0) 3.5px), var(--c);
  box-shadow: 0 0 9px 2px var(--c);
  animation: twinkle 2.4s ease-in-out var(--d) infinite;
}
.garland i::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -3px;
  width: 5px;
  height: 4px;
  border-radius: 1px;
  background: #2e3b33;
}
@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; box-shadow: 0 0 3px 0 var(--c); }
}
@media (prefers-reduced-motion: reduce) { .garland i, .balls i.cur { animation: none; } }

/* Попытки — ёлочные шары в цветах эмблемы */
.attempts { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; }
.attempts-text { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.balls { display: inline-flex; gap: 7px; align-items: center; padding-top: 4px; }
.balls i {
  position: relative;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .9) 0 1.6px, rgba(255, 255, 255, 0) 3.6px),
    radial-gradient(circle at 40% 35%, rgba(0, 0, 0, 0) 45%, rgba(20, 8, 50, .38) 100%),
    var(--c);
  transition: opacity .3s, filter .3s;
}
.balls i::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 6px;
  height: 4px;
  margin-left: -3px;
  border-radius: 1.5px 1.5px 0 0;
  background: linear-gradient(90deg, #c99a3a, #f6dc8c, #c99a3a);
}
.balls i.used { opacity: .35; filter: grayscale(1) brightness(.75); }
.balls i.cur { box-shadow: 0 0 12px 2px var(--c); animation: ballpulse 1.3s ease-in-out infinite; }
@keyframes ballpulse { 50% { transform: scale(1.16); } }

h1 {
  margin: 6px 0 8px;
  font-size: 36px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.5px;
  text-align: center;
  text-shadow: 0 0 28px rgba(190, 170, 255, .35);
}
h1 span { color: #ff5a66; text-shadow: 0 0 24px rgba(255, 70, 90, .45); }
h2 { margin: 10px 0 4px; font-size: 26px; font-weight: 900; text-align: center; }

.lead { margin: 0 0 14px; text-align: center; font-size: 14px; line-height: 1.4; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; line-height: 1.4; margin: 4px 0; }
.small { font-size: 12px; }

.card {
  width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.card.center { text-align: center; }
.card, .ready-top { position: relative; }
.lit { padding-top: 26px; }

/* ---------- форма ---------- */
input[type=text], input[type=email] {
  width: 100%;
  margin-bottom: 10px;
  padding: 14px 16px;
  font: inherit;
  font-size: 16px;
  color: var(--snow);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color .2s, background .2s;
}
input::placeholder { color: rgba(246, 244, 255, .5); }
input:focus { border-color: var(--warm); background: rgba(255, 255, 255, .12); }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 8px 2px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  cursor: pointer;
}
.check input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(255, 255, 255, .4);
  border-radius: 6px;
  cursor: pointer;
}
.check input:checked { background: var(--green); border-color: var(--green); }
.check input:checked::after {
  content: "";
  width: 10px;
  height: 5px;
  border: solid #fff;
  border-width: 0 0 2.5px 2.5px;
  transform: rotate(-45deg) translate(1px, -1px);
}
.check a { color: #fff; }

.error { min-height: 18px; margin: 2px 2px 0; font-size: 13px; color: #ffb4a8; }

.btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(90, 0, 10, .35);
  background: linear-gradient(180deg, #f55a63, #cf2333);
  box-shadow: 0 5px 0 var(--red-dark), 0 12px 28px rgba(230, 40, 60, .38);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-dark), 0 6px 16px rgba(230, 40, 60, .3); }
.btn.snow::before { top: -7px; left: 2px; right: 2px; }

.link {
  margin-top: 14px;
  padding: 4px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: rgba(246, 244, 255, .5);
  text-decoration: underline;
  cursor: pointer;
}

.rules {
  list-style: none;
  margin: 14px 0 4px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.rules li {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  font-size: 12px;
  color: var(--muted);
}
.rules b { color: var(--warm); }

.pill {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- перед попыткой ---------- */
#screen-ready { justify-content: space-between; cursor: pointer; }
.ready-top, .ready-hint {
  text-align: center;
  padding: 16px 20px;
  border-radius: 22px;
  background: rgba(18, 12, 61, .5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
}
.ready-top { margin-top: 9vh; max-width: 330px; padding-top: 28px; }
.ready-top h2 { font-size: 30px; text-shadow: 0 0 24px rgba(255, 211, 107, .35); }
.ready-hint { margin-bottom: 24vh; }
.tap-text { margin-top: 10px; font-size: 18px; font-weight: 800; }
.tap-ring {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  border: 3px solid rgba(255, 90, 102, .95);
  border-radius: 50%;
  animation: ring 1.4s ease-out infinite;
}
@keyframes ring {
  0% { transform: scale(.7); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- итоги ---------- */
.center-v { margin: auto 0; }
.big {
  font-size: 64px;
  line-height: 1;
  font-weight: 900;
  color: var(--warm);
  text-shadow: 0 0 30px rgba(255, 211, 107, .4);
  margin-top: 8px;
}
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 6px;
}
.stats div {
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .07);
}
.stats span { display: block; font-size: 11px; color: var(--muted); }
.stats b { font-size: 22px; }

.next-hint { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.next-hint b { color: var(--warm); }

.bonus {
  margin: 16px 0 10px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(232, 50, 63, .24), rgba(47, 163, 95, .14));
  border: 1px solid rgba(255, 120, 130, .38);
}
.bonus-title { margin-top: 4px; font-size: 26px; font-weight: 900; }
.bonus-desc { font-size: 13px; color: var(--muted); }
.promo {
  margin-top: 12px;
  padding: 10px 18px;
  border: 2px dashed rgba(255, 211, 107, .8);
  border-radius: 12px;
  background: rgba(18, 12, 61, .5);
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: .08em;
  color: var(--warm);
  cursor: pointer;
}
.promo-hint { margin-top: 6px; font-size: 11px; color: var(--muted); }

.ladder { list-style: none; margin: 12px 0 0; padding: 0; text-align: left; }
.ladder li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: rgba(246, 244, 255, .5);
}
.ladder li.reached { color: var(--snow); }
.ladder li.current { color: #fff; font-weight: 800; }
.ladder li span:first-child::before { content: "○ "; }
.ladder li.reached span:first-child::before { content: "● "; color: var(--green); }
.ladder li.current span:first-child::before { color: #ff5a66; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(max(12px, env(safe-area-inset-top)) + 16px) 14px 0;
  pointer-events: none;
}
.garland-hud { top: calc(env(safe-area-inset-top) - 6px); left: -6px; right: -6px; }
#hud.hidden { display: none; }
.hud-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-score {
  min-width: 74px;
  padding: 5px 16px 3px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f2525c, #c51f2f);
  box-shadow: 0 3px 0 var(--red-dark), 0 8px 20px rgba(200, 30, 50, .35);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 1px 0 rgba(90, 0, 10, .35);
  transition: transform .12s;
}
.hud-score.bump { transform: scale(1.14); color: #ffe9a8; }
.hud-attempt {
  padding: 2px 8px 4px;
  border-radius: 12px;
  background: rgba(18, 12, 61, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hud-attempt .balls { gap: 5px; }
.hud-attempt .balls i { width: 13px; height: 13px; }
.hud-right { display: flex; gap: 8px; }
.hud-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 13px;
  background: rgba(18, 12, 61, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--snow);
  cursor: pointer;
  pointer-events: auto;
}

#rotate {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--deep);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  z-index: 10;
}
@media (orientation: landscape) and (max-height: 500px) {
  #rotate { display: flex; }
}
