/* Ball Run — Synthwave Cyberpunk 3D Runner */
:root {
  --primary-accent: #ff1088;
  --primary-glow: rgba(255, 16, 136, 0.55);
  --cyan-accent: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.5);
  --bg-dark: #040612;
  --card-bg: rgba(16, 20, 40, 0.95);
  --card-border: rgba(138, 162, 220, 0.28);
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-family);
  color: #ffffff;
  touch-action: none;
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#game-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* UI Overlay Layer */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 12px max(20px, env(safe-area-inset-bottom)) 12px;
}

/* Top HUD */
#hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  pointer-events: auto;
  gap: 8px;
}

.hud-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #23283c;
  border: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
  flex-shrink: 0;
}

.hud-circle-btn:active {
  transform: scale(0.9);
  background: #ffffff;
}

#hud-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 2px 10px;
}

#hud-level-tag {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #ffffff;
  text-transform: uppercase;
  margin-bottom: 3px;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.95);
}

#hud-level-num {
  color: var(--cyan-accent);
  font-weight: 900;
}

#hud-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  overflow: hidden;
}

#hud-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #00f0ff, #ff1088);
  border-radius: 2.5px;
  transition: width 0.1s linear;
}

#hud-all-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 3px 6px;
  flex-shrink: 0;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.95);
}

.hud-all-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--cyan-accent);
  letter-spacing: 0.5px;
}

.hud-all-value {
  font-size: 13px;
  font-weight: 900;
  color: #ffffff;
}

/* Speed Up Banner (Matching Video Reference) */
.speed-banner {
  position: absolute;
  bottom: 16%;
  left: 50%;
  transform: translateX(-50%) scale(1);
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-align: center;
  white-space: nowrap;
  text-shadow: 
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0px  4px 0 #000,
     0px  6px 14px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  animation: speedBannerPop 0.65s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  z-index: 15;
}

@keyframes speedBannerPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.6) translateY(20px);
  }
  25% {
    opacity: 1;
    transform: translateX(-50%) scale(1.12) translateY(0);
  }
  40% {
    transform: translateX(-50%) scale(1.0);
  }
  80% {
    opacity: 1;
    transform: translateX(-50%) scale(1.0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(0.9) translateY(-10px);
  }
}

/* Tutorial Hint Matching Reference Video 2 Exactly */
.tutorial-wrap {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 12;
}

.tutorial-slider {
  display: flex;
  align-items: center;
  width: 260px;
  position: relative;
}

.slider-line {
  flex: 1;
  height: 5px;
  background: linear-gradient(90deg, #00f0ff, #8da6eb);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

.slider-arrow {
  font-size: 34px;
  line-height: 1;
  color: var(--cyan-accent);
  text-shadow: 0 0 12px var(--cyan-glow);
  padding: 0 6px;
}

.hand-icon {
  font-size: 36px;
  margin: 0 4px;
  animation: handSwipe 1.6s infinite ease-in-out alternate;
}

@keyframes handSwipe {
  0% { transform: translateX(-35px); }
  100% { transform: translateX(35px); }
}

.tutorial-text {
  margin-top: 14px;
  font-size: 19px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 240, 255, 0.5);
}

/* Screen Flash */
#flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 40, 120, 0.75) 0%, rgba(0, 0, 0, 0) 75%);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.15s ease-out;
}

#flash.active {
  opacity: 1;
}

/* Campaign Overlays */
.campaign-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 5, 14, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.campaign-card {
  width: 100%;
  max-width: 350px;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 26px;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 35px rgba(255, 16, 136, 0.18);
  animation: cardPop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes cardPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.campaign-eyebrow {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.eyebrow-win {
  color: var(--cyan-accent);
  text-shadow: 0 0 10px var(--cyan-glow);
}

.eyebrow-fail {
  color: #ff3366;
  text-shadow: 0 0 10px rgba(255, 51, 102, 0.5);
}

.campaign-title {
  font-size: 21px;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 8px;
}

.campaign-copy {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 20px;
  line-height: 1.4;
}

.campaign-stats {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 22px;
}

.fail-icon-wrap {
  font-size: 54px;
  margin: 8px 0 16px 0;
}

.trophy-wrap {
  font-size: 60px;
  margin-bottom: 10px;
  animation: bounceTrophy 1s infinite alternate ease-in-out;
}

@keyframes bounceTrophy {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

/* Stars Row */
.stars-row {
  display: flex;
  gap: 12px;
  margin: 14px 0 20px 0;
}

.star {
  font-size: 40px;
  color: rgba(255, 255, 255, 0.2);
  transition: color 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28), transform 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.star.lit {
  color: #ffd700;
  text-shadow: 0 0 16px rgba(255, 215, 0, 0.85);
  transform: scale(1.15);
}

/* Buttons */
.campaign-btn {
  width: 100%;
  height: 50px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-top: 10px;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.campaign-btn:active {
  transform: scale(0.96);
}

.campaign-btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.campaign-btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.campaign-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Tablet & iPad Responsive Tuning */
@media (min-width: 600px) {
  #hud-top {
    max-width: 580px;
  }
  .hud-circle-btn {
    width: 48px;
    height: 48px;
  }
  .speed-banner {
    font-size: 48px;
  }
  .campaign-card {
    max-width: 400px;
    padding: 36px 28px;
  }
  .campaign-btn {
    height: 56px;
    font-size: 18px;
  }
}
