/* CSS Custom Properties for extra styling not covered by Tailwind */

:root {
  --bounce-easing: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Custom Scrollbar for a modern look */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: #F8FAFC;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: #4A148C;
  border-radius: 10px;
  border: 2px solid #F8F9FA;
}
::-webkit-scrollbar-thumb:hover {
  background: #311B92;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-15px); }
  100% { transform: translateY(0px); }
}

@keyframes floatSlow {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes floatUpFade {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  80% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes flyRight {
  0% { transform: translateX(-100vw) translateY(0); }
  25% { transform: translateX(-50vw) translateY(-20px); }
  50% { transform: translateX(0vw) translateY(20px); }
  75% { transform: translateX(50vw) translateY(-10px); }
  100% { transform: translateX(100vw) translateY(0); }
}

@keyframes jumpArc {
  0% { transform: translateY(0) scaleX(-1); }
  50% { transform: translateY(-30px) scaleX(-1); }
  100% { transform: translateY(0) scaleX(-1); }
}

@keyframes scrollBg {
  0% { background-position: 0 0; }
  100% { background-position: -1000px 0; }
}

@keyframes swim {
  0% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(20px) translateY(10px); }
  100% { transform: translateX(0) translateY(0); }
}

.cloud-anim {
  animation: float 6s ease-in-out infinite;
}

.cloud-anim-slow {
  animation: floatSlow 8s ease-in-out infinite;
}

.animate-pop {
  animation: popIn 0.5s var(--bounce-easing) forwards;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

.animate-float-up {
  animation: floatUpFade 1s forwards;
  pointer-events: none;
}

.animate-fly {
  animation: flyRight 10s linear infinite;
}

.animate-jump {
  animation: jumpArc 0.5s ease-out;
}

.animate-scroll-bg {
  animation: scrollBg 2s linear infinite;
}

.animate-swim {
  animation: swim 3s ease-in-out infinite;
}


/* Glassmorphism Cards */
.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

/* Flashcard Flip Effect */
.flashcard-scene {
  perspective: 1000px;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}
.flashcard-scene.is-flipped .flashcard-inner {
  transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 1rem;
}
.flashcard-back {
  transform: rotateY(180deg);
}

/* Drag & Drop */
.draggable {
  cursor: grab;
}
.draggable:active {
  cursor: grabbing;
}
.drop-zone {
  transition: all 0.2s ease;
}
.drop-zone.drag-over {
  background-color: rgba(78, 205, 196, 0.2);
  border-color: #4ECDC4;
  transform: scale(1.05);
}

/* Custom Audio Player Styling */
.custom-audio-player {
  filter: sepia(20%) saturate(70%) grayscale(1) contrast(99%) invert(12%);
  border-radius: 50px;
  background-color: #F8F9FA;
}
.custom-audio-player::-webkit-media-controls-panel {
  background-color: #F8F9FA;
}
.custom-audio-player::-webkit-media-controls-play-button {
  background-color: #4A148C;
  border-radius: 50%;
  cursor: pointer;
}
.custom-audio-player::-webkit-media-controls-play-button:hover {
  background-color: #311B92;
}

/* --- Fairy Maze RPG Game Styles --- */
.maze-board {
    --cell-size: 55px;
    --cell-gap: 3px;
    position: relative;
    display: grid;
    grid-template-columns: repeat(13, var(--cell-size));
    grid-template-rows: repeat(13, var(--cell-size));
    gap: var(--cell-gap);
    background: #3B1650;
    padding: 15px;
    border-radius: 1.25rem;
    box-shadow: inset 0 0 25px rgba(0,0,0,0.5), 0 10px 25px rgba(236,72,153,0.2);
    border: 4px solid #F472B6;
    margin: 0 auto;
    direction: ltr;
    max-width: 100%;
    overflow: auto;
}

#maze-player {
    --cell-size: 55px;
    --cell-gap: 3px;
    position: absolute;
    left: calc(var(--x, 1) * (var(--cell-size) + var(--cell-gap)) + 15px);
    top: calc(var(--y, 1) * (var(--cell-size) + var(--cell-gap)) + 15px);
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size) * 0.7);
    z-index: 10;
    transition: left 0.15s ease, top 0.15s ease;
    pointer-events: none;
}

