* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Press Start 2P', monospace;
  background: linear-gradient(135deg, #0a0015 0%, #0d1b2a 40%, #1b0a2e 100%);
  min-height: 100vh;
  overflow-x: hidden;
  color: #e0e0e0;
}

#root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Stars */
.stars-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--duration) ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Device Shell */
.device-shell {
  position: relative;
  z-index: 1;
  width: 340px;
  background: linear-gradient(145deg, #3a2d5c, #2a1f4a, #1e1538);
  border-radius: 40px 40px 60px 60px;
  padding: 20px 16px 28px;
  box-shadow:
    0 0 0 3px #5a4a8a,
    0 0 0 6px #2a1f4a,
    0 8px 32px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

/* LCD Screen */
.lcd-screen {
  position: relative;
  background: #8bac0f;
  border-radius: 12px;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.4),
    0 0 0 2px #1a1230,
    0 0 0 4px #4a3a7a;
}

.lcd-screen.sleeping {
  background: #3a4a08;
}

/* Scanlines */
.scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.06) 2px,
    rgba(0,0,0,0.06) 4px
  );
  pointer-events: none;
  z-index: 10;
}

.lcd-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Pet Sprite */
.pet-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pet-sprite {
  image-rendering: pixelated;
  width: 96px;
  height: 96px;
  animation: idle-bob 2s ease-in-out infinite;
  transition: filter 0.3s;
}

.pet-sprite.sleeping {
  filter: brightness(0.5);
  animation: sleep-bob 3s ease-in-out infinite;
}

.pet-sprite.sick {
  filter: hue-rotate(80deg) saturate(0.5);
}

.pet-sprite.eating {
  animation: chomp 0.4s ease-in-out 3;
}

.pet-sprite.playing {
  animation: bounce-spin 0.6s ease-in-out 3;
}

.pet-sprite.cleaning {
  animation: wiggle 0.3s ease-in-out 4;
}

.pet-sprite.sad {
  animation: droop 2s ease-in-out infinite;
}

.pet-sprite.departing {
  animation: fly-away 3s ease-in forwards;
}

@keyframes idle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes sleep-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-2px) rotate(2deg); }
}

@keyframes chomp {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.85) scaleX(1.1); }
}

@keyframes bounce-spin {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

@keyframes droop {
  0%, 100% { transform: translateY(4px) rotate(-3deg); }
  50% { transform: translateY(8px) rotate(3deg); }
}

@keyframes fly-away {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  60% { transform: translateY(-10px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-200px) scale(0.2); opacity: 0; }
}

/* Egg wobble */
.pet-sprite.egg {
  animation: egg-wobble 1.5s ease-in-out infinite;
}

@keyframes egg-wobble {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-5deg) translateY(-2px); }
  75% { transform: rotate(5deg) translateY(-2px); }
}

/* Floating mood icons */
.mood-icon {
  position: absolute;
  font-size: 14px;
  animation: float-up 2s ease-out forwards;
  pointer-events: none;
  font-family: sans-serif;
  z-index: 5;
}

@keyframes float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(0.6); }
}

/* Sparkle */
.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  animation: sparkle-pop 0.8s ease-out forwards;
  pointer-events: none;
}

@keyframes sparkle-pop {
  0% { opacity: 1; transform: scale(0); }
  50% { opacity: 1; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(0); }
}

/* Zzz particles */
.zzz {
  position: absolute;
  font-size: 16px;
  color: #306030;
  font-family: 'Press Start 2P', monospace;
  animation: zzz-float 2.5s ease-out infinite;
  pointer-events: none;
}

.zzz:nth-child(2) { animation-delay: 0.8s; font-size: 12px; left: 60%; }
.zzz:nth-child(3) { animation-delay: 1.6s; font-size: 10px; left: 70%; }

@keyframes zzz-float {
  0% { opacity: 0; transform: translateY(0) translateX(0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-50px) translateX(15px); }
}

/* Stat bars */
.stat-bar-bg {
  background: #306030;
  height: 6px;
  border-radius: 1px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  transition: width 0.5s ease;
  border-radius: 1px;
}

