/* ===== Game Area ===== */
.game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--color-bg), var(--color-bg-surface));
    background-size: cover;
    background-position: center;
    transition: background 0.5s ease;
}

/* ===== GAME 1: Balloon Pop 🎈 ===== */
.balloon {
    position: absolute;
    bottom: -100px;
    width: 60px;
    height: 75px;
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    cursor: default;
    transition: transform 0.1s;
    box-shadow: inset -3px -3px 8px rgba(0,0,0,0.15), 2px 2px 6px rgba(0,0,0,0.1);
}

.balloon::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: rgba(0,0,0,0.2);
    transform: translateX(-50%);
}

.balloon.popped {
    transform: scale(1.5);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.175,0.885,0.32,1.275);
}

/* ===== GAME 2: Whack-a-Mole 🐹 ===== */
.mole-grid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10%;
    box-sizing: border-box;
    flex-wrap: wrap;
    align-content: center;
    gap: 30px;
}

.mole-hole {
    position: relative;
    width: 140px;
    height: 140px;
    overflow: hidden;
}

/* The actual hole (ellipse) */
.mole-hole::before {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 120px;
    height: 40px;
    background: #3e2723;
    border-radius: 50%;
    box-shadow: 
        inset 0 10px 15px rgba(0,0,0,0.8),
        0 4px 0 #5d4037;
    z-index: 1;
}

/* Front lip of the hole to cover mole */
.mole-hole::after {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 120px;
    height: 20px;
    background: transparent;
    border-radius: 50%;
    box-shadow: 0 10px 0 #5d4037;
    z-index: 3;
}

