:root {
  --uiScale: min(calc(100vw / 1080), calc(100svh / 1920));
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  background: #050810;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  position: fixed;
  inset: 0;
}

* {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#wrap {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #050810;
}

#stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  background: radial-gradient(1200px 1200px at 50% 40%, #0b1230, #050810 70%);
  touch-action: none;
}

#stageInner {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1080px;
  height: 1920px;
  transform: translate(-50%, -50%) scale(var(--uiScale, 1));
  transform-origin: center;
  overflow: hidden;
}

#cv {
  position: absolute;
  inset: 0;
  width: 1080px;
  height: 1920px;
  display: block;
  z-index: 1;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: rgba(255,255,255,0.95);
  text-shadow:
    -2px  0   0 rgba(0,0,0,0.95),
     2px  0   0 rgba(0,0,0,0.95),
     0   -2px 0 rgba(0,0,0,0.95),
     0    2px 0 rgba(0,0,0,0.95),
     0    2px 10px rgba(0,0,0,0.45);
}

#debug {
  position: absolute;
  top: 22px;
  left: 22px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.2px;
  opacity: 0.92;
  pointer-events: none;
  display: none;
}

.stick {
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 999px;
  background: rgba(30, 20, 10, 0.5);
  border: 4px solid rgba(212, 160, 23, 0.4);
  box-shadow: 0 18px 50px rgba(0,0,0,0.45), inset 0 0 30px rgba(212, 160, 23, 0.1);
  pointer-events: auto;
  touch-action: none;
  display: grid;
  place-items: center;
}

.stick .knob {
  width: 150px;
  height: 150px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #f0c040, #d4a017 60%, #8b6914);
  border: 4px solid rgba(240, 192, 64, 0.6);
  box-shadow: 0 14px 34px rgba(0,0,0,0.35), inset 0 -4px 10px rgba(0,0,0,0.3), inset 0 4px 10px rgba(255,255,255,0.2);
  transform: translate(0px, 0px);
}

#stickMove {
  left: 80px;
  bottom: 110px;
}

#boostWrap {
  position: absolute;
  right: 80px;
  bottom: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  pointer-events: auto;
}

#boostMeterWrap {
  width: 120px;
  height: 20px;
  background: rgba(30, 20, 10, 0.6);
  border: 3px solid rgba(212, 160, 23, 0.5);
  border-radius: 10px;
  overflow: hidden;
}

#boostMeterFill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d4a017, #f0c040, #d4a017);
  border-radius: 7px;
  transition: width 0.1s linear;
}

#boostBtn {
  width: 200px;
  height: 200px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #f0c040, #d4a017 50%, #8b6914 90%);
  border: 6px solid rgba(240, 192, 64, 0.7);
  box-shadow: 0 18px 50px rgba(0,0,0,0.5), inset 0 -8px 20px rgba(0,0,0,0.4), inset 0 8px 20px rgba(255,255,255,0.2);
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 900;
  color: #4a2800;
  text-shadow: 0 2px 4px rgba(255,255,255,0.3);
  cursor: pointer;
  touch-action: none;
}

#boostBtn:active, #boostBtn.active {
  background: radial-gradient(circle at 30% 30%, #ffdd66, #f0c040 50%, #d4a017 90%);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4), inset 0 -4px 10px rgba(0,0,0,0.3), inset 0 4px 10px rgba(255,255,255,0.3), 0 0 40px rgba(240, 192, 64, 0.5);
}

@media (max-aspect-ratio: 9/16) {
  #stickMove { left: 60px; bottom: 95px; }
  #boostWrap { right: 60px; bottom: 95px; }
}

@media (min-aspect-ratio: 1/1) {
  #stage { width: min(460px, 100vw); height: 100vh; box-shadow: 0 0 60px rgba(0,0,0,0.65); }
}

#xpBarWrap {
  position: absolute;
  top: 40px;
  left: 50px;
  right: 50px;
  height: 36px;
  background: rgba(0,0,0,0.5);
  border-radius: 18px;
  border: 3px solid rgba(212, 160, 23, 0.5);
  overflow: hidden;
}

#xpBarFill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #d4a017, #f0c040, #d4a017);
  border-radius: 14px;
  transition: width 0.2s ease-out;
}

