/* ============================================
   ALIEN COUNTING - GAME STYLES
   ============================================ */

:root {
    --space-dark: #0a0a1a;
    --space-purple: #1a1a3a;
    --accent-cyan: #4ecdc4;
    --accent-pink: #ff6b6b;
    --accent-gold: #ffd166;
    --accent-purple-light: #c77dff;
    --accent-purple-dark: #7b2cbf;
    --font-main: 'Nunito', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: radial-gradient(
        ellipse at 50% 50%,
        #2a1a4e 0%,
        var(--space-purple) 30%,
        var(--space-dark) 70%,
        #050510 100%
    );
}

/* Background Canvas */
#game-bg {
    position: fixed;
    bottom: 20px;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Game Container */
.game-container {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 30px;
    background: rgba(10, 10, 30, 0.7);
    border-bottom: 2px solid rgba(199, 125, 255, 0.3);
    position: relative;
}

.question-box {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.score-box {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
}

.question-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 2px;
}

#question-text {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 900;
    color: white;
    text-shadow: 0 0 10px rgba(199, 125, 255, 0.5);
}

.score-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.belly-bars {
    display: flex;
    gap: 4px;
}

.belly-bar {
    width: 16px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--accent-purple-light);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.belly-bar.fed {
    background: linear-gradient(to top, var(--accent-purple-dark), var(--accent-purple-light));
    box-shadow: 0 0 8px rgba(199, 125, 255, 0.4);
}

.score-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    min-width: 60px;
    text-align: right;
}

/* Game Area */
.game-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

/* Speech Bubble */
.speech-bubble {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 15px 25px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: bubblePop 0.4s ease-out;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

#alien-request {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--space-dark);
}

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

/* Alien Wrapper: holds alien + tummy together */
.alien-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Alien */
.alien-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
}

.alien {
    width: 300px;
    height: 315px;
    filter: drop-shadow(0 0 30px rgba(199, 125, 255, 0.5));
    user-drag: none;
    -webkit-user-drag: none;
    transition: transform 0.3s ease;
}

/* Alien mouth — the drop target */
.alien-mouth {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 96px;
    border-radius: 50%;
    border: 0;
    pointer-events: none;
    z-index: 8;
}

.alien-mouth.hungry {
    box-shadow: none;
    animation: none;
}

@keyframes mouthPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}

/* Alien Tummy: visible belly where fed biscuits are collected */
.alien-tummy {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    min-height: 96px;
    background: radial-gradient(circle, rgba(10, 10, 30, 0.72), rgba(123, 44, 191, 0.38));
    border: 2px solid rgba(255, 209, 102, 0.7);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    z-index: 6;
    transition: all 0.4s ease;
    box-shadow: inset 0 0 20px rgba(199, 125, 255, 0.1);
}

.alien-tummy.has-biscuits {
    border-color: var(--accent-gold);
    background: radial-gradient(circle, rgba(10, 10, 30, 0.74), rgba(123, 44, 191, 0.44));
    box-shadow: 0 0 25px rgba(255, 209, 102, 0.2), inset 0 0 20px rgba(255, 209, 102, 0.05);
    animation: tummyGlow 2s ease-in-out infinite;
}

.speech-bubble.feedback {
    max-width: min(420px, calc(100vw - 32px));
    border: 3px solid rgba(255, 209, 102, 0.85);
    box-shadow: 0 0 24px rgba(255, 209, 102, 0.28), 0 4px 15px rgba(0, 0, 0, 0.3);
}

@keyframes tummyGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 209, 102, 0.15), inset 0 0 20px rgba(255, 209, 102, 0.03); }
    50% { box-shadow: 0 0 35px rgba(255, 209, 102, 0.25), inset 0 0 20px rgba(255, 209, 102, 0.08); }
}

/* Tummy label */
.alien-tummy::before {
    content: none;
}

/* Container for the fed biscuits inside tummy */
.tummy-biscuits {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-height: 40px;
}

/* Fed rocks inside the tummy */
.tummy-biscuits .game-rock.fed {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: 28px;
    height: 28px;
    opacity: 1;
    transform: none;
    filter: drop-shadow(0 0 4px rgba(255, 209, 102, 0.5));
    pointer-events: auto;
    cursor: pointer;
    animation: moonPop 0.4s ease-out;
}

