/* ==========================================================================
   KKTamaGO Expanded Style System
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
  --font-lcd: 'Orbitron', monospace;
  --font-main: 'Outfit', sans-serif;

  /* HSL Colors */
  --bg-dark: hsl(260, 40%, 6%);
  --bg-card: hsla(260, 30%, 12%, 0.6);
  --border-glass: hsla(260, 30%, 30%, 0.3);
  
  --color-cyan: hsl(170, 90%, 50%);
  --color-cyan-glow: hsla(170, 90%, 50%, 0.4);
  --color-purple: hsl(280, 80%, 60%);
  --color-pink: hsl(335, 90%, 60%);
  --color-gold: hsl(45, 95%, 55%);
  --color-orange: hsl(15, 90%, 55%);
  --color-green: hsl(110, 80%, 50%);
  
  --device-shell-primary: linear-gradient(135deg, hsl(270, 80%, 42%) 0%, hsl(315, 80%, 46%) 100%);
  --device-shell-border: hsl(280, 70%, 30%);
  
  --lcd-bg-on: hsl(160, 50%, 15%);
  --lcd-bg-off: hsl(260, 40%, 8%);
  --lcd-text: hsl(160, 90%, 60%);
  --lcd-text-glow: hsla(160, 90%, 60%, 0.5);

  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-premium: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 2px 2px rgba(255, 255, 255, 0.1);
  --shadow-glow: 0 0 15px var(--color-cyan-glow);
}

/* Base Reset & Layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: #f5f5fa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-x: hidden;
  position: relative;
}

/* Ambient Animated Background Blobs */
.app-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -2;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, hsl(260, 45%, 8%), hsl(260, 50%, 3%));
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.25;
  animation: blobFloat 12s infinite alternate ease-in-out;
}

.blob-purple {
  width: 400px;
  height: 400px;
  background-color: var(--color-purple);
  top: -100px;
  left: -100px;
}

.blob-cyan {
  width: 450px;
  height: 450px;
  background-color: var(--color-cyan);
  bottom: -150px;
  right: -100px;
  animation-delay: 3s;
}

@keyframes blobFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(80px, 50px) scale(1.15); }
}

/* Main Container Layout */
.main-container {
  max-width: 1200px;
  width: 100%;
  margin: auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  gap: 24px;
  align-items: center;
  z-index: 1;
}

/* Glassmorphism Panel styles */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-premium);
}

/* Sidebar Information Column */
.info-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: fit-content;
}

.logo-area h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, var(--color-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-area h1 span {
  color: var(--color-pink);
  -webkit-text-fill-color: initial;
}

.logo-area .tagline {
  font-size: 0.85rem;
  color: hsl(260, 20%, 70%);
  margin-top: 4px;
}

.pet-status-card h3,
.instructions-card h3,
.control-panel h3,
.monitor-bars h3 {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--color-cyan);
  text-transform: uppercase;
  margin-bottom: 12px;
  border-bottom: 1px solid hsla(170, 90%, 50%, 0.15);
  padding-bottom: 6px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: hsla(260, 30%, 18%, 0.4);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid hsla(260, 30%, 40%, 0.1);
}

.stat-label {
  font-size: 0.75rem;
  color: hsl(260, 20%, 75%);
}

.stat-val {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.instructions-card .control-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instructions-card li {
  font-size: 0.85rem;
  color: hsl(260, 15%, 85%);
  line-height: 1.4;
}

.audio-control-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn-secondary, .btn-danger, .btn-primary {
  border: none;
  outline: none;
  font-family: var(--font-main);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
  font-size: 0.85rem;
  color: #fff;
}

.btn-secondary {
  background: hsla(260, 30%, 25%, 0.6);
  border: 1px solid hsla(260, 30%, 50%, 0.2);
  flex-grow: 1;
}

.btn-secondary:hover {
  background: hsla(260, 30%, 35%, 0.8);
}

.btn-danger {
  background: hsla(335, 90%, 40%, 0.3);
  border: 1px solid hsla(335, 90%, 60%, 0.3);
}

.btn-danger:hover {
  background: hsla(335, 90%, 50%, 0.6);
}

/* ==========================================================================
   Tamagotchi Egg Shell Casing
   ========================================================================== */
.device-section {
  display: flex;
  justify-content: center;
}

.tamagotchi-shell {
  width: 540px;
  height: 735px;
  background: var(--device-shell-primary);
  border: 12px solid var(--device-shell-border);
  border-radius: 50% 50% 45% 45% / 55% 55% 45% 45%;
  position: relative;
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.6),
    inset 0 8px 16px rgba(255, 255, 255, 0.25),
    inset 0 -12px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 60px;
  user-select: none;
  transform: translateZ(0);
}

