:root {
  --bg-deep: #1a1233;
  --bg-mid: #2b1c52;
  --accent: #8b5cf6;
  --accent-bright: #b794f6;
  --panel: rgba(20, 12, 40, 0.82);
  --text: #f4eeff;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--bg-mid), var(--bg-deep) 70%);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px;
}

#canvas-wrap {
  position: relative;
  width: min(94vw, 480px);
  aspect-ratio: 480 / 700;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55), inset 0 0 0 2px rgba(139, 92, 246, 0.35);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  background: radial-gradient(ellipse at 50% 30%, rgba(60, 30, 110, 0.55), rgba(15, 8, 30, 0.92) 75%);
  text-align: center;
  padding: 20px 20px 16px;
  overflow-y: auto;
}

.overlay.hidden { display: none; }

.game-name {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 14px rgba(183, 148, 246, 0.8);
}

.title-banner {
  width: 62%;
  max-width: 240px;
  filter: drop-shadow(0 10px 24px rgba(139, 92, 246, 0.55));
  margin-top: -6px;
}

.subtitle {
  margin: 0;
  color: var(--accent-bright);
  font-size: 15px;
  opacity: 0.9;
}

.best-score {
  margin: 0;
  font-size: 13px;
  opacity: 0.75;
}

#gameover-screen h2 {
  margin: 0;
  font-size: 30px;
  color: #ffd7f6;
}

.final-line { margin: 0; font-size: 16px; }

.legend {
  width: 100%;
  max-width: 340px;
  margin-top: 2px;
}
.legend-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-bright);
  opacity: 0.85;
}
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(183, 148, 246, 0.25);
  border-radius: 12px;
  padding: 6px 10px;
  text-align: left;
}
.legend-item img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
.legend-item .legend-text { display: flex; flex-direction: column; gap: 1px; }
.legend-item .legend-name { font-size: 12px; font-weight: 700; color: #fff; }
.legend-item .legend-desc { font-size: 11px; color: #c9b6f5; line-height: 1.25; }

.top10 {
  width: 100%;
  max-width: 260px;
  margin-top: 2px;
}
.top10-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
}
.top10-list li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.08);
}
.top10-list li.current {
  background: rgba(183, 148, 246, 0.35);
  font-weight: 700;
  color: #fff;
}
.top10-list li .rank { opacity: 0.65; margin-right: 8px; }

.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 34px;
  font-size: 17px;
  font-weight: 700;
  color: #2a1150;
  background: linear-gradient(180deg, #f5e6ff, #d9b8ff);
  box-shadow: 0 8px 0 #8a5ec2, 0 12px 20px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.primary-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #8a5ec2, 0 4px 10px rgba(0,0,0,0.4); }

.menu-btn {
  position: absolute;
  top: 8.5%;
  left: 2%;
  z-index: 5;
  border: 1px solid rgba(183, 148, 246, 0.4);
  border-radius: 999px;
  background: rgba(20, 12, 40, 0.65);
  color: #e6d9ff;
  font-size: clamp(9px, 2.3vw, 12px);
  font-weight: 600;
  padding: 0.9% 2.3%;
  cursor: pointer;
}
.menu-btn.hidden { display: none; }

.confirm-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}
.confirm-row {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.secondary-btn {
  border: 1px solid rgba(183, 148, 246, 0.5);
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 700;
  color: #e6d9ff;
  background: rgba(139, 92, 246, 0.12);
  cursor: pointer;
}
.danger-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ff8a8a, #e34d4d);
  box-shadow: 0 6px 0 #a53030, 0 10px 16px rgba(0,0,0,0.4);
  cursor: pointer;
}
.danger-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #a53030, 0 4px 8px rgba(0,0,0,0.4); }

.monetize-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -4px;
}
.ghost-btn {
  border: 1px solid rgba(183, 148, 246, 0.35);
  border-radius: 999px;
  background: transparent;
  color: #a493c9;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
}
.name-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.name-entry.hidden { display: none; }
.name-input {
  width: 110px;
  border: 1px solid rgba(183, 148, 246, 0.4);
  border-radius: 999px;
  background: rgba(20, 12, 40, 0.6);
  color: #f4eeff;
  font-size: 12px;
  padding: 6px 12px;
  text-align: center;
}
.name-input:focus { outline: none; border-color: var(--accent-bright); }
.ads-removed-badge {
  font-size: 11px;
  font-weight: 700;
  color: #8fe3a3;
}
.ads-removed-badge.hidden, .ghost-btn.hidden { display: none; }

.dev-note {
  margin: -6px 0 0;
  max-width: 300px;
  font-size: 11px;
  line-height: 1.4;
  color: #ffcf7a;
  background: rgba(255, 207, 122, 0.1);
  border: 1px solid rgba(255, 207, 122, 0.3);
  border-radius: 10px;
  padding: 8px 10px;
}
.dev-note.hidden { display: none; }

.continue-btn {
  background: linear-gradient(180deg, #a8f0c6, #4fc985);
  box-shadow: 0 8px 0 #2f8a5c, 0 12px 20px rgba(0,0,0,0.4);
}
.continue-btn:active { box-shadow: 0 2px 0 #2f8a5c, 0 4px 10px rgba(0,0,0,0.4); }
.continue-btn.hidden { display: none; }

.ad-progress-track {
  width: 220px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-top: 6px;
}
.ad-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #a8f0c6, #4fc985);
  transition: width 0.05s linear;
}

.twinkle {
  position: absolute;
  width: 6px; height: 6px;
  background: #fff;
  border-radius: 50%;
  opacity: 0.8;
  animation: twinkle 2.4s ease-in-out infinite;
  box-shadow: 0 0 8px 2px #fff;
}
.t1 { top: 18%; left: 20%; animation-delay: 0s; }
.t2 { top: 30%; left: 78%; animation-delay: 0.8s; }
.t3 { top: 70%; left: 15%; animation-delay: 1.4s; }
@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1.3); }
}

#powerup-bar {
  display: flex;
  gap: 10px;
  width: min(94vw, 480px);
  justify-content: center;
}

.powerup-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  border: 2px solid rgba(183, 148, 246, 0.5);
  background: var(--panel);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.powerup-btn img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.powerup-btn .charge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-deep);
}
.powerup-btn:active { transform: scale(0.94); }
.powerup-btn.disabled { opacity: 0.35; pointer-events: none; }
.powerup-btn.active-fx { box-shadow: 0 0 0 3px var(--accent-bright), 0 0 16px 4px rgba(183,148,246,0.7); }

@media (max-height: 720px) {
  .powerup-btn { width: 50px; height: 50px; }
}
