/* CSS Variables for Premium Pastel Design System */
:root {
  --mint-green: #c8f0e0;
  --mint-dark: #8bbfa1;
  --mint-light: #e5fdf5;
  --pink: #f4c2c2;
  --pink-dark: #d69f9f;
  --pink-light: #fff0f0;
  --warm-beige: #fdf3e3;
  --warm-beige-light: #fef9f0;
  --kraft-brown: #c8a06e;
  --kraft-dark: #a07a4a;
  --charcoal: #4a3e3d;
  --charcoal-light: #6e5f5e;
  --gold: #e5a93b;
  --white-glass: rgba(255, 255, 255, 0.45);
  --border-glass: rgba(255, 255, 255, 0.65);
  --shadow-cozy: 0 12px 40px rgba(74, 62, 61, 0.08);
  --shadow-hover: 0 16px 48px rgba(74, 62, 61, 0.14);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(135deg, var(--warm-beige) 0%, var(--warm-beige-light) 100%);
  color: var(--charcoal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-x: hidden;
  position: relative;
}

/* Magical Background Effects */
.stars-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.3;
  transition: opacity 0.5s ease;
}

.star-blink {
  animation: blink 3s infinite ease-in-out;
}

@keyframes blink {

  0%,
  100% {
    opacity: 0.1;
    transform: scale(0.8);
  }

  50% {
    opacity: 0.9;
    transform: scale(1.3);
  }
}

.clouds-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 40%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  opacity: 0.45;
}

.cloud {
  position: absolute;
  background: #ffffff;
  border-radius: 100px;
  opacity: 0.8;
  filter: blur(10px);
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
}

.cloud-1 {
  width: 150px;
  height: 50px;
  top: 10%;
  left: -50px;
  animation: floatCloud 45s infinite linear;
}

.cloud-2 {
  width: 220px;
  height: 70px;
  top: 25%;
  right: -80px;
  animation: floatCloudReverse 60s infinite linear;
}

@keyframes floatCloud {
  0% {
    transform: translateX(-150px);
  }

  100% {
    transform: translateX(110vw);
  }
}

@keyframes floatCloudReverse {
  0% {
    transform: translateX(150px);
  }

  100% {
    transform: translateX(-110vw);
  }
}

/* Application Container */
.app-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Header Styling */
.app-header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.title-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.app-header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--charcoal);
  letter-spacing: -0.5px;
  text-shadow: 0 2px 4px rgba(74, 62, 61, 0.04);
}

.eid-moon,
.eid-lantern {
  font-size: 2.4rem;
  filter: drop-shadow(0 2px 8px rgba(229, 169, 59, 0.25));
  animation: floatMini 3s infinite ease-in-out;
}

.eid-lantern {
  animation-delay: 1.5s;
}

.subtitle {
  font-size: 1.15rem;
  color: var(--charcoal-light);
  margin-top: 10px;
  font-weight: 300;
}

.controls-wrapper {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Sound Button and Pulse */
.sound-btn {
  background: var(--white-glass);
  border: 2px solid var(--border-glass);
  border-radius: 100px;
  padding: 10px 22px;
  color: var(--charcoal);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(74, 62, 61, 0.05);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sound-btn:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: var(--pink);
  box-shadow: 0 6px 16px rgba(244, 194, 194, 0.3);
}

.sound-btn:active {
  transform: translateY(0);
}

.sound-btn.muted {
  border-color: rgba(74, 62, 61, 0.15);
  background: rgba(74, 62, 61, 0.05);
  color: var(--charcoal-light);
}

/* .audio-status-tip {
  font-size: 0.82rem;
  color: var(--pink-dark);
  font-weight: 400;
  opacity: 0.9;
  letter-spacing: 0.2px;
} */

/* Pulse Glow Animation */
.pulse-glow {
  animation: btnPulse 2s infinite;
}

@keyframes btnPulse {
  0% {
    box-shadow: 0 0 0 0px rgba(244, 194, 194, 0.5);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(244, 194, 194, 0);
  }

  100% {
    box-shadow: 0 0 0 0px rgba(244, 194, 194, 0);
  }
}

/* Two-Card Game Layout */
.game-board {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(320px, 440px);
  gap: 35px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.15s backwards;
}

/* Premium Card Base */
.card {
  background: var(--white-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 28px;
  box-shadow: var(--shadow-cozy);
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

/* Centerpiece Card specific styling */
.centerpiece-card {
  position: relative;
  justify-content: center;
  overflow: hidden;
  animation: floatCard 6s infinite ease-in-out;
}

@keyframes floatCard {

  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
  }

  50% {
    transform: translateY(-8px) rotate(0.4deg);
  }
}

.mug-stage-wrapper {
  position: relative;
  width: 100%;
  max-width: 320px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.centerpiece-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 15px 30px rgba(74, 62, 61, 0.08));
}

/* Magic reveal structures for solid closed ceramic mug */
#beadSheep {
  transform: translateY(120px) scale(0.85);
  opacity: 0;
  transform-origin: center bottom;
  transition: transform 0.9s cubic-bezier(0.25, 1, 0.5, 1.25), opacity 0.5s ease;
}