/* Gloss reflection on the shell */
.shell-highlight {
  position: absolute;
  top: 22px;
  left: 82px;
  width: 345px;
  height: 135px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: 50% / 100% 100% 0% 0%;
  pointer-events: none;
}

.brand-name {
  font-family: var(--font-lcd);
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: hsla(300, 30%, 90%, 0.9);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  margin-bottom: 18px;
}

/* Screen outer frame (bezel) */
.screen-bezel {
  width: 390px;
  height: 330px;
  background-color: hsl(260, 20%, 15%);
  border: 8px solid hsl(260, 20%, 8%);
  border-radius: 30px;
  padding: 12px;
  box-shadow: 
    inset 0 4px 8px rgba(0, 0, 0, 0.6),
    0 2px 2px rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* LCD Panel Screen */
.lcd-screen {
  width: 100%;
  height: 100%;
  background-color: var(--lcd-bg-on);
  border-radius: 8px;
  border: 3px solid #000;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
  transition: var(--transition-smooth);
}

.lcd-screen.lights-off {
  background-color: var(--lcd-bg-off) !important;
}

.lcd-screen.lights-off .pet-sprite,
.lcd-screen.lights-off .poop-layer,
.lcd-screen.lights-off .header-icon {
  opacity: 0.15;
  filter: brightness(0.4) grayscale(0.5);
}

.lcd-screen.lights-off #sickness-effect {
  opacity: 0;
}

/* Scanline / retro screen effect */
.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 6px 100%;
  z-index: 10;
  pointer-events: none;
}

.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
  z-index: 9;
  pointer-events: none;
}

/* LCD Header Status indicators */
.lcd-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 18px;
  padding: 0 4px;
  border-bottom: 1px dotted hsla(160, 90%, 60%, 0.25);
  z-index: 3;
}

.header-icon {
  font-size: 0.8rem;
  opacity: 0.25;
  transition: var(--transition-smooth);
}

.header-icon.active {
  opacity: 1;
  text-shadow: 0 0 4px var(--lcd-text);
  transform: scale(1.15);
}