#maze-player::before {
    content: "";
    position: absolute;
    width: 90%;
    height: 90%;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.3);
    border: 2px solid #F472B6;
    box-shadow: 0 0 14px rgba(236, 72, 153, 0.9);
    z-index: -1;
    animation: player-pulse 1.2s infinite alternate;
}

.maze-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size) * 0.6);
    transition: all 0.25s ease;
    position: relative;
    user-select: none;
}

.maze-cell.wall {
    background: linear-gradient(145deg, #701A75, #4A044E);
    border: 1px solid #A21CAF;
}
.maze-cell.path {
    background: linear-gradient(135deg, #FFF1F2, #F5F3FF);
}
.maze-cell.door-locked {
    background: linear-gradient(135deg, #F43F5E, #9F1239);
    border: 2px solid #FDA4AF;
    color: white;
    cursor: pointer;
    animation: door-glow 1s infinite alternate;
}
.maze-cell.door-unlocked {
    background: linear-gradient(135deg, #10B981, #065F46);
    border: 2px solid #A7F3D0;
    color: white;
}
.maze-cell.start {
    background: linear-gradient(135deg, #FDF2F8, #FCE7F3);
    border: 2px dashed #EC4899;
}
.maze-cell.end {
    background: linear-gradient(135deg, #FDE047, #F59E0B);
    border: 2px solid #FEF08A;
    animation: gold-pulse 1.2s infinite alternate;
}

@keyframes door-glow {
    0% { box-shadow: 0 0 5px rgba(244, 63, 94, 0.5); }
    100% { box-shadow: 0 0 15px rgba(244, 63, 94, 0.9); }
}
@keyframes player-pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 15px #EC4899; }
}
@keyframes gold-pulse {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(245, 158, 11, 0.6); }
    100% { transform: scale(1.05); box-shadow: 0 0 25px rgba(245, 158, 11, 1); }
}

/* Tactile Console D-pad */
.maze-controls-layout {
    margin-top: 15px;
    position: relative;
    width: 150px;
    height: 150px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}
.maze-controls-layout .ctrl-btn {
    position: absolute;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
    font-weight: bold;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.maze-controls-layout .ctrl-btn:active {
    transform: scale(0.9);
    background: #e2e8f0;
}
#ctrl-up { top: 0; left: 50%; transform: translateX(-50%); }
#ctrl-up:active { transform: translateX(-50%) scale(0.9); }
#ctrl-down { bottom: 0; left: 50%; transform: translateX(-50%); }
#ctrl-down:active { transform: translateX(-50%) scale(0.9); }
#ctrl-left { left: 0; top: 50%; transform: translateY(-50%); }
#ctrl-left:active { transform: translateY(-50%) scale(0.9); }
#ctrl-right { right: 0; top: 50%; transform: translateY(-50%); }
#ctrl-right:active { transform: translateY(-50%) scale(0.9); }

@media (max-width: 768px) {
    .maze-board {
        --cell-size: 25px;
        --cell-gap: 2px;
        padding: 8px;
    }
    #maze-player {
        --cell-size: 25px;
        --cell-gap: 2px;
    }
}

/* --- Professional Game Effects & SVGs --- */
.game-bg-waves {
    background: linear-gradient(to bottom, #0ea5e9 0%, #38bdf8 100%);
    position: relative;
}
.game-bg-waves::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 120px;
    background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1440 320" xmlns="http://www.w3.org/2000/svg"><path fill="%23ffffff" fill-opacity="0.3" d="M0,160L48,170.7C96,181,192,203,288,202.7C384,203,480,181,576,149.3C672,117,768,75,864,69.3C960,64,1056,96,1152,117.3C1248,139,1344,149,1392,154.7L1440,160L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path></svg>') bottom/cover no-repeat;
    animation: wave-slide 10s linear infinite;
    pointer-events: none;
}

@keyframes wave-slide {
    0% { background-position-x: 0; }
    100% { background-position-x: 1440px; }
}

.isometric-stairs {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    perspective: 1200px;
}

.stair-step {
    width: 250px;
    height: 60px;
    background: linear-gradient(135deg, #FFCBA4, #FF8BA7);
    transform: rotateX(60deg) rotateZ(45deg);
    transform-style: preserve-3d;
    box-shadow: 
      -15px 15px 0 #d86b87,
      -15px 15px 20px rgba(0,0,0,0.4);
    margin-top: -25px;
    transition: all 0.5s;
    position: relative;
    border: 1px solid #FFE4E1;
}

.car-sprite {
    width: 140px;
    height: 70px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 50"><path d="M10 30 h 80 v 10 h -80 z" fill="%23ef4444"/><circle cx="25" cy="40" r="10" fill="%231f2937"/><circle cx="75" cy="40" r="10" fill="%231f2937"/><path d="M20 30 l 10 -15 h 30 l 15 15 z" fill="%23b91c1c"/><rect x="40" y="18" width="10" height="10" fill="%2360a5fa" opacity="0.8"/></svg>') no-repeat center/contain;
    filter: drop-shadow(0 15px 10px rgba(0,0,0,0.4));
}

.exhaust-flame {
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 20px;
    background: radial-gradient(ellipse at right, #fbbf24, #ef4444, transparent);
    animation: flicker 0.1s infinite alternate;
}

@keyframes flicker {
    0% { opacity: 0.7; transform: translateY(-50%) scaleX(0.8); }
    100% { opacity: 1; transform: translateY(-50%) scaleX(1.2); }
}

.particle-explosion {
    position: absolute;
    pointer-events: none;
    width: 12px;
    height: 12px;
    background: #fbbf24;
    border-radius: 50%;
    animation: popOut 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    z-index: 100;
}

@keyframes popOut {
    0% { transform: scale(1) translate(0,0); opacity: 1; }
    100% { transform: scale(0) translate(var(--tx), var(--ty)); opacity: 0; }
}

.target-broken {
    animation: breakApart 0.6s forwards;
}

@keyframes breakApart {
    0% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 10px red); }
    100% { transform: scale(1.5) rotate(45deg); opacity: 0; filter: grayscale(1); }
}

/* Character Animation for Stairs */
.runner-char {
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 20;
    filter: drop-shadow(0 10px 5px rgba(0,0,0,0.5));
}

/* Fishing Hook Enhancements */
.fishing-line {
    background: linear-gradient(to right, #9ca3af, #f3f4f6, #9ca3af);
    box-shadow: 0 0 5px rgba(255,255,255,0.8);
}

/* Flash Screen for Errors */
.flash-error {
    animation: flashRed 0.5s;
}
@keyframes flashRed {
    0% { box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: inset 0 0 50px 20px rgba(239, 68, 68, 0.5); }
    100% { box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* --- Enchanted Butterfly Theme UI Styles --- */
.butterfly-bg {
    background: linear-gradient(135deg, #FFF0F7 0%, #F5F0FF 40%, #EEF2FF 70%, #FFF5EB 100%);
    background-image: 
        radial-gradient(rgba(236, 72, 153, 0.08) 15%, transparent 15%), 
        radial-gradient(rgba(168, 85, 247, 0.08) 15%, transparent 15%);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
}

.butterfly-header {
    position: relative;
    z-index: 10;
}

/* Butterfly Wing Flutter Animation */
@keyframes butterflyFlutter {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.04) rotate(-3deg) translateY(-4px); }
    75% { transform: scale(1.04) rotate(3deg) translateY(-2px); }
}

@keyframes fairyGlow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(236, 72, 153, 0.4)); }
    50% { filter: drop-shadow(0 0 25px rgba(168, 85, 247, 0.8)); }
}

@keyframes sparkleFloat {
    0% { transform: translateY(0px) rotate(0deg) scale(0.8); opacity: 0.3; }
    50% { transform: translateY(-20px) rotate(180deg) scale(1.1); opacity: 0.9; }
    100% { transform: translateY(0px) rotate(360deg) scale(0.8); opacity: 0.3; }
}

.butterfly-glow {
    animation: fairyGlow 3s infinite alternate ease-in-out;
}

/* --- Luxury Unit Cards (تصميم بطاقات الوحدات الفاخرة المندمجة) --- */
.unit-card-luxury {
    position: relative;
    border-radius: 28px;
    background: #FFFFFF;
    border: 2px solid #FCE7F3;
    box-shadow: 0 10px 25px rgba(236, 72, 153, 0.08), 0 4px 10px rgba(0, 0, 0, 0.02);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.unit-card-luxury:hover {
    transform: translateY(-8px);
    border-color: #F472B6;
    box-shadow: 0 20px 40px rgba(236, 72, 153, 0.18), 0 8px 20px rgba(168, 85, 247, 0.12);
}

.unit-hero-cover {
    position: relative;
    width: 100%;
    height: 190px;
    overflow: hidden;
    background: #231238;
}

.unit-hero-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.unit-card-luxury:hover .unit-hero-cover img {
    transform: scale(1.09);
}

.unit-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 7, 26, 0.85) 0%, rgba(15, 7, 26, 0.2) 60%, transparent 100%);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 16px 20px;
}

/* --- Luxury Lesson Capsules (كبسولات الدروس الانسيابية الدائرية) --- */
.lesson-capsule-luxury {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    border-radius: 26px;
    border: 2.5px solid #FCE7F3;
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.08), 0 3px 8px rgba(0, 0, 0, 0.02);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.lesson-capsule-luxury:hover {
    transform: scale(1.03) translateY(-3px);
    border-color: #EC4899;
    background: #FFFFFF;
    box-shadow: 0 16px 32px rgba(236, 72, 153, 0.2), 0 6px 14px rgba(168, 85, 247, 0.12);
}

.lesson-avatar-circle {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 3px solid #F472B6;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
    background: #2A1B40;
    position: relative;
    transition: transform 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.lesson-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.5s ease;
}

.lesson-capsule-luxury:hover .lesson-avatar-circle {
    transform: scale(1.08) rotate(-4deg);
    border-color: #A855F7;
    box-shadow: 0 6px 18px rgba(168, 85, 247, 0.4);
}

.lesson-capsule-luxury:hover .lesson-avatar-circle img {
    transform: scale(1.15);
}

.lesson-action-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FDE047, #F59E0B);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3E2723;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    border: 2px solid #FFFFFF;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.lesson-capsule-luxury:hover .lesson-action-btn {
    transform: scale(1.12) rotate(10deg);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.55);
}

/* Butterfly Trail Container */
.butterfly-trail-container {
    position: relative;
    padding: 30px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.butterfly-trail-container::before {
    content: '';
    position: absolute;
    top: 20px;
    bottom: 20px;
    left: 50%;
    width: 6px;
    transform: translateX(-50%);
    background: repeating-linear-gradient(
        to bottom,
        #F472B6,
        #F472B6 14px,
        transparent 14px,
        transparent 28px
    );
    border-radius: 4px;
    opacity: 0.4;
    z-index: 0;
}

/* Floating Fairy Particles */
.fairy-sparkle {
    position: absolute;
    pointer-events: none;
    font-size: 1.2rem;
    animation: sparkleFloat 4s infinite ease-in-out;
}
