@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Nunito:wght@400;700;800&display=swap');

:root {
  --gold: #FFD700;
  --gold-dark: #B8860B;
  --jungle-dark: #0d1f0f;
  --jungle-mid: #1a3a1c;
  --accent: #ff6b35;
  --white: #fff;
  --shadow: 0 8px 32px rgba(0,0,0,0.7);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--jungle-dark);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(34,85,34,0.3) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(20,60,20,0.4) 0%, transparent 50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Nunito', sans-serif;
  overflow-x: hidden;
  padding: 8px;
  user-select: none;
}

/* ---- TITLE ---- */
#title-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  animation: titleDrop 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes titleDrop {
  from { transform: translateY(-40px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

#game-title {
  font-family: 'Bangers', cursive;
  font-size: 2.8rem;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow:
    3px 3px 0 var(--gold-dark),
    0 0 20px rgba(255,215,0,0.4);
}

.title-emoji { font-size: 2.4rem; animation: swing 2s ease-in-out infinite; }
@keyframes swing {
  0%,100% { transform: rotate(-10deg); }
  50%      { transform: rotate(10deg); }
}

/* ---- CANVAS WRAPPER ---- */
#canvas-wrapper {
  position: relative;
  border-radius: 14px;
  box-shadow: var(--shadow), 0 0 0 3px var(--gold), 0 0 40px rgba(255,215,0,0.15);
  overflow: hidden;
  animation: fadeIn 0.5s 0.2s both;
}
@keyframes fadeIn { from { opacity:0; transform: scale(0.96); } to { opacity:1; transform: scale(1); } }

canvas {
  display: block;
  touch-action: none;
}
#canvas-wrapper:fullscreen {
  display: flex; align-items: center; justify-content: center;
  background: #000; border-radius: 0; box-shadow: none;
}

/* ---- STATS BAR ---- */
#stats-bar {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  animation: fadeIn 0.5s 0.4s both;
}

.stat-pill {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,215,0,0.25);
  border-radius: 30px;
  padding: 6px 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #ccc;
  letter-spacing: 0.5px;
  transition: border-color 0.3s;
}
.stat-pill span.label { color: var(--gold); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; }
.stat-pill span.value { color: #fff; font-size: 1rem; min-width: 30px; text-align: right; }
.stat-pill:hover { border-color: rgba(255,215,0,0.6); }

/* ---- CONTROLS HINT ---- */
#controls-hint {
  margin-top: 10px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  animation: fadeIn 0.5s 0.6s both;
}

kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.72rem;
  color: var(--gold);
}

/* ---- SCORE POPUP ANIMATION (DOM overlay) ---- */
.score-popup {
  position: absolute;
  pointer-events: none;
  font-family: 'Bangers', cursive;
  font-size: 1.6rem;
  color: var(--gold);
  text-shadow: 2px 2px 0 #503000, 0 0 10px rgba(255,215,0,0.6);
  animation: popFloat 0.8s ease-out forwards;
  white-space: nowrap;
  z-index: 10;
}
@keyframes popFloat {
  0%   { transform: translateY(0) scale(1.2);   opacity: 1; }
  100% { transform: translateY(-55px) scale(0.8); opacity: 0; }
}

/* ---- MILESTONE TOAST ---- */
#milestone-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: linear-gradient(135deg, #1a4a1a, #2a6a2a);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 8px 22px;
  font-family: 'Bangers', cursive;
  font-size: 1.3rem;
  color: var(--gold);
  letter-spacing: 2px;
  white-space: nowrap;
  z-index: 20;
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
  text-shadow: 0 0 10px rgba(255,215,0,0.5);
}
#milestone-toast.show { transform: translateX(-50%) translateY(0); }

/* ---- LEVEL BADGE ---- */
#level-badge {
  position: absolute;
  bottom: 10px;
  right: 12px;
  background: var(--gold);
  color: #1a1a00;
  font-family: 'Bangers', cursive;
  font-size: 0.95rem;
  letter-spacing: 1px;
  padding: 3px 12px;
  border-radius: 20px;
  z-index: 15;
  box-shadow: 0 2px 8px rgba(255,215,0,0.4);
  transition: transform 0.2s;
}
#level-badge.bump { animation: bump 0.3s ease; }
@keyframes bump {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.35); }
}

@media (max-width: 600px) {
  #game-title { font-size: 1.9rem; letter-spacing: 2px; }
  .title-emoji { font-size: 1.6rem; }
  #stats-bar { gap: 8px; flex-wrap: wrap; justify-content: center; }
  #controls-hint { display: none; }
}
.control-btn { cursor: pointer; font: inherit; min-width: 44px; min-height: 44px; justify-content: center; }
.control-btn:focus-visible { outline: 3px solid white; outline-offset: 2px; }
#touch-hint { display: none; margin-top: 10px; text-align: center; color: #ddd; font-size: .8rem; }
@media (pointer: coarse), (max-width: 600px) { #touch-hint { display: block; } }
@media (prefers-reduced-motion: reduce) {
  #title-bar, .title-emoji, #canvas-wrapper, #stats-bar, #controls-hint { animation: none; }
  #milestone-toast { transition: none; }
}
