:root {
  --ink: #0a0a17;
  --panel: #13122b;
  --surface: #1a1933;
  --accent: #ff4f6a;
  --accent2: #ffd644;
  --accent3: #4de8ff;
  --purple: #b554ec;
  --orange: #ff8c4a;
  --text: #f0ede6;
  --muted: #a09cb8;
  --glow-pink: rgba(255, 79, 106, 0.5);
  --glow-gold: rgba(255, 214, 68, 0.55);
  --glow-cyan: rgba(77, 232, 255, 0.5);
  --glass-bg: rgba(20, 18, 40, 0.65);
  --glass-border: rgba(255, 255, 255, 0.12);
  --card-bg: linear-gradient(160deg, rgba(30, 27, 55, 0.95), rgba(20, 18, 38, 0.98));
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #06060f;
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: radial-gradient(ellipse at 50% 30%, #1a1838 0%, #0a0a17 60%);
  overflow: hidden;
  box-shadow: 0 0 80px rgba(120, 80, 200, 0.15), 0 0 0 2px rgba(255, 255, 255, 0.04);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ───────── Preloader ───────── */
#preloader {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 38%, #1c1a3a 0%, #08081a 65%);
  transition: opacity 0.5s ease;
}
#preloader.hidden {
  opacity: 0;
  pointer-events: none;
}
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 38px;
  animation: floaty 2.4s ease-in-out infinite;
}
.logo-bird {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: linear-gradient(145deg, #ffd644, #ff8c4a);
  border: 4px solid #ff4f6a;
  box-shadow: 0 0 30px rgba(255, 140, 74, 0.6), 0 0 60px rgba(255, 79, 106, 0.3);
  position: relative;
  animation: birdPulse 1.6s ease-in-out infinite;
}
.logo-bird::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 16px;
  width: 12px;
  height: 12px;
  background: #f0ede6;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}
@keyframes birdPulse {
  0%,
  100% {
    box-shadow: 0 0 30px rgba(255, 140, 74, 0.6), 0 0 60px rgba(255, 79, 106, 0.3);
  }
  50% {
    box-shadow: 0 0 45px rgba(255, 140, 74, 0.9), 0 0 80px rgba(255, 79, 106, 0.5);
  }
}
.logo-text {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #f0ede6 0%, #c4bfd8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
.logo-text span {
  background: linear-gradient(180deg, #ffd644, #ff8c4a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-12px) rotate(2deg);
  }
}
.bar-track {
  width: 72%;
  max-width: 290px;
  height: 16px;
  border-radius: 20px;
  background: #1a1830;
  overflow: hidden;
  border: 2px solid #2d2a48;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff4f6a, #ffd644, #b554ec, #4de8ff);
  background-size: 300% 100%;
  animation: shimmerBar 1.5s linear infinite;
  border-radius: 20px;
  transition: width 0.2s ease-out;
  box-shadow: 0 0 12px rgba(255, 214, 68, 0.5);
}
@keyframes shimmerBar {
  0% {
    background-position: 0% 0;
  }
  100% {
    background-position: 300% 0;
  }
}
#loadLabel {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.6px;
  font-weight: 600;
}

/* ───────── Overlays ───────── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 16, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}
.hidden {
  display: none !important;
}
.card {
  width: 88%;
  max-width: 370px;
  background: var(--card-bg);
  border: 2px solid var(--glass-border);
  border-radius: 22px;
  padding: 26px 24px 28px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(120, 80, 200, 0.08);
  animation: popIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  border-radius: 50%;
}
@keyframes popIn {
  0% {
    transform: scale(0.82);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.title-big {
  font-size: 28px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 8px;
  background: linear-gradient(180deg, #ffd644, #ff8c4a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}
.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.btn {
  display: block;
  width: 100%;
  padding: 15px 10px;
  margin: 10px 0 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #1a1a1a;
  background: linear-gradient(180deg, #ffe06b, #ff9f43);
  box-shadow: 0 7px 0 #c26e1f, 0 10px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(255, 159, 67, 0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.2s ease;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 12px;
  right: 12px;
  height: 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent);
  border-radius: 50%;
  pointer-events: none;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #c26e1f, 0 6px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 159, 67, 0.2);
}
.btn.secondary {
  background: linear-gradient(180deg, #5de9ff, #28a0d1);
  box-shadow: 0 7px 0 #166685, 0 10px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(40, 160, 209, 0.25);
}
.btn.secondary:active {
  box-shadow: 0 2px 0 #166685, 0 6px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(40, 160, 209, 0.15);
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border: 2px solid #3d3a58;
  padding: 11px;
  font-size: 14px;
  backdrop-filter: blur(4px);
}
.btn.ghost::after {
  display: none;
}
.btn.ghost:active {
  transform: translateY(2px);
  background: rgba(255, 255, 255, 0.03);
}

/* How-to list */
.howto-list {
  text-align: left;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}
.howto-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.4;
}
.howto-ico {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.ico-tap {
  background: rgba(255, 214, 68, 0.18);
  color: #ffd644;
  border: 2px solid #ffd644;
  box-shadow: 0 0 16px rgba(255, 214, 68, 0.25);
}
.ico-num {
  background: rgba(181, 84, 236, 0.18);
  color: #b554ec;
  border: 2px solid #b554ec;
  box-shadow: 0 0 16px rgba(181, 84, 236, 0.25);
}
.ico-star {
  background: rgba(77, 232, 255, 0.18);
  color: #4de8ff;
  border: 2px solid #4de8ff;
  box-shadow: 0 0 16px rgba(77, 232, 255, 0.25);
}
.ico-bolt {
  background: rgba(255, 79, 106, 0.18);
  color: #ff4f6a;
  border: 2px solid #ff4f6a;
  box-shadow: 0 0 16px rgba(255, 79, 106, 0.25);
}

#scoreRow {
  display: flex;
  justify-content: space-between;
  margin: 18px 0 6px;
  padding: 14px 18px;
  background: rgba(16, 14, 30, 0.7);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
}
.scoreItem .num {
  font-size: 24px;
  font-weight: 900;
  color: #ffd644;
  text-shadow: 0 0 14px rgba(255, 214, 68, 0.5);
}
.scoreItem .lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ───────── HUD ───────── */
#hud {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}
.score-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: linear-gradient(180deg, rgba(55, 60, 140, 0.85), rgba(30, 28, 70, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 0 22px rgba(90, 130, 255, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.score-label {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
}
#scoreDisplay {
  min-width: 80px;
  text-align: center;
  color: #ffe97d;
  font-size: 36px;
  font-weight: 900;
  text-shadow: 0 2px 0 #8a5d00, 0 0 16px rgba(255, 220, 0, 0.7);
  transition: transform 0.18s ease;
}
#scoreDisplay.pop {
  animation: scorePop 0.28s ease;
}
@keyframes scorePop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

#livesDisplay {
  position: absolute;
  top: 16px;
  left: 18px;
  display: flex;
  gap: 5px;
  z-index: 101;
}
.heart {
  font-size: 22px;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.5));
  transition: transform 0.25s ease, opacity 0.25s ease;
  cursor: default;
}
.heart.lost {
  opacity: 0.25;
  transform: scale(0.75);
  filter: grayscale(0.6) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}
@keyframes heartPop {
  0% {
    transform: scale(1.7);
  }
  100% {
    transform: scale(1);
  }
}
.heart.pop {
  animation: heartPop 0.35s ease;
}

.powerBadge {
  position: absolute;
  top: 44px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(77, 232, 255, 0.13);
  border: 2px solid rgba(77, 232, 255, 0.5);
  padding: 6px 12px;
  border-radius: 22px;
  font-size: 12px;
  font-weight: 800;
  color: #4de8ff;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 102;
  letter-spacing: 0.5px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 18px rgba(77, 232, 255, 0.25);
  animation: badgeGlow 1.2s ease-in-out infinite;
}
@keyframes badgeGlow {
  0%,
  100% {
    box-shadow: 0 0 18px rgba(77, 232, 255, 0.25);
  }
  50% {
    box-shadow: 0 0 30px rgba(77, 232, 255, 0.5);
  }
}

#muteBtn {
  position: absolute;
  top: 12px;
  right: 14px;
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 103;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#muteBtn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4), 0 0 14px rgba(255, 255, 255, 0.08);
}
#muteBtn:active {
  transform: scale(0.92);
}