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

:root {
  --bg-dark: #0f0f23;
  --bg-mid: #1a1a3e;
  --bg-light: #2a2a5e;
  --accent-yellow: #ffd700;
  --accent-green: #4ade80;
  --accent-pink: #ff6b9d;
  --accent-blue: #3b82f6;
  --text-light: #e2e8f0;
  --text-dim: #94a3b8;
  --border-color: #3f3f6f;
}

body {
  font-family: 'Press Start 2P', monospace;
  background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-mid) 100%);
  color: var(--text-light);
  min-height: 100vh;
  overflow-x: hidden;
}

.pixel-render {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-light);
  border-bottom: 4px solid var(--border-color);
}

.title {
  font-size: 14px;
  color: var(--accent-yellow);
  text-shadow: 2px 2px 0 #b8860b, 0 0 20px rgba(255, 215, 0, 0.5);
}

.header-stats {
  display: flex;
  gap: 16px;
  font-size: 10px;
}

.coins {
  color: var(--accent-yellow);
}

.level {
  color: var(--accent-green);
}

/* Daily Bonus */
.daily-bonus-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border: none;
  color: var(--bg-dark);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 120px;
}

/* Main View */
.main-view {
  display: flex;
  flex-direction: column;
}

.pet-room {
  position: relative;
  height: 280px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  overflow: hidden;
}

.window {
  position: absolute;
  top: 20px;
  right: 30px;
  width: 80px;
  height: 100px;
  background: linear-gradient(180deg, #1e3a5f 0%, #2d5a87 100%);
  border: 6px solid #4a3728;
  border-radius: 4px;
}

.moon {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  background: #fef3c7;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(254, 243, 199, 0.6);
}

.stars {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 40px;
  height: 40px;
  background-image: radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 8px 8px;
}

.lamp {
  position: absolute;
  top: 40px;
  left: 30px;
  width: 20px;
  height: 50px;
  background: #78716c;
  border-radius: 2px;
}

.lamp::before {
  content: '';
  position: absolute;
  top: -15px;
  left: -10px;
  width: 40px;
  height: 25px;
  background: #fbbf24;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.5);
}

.pet-display {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.floating-hearts {
  position: absolute;
  top: -30px;
  animation: floatUp 2s infinite;
  font-size: 16px;
}

@keyframes floatUp {
  0%, 100% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-30px); opacity: 0; }
}

.walking-indicator {
  position: absolute;
  bottom: -30px;
  font-size: 8px;
  color: var(--accent-yellow);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.no-pet {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
}

/* Pet Info Bar */
.pet-info-bar {
  padding: 12px 16px;
  background: var(--bg-light);
  border-bottom: 4px solid var(--border-color);
}

.pet-name-level {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pet-name {
  font-size: 10px;
}

.pet-level {
  font-size: 10px;
  color: var(--accent-green);
}

.xp-bar {
  height: 8px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: width 0.3s;
}

.evolve-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
  border: 3px solid #6d28d9;
  border-radius: 4px;
  color: white;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
}

.evolve-btn.pulse {
  animation: glow 1s infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(139, 92, 246, 0.5); }
  50% { box-shadow: 0 0 25px rgba(139, 92, 246, 0.8); }
}

/* Stats Panel */
.stats-panel {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-icon {
  font-size: 16px;
  width: 24px;
}

.stat-bar {
  flex: 1;
  height: 12px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  transition: width 0.5s;
}

.stat-fill.hunger {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.stat-fill.happiness {
  background: linear-gradient(90deg, #ec4899, #f472b6);
}

.stat-fill.energy {
  background: linear-gradient(90deg, #eab308, #facc15);
}

/* Action Bar */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: var(--bg-light);
  border-top: 4px solid var(--border-color);
  z-index: 100;
}

.action-btn {
  flex: 1;
  min-width: 60px;
  padding: 8px 4px;
  background: var(--bg-mid);
  border: 3px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-light);
  font-family: inherit;
  font-size: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  transition: all 0.1s;
}

.action-btn:active {
  transform: scale(0.95);
  background: var(--bg-dark);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-icon {
  font-size: 18px;
}

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-pink);
  color: white;
  font-size: 8px;
  padding: 2px 4px;
  border-radius: 4px;
}

/* Food Menu */
.food-menu, .egg-view, .collection-view, .games-view {
  padding: 16px;
}

.food-menu h3, .egg-view h3, .collection-view h3, .games-view h3 {
  font-size: 14px;
  color: var(--accent-yellow);
  margin-bottom: 16px;
  text-align: center;
}

.food-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.food-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  background: var(--bg-light);
  border: 3px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.1s;
  font-family: inherit;
  color: var(--text-light);
}

