:root {
  --sky-top: #7cc9f0;
  --sky-bottom: #cdeeff;
  --grass: #7bb955;
  --grass-dark: #5a9a3a;
  --poop-1: #8a5a2b;
  --poop-2: #a9713a;
  --poop-3: #6e4420;
  --wood: #b5793a;
  --wood-dark: #8a5a26;
  --cream: #fff3df;
  --ink: #3a2a1a;
  --angry-red: #e2432b;
  --mad-orange: #f2a13a;
  --annoyed-yellow: #f2d43a;
  --calm-blue: #4d9de0;
  --accent: #e2432b;
  --shadow: rgba(0,0,0,0.25);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Baloo 2', sans-serif;
  background: #2a1e14;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.screen.active { display: flex; }

/* ===================== MAIN MENU ===================== */
#screen-menu {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 65%, var(--grass) 65%, var(--grass-dark) 100%);
  overflow: hidden;
}

.fly-cloud {
  position: absolute;
  background: #fff;
  border-radius: 50px;
  opacity: 0.9;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.05));
}
.fly-cloud::before, .fly-cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.cloud1 { width: 120px; height: 40px; top: 12%; left: -140px; animation: drift 22s linear infinite; }
.cloud1::before { width: 60px; height: 60px; top: -30px; left: 15px; }
.cloud1::after { width: 40px; height: 40px; top: -18px; left: 65px; }
.cloud2 { width: 90px; height: 32px; top: 24%; left: -140px; animation: drift 30s linear infinite 4s; }
.cloud2::before { width: 44px; height: 44px; top: -22px; left: 10px; }
.cloud2::after { width: 30px; height: 30px; top: -14px; left: 50px; }
.cloud3 { width: 70px; height: 26px; top: 8%; left: -140px; animation: drift 26s linear infinite 12s; }
.cloud3::before { width: 34px; height: 34px; top: -17px; left: 8px; }
.cloud3::after { width: 24px; height: 24px; top: -10px; left: 40px; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(140vw); }
}

.menu-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.game-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(3rem, 12vw, 5.5rem);
  line-height: 0.95;
  margin: 0;
  letter-spacing: 2px;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 6px 6px 0 rgba(0,0,0,0.15);
}
.title-angry { display: block; color: var(--angry-red); }
.title-turds { display: block; color: var(--poop-2); }
.turd-dot { font-size: 0.6em; -webkit-text-stroke: 0; margin-left: 6px; display: inline-block; animation: wiggle 1.8s ease-in-out infinite; }

.game-subtitle {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  opacity: 0.75;
  margin: 0 0 10px;
  letter-spacing: 1px;
}

.menu-poop {
  font-size: 4.5rem;
  margin: 6px 0 18px;
  animation: bob 2.2s ease-in-out infinite;
  filter: drop-shadow(0 10px 8px rgba(0,0,0,0.25));
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-16px) rotate(6deg); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

.btn-primary, .btn-secondary {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 1px;
  padding: 14px 42px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 6px 0 var(--shadow-dark, rgba(0,0,0,0.3)), 0 8px 14px rgba(0,0,0,0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn-primary {
  background: linear-gradient(180deg, #f2603a, var(--angry-red));
}
.btn-secondary {
  background: linear-gradient(180deg, #6d8fae, #4d6e8f);
  font-size: 1.05rem;
  padding: 12px 28px;
}
.btn-primary:active, .btn-secondary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.3), 0 3px 6px rgba(0,0,0,0.2);
}

.menu-footer {
  margin-top: 26px;
  font-size: 0.8rem;
  opacity: 0.55;
  font-weight: 600;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.85);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15), 0 4px 8px rgba(0,0,0,0.15);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }

#mute-btn { position: absolute; top: 18px; right: 18px; z-index: 3; }

