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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #2c1810 0%, #1a0e08 100%);
  color: #fff;
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
}

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

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

.hidden { display: none !important; }

/* --- Title screen --- */
h1 {
  font-size: 3rem;
  text-shadow: 2px 2px 8px rgba(255, 100, 0, 0.4);
  color: #ffe0b2;
}
h2 { font-size: 2.5rem; color: #ffe0b2; text-shadow: 2px 2px 0 #000; }

.title-dragon {
  font-size: 8rem;
  animation: dragonBob 2s ease-in-out infinite;
}
@keyframes dragonBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.subtitle {
  font-size: 1.2rem;
  opacity: 0.7;
  font-style: italic;
}

.btn-big {
  font-size: 2rem;
  padding: 15px 40px;
  background: #e65100;
  color: #fff;
  border: 4px solid #ffab40;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s, transform 0.1s;
}
.btn-big:hover { background: #ff6d00; }
.btn-big:active { transform: scale(0.96); }

.back-link {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: rgba(255,255,255,0.8);
}

/* --- HUD --- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-around;
  padding: 15px;
  background: rgba(0, 0, 0, 0.5);
  font-size: 1.5rem;
  z-index: 10;
}
.hud-item { font-weight: bold; }

#hud-timer-wrap.timer-removed {
  text-decoration: line-through;
  opacity: 0.4;
}

/* --- Scene (play area) --- */
#scene {
  position: absolute;
  top: 70px; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 50% 120%, #3e2723 0%, transparent 60%),
    linear-gradient(180deg, #1a0e08 0%, #2c1810 50%, #3e2723 100%);
  overflow: hidden;
}

/* Crystals */
.crystal {
  position: absolute;
  width: 0;
  height: 0;
}
.crystal-1 {
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-bottom: 50px solid #ce93d8;
  top: 20%;
  left: 8%;
  opacity: 0.7;
  filter: drop-shadow(0 0 8px #ce93d8);
  animation: crystalGlow 3s ease-in-out infinite;
}
.crystal-2 {
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 40px solid #80deea;
  top: 15%;
  right: 12%;
  opacity: 0.6;
  filter: drop-shadow(0 0 8px #80deea);
  animation: crystalGlow 4s ease-in-out 1s infinite;
}
.crystal-3 {
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 35px solid #a5d6a7;
  top: 30%;
  left: 22%;
  opacity: 0.5;
  filter: drop-shadow(0 0 6px #a5d6a7);
  animation: crystalGlow 3.5s ease-in-out 0.5s infinite;
}
@keyframes crystalGlow {
  0%, 100% { filter: drop-shadow(0 0 6px currentColor) brightness(1); }
  50% { filter: drop-shadow(0 0 14px currentColor) brightness(1.3); }
}

/* Rocks */
.rock {
  position: absolute;
  bottom: 5%;
  width: 100px;
  height: 60px;
  background: #4e342e;
  border-radius: 50% 50% 45% 45%;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.3);
}
.rock-left { left: 5%; }
.rock-right { right: 5%; }

/* Treasure pile */
.treasure {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 40px;
  background: radial-gradient(ellipse, #ffd54f 0%, #ff8f00 80%);
  border-radius: 50%;
  opacity: 0.6;
  box-shadow: 0 0 20px rgba(255, 213, 79, 0.3);
}

/* --- Dragon --- */
.dragon {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7rem;
  cursor: pointer;
  transition: transform 0.15s;
  z-index: 5;
}
.dragon:active { transform: translateX(-50%) scale(0.93); }

/* Dragon mood data-attribute glow */
.dragon[data-mood="wary"] { filter: none; }
.dragon[data-mood="warming"] { filter: drop-shadow(0 0 8px rgba(255,183,77,0.4)); }
.dragon[data-mood="love"] { filter: drop-shadow(0 0 16px rgba(255,82,82,0.5)); }

/* Dragon pet animations */
.dragon.eyes-close-one { animation: eyeCloseOne 0.5s ease-out; }
.dragon.tail-flick-small { animation: tailFlick 0.4s ease-out; }
.dragon.eyes-close-both { animation: eyeCloseBoth 0.6s ease-out; }
.dragon.tail-wag { animation: tailWag 0.5s ease-in-out; }
.dragon.purr-smoke { animation: purrSmoke 0.5s ease-out; }
.dragon.hearts-float { animation: heartsPulse 0.5s ease-out; }
.dragon.happy-face { animation: happyBounce 0.5s ease-out; }
.dragon.sparkle { animation: sparkleSpin 0.6s ease-out; }

@keyframes eyeCloseOne {
  0%, 100% { transform: translateX(-50%) scaleY(1); }
  40% { transform: translateX(-50%) scaleY(0.85); }
}
@keyframes tailFlick {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  30% { transform: translateX(-50%) rotate(5deg); }
  60% { transform: translateX(-50%) rotate(-3deg); }
}
@keyframes eyeCloseBoth {
  0%, 100% { transform: translateX(-50%) scaleY(1); }
  30%, 60% { transform: translateX(-50%) scaleY(0.82); }
}
@keyframes tailWag {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  25% { transform: translateX(-50%) rotate(8deg); }
  75% { transform: translateX(-50%) rotate(-8deg); }
}
@keyframes purrSmoke {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}
@keyframes heartsPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.1); }
}
@keyframes happyBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-15px); }
}
@keyframes sparkleSpin {
  0% { transform: translateX(-50%) rotate(0deg) scale(1); }
  50% { transform: translateX(-50%) rotate(10deg) scale(1.08); }
  100% { transform: translateX(-50%) rotate(0deg) scale(1); }
}