#mugHeart {
  transform-origin: 200px 255px;
  transition: transform 0.5s ease;
}

.centerpiece-card.revealed #beadSheep {
  opacity: 1;
  transform: translateY(-152px) scale(1);
  animation: sheepWobbleCelebrate 2s infinite alternate ease-in-out 0.9s;
}

.centerpiece-card.revealed #mugHeart {
  animation: heartCelebrate 1.6s infinite ease-in-out;
}

@keyframes sheepWobbleCelebrate {
  0% {
    transform: translateY(-152px) rotate(-3deg) scale(1);
  }

  100% {
    transform: translateY(-158px) rotate(3deg) scale(1.05);
  }
}

@keyframes heartCelebrate {

  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }

  50% {
    transform: scale(1.12) rotate(6deg);
  }
}

/* Locked Indicator Badge */
.lock-indicator {
  position: absolute;
  bottom: 24px;
  background: rgba(74, 62, 61, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 100px;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.lock-icon {
  font-size: 0.95rem;
}

/* Flying & Interactive Lid Animations */
#interactiveBoxLid {
  transform-origin: center bottom;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#interactiveBoxLid.fly-away {
  animation: flyUp 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
  pointer-events: none;
}

@keyframes flyUp {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.2));
  }

  20% {
    transform: translateY(-15px) rotate(-2deg) scale(1.02);
    opacity: 1;
    filter: drop-shadow(0 20px 25px rgba(0, 0, 0, 0.3));
  }

  100% {
    transform: translateY(-380px) rotate(22deg) scale(0.85);
    opacity: 0;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0));
  }
}

/* Sheep Animations */
.sheep-idle {
  transform-origin: center bottom;
  animation: sheepBreath 3.5s infinite ease-in-out;
}

@keyframes sheepBreath {

  0%,
  100% {
    transform: translateY(0) scaleY(1);
  }

  50% {
    transform: translateY(1.5px) scaleY(0.97) scaleX(1.01);
  }
}

.sheep-bounce {
  animation: bounceIn 1.5s cubic-bezier(0.25, 1.25, 0.5, 1) forwards !important;
  transform-origin: center bottom;
}

@keyframes bounceIn {
  0% {
    transform: translateY(50px) scaleY(0.6) scaleX(1.2);
    opacity: 0.8;
  }

  35% {
    transform: translateY(-28px) scaleY(1.15) scaleX(0.85);
  }

  55% {
    transform: translateY(12px) scaleY(0.9) scaleX(1.08);
  }

  75% {
    transform: translateY(-6px) scaleY(1.03) scaleX(0.97);
  }

  90% {
    transform: translateY(2px) scaleY(0.99) scaleX(1.01);
  }

  100% {
    transform: translateY(0px) scaleY(1) scaleX(1);
    opacity: 1;
  }
}

/* Arabic Eid Mubarak Text overlay styles */
.eid-mubarak-text {
  position: absolute;
  top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  z-index: 5;
}

.eid-mubarak-text.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: glowText 2.5s infinite ease-in-out 0.8s;
}

.eid-mubarak-text .arabic {
  font-family: 'Tajawal', sans-serif;
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
}

.eid-mubarak-text .english {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--pink-dark);
  text-transform: uppercase;
  margin-top: 4px;
}

@keyframes glowText {

  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(229, 169, 59, 0.3)) drop-shadow(0 0 12px rgba(244, 194, 194, 0.2));
    transform: scale(1);
  }

  50% {
    filter: drop-shadow(0 0 12px rgba(229, 169, 59, 0.75)) drop-shadow(0 0 24px rgba(244, 194, 194, 0.5));
    transform: scale(1.05);
  }
}

/* Puzzle Card specific styling */
.puzzle-card {
  justify-content: space-between;
}

.puzzle-header {
  text-align: center;
  margin-bottom: 25px;
  width: 100%;
}

.puzzle-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.puzzle-header p {
  font-size: 0.9rem;
  color: var(--charcoal-light);
}

/* Puzzle Board & Grid (5x2 ratio for 10 pieces) */
.puzzle-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 2.1;
  margin: 10px auto 25px auto;
  position: relative;
}