/* Main Graphic Window */
.lcd-main {
  flex-grow: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

/* Wallpaper styles */
.lcd-main.wp-retro-green {
  background-color: var(--lcd-bg-on);
}
.lcd-main.wp-cyberpunk {
  background: radial-gradient(circle at center, #311b92, #0d001a);
}
.lcd-main.wp-cyberpunk::before {
  content: '🏙️';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 2.5rem;
  text-align: center;
  opacity: 0.1;
  letter-spacing: 6px;
  z-index: 1;
}
.lcd-main.wp-cozy-room {
  background: linear-gradient(to bottom, #5d4037 0%, #3e2723 100%);
}
.lcd-main.wp-cozy-room::before {
  content: '🪟';
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 1.8rem;
  opacity: 0.15;
  z-index: 1;
}
.lcd-main.wp-forest {
  background: linear-gradient(to bottom, #2e7d32 0%, #1b5e20 60%, #0d5312 100%);
}
.lcd-main.wp-forest::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 25px;
  background: linear-gradient(to top, #0d3c12 50%, #1b5e20 100%);
  border-top: 1.5px solid #a5d6a7;
  z-index: 1;
}
.lcd-main.wp-forest::after {
  content: '🌲  🌲   🌲';
  position: absolute;
  bottom: 18px;
  left: 10px;
  font-size: 1.4rem;
  opacity: 0.3;
  letter-spacing: 26px;
  color: #1b5e20;
  z-index: 0;
}
.lcd-main.wp-ocean {
  background: linear-gradient(to bottom, #0097a7 0%, #006064 60%, #00363a 100%);
}
.lcd-main.wp-ocean::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to top, #d7ccc8 60%, #efebe9 100%);
  border-top: 1.5px solid #ffcc80;
  z-index: 1;
}
.lcd-main.wp-ocean::after {
  content: '🫧  🫧   🫧';
  position: absolute;
  bottom: 24px;
  left: 12px;
  font-size: 1.3rem;
  opacity: 0.35;
  letter-spacing: 28px;
  animation: floatBubbles 5s infinite linear alternate;
  z-index: 0;
}
@keyframes floatBubbles {
  0% { transform: translateY(0) translateX(0); }
  100% { transform: translateY(-16px) translateX(8px); }
}
.lcd-main.wp-sky {
  background: linear-gradient(to bottom, #0288d1 0%, #00bcd4 60%, #b2ebf2 100%);
}
.lcd-main.wp-sky::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to top, rgba(255,255,255,0.7) 40%, rgba(255,255,255,0.95) 100%);
  filter: blur(1px);
  z-index: 1;
}
.lcd-main.wp-sky::after {
  content: '☁️   ☁️   ☁️';
  position: absolute;
  top: 15px;
  left: 12px;
  font-size: 1.8rem;
  opacity: 0.35;
  letter-spacing: 34px;
  animation: driftClouds 9s infinite linear alternate;
  z-index: 0;
}
@keyframes driftClouds {
  0% { transform: translateX(0); }
  100% { transform: translateX(18px); }
}

.pet-container {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.pet-sprite {
  width: 100%;
  height: 100%;
  transform-origin: bottom center;
}

/* Adjust hat position based on pet stage */
.pet-sprite.wiggling .hat-group {
  display: none !important; /* No hats on egg! */
}
.pet-sprite #state-baby ~ .hat-group,
.pet-group[style*="display: none"] ~ .hat-group {
  /* Dynamic visibility is controlled by JS state, but we override coordinates */
}

/* Poop graphic overlay */
.poop-layer {
  position: absolute;
  bottom: 12px;
  right: 20px;
  z-index: 5;
  display: flex;
  gap: 4px;
}

.poop-element {
  font-size: 1.65rem;
  animation: poopBounce 1s infinite alternate ease-in-out;
}

@keyframes poopBounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

/* Food feeding item overlay */
.food-layer {
  position: absolute;
  top: 45px;
  left: 30px;
  font-size: 2.1rem;
  z-index: 5;
  animation: foodEntry 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes foodEntry {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Sickness effect overlay */
.sickness-layer {
  position: absolute;
  top: 22px;
  right: 30px;
  font-size: 1.95rem;
  z-index: 5;
  animation: floatSkull 2s infinite ease-in-out;
}

@keyframes floatSkull {
  0% { transform: translateY(0) scale(1); opacity: 0.8; }
  50% { transform: translateY(-8px) scale(1.1); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 0.8; }
}

/* ==========================================================================
   LCD SUB-SCREENS (OVERLAYS)
   ========================================================================== */
.lcd-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--lcd-bg-off);
  border: 1px solid var(--lcd-text);
  color: var(--lcd-text);
  font-family: var(--font-lcd);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  z-index: 8;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.overlay-title {
  font-size: 0.75rem;
  text-align: center;
  border-bottom: 1px dotted hsla(160, 90%, 60%, 0.3);
  padding-bottom: 4px;
  font-weight: 900;
  color: var(--color-cyan);
}

.overlay-footer {
  font-size: 0.55rem;
  text-align: center;
  border-top: 1px dotted hsla(160, 90%, 60%, 0.3);
  padding-top: 4px;
  color: hsl(160, 40%, 60%);
}

/* Shop and Inventory list styling */
.shop-list, .inventory-list, .custom-list, .achieve-list {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
  /* Hide scrollbar */
  scrollbar-width: none; 
}
.shop-list::-webkit-scrollbar,
.inventory-list::-webkit-scrollbar,
.custom-list::-webkit-scrollbar,
.achieve-list::-webkit-scrollbar {
  display: none;
}

.shop-item, .inventory-item, .custom-item, .achieve-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(16, 40, 30, 0.5);
  border: 1px solid transparent;
}

.shop-item.active, .inventory-item.active, .custom-item.active {
  border-color: var(--lcd-text);
  background: var(--lcd-text);
  color: var(--lcd-bg-off);
}

.shop-item-price {
  color: var(--color-gold);
}
.shop-item.active .shop-item-price {
  color: hsl(45, 90%, 20%);
}

/* Customize Tabs */
.custom-tabs {
  display: flex;
  justify-content: space-around;
  font-size: 0.65rem;
  margin-bottom: 2px;
}
.custom-tab {
  opacity: 0.5;
  cursor: pointer;
}
.custom-tab.active {
  opacity: 1;
  font-weight: 800;
  border-bottom: 1.5px solid var(--lcd-text);
}

/* Collection Species Book */
.collection-grid {
  flex-grow: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px 0;
  overflow-y: auto;
}
.collection-item {
  font-size: 0.6rem;
  padding: 4px;
  background: rgba(16, 40, 30, 0.6);
  border-radius: 4px;
  text-align: center;
  border: 1px solid transparent;
}
.collection-item.active {
  background: var(--lcd-text);
  color: var(--lcd-bg-off);
}
.collection-item.locked {
  opacity: 0.4;
}

/* Achievements List styling */
.achieve-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.achieve-title {
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 4px;
}
.achieve-desc {
  font-size: 0.55rem;
  opacity: 0.7;
}

/* Matchmaker Overlay styling */
.matchmaker-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.match-text {
  font-size: 0.65rem;
}
.match-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
}
.heart-pulse {
  animation: heartPulse 0.6s infinite alternate ease-in-out;
}
@keyframes heartPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.25); }
}
.match-prompt {
  font-size: 0.6rem;
  color: var(--color-cyan);
}
.match-choices {
  display: flex;
  gap: 12px;
}
.match-opt {
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1.5px solid transparent;
  border-radius: 4px;
}
.match-opt.active {
  border-color: var(--lcd-text);
  background: var(--lcd-text);
  color: var(--lcd-bg-off);
}