/* Action buttons */
.action-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: linear-gradient(145deg, #4a3a7a, #3a2a6a);
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow:
    0 3px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.15);
  font-family: sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.action-btn:active {
  transform: scale(0.92);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.action-btn:hover {
  background: linear-gradient(145deg, #5a4a8a, #4a3a7a);
  border-color: rgba(255,255,255,0.25);
}

.action-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Food menu */
.food-menu {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #2a1f4a;
  border: 2px solid #5a4a8a;
  border-radius: 8px;
  padding: 6px;
  display: flex;
  gap: 4px;
  z-index: 20;
  margin-bottom: 8px;
}

.food-item {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #3a2d5c;
  border: 1px solid #5a4a8a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: sans-serif;
}

.food-item:hover {
  background: #4a3d6c;
  transform: scale(1.1);
}

/* Stats overlay */
.stats-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 40, 10, 0.92);
  z-index: 15;
  display: flex;
  flex-direction: column;
  padding: 10px;
  font-size: 7px;
  color: #306030;
  overflow-y: auto;
}

/* Event popup */
.event-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a2a0a;
  border: 2px solid #4a6a20;
  border-radius: 8px;
  padding: 10px;
  font-size: 7px;
  color: #8bac0f;
  text-align: center;
  z-index: 20;
  max-width: 85%;
  line-height: 1.6;
}

/* Name modal */
.name-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.name-modal {
  background: linear-gradient(145deg, #3a2d5c, #2a1f4a);
  border: 3px solid #6a5a9a;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  max-width: 300px;
  width: 90%;
}

.name-input {
  background: #1a1230;
  border: 2px solid #5a4a8a;
  border-radius: 8px;
  padding: 8px 12px;
  color: #8bac0f;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  width: 100%;
  text-align: center;
  outline: none;
}

.name-input:focus {
  border-color: #8bac0f;
}

.name-submit-btn {
  margin-top: 12px;
  padding: 8px 20px;
  background: linear-gradient(145deg, #4a8a0f, #3a6a08);
  border: 2px solid #6aaa2f;
  border-radius: 8px;
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.name-submit-btn:hover {
  background: linear-gradient(145deg, #5a9a1f, #4a7a18);
}

/* Mini game */
.mini-game {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 40, 10, 0.95);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
}

.rps-choice {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #306030;
  border: 2px solid #4a8a20;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: sans-serif;
}

.rps-choice:hover {
  background: #408040;
  transform: scale(1.1);
}

/* Device top area */
.device-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px 8px;
  font-size: 8px;
  color: #8a7aba;
}

.pet-name-display {
  color: #baa0ea;
  font-size: 9px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.age-display {
  color: #7a6aaa;
  font-size: 7px;
}

.sound-toggle {
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.2s;
  font-family: sans-serif;
}

.sound-toggle:hover {
  opacity: 1;
}

/* Responsive */
@media (max-width: 400px) {
  .device-shell {
    width: 95vw;
    max-width: 340px;
    border-radius: 30px 30px 45px 45px;
    padding: 14px 12px 20px;
  }
  
  .action-btn {
    width: 44px;
    height: 44px;
    font-size: 17px;
  }
}

@media (min-width: 768px) {
  .device-shell {
    width: 360px;
  }
}

/* Footer */
.game-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 16px;
  font-size: 6px;
  color: #4a3a6a;
  line-height: 2;
}

.game-footer a {
  color: #6a5a9a;
  text-decoration: none;
}

.game-footer a:hover {
  color: #8a7aba;
  text-decoration: underline;
}

/* Poop icon */
.poop-pile {
  position: absolute;
  bottom: 15%;
  right: 15%;
  font-size: 20px;
  font-family: sans-serif;
  animation: poop-appear 0.5s ease-out;
}

@keyframes poop-appear {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* UFO departure */
.ufo-scene {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.ufo-sprite {
  font-size: 32px;
  font-family: sans-serif;
  animation: ufo-hover 1s ease-in-out infinite;
}

@keyframes ufo-hover {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.beam {
  width: 40px;
  height: 60px;
  background: linear-gradient(180deg, rgba(139,172,15,0.8), transparent);
  clip-path: polygon(30% 0%, 70% 0%, 100% 100%, 0% 100%);
  animation: beam-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes beam-pulse {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}