/* Floating emoji (hearts, smoke, sparkles) */
.float-emoji {
  position: absolute;
  font-size: 2rem;
  pointer-events: none;
  animation: floatUp 0.9s ease-out forwards;
  z-index: 15;
}
@keyframes floatUp {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-70px); opacity: 0; }
}

/* --- Panda --- */
.panda {
  position: absolute;
  font-size: 4rem;
  cursor: pointer;
  z-index: 6;
  transition: all 0.3s ease;
}

/* Peek positions */
.panda.peek-left {
  bottom: 8%;
  left: 2%;
  animation: peekFromLeft 0.4s ease-out;
}
.panda.peek-right {
  bottom: 8%;
  right: 2%;
  animation: peekFromRight 0.4s ease-out;
}
.panda.peek-top {
  top: 12%;
  right: 20%;
  animation: peekFromTop 0.4s ease-out;
}

@keyframes peekFromLeft {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(0); }
}
@keyframes peekFromRight {
  0% { transform: translateX(100%); }
  100% { transform: translateX(0); }
}
@keyframes peekFromTop {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(0); }
}

/* Panda joined state — sits next to dragon */
.panda.panda-joined {
  bottom: 16%;
  left: 50%;
  margin-left: 80px;
  font-size: 4.5rem;
  animation: pandaHop 0.6s ease-out;
}
@keyframes pandaHop {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.15) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Panda pet animations */
.panda.panda-cover-face { animation: pandaCover 0.5s ease-out; }
.panda.panda-roll { animation: pandaRoll 0.6s ease-out; }
.panda.panda-wave { animation: pandaWave 0.5s ease-out; }

@keyframes pandaCover {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.88); }
}
@keyframes pandaRoll {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(20deg); }
}
@keyframes pandaWave {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

/* Timer sparkle dissolve effect */
#timer-sparkle {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  pointer-events: none;
  z-index: 20;
}
.sparkle-particle {
  position: absolute;
  font-size: 1.2rem;
  animation: sparkleFade 0.8s ease-out forwards;
}
@keyframes sparkleFade {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(20px) scale(0.5); }
}

/* --- Win screen --- */
#win-scene {
  font-size: 6rem;
  display: flex;
  gap: 10px;
  animation: winSnuggle 1.5s ease-in-out infinite;
}
@keyframes winSnuggle {
  0%, 100% { transform: rotate(-1deg); }
  50% { transform: rotate(1deg); }
}
.win-panda { font-size: 5rem; }

/* --- Game Over screen --- */
#screen-game-over {
  background: #000;
}

.chomp-text {
  font-size: 5rem;
  font-weight: bold;
  color: #ff3d00;
  text-shadow: 3px 3px 0 #300;
  /* Slam in, hold, then fade out */
  animation: chompSlam 0.4s ease-out both, chompFade 0.6s ease-in 1.4s forwards;
}
@keyframes chompSlam {
  0% { transform: scale(3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes chompFade {
  0% { opacity: 1; }
  100% { opacity: 0; display: none; }
}

.chomp-sub {
  font-size: 1.4rem;
  color: #ccc;
  opacity: 0;
  animation: fadeIn 0.8s ease-out 2.2s forwards;
}

#screen-game-over .btn-big {
  opacity: 0;
  animation: fadeIn 0.6s ease-out 3.4s forwards;
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 500px) {
  h1 { font-size: 2.2rem; }
  .title-dragon { font-size: 5rem; }
  .dragon { font-size: 5rem; }
  .hud { font-size: 1.2rem; padding: 10px; }
  .panda.panda-joined { margin-left: 55px; font-size: 3.5rem; }
  .chomp-text { font-size: 3.5rem; }
}
