/* ===========================================
   Catch the Drops - Styles
   Mobile-first CSS
   =========================================== */

/* CSS Variables */
:root {
    /* Sky and atmosphere */
    --color-sky-light: #87CEEB;
    --color-sky-dark: #4A90A4;
    --color-cloud: #FFFFFF;

    /* Drops */
    --color-drop: #4FC3F7;
    --color-drop-shine: #B3E5FC;
    --color-splash: #81D4FA;

    /* Bucket */
    --color-bucket: #795548;
    --color-bucket-dark: #5D4037;
    --color-bucket-water: #29B6F6;

    /* UI */
    --color-ground: #8BC34A;
    --color-text: #FFFFFF;
    --color-text-shadow: #333333;
    --color-heart: #F44336;
    --color-button: #4CAF50;
    --color-button-hover: #45A049;
    --color-button-secondary: #2196F3;
    --color-button-secondary-hover: #1976D2;

    /* States */
    --color-overlay: rgba(0, 0, 0, 0.75);

    /* Sizing */
    --btn-min-height: 56px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --border-radius: 12px;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--color-sky-light) 0%, var(--color-sky-dark) 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    position: relative;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Canvas */
#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Screen management */
.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen.overlay {
    background: var(--color-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Menu Screen */
.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-lg);
    max-width: 320px;
    width: 100%;
}

.game-title {
    color: var(--color-text);
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    text-shadow: 3px 3px 0 var(--color-text-shadow);
    margin-bottom: var(--spacing-xl);
    line-height: 1.1;
}

.drop-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: var(--spacing-sm);
    animation: dropBounce 2s ease-in-out infinite;
}

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

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--btn-min-height);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--color-button);
    color: var(--color-text);
    box-shadow: 0 4px 0 #388E3C;
}

.btn-primary:hover {
    background: var(--color-button-hover);
}

.btn-primary:active {
    box-shadow: 0 2px 0 #388E3C;
    transform: translateY(2px) scale(0.98);
}

.btn-secondary {
    background: var(--color-button-secondary);
    color: var(--color-text);
    box-shadow: 0 4px 0 #1565C0;
}

.btn-secondary:hover {
    background: var(--color-button-secondary-hover);
}

.btn-secondary:active {
    box-shadow: 0 2px 0 #1565C0;
    transform: translateY(2px) scale(0.98);
}

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-text);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    font-size: 1.5rem;
    margin-right: var(--spacing-sm);
}

.btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.btn-text strong {
    font-size: 1.2rem;
}

.btn-text small {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 400;
}

/* High scores */
.highscores {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius);
    width: 100%;
}

.highscore-item {
    display: flex;
    justify-content: space-between;
    color: var(--color-text);
    font-size: 1rem;
    padding: var(--spacing-sm) 0;
}

.highscore-item span:last-child {
    font-weight: 700;
}

/* Overlay content (pause/gameover) */
.overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-xl);
    max-width: 300px;
    width: 90%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
}

.overlay-content h2 {
    color: var(--color-text);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    text-shadow: 2px 2px 0 var(--color-text-shadow);
}

.score-display {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    color: var(--color-text);
}

.score-display p {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-sm);
}

.final-score {
    font-size: 1.5rem !important;
    font-weight: 700;
}

.new-record {
    font-size: 1.3rem !important;
    color: #FFD700;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    z-index: 5;
    pointer-events: none;
}

#hud.hidden {
    display: none;
}

.hud-left, .hud-center, .hud-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.hud-left {
    justify-content: flex-start;
}

.hud-center {
    justify-content: center;
}

.hud-right {
    justify-content: flex-end;
}

.hud-score {
    color: var(--color-text);
    font-size: 1.3rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.hud-lives {
    font-size: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.btn-pause {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    font-size: 1.5rem;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease;
}

.btn-pause:hover {
    background: rgba(255, 255, 255, 0.4);
}

.btn-pause:active {
    background: rgba(255, 255, 255, 0.5);
}

/* Utility */
.hidden {
    display: none !important;
}

/* Fallback */
.fallback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--color-text);
    padding: var(--spacing-lg);
}

/* Safe area for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
    #hud {
        padding-top: max(var(--spacing-md), env(safe-area-inset-top));
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }
}

/* Tablet and desktop */
@media (min-width: 768px) {
    .game-title {
        font-size: 3.5rem;
    }

    .drop-icon {
        font-size: 4rem;
    }

    .menu-content {
        max-width: 400px;
    }

    .overlay-content {
        max-width: 400px;
    }

    .btn {
        min-height: 64px;
        font-size: 1.2rem;
    }

    .hud-score {
        font-size: 1.5rem;
    }

    .hud-lives {
        font-size: 1.8rem;
    }
}