.food-item:active {
  transform: scale(0.95);
}

.food-item:disabled {
  opacity: 0.5;
}

.food-emoji {
  font-size: 32px;
}

.food-name {
  font-size: 8px;
  color: var(--text-light);
}

.food-stats {
  font-size: 8px;
  color: var(--accent-green);
}

.food-cost {
  font-size: 8px;
  color: var(--accent-yellow);
}

.back-btn {
  display: block;
  margin: 20px auto 0;
  padding: 12px 24px;
  background: var(--bg-mid);
  border: 3px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-light);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
}

/* Egg View */
.eggs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.egg-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--bg-light);
  border: 3px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.egg-item:active {
  transform: scale(0.9);
}

.egg-shell {
  position: relative;
  font-size: 40px;
  animation: wobble 0.5s ease-in-out;
}

.egg-item:active .egg-shell {
  animation: crack 0.2s;
}

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

@keyframes crack {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.crack-lines {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  border: 2px dashed rgba(255,255,255,0.5);
  transform: translate(-50%, -50%);
}

.hatch-progress {
  width: 100%;
  height: 6px;
  background: var(--bg-dark);
  border-radius: 3px;
  overflow: hidden;
}

.hatch-fill {
  height: 100%;
  background: var(--accent-green);
  transition: width 0.2s;
}

.egg-rarity {
  font-size: 6px;
}

.buy-egg-btn {
  padding: 16px;
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
  border: 3px solid #6d28d9;
  border-radius: 8px;
  color: white;
  font-family: inherit;
  font-size: 8px;
  cursor: pointer;
}

.buy-egg-btn:disabled {
  opacity: 0.5;
}

.hint {
  text-align: center;
  font-size: 8px;
  color: var(--text-dim);
  margin-top: 16px;
}

/* Collection View */
.collection-count {
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.pets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pet-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--bg-light);
  border: 3px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.1s;
}

.pet-card.active {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.pet-card:active {
  transform: scale(0.95);
}

.pet-card-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.pet-card-name {
  font-size: 6px;
}

.pet-card-level {
  font-size: 8px;
  color: var(--accent-green);
}

/* Games View */
.games-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-light);
  border: 3px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-light);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s;
}

.game-btn:active {
  transform: scale(0.98);
}

.game-btn:disabled {
  opacity: 0.5;
}

.game-icon {
  font-size: 32px;
}

.game-desc {
  font-size: 8px;
  color: var(--text-dim);
  display: block;
  margin-top: 4px;
}

/* Mini Games */
.mini-game-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-dark);
  border: 4px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  z-index: 200;
  box-shadow: 0 0 50px rgba(0,0,0,0.8);
  max-width: 95vw;
}

.mini-game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--accent-yellow);
}

.close-btn {
  background: #ef4444;
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.mini-game-canvas {
  display: block;
  border: 3px solid var(--border-color);
  border-radius: 4px;
  image-rendering: pixelated;
  max-width: 100%;
  height: auto;
}

.mini-game-hint {
  text-align: center;
  font-size: 8px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Memory Game */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 280px;
  max-width: 100%;
}

.memory-card {
  aspect-ratio: 1;
  perspective: 1000px;
  cursor: pointer;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s;
}

.memory-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--border-color);
  border-radius: 4px;
  font-size: 10px;
}

.card-front {
  background: var(--bg-light);
  color: var(--accent-yellow);
}

.card-back {
  background: var(--card-color, var(--bg-mid));
  transform: rotateY(180deg);
  font-size: 24px;
}

.moves-counter {
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 12px;
}

