/* Reset and base styles */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Nunito', Arial, sans-serif;
  background: #ffefba;
  overflow: hidden;
  touch-action: manipulation;
}
.fullscreen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw; height: 100vh;
  z-index: 1;
}
.gradient-bg {
  background: linear-gradient(135deg, #ffe082 0%, #ffb74d 100%);
  animation: gradientMove 7s ease-in-out infinite alternate;
}
@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* Welcome Screen */
.welcome-content {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -55%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90vw;
}
.game-title {
  font-size: 2.1rem;
  color: #ff9100;
  margin-bottom: 1.2em;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px #fff8;
  font-weight: 800;
}
.chicken-anim-container {
  position: relative;
  width: 120px; height: 110px;
  margin-bottom: 2em;
}
.chicken-anim {
  width: 90px; position: absolute; left: 20px; top: 5px;
  animation: chickenFloat 1.8s cubic-bezier(.4,0,.2,1) infinite alternate;
  z-index: 2;
}
@keyframes chickenFloat {
  0% { transform: translateY(0) rotate(-7deg);}
  100% { transform: translateY(-20px) rotate(7deg);}
}
.jewel-anim {
  width: 32px;
  position: absolute; left: 62px; top: 50px;
  animation: jewelSparkle 1s steps(2) infinite alternate;
  filter: drop-shadow(0 0 8px #ffe082);
}
@keyframes jewelSparkle {
  0% { filter: drop-shadow(0 0 8px #ffe082); }
  100% { filter: drop-shadow(0 0 24px #ffd740) brightness(1.4); }
}
.players-online {
  font-size: 1.1rem;
  color: #ff6f00;
  margin-bottom: 2.2em;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 1px 5px #fff4;
}
.cta-btn {
  padding: 1.2em 2.2em;
  background: linear-gradient(90deg, #ff9100 60%, #ffd740 100%);
  color: #fff;
  font-size: 1.5em;
  border: none;
  border-radius: 2em;
  box-shadow: 0 4px 24px #ff910033;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 2px;
  outline: none;
  animation: bounceGlow 1.5s infinite alternate;
  transition: filter .2s;
}
@keyframes bounceGlow {
  0% { transform: scale(1); filter: brightness(1);}
  60% { transform: scale(1.09); filter: brightness(1.12);}
  100% { transform: scale(1.14); filter: brightness(1.19) drop-shadow(0 0 10px #ffc400);}
}
.cta-btn:active { filter: brightness(1.3); }

/* Game Screen and canvas */
#game-bg {
  position: absolute; width: 100vw; height: 100vh; z-index: 1; overflow: hidden;
}
.bg-img {
  width: 100vw; height: 100vh; object-fit: cover; pointer-events: none;
  animation: bgMove 24s linear infinite alternate;
}
@keyframes bgMove {
  0% { transform: translateY(0);}
  100% { transform: translateY(-30px);}
}
#game-canvas {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  z-index: 2;
  border-radius: 16px;
  touch-action: none;
  box-shadow: 0 4px 40px #ffb74d33;
  max-width: 98vw;
  max-height: 90vh;
}
#hearts-container {
  position: absolute;
  top: 18px; left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  gap: 6px;
}
.heart-img {
  width: 34px; height: 34px;
  filter: drop-shadow(0 0 5px #fff8);
  animation: heartBounce 1.3s infinite alternate;
}
@keyframes heartBounce {
  0% { transform: scale(1) rotate(-6deg);}
  100% { transform: scale(1.10) rotate(8deg);}
}

/* SECTION 3: Mobile Controls */
.mobile-controls {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 36px);
  left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-end;
  width: 100vw;
  z-index: 20;
  padding: 0 16px 10px 16px;
  margin-bottom: 140px;
  pointer-events: none;
}
.ctrl-btn {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, #ff9100 60%, #ffd740 100%);
  border: none;
  border-radius: 50%;
  font-size: 2.3em;
  color: #fff;
  box-shadow: 0 2px 20px #ffb74d33;
  margin: 0 8px;
  transition: filter .2s;
  font-weight: 900;
  pointer-events: all;
  outline: none;
  animation: controlsBounce 5s infinite;
}
@keyframes controlsBounce {
  0% { transform: scale(1);}
  93% { transform: scale(1);}
  97% { transform: scale(1.1);}
  100% { transform: scale(1);}
}
.ctrl-btn:active {
  filter: brightness(1.3);
}
.center-btn {
  margin-bottom: 10px;
}

/* SECTION 4/5: Modals */
.modal-overlay {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.28);
  z-index: 99;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fffbe6;
  border-radius: 20px;
  box-shadow: 0 8px 40px #ffb74d99;
  padding: 2em 1.6em 1.4em 1.6em;
  width: 85vw; max-width: 340px;
  text-align: center;
  position: relative;
  z-index: 101;
  animation: modalPop 0.4s cubic-bezier(.7,-0.03,.44,1.12);
}
@keyframes modalPop {
  0% { transform: scale(0.7) translateY(50px);}
  100% { transform: scale(1) translateY(0);}
}
.modal .modal-title {
  font-size: 1.3em; font-weight: bold; color: #ff9100;
  margin-bottom: .7em;
}
.modal .modal-msg {
  font-size: 1.1em; color: #f57c00;
  margin-bottom: 1em;
}
.modal .code {
  font-family: 'Courier New', monospace;
  font-size: 1.6em;
  color: #43a047;
  background: #f5ffd6;
  padding: 0.6em 1.2em;
  border-radius: 10px;
  letter-spacing: 2px;
  margin-bottom: 1em;
  box-shadow: 0 2px 8px #cddc3988;
  display: inline-block;
  animation: codeGlow 1s infinite alternate;
  user-select: all;
  cursor: pointer;
}
@keyframes codeGlow {
  0% { box-shadow: 0 0 8px #fff;}
  100% { box-shadow: 0 0 20px #ffd740;}
}
.modal .modal-btn {
  margin: 1.1em 0 0.6em 0;
  background: linear-gradient(90deg, #ff9100 70%, #ffd740 100%);
  color: #fff;
  font-size: 1.15em;
  font-weight: 800;
  border: none;
  border-radius: 2em;
  padding: 0.9em 2.5em;
  box-shadow: 0 2px 18px #ffd74077;
  cursor: pointer;
  transition: filter .2s;
}
.modal .modal-btn:active { filter: brightness(1.25);}
.modal .timer {
  font-size: 1.1em; margin-top: 0.7em; color: #ee4d00; font-weight: 700;
}
.modal .sparkle {
  display:inline-block;
  animation: sparkleScale 1.1s infinite alternate;
  font-size: 2.2em;
  margin-bottom: -0.6em;
}
@keyframes sparkleScale {
  0% { transform: scale(1);}
  100% { transform: scale(1.2);}
}

/* Fake notification */
.notification {
  position: fixed;
  top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 111;
  background: #fffbe6;
  color: #f57c00;
  font-weight: 700;
  padding: 0.7em 2em;
  border-radius: 1em;
  box-shadow: 0 2px 16px #ffd74077;
  font-size: 1.12em;
  animation: notifIn 0.3s;
}
@keyframes notifIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px);}
  to { opacity: 1; transform: translateX(-50%) translateY(0);}
}

/* Misc */
@media (max-width: 480px) {
  .welcome-content { width: 98vw;}
  .modal { width: 97vw; max-width: 97vw;}
  #game-canvas { max-width: 99vw; }
}