@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/unbounded-cyrillic-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/unbounded-latin-500.woff2") format("woff2");
  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;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/unbounded-cyrillic-700.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/unbounded-latin-700.woff2") format("woff2");
  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;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("assets/fonts/nunito-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("assets/fonts/nunito-latin.woff2") format("woff2");
  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 {
  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Unbounded", var(--font-system);
  --font-body: "Nunito", var(--font-system);
  --bg: #0b1a14;
  --bg2: #12301f;
  --felt: #1c5a3a;
  --panel: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.14);
  --text: #f3f7f4;
  --muted: #9fb8aa;
  --accent: #ffcf4a;
  --accent-text: #2a1d00;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 50% 20%, var(--felt) 0%, var(--bg2) 45%, var(--bg) 100%) fixed;
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* Запасной режим: <html data-fonts="system"> возвращает системные шрифты */
:root[data-fonts="system"] {
  --font-head: var(--font-system);
  --font-body: var(--font-system);
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.screen.active { display: flex; animation: fade 0.5s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.panel {
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 28px 22px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.panel.wide { max-width: 480px; }

.app-icon {
  width: 92px;
  height: 92px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  font-size: 48px;
  background: linear-gradient(145deg, #232323, #000);
  border-radius: 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

h1 { font-size: 26px; margin: 0 0 8px; }
h2 { font-size: 22px; margin: 0 0 18px; }
h3 { font-size: 20px; margin: 0 0 10px; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; }
p { line-height: 1.5; margin: 0 0 16px; }
h1, h2, h3, p { text-wrap: balance; }
.changelog li span:last-child { text-wrap: pretty; }

.muted { color: var(--muted); }

.btn {
  appearance: none;
  border: 0;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.row { display: flex; gap: 10px; justify-content: center; }
.row .btn { flex: 0 1 auto; }
.row .btn:not(.ghost) { flex: 1; }
.row .btn.ghost { white-space: nowrap; }

#screen-finale .row { flex-direction: column; }
#screen-finale .row .btn { width: 100%; flex: 0 0 auto; }

#boot-panel.has-gif {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px 14px 22px;
}
.boot-gif {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  margin: 0 0 16px;
  object-fit: cover;
  border-radius: 16px;
}
.boot-gif[hidden] { display: none; }

.fly-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.4s ease;
}
.fly-layer.out { opacity: 0; }
.fly-item {
  position: absolute;
  top: 100%;
  line-height: 1;
  opacity: 0;
  will-change: transform, opacity;
  animation: fly var(--dur, 4s) linear forwards;
}
@keyframes fly {
  0% { opacity: 0; transform: translate(0, 0) rotate(0); }
  12% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), calc(-100vh - 80px)) rotate(var(--rot)); }
}

.progress {
  height: 8px;
  margin: 18px 0 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 1.5s linear;
}
.status { min-height: 1.5em; font-size: 14px; color: var(--muted); }

.changelog {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  text-align: left;
}
.changelog li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
  opacity: 0;
  transform: translateX(-10px);
  animation: slide-in 0.5s ease forwards;
}
.changelog li:last-child { border-bottom: 0; }
.changelog .ico { font-size: 22px; line-height: 1.2; }
@keyframes slide-in { to { opacity: 1; transform: none; } }
@media (max-height: 880px) {
  #screen-changelog .panel { padding: 22px 20px; }
  .changelog { margin-bottom: 16px; }
  .changelog li { padding: 8px 0; }
}
@media (max-height: 680px) {
  #screen-changelog .panel { padding: 16px 16px; }
  #screen-changelog h2 { font-size: 18px; margin-bottom: 8px; }
  .changelog { margin-bottom: 10px; }
  .changelog li { padding: 5px 0; gap: 10px; font-size: 13.5px; line-height: 1.3; }
  .changelog .ico { font-size: 18px; }
  #btn-to-wishes { padding: 12px 28px; }
}

#screen-wishes {
  padding: 0;
  align-items: stretch;
}
.panel.wish-panel {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: max(24px, calc(env(safe-area-inset-top) + 12px)) 16px max(16px, env(safe-area-inset-bottom));
  border-radius: 0;
  border-top: 0;
  border-bottom: 0;
}
@media (min-width: 520px) {
  .panel.wish-panel {
    height: calc(100dvh - 32px);
    margin: 16px auto;
    border-radius: 24px;
    border: 1px solid var(--border);
  }
}

#wish-decor {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}
.decor-item {
  position: absolute;
  line-height: 1;
  opacity: 0;
  transform: rotate(var(--rot, 0deg));
  animation:
    decor-in 0.6s ease forwards,
    decor-float 3.5s ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s), var(--delay, 0s);
}
@keyframes decor-in {
  from { opacity: 0; transform: scale(0.3) rotate(var(--rot, 0deg)); }
  to { opacity: 0.92; transform: scale(1) rotate(var(--rot, 0deg)); }
}
@keyframes decor-float {
  from { translate: 0 0; }
  to { translate: 0 -7px; }
}

.wish-mid {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.wish-photo {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.wish-photo img {
  display: none;
  max-width: 100%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.wish-photo.loaded img { display: block; }
.wish-photo .wish-emoji { margin: 0; font-size: 72px; }
.wish-photo.loaded .wish-emoji { display: none; }

.wish-card {
  flex: 0 0 auto;
  padding: 0 6px;
}
.wish-card.swap { animation: fade 0.4s ease; }
.wish-emoji { font-size: 54px; margin-bottom: 8px; }
.wish-card h3 { margin: 0 0 6px; font-size: 19px; }
.wish-card p { font-size: 16px; margin: 0; }

.dots { display: flex; justify-content: center; gap: 8px; margin: 12px 0 14px; }
.dots span {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  transition: all 0.2s;
}
.dots span.on { background: var(--accent); transform: scale(1.3); }

.ball {
  position: relative;
  display: block;
  width: min(260px, 70vw);
  height: min(260px, 70vw);
  margin: 10px auto 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 32% 28%, #5a5a5a 0%, #1b1b1b 35%, #000 75%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 -12px 24px rgba(0, 0, 0, 0.6);
}
.ball-shine {
  position: absolute;
  top: 8%;
  left: 18%;
  width: 28%;
  height: 16%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.55), transparent 70%);
  border-radius: 50%;
  transform: rotate(-30deg);
}
.ball-window {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52%;
  height: 52%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 40% 35%, #fff, #e6e6e6);
  border-radius: 50%;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.ball-eight {
  font-size: min(80px, 20vw);
  font-weight: 800;
  color: #000;
  transition: opacity 0.3s;
}
.ball-answer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14%;
  font-size: clamp(10px, 3vw, 13px);
  line-height: 1.25;
  font-weight: 700;
  color: #fff;
  text-align: center;
  background: radial-gradient(circle, #1a2a8a, #0a1148);
  opacity: 0;
  transition: opacity 0.6s;
}
.ball.answered .ball-eight { opacity: 0; }
.ball.answered .ball-answer { opacity: 1; }
.ball.shaking { animation: shake 0.8s ease; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  10% { transform: translate(-14px, 6px) rotate(-6deg); }
  25% { transform: translate(14px, -8px) rotate(6deg); }
  40% { transform: translate(-12px, -6px) rotate(-5deg); }
  55% { transform: translate(12px, 8px) rotate(5deg); }
  70% { transform: translate(-8px, 4px) rotate(-3deg); }
  85% { transform: translate(8px, -4px) rotate(3deg); }
}

.finale-text { font-size: 17px; }

[hidden] { display: none !important; }