#timerDisplay {
  position: absolute;
  top: 95px;
  right: 50px;
  font-size: 48px;
  font-weight: 900;
  color: #f0c040;
}

#heartsWrap {
  position: absolute;
  top: 95px;
  left: 50px;
  display: flex;
  gap: 12px;
}

.heart {
  width: 48px;
  height: 48px;
  font-size: 42px;
  line-height: 48px;
  text-align: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.heart.empty {
  opacity: 0.3;
}

#levelUpOverlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: auto;
}

#levelUpOverlay.active {
  display: flex;
}

#confettiCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

#levelUpContent {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

#levelUpTitle {
  font-size: 96px;
  font-weight: 900;
  color: #f0c040;
  text-shadow: 0 0 30px rgba(240, 192, 64, 0.8), 0 4px 8px rgba(0,0,0,0.8);
  letter-spacing: 4px;
}

#upgradeOptions {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.upgradeCard {
  width: 700px;
  padding: 32px 40px;
  background: rgba(30, 40, 80, 0.9);
  border: 4px solid rgba(100, 120, 200, 0.5);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
}

.upgradeCard:hover {
  background: rgba(40, 55, 110, 0.95);
  border-color: rgba(140, 160, 255, 0.7);
}

.upgradeCard.selected {
  background: rgba(60, 80, 140, 0.95);
  border-color: #f0c040;
  box-shadow: 0 0 30px rgba(240, 192, 64, 0.4);
}

.upgradeInfo {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upgradeName {
  font-size: 42px;
  font-weight: 700;
  color: #fff;
}

.upgradeLevel {
  font-size: 28px;
  color: rgba(255,255,255,0.6);
}

.upgradeBonus {
  font-size: 38px;
  font-weight: 700;
  color: #7eff7e;
}

#yayBtn {
  width: 400px;
  padding: 32px 0;
  font-size: 52px;
  font-weight: 900;
  color: rgba(255,255,255,0.3);
  background: rgba(60, 60, 80, 0.6);
  border: 4px solid rgba(100, 100, 120, 0.4);
  border-radius: 20px;
  cursor: not-allowed;
  transition: all 0.2s ease;
  margin-top: 20px;
}

#yayBtn.enabled {
  color: #fff;
  background: linear-gradient(180deg, #d4a017, #b8860b);
  border-color: #f0c040;
  cursor: pointer;
  box-shadow: 0 0 40px rgba(240, 192, 64, 0.5);
  animation: btnPulse 1s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

#gameOverOverlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 0, 0, 0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  z-index: 150;
  pointer-events: auto;
}

#gameOverOverlay.active {
  display: flex;
}

#gameOverTitle {
  font-size: 88px;
  font-weight: 900;
  color: #ff4444;
  text-shadow: 0 0 30px rgba(255, 68, 68, 0.8), 0 4px 8px rgba(0,0,0,0.8);
  letter-spacing: 4px;
}

#survivedText {
  font-size: 48px;
  font-weight: 700;
  color: #fff;
}

#retryBtn {
  width: 400px;
  padding: 32px 0;
  font-size: 52px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, #d4a017, #b8860b);
  border: 4px solid #f0c040;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 0 40px rgba(240, 192, 64, 0.5);
  margin-top: 20px;
}

.fadeOut {
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
}

.fadeIn {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#mainMenu, #mainMenu * {
  pointer-events: auto !important;
}

#menuBg {
  pointer-events: none !important;
}

#menuSlot {
  position: relative;
  width: 420px;
  min-height: 140px;
  display: grid;
  place-items: center;
}

#menuSlot > #startBtn,
#menuSlot > #mainButtons {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

#startBtn {
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#startBtn.fadeOut {
  opacity: 0;
  transform: translateX(-50%) translateY(10px) scale(0.98);
  pointer-events: none;
}

#mainButtons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  opacity: 0;
  transform: translateX(-50%) translateY(10px) scale(0.98);
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 2;
  pointer-events: none;
}

#mainButtons.menuShown {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}

#mainButtons.menuHidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px) scale(0.98);
  pointer-events: none;
}

