/* CSS variables for consistent aesthetics */
:root {
  --bg-gradient: radial-gradient(circle at center, #1b263b 0%, #0d1b2a 70%, #010811 100%);
  --neon-turq: #24bfae;
  --neon-pink: #bf24b5;
  --neon-yellow: #ece213;
  --neon-red: #ff3366;
  --panel-bg: rgba(13, 27, 42, 0.85);
  --border-glow: rgba(36, 191, 174, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  height: 100%;
  height: -webkit-fill-available;
  background: #030308;
}

body {
  font-family: 'Outfit', sans-serif;
  color: #fff;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.game-wrapper {
  position: relative;
  width: 100vw;
  width: 100dvw;
  height: 177.78vw;
  height: 177.78dvw;
  max-width: 450px;
  max-height: 800px;
  background: var(--bg-gradient);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.95), inset 0 0 25px rgba(255, 255, 255, 0.01);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 16px;
}

@media (min-aspect-ratio: 9/16) {
  .game-wrapper {
    height: 100vh;
    height: 100dvh;
    width: 56.25vh;
    width: 56.25dvh;
  }
}

/* Top ad banner bar styling */
.top-header-bar {
  position: relative !important;
  width: 100% !important;
  height: 64px !important;
  background: rgba(2, 4, 10, 0.85) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 8 !important;
  box-sizing: border-box !important;
  top: auto !important;
  left: auto !important;
  margin: 0 !important;
}

.top-header-bar.hidden {
  display: none !important;
}

/* Header Controls */
.game-header-controls {
  position: absolute;
  top: 15px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 15px;
  z-index: 100;
  transition: top 0.2s ease;
}

/* Push header controls down if ad banner is active */
.top-header-bar:not(.hidden) ~ .game-header-controls {
  top: 79px;
}

.nav-btn {
  background: rgba(13, 27, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 11px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  backdrop-filter: blur(5px);
}

.nav-btn svg {
  width: 12px;
  height: 12px;
}

.nav-btn:hover {
  background: var(--neon-turq);
  color: #010811;
  border-color: var(--neon-turq);
  box-shadow: 0 0 10px rgba(36, 191, 174, 0.5);
}

/* Lang Selector dropdown */
.lang-selector-container {
  position: relative;
}

.lang-dropdown {
  position: absolute;
  top: 36px;
  right: 0;
  background: rgba(13, 27, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  z-index: 200;
  width: 110px;
  backdrop-filter: blur(10px);
}

.lang-option {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}

.lang-option:hover {
  background: var(--neon-turq);
  color: #010811;
}

/* Canvas Layout Container */
.canvas-container {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  background: #0d1b2a;
  display: block;
}

/* HUD Styling */
.game-hud-overlay {
  position: absolute;
  top: 75px;
  width: 100%;
  padding: 0 12px;
  z-index: 10;
  pointer-events: none;
}

.hud-top-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.hud-score-card, .hud-streak-card, .hud-lives-card {
  flex: 1;
  background: rgba(13, 27, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(5px);
}

.hud-label {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 2px;
}

.hud-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--neon-turq);
  text-shadow: 0 0 8px rgba(36, 191, 174, 0.4);
}

.hearts-row {
  display: flex;
  gap: 3px;
  font-size: 12px;
}

.heart-icon.lost {
  opacity: 0.2;
  filter: grayscale(100%);
}

/* Overlay Layers */
.overlay-layer {
  z-index: 10001 !important;
}

.game-title {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 12px var(--neon-turq);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.game-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  margin-bottom: 25px;
}

/* Score Summary */
.score-summary {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 25px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.score-row:last-child {
  margin-bottom: 0;
}

.highlight-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--neon-yellow);
}

.over-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--neon-red);
  text-shadow: 0 0 15px rgba(255, 51, 102, 0.4);
  margin-bottom: 20px;
}

/* Level Select Grid */
.levels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
  width: 100%;
}

.level-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
}

.level-card:hover:not(.locked) {
  background: rgba(36, 191, 174, 0.15);
  border-color: var(--neon-turq);
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(36, 191, 174, 0.3);
}

.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.level-card-number {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.level-card-stars {
  font-size: 8px;
  color: var(--neon-yellow);
  margin-top: 4px;
  letter-spacing: 1px;
}

/* Ball Shop */
.shop-coins-header {
  margin: 10px 0 15px 0;
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.85);
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 15px 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.shop-grid::-webkit-scrollbar {
  width: 4px;
}
.shop-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.ball-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.ball-card.active {
  border-color: var(--neon-turq);
  background: rgba(36, 191, 174, 0.08);
  box-shadow: 0 0 10px rgba(36, 191, 174, 0.2);
}

.ball-preview-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}

.ball-name {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.ball-price-tag {
  font-size: 10px;
  color: var(--neon-yellow);
  font-weight: 800;
}

.ball-btn {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 800;
  padding: 5px 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  width: 100%;
  text-transform: uppercase;
  transition: background 0.2s;
}

.ball-btn.buy { background: var(--neon-yellow); color: #000; }
.ball-btn.equip { background: rgba(255,255,255,0.1); color: #fff; }
.ball-btn.equipped { background: var(--neon-turq); color: #010811; }

/* Level Cleared Stars */
.stars-celebration {
  font-size: 32px;
  letter-spacing: 6px;
  color: var(--neon-yellow);
  margin: 15px 0;
  text-shadow: 0 0 12px rgba(236, 226, 19, 0.55);
}

.reward-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* Floating Trophy animation */
.trophy-container {
  font-size: 52px;
  margin: 0 auto 10px auto;
  animation: wr-float 2.5s ease-in-out infinite, wr-glow 1.5s ease-in-out infinite alternate;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
}

@keyframes wr-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.06); }
}

@keyframes wr-glow {
  0% { filter: drop-shadow(0 0 4px rgba(236, 226, 19, 0.35)); }
  100% { filter: drop-shadow(0 0 16px rgba(236, 226, 19, 0.85)); }
}

/* Pop In Animation */
.animate-pop {
  animation: overlay-pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlay-pop-in {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