/* Online Hub overlay styling */
.online-menu {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.online-opt {
  font-size: 0.7rem;
  padding: 4px;
  border-radius: 4px;
  text-align: center;
  border: 1px solid transparent;
}
.online-opt.active {
  border-color: var(--lcd-text);
  background: var(--lcd-text);
  color: var(--lcd-bg-off);
}

/* Games selection menu */
.games-menu {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.game-opt {
  font-size: 0.7rem;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid transparent;
}
.game-opt.active {
  border-color: var(--lcd-text);
  background: var(--lcd-text);
  color: var(--lcd-bg-off);
}

/* Guessing Game overlay */
.game-choices {
  display: flex;
  gap: 15px;
}
.choice-btn {
  background: var(--lcd-bg-on);
  border: 1.5px solid var(--lcd-text);
  color: var(--lcd-text);
  font-family: var(--font-lcd);
  font-size: 1.1rem;
  width: 44px;
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}
.choice-btn:hover {
  background: var(--lcd-text);
  color: var(--lcd-bg-on);
}

/* Simon Says Memory Game */
.memory-colors-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 10px 0;
}
.mem-color-btn {
  font-size: 0.8rem;
  font-weight: bold;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: 2px solid #000;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.4);
  opacity: 0.3;
  transition: opacity 0.1s ease;
}
.mem-color-btn.active {
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 10px #fff;
}

/* Catch Coin Game Field */
.catch-score-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  border-bottom: 1.5px solid var(--lcd-text);
  padding-bottom: 3px;
  color: var(--color-cyan);
}
.catch-field {
  flex-grow: 1;
  position: relative;
  background: #06120e;
  border: 1.5px solid var(--lcd-text);
  margin: 4px 0;
  overflow: hidden;
}
.falling-item {
  position: absolute;
  font-size: 1rem;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
}
.catch-player {
  position: absolute;
  font-size: 1.2rem;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  transition: left 0.1s ease;
}

/* ==========================================================================
   Pet SVG State Animations
   ========================================================================== */

/* 1. Egg Hatching wiggle */
.wiggling {
  animation: eggWiggle 0.8s infinite ease-in-out;
}

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

/* Hatching shake */
.hatching-shake {
  animation: hatchShake 0.15s infinite linear;
}

@keyframes hatchShake {
  0% { transform: translate(1px, 1px) rotate(0); }
  10% { transform: translate(-1px, -1px) rotate(-1deg); }
  30% { transform: translate(-2px, 0px) rotate(1deg); }
  50% { transform: translate(1px, 2px) rotate(0); }
  70% { transform: translate(-1px, 1px) rotate(1deg); }
  90% { transform: translate(2px, -1px) rotate(-1deg); }
  100% { transform: translate(1px, 1px) rotate(0); }
}

/* 2. Normal idle bouncing */
.bouncing {
  animation: petBounce 1.2s infinite ease-in-out;
}

@keyframes petBounce {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-5px) scaleY(0.92) scaleX(1.04); }
}

/* 3. Eating animation */
.eating {
  animation: petEat 0.4s infinite alternate ease-in-out;
}