/* Race Game */
.race-game {
  width: 320px;
  max-width: 100%;
}

.race-track {
  background: var(--bg-mid);
  border: 3px solid var(--border-color);
  border-radius: 4px;
  padding: 8px;
}

.race-lane {
  display: flex;
  align-items: center;
  height: 40px;
  position: relative;
  border-bottom: 2px dashed var(--border-color);
}

.race-lane:last-child {
  border-bottom: none;
}

.lane-number {
  width: 20px;
  font-size: 10px;
  color: var(--text-dim);
}

.racer {
  position: absolute;
  left: 20px;
  transition: left 0.1s linear;
}

.racer.winner {
  animation: celebrate 0.3s infinite;
}

@keyframes celebrate {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.finish-line {
  position: absolute;
  right: 0;
  width: 10px;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    #fff 0px,
    #fff 5px,
    #000 5px,
    #000 10px
  );
}

.bet-panel {
  margin-top: 12px;
  text-align: center;
}

.bet-panel p {
  font-size: 10px;
  margin-bottom: 8px;
}

.bet-options {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.bet-btn {
  padding: 8px 12px;
  background: var(--bg-light);
  border: 2px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-light);
  font-family: inherit;
  font-size: 8px;
  cursor: pointer;
}

.bet-btn.selected {
  border-color: var(--accent-yellow);
  background: var(--bg-mid);
}

.start-race-btn {
  padding: 12px 24px;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border: 3px solid #16a34a;
  border-radius: 4px;
  color: var(--bg-dark);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
}

.start-race-btn:disabled {
  opacity: 0.5;
}

.race-result {
  text-align: center;
  margin-top: 12px;
  font-size: 12px;
}

.race-result .win {
  color: var(--accent-green);
}

.race-result .lose {
  color: #ef4444;
}

/* Evolution Overlay */
.evolution-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.evolution-animation {
  text-align: center;
  animation: evolveGlow 2s infinite;
}

@keyframes evolveGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5) hue-rotate(30deg); }
}

.evolution-animation h2 {
  font-size: 16px;
  color: var(--accent-yellow);
  margin-top: 16px;
  animation: pulse 0.5s infinite;
}

.sparkles {
  position: absolute;
  width: 200px;
  height: 200px;
  background-image: radial-gradient(circle, var(--accent-yellow) 2px, transparent 2px);
  background-size: 20px 20px;
  animation: sparkle 1s infinite;
}

@keyframes sparkle {
  0% { transform: rotate(0deg) scale(0.8); opacity: 0.5; }
  50% { transform: rotate(180deg) scale(1.2); opacity: 1; }
  100% { transform: rotate(360deg) scale(0.8); opacity: 0.5; }
}

/* Notification */
.notification {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-light);
  border: 3px solid var(--accent-yellow);
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 10px;
  color: var(--text-light);
  z-index: 250;
  animation: slideIn 0.3s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  max-width: 90vw;
  text-align: center;
}

@keyframes slideIn {
  from { 
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

/* Footer */
.footer {
  position: fixed;
  bottom: 100px;
  left: 0;
  right: 0;
  text-align: center;
  padding: 8px;
  font-size: 8px;
}

.footer a {
  color: var(--accent-pink);
  text-decoration: none;
}

/* Mobile adjustments */
@media (max-width: 400px) {
  .action-bar {
    gap: 2px;
    padding: 4px;
  }
  
  .action-btn {
    min-width: 45px;
    padding: 6px 2px;
    font-size: 6px;
  }
  
  .action-icon {
    font-size: 14px;
  }
  
  .title {
    font-size: 10px;
  }
  
  .header-stats {
    font-size: 8px;
    gap: 8px;
  }
  
  .mini-game-container {
    width: 95%;
    max-width: 340px;
    padding: 8px;
  }
  
  .mini-game-canvas {
    width: 100%;
    height: auto;
  }
  
  .memory-grid {
    width: 100%;
    max-width: 260px;
    gap: 4px;
  }
  
  .eggs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .food-grid {
    gap: 8px;
  }
  
  .food-item {
    padding: 8px;
  }
  
  .food-emoji {
    font-size: 24px;
  }
}