/* ============================================
   COMET CATCHER - GAME STYLES
   ============================================ */

:root {
    --space-dark: #0a0a1a;
    --space-purple: #1a1a3a;
    --accent-cyan: #4ecdc4;
    --accent-pink: #ff6b6b;
    --accent-gold: #ffd166;
    --accent-orange: #ff9e00;
    --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%,
        #1a1a4e 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(255, 107, 107, 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(255, 107, 107, 0.5);
}

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

.score-stars {
    display: flex;
    gap: 4px;
}

.score-star {
    width: 24px;
    height: 24px;
    opacity: 0.2;
    transition: opacity 0.3s ease;
}

.score-star.lit {
    opacity: 1;
    filter: drop-shadow(0 0 6px var(--accent-gold));
}

.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;
    overflow: hidden;
    touch-action: none;
}

/* Flying Comets */
.game-comet {
    position: absolute;
    width: 108px;
    height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.game-comet:hover {
    transform: scale(1.15);
}

.game-comet img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 12px rgba(255, 158, 0, 0.6));
    user-drag: none;
    -webkit-user-drag: none;
    pointer-events: none;
    transform: rotate(45deg);
}

/* Flip comet image so it faces the direction it is flying */
.comet-flipped img {
    transform: scaleX(-1) rotate(45deg);
}

.comet-number {
    position: absolute;
    top: 50%;
    left: 40%;
    transform: translate(-50%, -50%);
    font-size: 1.9rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.comet-flipped .comet-number {
    left: 64%;
}

/* Comet trail effect */
.comet-trail {
    position: absolute;
    right: 80%;
    top: 50%;
    width: 60px;
    height: 4px;
    background: linear-gradient(to left, rgba(255, 158, 0, 0.6), transparent);
    border-radius: 2px;
    pointer-events: none;
}

/* Comet Animations */
@keyframes flyRight {
    from {
        left: -120px;
    }
    to {
        left: calc(100% + 120px);
    }
}

@keyframes flyLeft {
    from {
        left: calc(100% + 120px);
    }
    to {
        left: -120px;
    }
}

@keyframes flyRightFast {
    from {
        left: -120px;
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg);
    }
    to {
        left: calc(100% + 120px);
        transform: rotate(-5deg);
    }
}

@keyframes wobble {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes explode {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.comet-wrong {
    animation: wobble 0.3s ease-in-out !important;
}

.comet-correct {
    animation: explode 0.4s ease-out forwards !important;
}

/* Cannon Area */
.cannon-area {
    display: flex;
    justify-content: center;
    padding: 10px;
    background: rgba(10, 10, 30, 0.5);
}

.cannon {
    width: 70px;
    height: 70px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.15s ease-out;
    transform: rotate(-45deg); /* Rocket image is 45° right; rotate -45° to point straight up */
}

/* Laser Beam */
.laser {
    position: fixed;
    bottom: 20px;
    width: 4px;
    background: linear-gradient(to top, transparent, var(--accent-pink), #ffffff);
    z-index: 10;
    pointer-events: none;
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent-pink), 0 0 20px rgba(255, 107, 107, 0.5);
    animation: laserFade 0.3s ease-out forwards;
    transform-origin: top center;
}

@keyframes laserFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Message */
.message {
    position: fixed;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message.show {
    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-comet {
    width: 100px;
    height: 100px;
    margin-bottom: 20px;
    animation: float 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 158, 0, 0.4));
}

.overlay h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: var(--accent-orange);
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(255, 158, 0, 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;
}

.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-orange), #ff6b6b);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 158, 0, 0.4);
    transition: all 0.3s ease;
}

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

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

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

.diff-btn {
    padding: 22px 28px;
    border-radius: 20px;
    border: 3px solid;
    font-family: var(--font-main);
    font-size: 1.3rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
    min-height: 80px;
    color: white;
    background: transparent;
}

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

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

/* Easy: Soft Green */
.diff-easy {
    border-color: #7ee787;
    background: rgba(126, 231, 135, 0.15);
    box-shadow: 0 0 15px rgba(126, 231, 135, 0.2);
}

.diff-easy:hover {
    background: rgba(126, 231, 135, 0.3);
    box-shadow: 0 0 25px rgba(126, 231, 135, 0.4);
}

/* Medium: Warm Orange */
.diff-medium {
    border-color: #ff9e00;
    background: rgba(255, 158, 0, 0.15);
    box-shadow: 0 0 15px rgba(255, 158, 0, 0.2);
}

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

/* Hard: Deep Pink-Red */
.diff-hard {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.2);
}

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

.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(-10deg);
    }
    50% {
        transform: translateY(-20px) rotate(-10deg);
    }
}

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

/* 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;
    }

    .game-comet {
        width: 84px;
        height: 84px;
    }

    .comet-number {
        font-size: 1.5rem;
    }

    .score-star {
        width: 20px;
        height: 20px;
    }

    .difficulty-buttons {
        gap: 12px;
    }

    .diff-btn {
        padding: 18px 22px;
        font-size: 1.1rem;
        min-width: 120px;
        min-height: 70px;
    }
}

/* ============================================
   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);
}

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

/* Very small phones */
@media (max-width: 360px) {
    .game-comet {
        width: 68px;
        height: 68px;
    }

    .comet-number {
        font-size: 1.25rem;
    }

    .cannon {
        width: 55px;
        height: 55px;
    }

    .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-width: 600px) {
    .score-box {
        gap: 6px;
    }

    .score-stars {
        gap: 2px;
    }

    .score-star {
        width: 16px;
        height: 16px;
    }

    .score-text {
        min-width: 45px;
        font-size: 1rem;
    }
}

@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;
    }
}

.game-level {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-purple, #a855f7);
    letter-spacing: 1px;
}