.btnBig {
  width: 420px;
  height: 140px;
  font-size: 72px;
  font-weight: 900;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 4px 8px rgba(0,0,0,0.5), 0 0 20px rgba(255,200,100,0.3);
  background: linear-gradient(180deg, #cc2a2a 0%, #a01818 50%, #7a1010 100%);
  border: 6px solid #d4a017;
  border-radius: 24px;
  box-shadow:
    0 8px 0 #5a0a0a,
    0 12px 20px rgba(0,0,0,0.6),
    inset 0 2px 4px rgba(255,255,255,0.25),
    inset 0 -4px 8px rgba(0,0,0,0.3),
    0 0 40px rgba(212,160,23,0.3);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.35s ease;
  position: relative;
  z-index: 2;
}

.btnBig:active {
  transform: translateY(4px);
  box-shadow:
    0 4px 0 #5a0a0a,
    0 6px 12px rgba(0,0,0,0.5),
    inset 0 2px 4px rgba(255,255,255,0.2),
    inset 0 -2px 6px rgba(0,0,0,0.3),
    0 0 30px rgba(212,160,23,0.25);
}

.btnSmall {
  width: 420px;
  height: 110px;
  font-size: 52px;
  font-weight: 900;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  letter-spacing: 4px;
  border-radius: 22px;
  border: 5px solid rgba(212,160,23,0.85);
  background: rgba(20,30,60,0.55);
  color: #fff;
  box-shadow: 0 10px 18px rgba(0,0,0,0.55), inset 0 2px 3px rgba(255,255,255,0.12);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#menuFooter {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  z-index: 260;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 920px;
  max-width: calc(100% - 120px);
  pointer-events: auto;
}

#menuFooter .menuLegal {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  color: rgba(255,255,255,0.86);
  text-align: center;
  text-shadow: 0 3px 12px rgba(0,0,0,0.7);
}

#menuFooter .menuCreditsBtn {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  padding: 16px 28px;
  border-radius: 20px;
  border: 5px solid rgba(212,160,23,0.9);
  background: rgba(20,30,60,0.55);
  box-shadow: 0 12px 22px rgba(0,0,0,0.55), inset 0 2px 3px rgba(255,255,255,0.12);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#menuFooter .menuCreditsBtn:active {
  transform: translateY(3px);
  opacity: 0.92;
}

#creditsOverlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.82);
  z-index: 400;
  pointer-events: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

#creditsOverlay.active {
  display: flex;
}

#creditsBox {
  width: 920px;
  max-width: calc(100% - 120px);
  height: min(1500px, calc(100% - 220px));
  background: rgba(10,16,32,0.94);
  border: 6px solid rgba(212,160,23,0.75);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.75);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#creditsHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 30px;
  border-bottom: 2px solid rgba(255,255,255,0.10);
  flex: 0 0 auto;
}

#creditsTitle {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.95);
  text-shadow: 0 3px 12px rgba(0,0,0,0.65);
}

#creditsClose {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 5px solid rgba(212,160,23,0.85);
  background: rgba(20,30,60,0.55);
  color: rgba(255,255,255,0.95);
  font-size: 28px;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#creditsBody {
  padding: 40px 44px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 34px;
  font-weight: 750;
  line-height: 1.35;
  color: rgba(255,255,255,0.94);
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  text-align: left;
}

#creditsBody a {
  color: rgba(240,192,64,0.98);
  text-decoration: none;
  font-weight: 900;
  word-break: break-word;
}

#creditsBody a:active {
  opacity: 0.85;
}

#creditsBody .creditsIntro {
  font-size: 32px;
  font-weight: 800;
  opacity: 0.92;
  margin-bottom: 26px;
}

#creditsBody .creditsLine {
  margin-top: 22px;
}

#creditsBody .creditsLine b {
  display: block;
  font-size: 28px;
  font-weight: 950;
  letter-spacing: 0.4px;
  color: rgba(240,192,64,0.98);
  margin-bottom: 6px;
}

#creditsBody .spacer {
  height: 30px;
}

#creditsBody .creditsSection b {
  display: block;
  font-size: 32px;
  font-weight: 950;
  margin-bottom: 8px;
}

#creditsBody .muted {
  font-size: 22px;
  opacity: 0.78;
  font-weight: 750;
  line-height: 1.3;
}
#creditsBody .creditsDisclaimer {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  align-items: center;
}

#creditsBody .creditsDisclaimer div {
  max-width: 760px;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 750;
  opacity: 0.78;
}