@keyframes moonPop {
    0% { transform: scale(0) rotate(-20deg); }
    60% { transform: scale(1.3) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Alien happy animation */
.alien.happy {
    animation: alienHappy 0.5s ease-in-out;
}

@keyframes alienHappy {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.15) rotate(-5deg); }
    50% { transform: scale(1.15) rotate(5deg); }
    75% { transform: scale(1.15) rotate(-5deg); }
}

/* Alien sad/shake animation */
.alien.sad {
    animation: alienSad 0.4s ease-in-out;
}

@keyframes alienSad {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
    75% { transform: translateX(-10px); }
}

/* Rocks Tray */
.rocks-tray {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px;
    background: rgba(10, 10, 30, 0.6);
    border-top: 2px solid rgba(199, 125, 255, 0.2);
    min-height: 100px;
    max-height: 220px;
    overflow-y: auto;
}

/* Draggable Rocks — NO NUMBERS, just plain moon icons */
.game-rock {
    width: 50px;
    height: 50px;
    position: relative;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    transition: transform 0.1s ease;
}

.game-rock:active {
    cursor: grabbing;
}

.game-rock.dragging {
    position: fixed;
    bottom: 20px;
    z-index: 100;
    pointer-events: none;
    transform: scale(1.3);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}

.game-rock.returning {
    transition: all 0.4s ease-out;
}

/* Fed rocks — stay visible near the alien so kids can count them */
.game-rock.fed {
    position: fixed !important;
    z-index: 5;
    opacity: 0.85;
    transform: scale(0.85);
    pointer-events: auto;
    filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.3));
}

.game-rock img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.4));
    pointer-events: none;
    user-drag: none;
    -webkit-user-drag: none;
}

/* Message - positioned right NEXT to the alien's MOUTH */
/* NO transform on the outer element — that causes the jump!
   We position with top/left only, and animate scale on a child. */
.message {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Little speech tail pointing back to the alien's mouth */
.message::before {
    content: none;
}

.message.show {
    opacity: 0;
}

/* Clean animation: only scale and opacity, NO translateY! */
@keyframes messagePop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Overlays */
.overlay {
    position: fixed;
    bottom: 20px;
    inset: 0;
    background: rgba(5, 5, 16, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    max-width: 500px;
    max-height: 92vh;
    overflow-y: auto;
}

.overlay-alien {
    width: 100px;
    height: 100px;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(199, 125, 255, 0.4));
}

.overlay h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: var(--accent-purple-light);
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(199, 125, 255, 0.3);
}

.overlay p {
    font-size: 1.2rem;
    color: white;
    margin-bottom: 10px;
    line-height: 1.5;
}

.game-desc {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.6;
    max-width: 480px;
    margin: 0 auto 20px;
}

/* Difficulty Selection Buttons */
.choose-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-top: 15px;
    letter-spacing: 1px;
}

.difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.diff-btn {
    padding: 18px 28px;
    border-radius: 20px;
    border: 2px solid;
    font-family: var(--font-main);
    font-size: 1.25rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
    color: white;
    background: transparent;
}

.diff-btn span {
    font-size: 0.95rem;
    font-weight: 400;
    opacity: 0.8;
    display: block;
    margin-top: 4px;
}

.diff-btn:hover {
    transform: scale(1.08);
}

/* Easy: Light Purple */
.diff-easy {
    border-color: var(--accent-purple-light);
    background: rgba(199, 125, 255, 0.15);
    box-shadow: 0 0 15px rgba(199, 125, 255, 0.2);
}

.diff-easy:hover {
    background: rgba(199, 125, 255, 0.3);
    box-shadow: 0 0 25px rgba(199, 125, 255, 0.4);
}

/* Medium: Medium Purple */
.diff-medium {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.15);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

.diff-medium:hover {
    background: rgba(168, 85, 247, 0.3);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.4);
}

/* Hard: Deep Purple */
.diff-hard {
    border-color: var(--accent-purple-dark);
    background: rgba(123, 44, 191, 0.15);
    box-shadow: 0 0 15px rgba(123, 44, 191, 0.2);
}

.diff-hard:hover {
    background: rgba(123, 44, 191, 0.3);
    box-shadow: 0 0 25px rgba(123, 44, 191, 0.4);
}

