:root {
    /* Color Palette - Solar City Style */
    --sky-color: #4EE2EC;
    /* Bright Cyan Sky */
    --ground-color: #5D4037;
    /* Dark Earth */
    --building-1: #FFB74D;
    /* Orange */
    --building-2: #FFF176;
    /* Yellow */
    --building-3: #FF8A65;
    /* Darker Orange */
    --ui-text: #FFFFFF;
    --ui-accent: #6200EA;
    /* Deep Purple for buttons */
    --ui-accent-hover: #7C4DFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    /* Prevent selection while playing */
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--sky-color);
    font-family: 'Rubik', sans-serif;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Layers */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas if needed, but screens will override */
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s;
    pointer-events: auto;
    /* Re-enable clicks for UI elements */
}

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

/* Typography & HUD */
.title-block h1 {
    font-size: 4rem;
    color: #FFF;
    text-align: center;
    line-height: 1.1;
    text-shadow: 4px 4px 0px #000;
    transform: skew(-5deg);
    margin-bottom: 2rem;
}

#goals-container {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 16px;
    border-radius: 20px;
    display: flex;
    gap: 15px;
    z-index: 10;
}

.goal-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #FFF;
    font-weight: 700;
    font-size: 1rem;
}

.goal-icon {
    font-size: 1.2rem;
}

.goal-item.complete span:not(.goal-icon) {
    color: #4CAF50;
}

@keyframes goal-complete {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

#hud {
    position: absolute;
    top: 50px;
    left: 12px;
    right: 100px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    pointer-events: none;
}

#menu-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    pointer-events: all;
    padding: 6px 14px;
    font-size: 0.9rem;
}

.score-container {
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 20px;
    color: #FFF;
    font-weight: 900;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.score-container .label {
    font-size: 0.65rem;
    opacity: 0.8;
    font-weight: 400;
    margin-bottom: 1px;
}

.health-container {
    min-width: 100px;
}

.hearts {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    min-height: 20px;
}

.heart {
    font-size: 1.1rem;
    line-height: 1;
    color: #E53935;
    text-shadow: 1px 1px 0 #000;
}

.heart.empty {
    color: rgba(255, 255, 255, 0.35);
}

.primary-btn.outline {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.7);
    box-shadow: none;
}

.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.menu-screen.hidden {
    opacity: 0;
}

.menu-screen:not(.hidden) {
    pointer-events: auto;
    opacity: 1;
}

.menu-content {
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.6);
    padding: 30px;
    border-radius: 22px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.menu-content h3 {
    margin: 0;
    font-size: 2rem;
    text-transform: uppercase;
}

@media (max-width: 900px) {
    #hud {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .score-container {
        min-width: 90px;
        padding: 8px 14px;
        font-size: 1.2rem;
    }

    .score-container .label {
        font-size: 0.7rem;
    }

    .health-container {
        min-width: 120px;
    }

    .hearts {
        gap: 4px;
        min-height: 22px;
    }

    .heart {
        font-size: 1.2rem;
    }
}

@media (max-width: 600px) {
    .title-block h1 {
        font-size: 2.6rem;
    }

    .primary-btn {
        font-size: 1.2rem;
        padding: 12px 30px;
    }

    .instructions {
        font-size: 1rem;
    }
}

@media (orientation: portrait) {
    .title-block h1 {
        font-size: 3rem;
        margin-bottom: 1rem;
    }

    #goals-container {
        top: 8px;
        padding: 5px 12px;
        gap: 12px;
    }

    .goal-item {
        font-size: 0.9rem;
    }

    .goal-icon {
        font-size: 1rem;
    }

    #hud {
        top: 45px;
        left: 10px;
        right: 70px;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    #menu-btn {
        top: 8px;
        right: 10px;
        padding: 5px 12px;
        font-size: 0.9rem;
    }

    .score-container {
        min-width: 80px;
        padding: 5px 12px;
        font-size: 1rem;
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
    }

    .score-container .label {
        margin-bottom: 0;
    }

    .health-container {
        min-width: 110px;
    }
}

@media (max-width: 400px) {
    .title-block h1 {
        font-size: 2.2rem;
    }

    .score-container {
        font-size: 0.9rem;
    }
}

/* Mobile Landscape - small height screens */
@media (max-height: 500px) and (orientation: landscape) {
    #goals-container {
        top: 5px;
        padding: 4px 10px;
        gap: 10px;
    }

    .goal-item {
        font-size: 0.8rem;
        gap: 3px;
    }

    .goal-icon {
        font-size: 0.9rem;
    }

    #hud {
        top: 35px;
        left: 10px;
        right: 70px;
        gap: 6px;
    }

    .score-container {
        min-width: 55px;
        padding: 3px 8px;
        font-size: 0.85rem;
        border-radius: 15px;
    }

    .score-container .label {
        font-size: 0.5rem;
        margin-bottom: 0;
    }

    .health-container {
        min-width: 80px;
    }

    .hearts {
        gap: 2px;
        min-height: 16px;
    }

    .heart {
        font-size: 0.85rem;
    }

    #menu-btn {
        top: 5px;
        right: 8px;
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .title-block h1 {
        font-size: 2rem;
        margin-bottom: 0.8rem;
    }

    .primary-btn {
        padding: 10px 25px;
        font-size: 1.1rem;
    }

    .instructions {
        font-size: 0.9rem;
        margin-top: 10px;
    }
}

/* Buttons */
.primary-btn {
    background: var(--ui-accent);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #311B92;
    transition: transform 0.1s, background 0.2s;
    font-family: 'Rubik', sans-serif;
    text-transform: uppercase;
}

.primary-btn:hover {
    background: var(--ui-accent-hover);
    transform: translateY(-2px);
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #311B92;
}

.instructions {
    margin-top: 20px;
    color: white;
    font-size: 1.2rem;
    text-align: center;
    opacity: 0.9;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

#game-over-screen h2 {
    font-size: 3rem;
    color: #FF5252;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 1rem;
    text-align: center;
}

#win-screen .win-title {
    font-size: 3rem;
    color: #4CAF50;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 1rem;
    text-align: center;
}

.final-score {
    font-size: 2rem;
    color: white;
    margin-bottom: 2rem;
    font-weight: bold;
}