/* ===================== LEVEL SELECT ===================== */
#screen-levels {
  background: linear-gradient(180deg, #ffe9b8, #ffd27a);
}
.btn-back {
  position: absolute;
  top: 18px;
  left: 18px;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  background: rgba(255,255,255,0.85);
  border: none;
  padding: 10px 18px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15);
}
.btn-back:active { transform: translateY(2px); box-shadow: none; }

.section-title {
  font-family: 'Bangers', cursive;
  font-size: 2.2rem;
  letter-spacing: 1px;
  color: var(--ink);
  margin: 0 0 24px;
  text-align: center;
}

.level-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 900px;
}

.level-card {
  width: 210px;
  background: var(--cream);
  border-radius: 20px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  border: 4px solid var(--wood);
  box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 8px 14px rgba(0,0,0,0.15);
  transition: transform 0.1s ease;
  position: relative;
}
.level-card:hover { transform: translateY(-4px); }
.level-card:active { transform: translateY(2px); }
.level-card.locked { opacity: 0.55; cursor: not-allowed; }
.level-card.locked:hover { transform: none; }

.level-emoji { font-size: 2.6rem; margin-bottom: 6px; }
.level-name { font-weight: 800; font-size: 1.15rem; margin: 4px 0; }
.level-desc { font-size: 0.85rem; opacity: 0.75; font-weight: 600; margin: 0 0 8px; }
.level-best {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--angry-red);
  background: #fff2e0;
  border-radius: 20px;
  padding: 4px 10px;
  display: inline-block;
}
.level-stars { font-size: 1rem; letter-spacing: 2px; color: #d9a441; }

/* ===================== GAMEPLAY ===================== */
#screen-game {
  background: #1c140c;
  justify-content: flex-start;
  padding: 0;
  gap: 0;
}

.hud {
  width: 100%;
  max-width: none;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(0,0,0,0.45);
  border-radius: 0;
  padding: 8px 20px;
  color: #fff;
  flex-wrap: wrap;
  flex: 0 0 auto;
  box-sizing: border-box;
}
.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.hud-label { font-size: 0.65rem; text-transform: uppercase; opacity: 0.7; letter-spacing: 1px; font-weight: 700; }
.hud-value { font-family: 'Bangers', cursive; font-size: 1.4rem; letter-spacing: 1px; }
.hud-buttons { margin-left: auto; display: flex; gap: 8px; }
.hud-buttons .icon-btn { width: 36px; height: 36px; font-size: 1rem; }

.canvas-wrap {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  overflow: hidden;
  touch-action: none;
  background: #0d0906;
}
#game-canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 960 / 540;
  display: block;
  cursor: grab;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}
#game-canvas:active { cursor: grabbing; }

.game-hint {
  color: #fff;
  opacity: 0.65;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
  padding: 6px 0;
  text-align: center;
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  background: rgba(0,0,0,0.45);
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 6, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay.hidden { display: none; }

.overlay-card {
  background: var(--cream);
  border-radius: 22px;
  padding: 30px 38px;
  text-align: center;
  border: 5px solid var(--wood);
  box-shadow: 0 10px 0 rgba(0,0,0,0.25);
  max-width: 90%;
}
#overlay-title {
  font-family: 'Bangers', cursive;
  font-size: 2rem;
  color: var(--angry-red);
  margin: 0 0 8px;
  letter-spacing: 1px;
}
.overlay-line { font-weight: 700; font-size: 1.1rem; margin: 4px 0; }
#overlay-score { color: var(--angry-red); font-family: 'Bangers', cursive; font-size: 1.4rem; }
.overlay-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.overlay-buttons button { font-size: 1rem; padding: 10px 22px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 640px) {
  .game-title { font-size: 3rem; }
  .menu-poop { font-size: 3.4rem; }
  .btn-primary { font-size: 1.1rem; padding: 12px 34px; }
  .level-card { width: 42%; padding: 12px; }
  .hud-value { font-size: 1.1rem; }
  .hud-label { font-size: 0.55rem; }
}