.mole {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 100px;
    height: 100px;
    background-image: url('../assets/img/mole.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom;
    z-index: 2;
    transform: translateY(120px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mole.up {
    transform: translateY(0);
}

.mole.whacked {
    transform: translateY(20px) scaleY(0.6);
    filter: brightness(0.5);
    transition: transform 0.1s ease-out;
}

.mole-letter {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 3px solid #6d4c41;
    border-radius: 8px;
    padding: 2px 12px;
    font-size: 2rem;
    font-weight: 900;
    color: #3e2723;
    box-shadow: 0 4px 0 #6d4c41;
    text-shadow: none;
}

.hammer {
    position: absolute;
    width: 80px;
    height: 80px;
    background-image: url('../assets/img/hammer.svg');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 10;
    top: -20px;
    right: -20px;
    transform-origin: bottom right;
    transform: rotate(45deg);
    animation: whackAnim 0.15s ease-in forwards;
}

@keyframes whackAnim {
    0% { transform: rotate(45deg); }
    100% { transform: rotate(-45deg); }
}

/* ===== GAME 3: Typing Runner 🏎️ ===== */
.game-area.runner-bg {
    background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 60%, #90EE90 100%) !important;
    overflow: hidden;
}

/* Clouds background for parallax */
.game-area.runner-bg::before {
    content: '☁️ \u00A0 \u00A0 \u00A0 ☁️ \u00A0 \u00A0 \u00A0 \u00A0 \u00A0 ☁️';
    position: absolute;
    top: 20px;
    left: 0;
    width: 200%;
    font-size: 3rem;
    color: white;
    opacity: 0.8;
    animation: moveTrack 20s linear infinite;
    pointer-events: none;
}

.runner-track {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    height: 60px;
    background: #7f8fa6;
    border-top: 4px solid #dcdde1;
    border-bottom: 4px solid #dcdde1;
    box-shadow: inset 0 20px 20px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* Moving dashed line */
.runner-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 200%;
    height: 4px;
    background-image: linear-gradient(90deg, #fbc531 50%, transparent 50%);
    background-size: 60px 100%;
    transform: translateY(-50%);
    animation: moveTrack 0.3s linear infinite;
}

@keyframes moveTrack {
    0% { transform: translateY(-50%) translateX(0); }
    100% { transform: translateY(-50%) translateX(-60px); }
}

.runner-char {
    position: absolute;
    bottom: 50px;
    left: 100px;
    width: 120px;
    height: 100px;
    background-image: url('../assets/img/kart.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom;
    z-index: 10;
    /* Gentle bobbing while driving */
    animation: kartBob 0.4s infinite alternate;
}

@keyframes kartBob {
    0% { bottom: 50px; }
    100% { bottom: 52px; }
}

.runner-char.jump {
    animation: kartJump 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes kartJump {
    0% { transform: translateY(0) rotate(0deg); }
    40% { transform: translateY(-120px) rotate(-15deg); }
    60% { transform: translateY(-120px) rotate(15deg); }
    100% { transform: translateY(0) rotate(360deg); } /* Full flip! */
}

.runner-char.stumble {
    transform: rotate(15deg);
    filter: grayscale(0.3);
    transition: all 0.2s;
}

/* Traffic Cone style for Hurdle */
.hurdle {
    position: absolute;
    bottom: 60px;
    width: 50px;
    height: 60px;
    background: linear-gradient(to right, #ff7f50, #ff6348, #ff7f50);
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 15px;
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 0px #333;
    z-index: 5;
}

.hurdle::after {
    content: '';
    position: absolute;
    top: 30%;
    left: 0;
    width: 100%;
    height: 25%;
    background: #fff;
    opacity: 0.9;
    z-index: -1;
}

.hurdle.cleared {
    opacity: 0;
    transform: translateY(-50px) rotate(180deg) scale(1.5);
    transition: all 0.4s ease-out;
}

/* ===== GAME 4: Space Defender 🛸 ===== */
.game-area.space-bg {
    background: #0f0c29 !important;
}

/* Starfield effect */
.game-area.space-bg::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background-image: 
      radial-gradient(1px 1px at 20px 30px, #fff, rgba(0,0,0,0)),
      radial-gradient(1.5px 1.5px at 40px 70px, #fff, rgba(0,0,0,0)),
      radial-gradient(1px 1px at 50px 160px, #fff, rgba(0,0,0,0)),
      radial-gradient(2px 2px at 90px 40px, #fff, rgba(0,0,0,0)),
      radial-gradient(1px 1px at 130px 80px, #fff, rgba(0,0,0,0)),
      radial-gradient(1.5px 1.5px at 160px 120px, #fff, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: rotateStars 100s linear infinite;
    opacity: 0.5;
    pointer-events: none;
}

@keyframes rotateStars {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.space-ship {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 120px;
    background-image: url('../assets/img/space.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 10;
    transition: transform 0.1s;
    filter: drop-shadow(0 0 10px rgba(0, 206, 201, 0.5));
}

.asteroid {
    position: absolute;
    width: 70px;
    height: 70px;
    background-image: url('../assets/img/asteroid.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 2px 2px 0px #000, -1px -1px 0px #000;
    z-index: 5;
    animation: slowSpin 10s linear infinite;
}

@keyframes slowSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.asteroid .letter-wrap {
    /* Counter-rotate so letter stays upright */
    animation: counterSpin 10s linear infinite;
}

@keyframes counterSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

.asteroid.destroyed {
    animation: explosion 0.3s ease-out forwards;
}

@keyframes explosion {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.5); filter: brightness(3) hue-rotate(90deg); }
    100% { transform: scale(2); opacity: 0; filter: brightness(5); }
}

.laser {
    position: absolute;
    width: 6px;
    background: #00e5ff;
    border-radius: 3px;
    box-shadow: 0 0 10px #00e5ff, 0 0 20px #00e5ff, 0 0 30px #fff;
    transform-origin: bottom center;
    z-index: 8;
    opacity: 0;
    animation: fireLaser 0.15s ease-out;
}

@keyframes fireLaser {
    0% { opacity: 1; transform: rotate(var(--angle)) scaleY(0); }
    50% { opacity: 1; transform: rotate(var(--angle)) scaleY(1); }
    100% { opacity: 0; transform: rotate(var(--angle)) scaleY(1); }
}


/* ===== Game Card Style on Map ===== */
.lesson-card.game-card {
    background: linear-gradient(135deg, var(--color-accent-soft), #ffe4e6);
    border-color: var(--color-accent);
}
.lesson-card.game-card .lesson-num {
    font-size: 2.2rem;
}