/* Individual Tiles */
.puzzle-tile {
  background: var(--warm-beige);
  border: 1.5px solid rgba(74, 62, 61, 0.15);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(74, 62, 61, 0.04);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  touch-action: manipulation;
}

.puzzle-tile svg {
  width: 100%;
  height: 100%;
  display: block;
}

.puzzle-tile:hover {
  transform: translateY(-4px) scale(1.04);
  border-color: var(--pink);
  box-shadow: 0 8px 20px rgba(74, 62, 61, 0.1);
}

.puzzle-tile:active {
  transform: scale(0.98);
}

/* Selected Tile highlight state */
.puzzle-tile.selected {
  border-color: var(--pink-dark);
  transform: translateY(-4px) scale(1.04);
  animation: pulseSelect 1.5s infinite;
  z-index: 2;
}

@keyframes pulseSelect {
  0% {
    box-shadow: 0 0 0 0px var(--pink);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(244, 194, 194, 0);
  }

  100% {
    box-shadow: 0 0 0 0px rgba(244, 194, 194, 0);
  }
}

/* Confirmed Correct Position State */
.puzzle-tile.correct-position {
  border-color: var(--mint-dark);
}

/* Actions in Puzzle Card */
.puzzle-actions {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-top: 10px;
}

.action-btn-secondary {
  background: transparent;
  border: 1.5px dashed var(--charcoal-light);
  color: var(--charcoal);
  padding: 8px 18px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.action-btn-secondary:hover {
  background: rgba(74, 62, 61, 0.05);
  border-style: solid;
}

.puzzle-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.red {
  background: #ff6b6b;
  box-shadow: 0 0 8px #ff6b6b;
}

.status-dot.green {
  background: #4cd137;
  box-shadow: 0 0 8px #4cd137;
}

.status-msg {
  color: var(--charcoal-light);
}

/* Celebration Overlay screen */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(253, 243, 227, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.celebration-overlay.show {
  opacity: 1;
  pointer-events: all;
}

#confettiCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.celebration-content {
  text-align: center;
  max-width: 500px;
  padding: 40px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: 36px;
  box-shadow: var(--shadow-hover);
  z-index: 2;
  transform: scale(0.85);
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.celebration-overlay.show .celebration-content {
  transform: scale(1);
}

.success-stars {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 12px;
  animation: wobble 2s infinite;
}

@keyframes wobble {

  0%,
  100% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-5deg) scale(1.05);
  }

  75% {
    transform: rotate(5deg) scale(1.05);
  }
}

.solved-headline {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--charcoal);
  margin-bottom: 10px;
}

.solved-sub {
  font-size: 1.05rem;
  color: var(--charcoal-light);
  line-height: 1.5;
  margin-bottom: 25px;
}

.bead-sheep-showcase {
  margin-bottom: 30px;
  perspective: 1000px;
}

.bead-sheep-trophy {
  font-size: 5rem;
  display: inline-block;
  animation: popBounce 1.5s infinite alternate cubic-bezier(0.25, 0.8, 0.25, 1);
  filter: drop-shadow(0 8px 16px rgba(74, 62, 61, 0.15));
}

@keyframes popBounce {
  0% {
    transform: translateY(0) scale(1);
  }

  100% {
    transform: translateY(-20px) scale(1.1) rotate(5deg);
  }
}

.restart-btn {
  background: var(--mint-green);
  border: 2px solid var(--border-glass);
  color: var(--charcoal);
  font-family: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 14px 36px;
  border-radius: 100px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(139, 191, 161, 0.25);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.restart-btn:hover {
  transform: translateY(-3px) scale(1.03);
  background: #ffffff;
  border-color: var(--mint-dark);
  box-shadow: 0 8px 24px rgba(139, 191, 161, 0.4);
}

.restart-btn:active {
  transform: translateY(0) scale(1);
}

/* Footer styling */
.app-footer {
  text-align: center;
  padding: 25px;
  font-size: 0.85rem;
  color: var(--charcoal-light);
  opacity: 0.7;
  z-index: 1;
}

/* Animation utilities for entrance effects */
@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-25px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(25px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatMini {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

/* Media Queries (Mobile Responsiveness) */
@media (max-width: 820px) {
  .app-container {
    padding: 20px 10px;
  }

  .app-header h1 {
    font-size: 2.2rem;
  }

  .eid-moon,
  .eid-lantern {
    font-size: 1.8rem;
  }

  .game-board {
    grid-template-columns: 1fr;
    gap: 25px;
    max-width: 440px;
  }

  .card {
    padding: 25px 20px;
  }

  .puzzle-board {
    margin-bottom: 20px;
  }

  .celebration-content {
    padding: 30px 20px;
    margin: 15px;
  }

  .solved-headline {
    font-size: 1.8rem;
  }
}