@keyframes petEat {
  0% { transform: scale(1) translateX(0); }
  100% { transform: scale(1.08, 0.94) translateX(5px); }
}

/* 4. Dancing animation (happy) */
.dancing {
  animation: petDance 0.5s infinite alternate ease-in-out;
}

@keyframes petDance {
  0% { transform: translateY(0) rotate(-8deg); }
  100% { transform: translateY(-12px) rotate(8deg); }
}

/* 5. Shaking (Sick / Sad) */
.shaking {
  animation: petShake 0.3s infinite ease-in-out;
}

@keyframes petShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(2deg); }
}

/* 6. Sleeping animation */
.sleeping {
  animation: petSleep 2s infinite ease-in-out;
}

@keyframes petSleep {
  0%, 100% { transform: scaleY(1) scaleX(1); opacity: 0.9; }
  50% { transform: scaleY(0.88) scaleX(1.05); opacity: 0.75; }
}

/* Category Specific Animations */
.flapping .wing-left {
  animation: wingFlapLeft 0.2s infinite alternate ease-in-out;
  transform-origin: 32px 42px;
}
.flapping .wing-right {
  animation: wingFlapRight 0.2s infinite alternate ease-in-out;
  transform-origin: 68px 42px;
}
@keyframes wingFlapLeft {
  0% { transform: rotate(0); }
  100% { transform: rotate(-25deg); }
}
@keyframes wingFlapRight {
  0% { transform: rotate(0); }
  100% { transform: rotate(25deg); }
}

.swimming .tail-fin {
  animation: tailSwim 0.3s infinite alternate ease-in-out;
  transform-origin: 50px 72px;
}
@keyframes tailSwim {
  0% { transform: rotate(-10deg); }
  100% { transform: rotate(10deg); }
}

.swimming .tentacles {
  animation: tentaclesWave 0.5s infinite alternate ease-in-out;
  transform-origin: 50px 65px;
}
@keyframes tentaclesWave {
  0% { transform: scaleY(0.9) skewX(-5deg); }
  100% { transform: scaleY(1.1) skewX(5deg); }
}

/* ==========================================================================
   Tactile Action Buttons (A, B, C)
   ========================================================================== */
.physical-buttons {
  display: flex;
  justify-content: space-between;
  width: 315px;
  margin-top: 45px;
}

.button-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.physical-btn {
  width: 66px;
  height: 66px;
  background: linear-gradient(135deg, hsl(45, 90%, 55%) 0%, hsl(35, 90%, 50%) 100%);
  border: 6px solid hsl(35, 90%, 30%);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  outline: none;
  box-shadow: 
    0 9px 0 hsl(35, 90%, 25%),
    0 12px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.physical-btn:active {
  transform: translateY(6px);
  box-shadow: 
    0 3px 0 hsl(35, 90%, 25%),
    0 6px 9px rgba(0, 0, 0, 0.4);
}

.physical-btn .btn-inner {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 80%);
  border-radius: 50%;
}

/* Unique colors for A, B, and C buttons */
.btn-action-a {
  background: linear-gradient(135deg, hsl(0, 90%, 55%) 0%, hsl(350, 90%, 45%) 100%);
  border-color: hsl(350, 90%, 25%);
  box-shadow: 
    0 9px 0 hsl(350, 90%, 20%),
    0 12px 18px rgba(0, 0, 0, 0.4);
}

.btn-action-a:active {
  transform: translateY(6px);
  box-shadow: 
    0 3px 0 hsl(350, 90%, 20%),
    0 6px 9px rgba(0, 0, 0, 0.4);
}

.btn-action-b {
  background: linear-gradient(135deg, hsl(120, 80%, 50%) 0%, hsl(110, 80%, 40%) 100%);
  border-color: hsl(110, 80%, 22%);
  box-shadow: 
    0 9px 0 hsl(110, 80%, 18%),
    0 12px 18px rgba(0, 0, 0, 0.4);
}

.btn-action-b:active {
  transform: translateY(6px);
  box-shadow: 
    0 3px 0 hsl(110, 80%, 18%),
    0 6px 9px rgba(0, 0, 0, 0.4);
}

.btn-action-c {
  background: linear-gradient(135deg, hsl(215, 90%, 55%) 0%, hsl(200, 90%, 45%) 100%);
  border-color: hsl(200, 90%, 25%);
  box-shadow: 
    0 9px 0 hsl(200, 90%, 20%),
    0 12px 18px rgba(0, 0, 0, 0.4);
}