.launch-btn {
    display: inline-block;
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: 900;
    font-family: var(--font-main);
    color: var(--space-dark);
    background: linear-gradient(135deg, var(--accent-purple-light), var(--accent-purple-dark));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(199, 125, 255, 0.4);
    transition: all 0.3s ease;
}

.launch-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(199, 125, 255, 0.6);
}

.home-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-cyan);
    text-decoration: none;
    border: 2px solid var(--accent-cyan);
    border-radius: 50px;
    transition: all 0.3s ease;
}

.home-btn:hover {
    background: var(--accent-cyan);
    color: var(--space-dark);
}

/* Win Screen */
.win-rocket {
    margin: 20px 0;
    animation: launch 2s ease-in-out infinite;
}

.win-rocket img {
    width: 80px;
    height: 80px;
}

@keyframes launch {
    0%, 100% { transform: translateY(6px) rotate(-90deg); }
    50% { transform: translateY(-20px) rotate(-90deg); }
}

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

/* Responsive */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 15px;
    }

    .question-box {
        text-align: center;
    }

    .score-box {
        position: static;
        transform: none;
        order: -1;
    }

    .alien {
        width: 220px;
        height: 231px;
    }

    .alien-tummy {
        bottom: 16px;
        width: 140px;
        min-height: 76px;
        padding: 8px;
    }

    .alien-mouth {
        width: 140px;
        height: 76px;
        bottom: 16px;
    }

    .tummy-biscuits {
        gap: 2px;
        min-height: 32px;
    }

    .tummy-biscuits .game-rock.fed {
        width: 21px;
        height: 21px;
    }

    .speech-bubble.feedback {
        padding: 10px 14px;
    }

    .speech-bubble.feedback #alien-request {
        font-size: 1rem;
        line-height: 1.3;
    }

    .game-rock {
        width: 42px;
        height: 42px;
    }

    .rocks-tray {
        gap: 8px;
        min-height: 142px;
        padding: 10px 10px max(58px, calc(env(safe-area-inset-bottom) + 50px));
    }

    .difficulty-buttons {
        gap: 12px;
    }

    .diff-btn {
        padding: 14px 20px;
        font-size: 1.1rem;
        min-width: 130px;
    }

    .speech-bubble {
        padding: 10px 18px;
        margin-bottom: 15px;
    }

    #alien-request {
        font-size: 1.1rem;
    }

}

/* ============================================
   EXIT BUTTON — Bottom Right Corner
   ============================================ */
.exit-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    padding: 8px 16px;
    border-radius: 24px;
    background: rgba(10, 10, 30, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.exit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.check-btn {
    margin-top: 16px;
    padding: 10px 22px;
    border-radius: 24px;
    background: rgba(34, 197, 94, 0.25);
    border: 2px solid rgba(34, 197, 94, 0.5);
    font-family: 'Nunito', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.check-btn:hover {
    background: rgba(34, 197, 94, 0.4);
    border-color: rgba(34, 197, 94, 0.8);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.check-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 600px) {
    .exit-btn {
        bottom: 12px;
        right: 12px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .check-btn {
        padding: 8px 18px;
        font-size: 0.95rem;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .alien {
        width: 180px;
        height: 189px;
    }

    .alien-tummy {
        bottom: 12px;
        width: 114px;
        min-height: 62px;
        padding: 6px;
    }

    .alien-mouth {
        bottom: 12px;
        width: 114px;
        height: 62px;
    }

    .tummy-biscuits .game-rock.fed {
        width: 17px;
        height: 17px;
    }

    .game-rock {
        width: 36px;
        height: 36px;
    }

    .question-box {
        font-size: 1.2rem;
    }

    .score-box {
        font-size: 0.85rem;
    }
}



/* Short landscape screens (Nest Hub, landscape phones, small tablets) */
@media (max-width: 1050px) {
    .game-header {
        flex-direction: column;
        gap: 6px;
        padding: 12px 18px;
    }

    .score-box {
        position: static;
        transform: none;
        order: -1;
        justify-content: center;
    }

    #question-text {
        font-size: clamp(1.35rem, 4vw, 2.25rem);
        line-height: 1.15;
    }
}

@media (max-height: 640px) {
    .game-container {
        padding: 8px;
    }

    .game-header {
        padding: 8px 14px;
        margin-bottom: 8px;
    }

    .message {
        margin-bottom: 6px;
        min-height: 22px;
        font-size: 0.95rem;
    }
}