.btn-action-c:active {
  transform: translateY(6px);
  box-shadow: 
    0 3px 0 hsl(200, 90%, 20%),
    0 6px 9px rgba(0, 0, 0, 0.4);
}

.btn-label {
  font-family: var(--font-lcd);
  font-size: 1.1rem;
  font-weight: 700;
  color: hsla(280, 20%, 90%, 0.6);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Side Interaction / Control Panel
   ========================================================================== */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: auto;
  max-height: 735px;
  scrollbar-width: none;
}
.control-panel::-webkit-scrollbar {
  display: none;
}

.control-panel h3,
.monitor-bars h3 {
  margin-bottom: 6px !important;
  padding-bottom: 3px !important;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.action-btn {
  background: hsla(260, 30%, 16%, 0.6);
  border: 1px solid hsla(260, 30%, 45%, 0.15);
  border-radius: 12px;
  padding: 6px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  transition: var(--transition-smooth);
  outline: none;
}

.action-btn:hover {
  background: hsla(260, 30%, 25%, 0.7);
  border-color: var(--color-cyan-glow);
  transform: translateY(-1px);
}

.action-btn:active {
  transform: scale(0.95);
}

.action-btn .btn-icon {
  font-size: 1.05rem;
  background: hsla(260, 30%, 22%, 0.8);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn .btn-text {
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

/* Realtime Monitor Bars */
.monitor-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.meter-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: hsl(260, 15%, 85%);
  font-weight: 600;
}

.meter-bg {
  height: 6px;
  background-color: hsla(260, 30%, 8%, 0.8);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid hsla(260, 30%, 40%, 0.15);
}

.meter-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease-out;
}

/* Custom bar gradients */
.bar-hunger {
  background: linear-gradient(to right, var(--color-orange), var(--color-pink));
}

.bar-happiness {
  background: linear-gradient(to right, var(--color-purple), var(--color-pink));
}

.bar-energy {
  background: linear-gradient(to right, var(--color-gold), #ffee58);
}

.bar-hygiene {
  background: linear-gradient(to right, hsl(190, 80%, 45%), var(--color-cyan));
}

/* ==========================================================================
   GAME 4: Mario Platformer Game
   ========================================================================== */
.mario-score-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  border-bottom: 1.5px solid var(--lcd-text);
  padding-bottom: 3px;
  color: var(--color-cyan);
}
.mario-field {
  flex-grow: 1;
  position: relative;
  background: linear-gradient(to bottom, #80deea 0%, #00acc1 100%);
  border: 1.5px solid var(--lcd-text);
  margin: 4px 0;
  overflow: hidden;
}
.mario-ground {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12px;
  background: repeating-linear-gradient(45deg, #8d6e63, #8d6e63 4px, #5d4037 4px, #5d4037 8px);
  border-top: 2.5px solid #a5d6a7;
}
.mario-bg-cloud {
  position: absolute;
  font-size: 1.5rem;
  top: 8px;
  right: 20px;
  opacity: 0.25;
}
.mario-player {
  position: absolute;
  left: 30px;
  bottom: 12px;
  z-index: 6;
  transition: bottom 0.05s linear;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mario-player svg {
  width: 100%;
  height: 100%;
  display: block;
}
.mario-obstacle {
  position: absolute;
  font-size: 1.7rem;
  bottom: 12px;
  left: 100%;
  z-index: 5;
}
.mario-coin {
  position: absolute;
  font-size: 1.4rem;
  bottom: 40px;
  left: 100%;
  z-index: 5;
}

/* ==========================================================================
   Footer & Responsive Settings
   ========================================================================== */
.app-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.75rem;
  color: hsl(260, 15%, 55%);
  z-index: 1;
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr 1fr;
    max-width: 760px;
  }
  .info-sidebar {
    grid-column: 1 / 3;
    display: grid;
    grid-template-columns: 1fr 1.2fr;
  }
  .instructions-card {
    grid-column: 1 / 3;
  }
  .device-section {
    grid-column: 1;
  }
  .control-panel {
    grid-column: 2;
  }
}

@media (max-width: 768px) {
  .main-container {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .info-sidebar {
    grid-column: 1;
    display: flex;
    flex-direction: column;
  }
  .instructions-card {
    grid-column: 1;
  }
  .device-section {
    grid-column: 1;
  }
  .control-panel {
    grid-column: 1;
    height: auto;
  }
}
