/* Charity: water Brand Colors

Primary Colors:
- Yellow:     #FFC907
- Blue:       #2E9DF7

Secondary Colors:
- Light Blue: #8BD1CB
- Green:      #4FCB53
- Orange:     #FF902A
- Red:        #F5402C
- Dark Green: #159A48
- Pink:       #F16061

*/

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
}

body {
    font-family: Arial, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #2E9DF7 0%, #8BD1CB 100%);
    height: 100vh;
    min-height: 100dvh;
}

img {
    max-width: 100%;
    height: auto;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Start Screen */
#startScreen {
    background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 100%);
    justify-content: center;
    align-items: center;
}

.start-container {
    text-align: center;
    z-index: 10;
}

.start-container h1 {
    font-size: 4rem;
    color: #000;
    text-shadow: 3px 3px 0px #FFC907;
    margin-bottom: 10px;
    font-weight: bold;
    letter-spacing: 2px;
}

.brand-text {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 10px;
    font-weight: bold;
}

.logo-placeholder {
    font-size: 2rem;
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    color: #2E9DF7;
    font-weight: bold;
}

.charity-logo {
    display: block;
    width: clamp(180px, 34vw, 340px);
    margin: 0 auto;
    object-fit: contain;
}

/* Drop Preview Container (Start Screen) */
.drop-preview-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 20px auto;
    border: 3px solid #FFC907;
    border-radius: 10px;
    background: linear-gradient(180deg, #B3E5FC 0%, #E1F5FE 100%);
    overflow: hidden;
}

.collect-btn {
    background: linear-gradient(135deg, #FFC907 0%, #FF902A 100%);
    color: #000;
    border: none;
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-top: 20px;
}

.collect-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.collect-btn:active {
    transform: scale(0.95);
}

.star-emoji {
    display: inline-block;
    animation: shimmer 1.5s ease-in-out infinite;
    margin: 0 10px;
}

@keyframes shimmer {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* Instruction Screen */
#instructionScreen {
    background: linear-gradient(135deg, #2E9DF7 0%, #8BD1CB 100%);
    justify-content: center;
    align-items: center;
}

.instruction-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: min(92vw, 500px);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.splash-text h2 {
    color: #2E9DF7;
    font-size: 2rem;
    margin-bottom: 10px;
}

.splash-text p {
    color: #333;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.instruction-box {
    background: #E8F4FD;
    padding: 20px;
    border-left: 5px solid #FFC907;
    margin: 20px 0;
    border-radius: 5px;
    text-align: left;
}

.instruction-box p {
    margin: 10px 0;
    color: #333;
    font-size: 1rem;
}

.continue-btn {
    background: linear-gradient(135deg, #4FCB53 0%, #159A48 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.continue-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Countdown Screen */
#countdownScreen {
    background: linear-gradient(135deg, #2E9DF7 0%, #8BD1CB 100%);
    justify-content: center;
    align-items: center;
}

.countdown-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.countdown-text {
    font-size: 8rem;
    font-weight: bold;
    color: #FFC907;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    animation: countdownPulse 1s ease-in-out;
}

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

/* Game Screen */
#gameScreen {
    background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 100%);
    justify-content: flex-start;
    align-items: flex-end;
}

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

.game-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #87CEEB 0%, #B3E5FC 50%, #E1F5FE 100%);
}

.drops-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.speed-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.94);
    z-index: 160;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border: 2px solid #FFC907;
    border-radius: 14px;
    padding: 16px 22px;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    width: min(92vw, 420px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.speed-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* HUD (Heads-Up Display) */
.hud {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hud-item {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.label {
    color: #2E9DF7;
    margin-right: 10px;
}

.hud-reset-btn {
    margin-top: 4px;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #F5402C 0%, #FF902A 100%);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.hud-reset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.25);
}

.hud-reset-btn:active {
    transform: translateY(0);
}

/* Heart Indicator */
.heart-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

#heartSvg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Bucket */
.bucket {
    position: absolute;
    top: calc(100% - 120px);
    left: 50%;
    z-index: 50;
    width: 100px;
    height: 100px;
    touch-action: none;
    object-fit: contain;
    -webkit-user-drag: none;
    cursor: grab;
}

.bucket-arrow {
    position: absolute;
    top: 18px;
    font-size: 1.7rem;
    font-weight: bold;
    color: #1f1f1f;
    opacity: 0.5;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
    animation: arrowHintPulse 1.6s ease-in-out infinite;
}

.bucket-arrow-left {
    left: -24px;
}

.bucket-arrow-right {
    right: -24px;
}

@keyframes arrowHintPulse {
    0%,
    100% {
        opacity: 0.35;
    }
    50% {
        opacity: 0.6;
    }
}

.bucket-body {
    position: absolute;
    bottom: 0;
    left: 10px;
    width: 60px;
    height: 50px;
    background: linear-gradient(90deg, #D4A574 0%, #E8C9A0 50%, #D4A574 100%);
    border: 2px solid #8B4513;
    border-radius: 0 0 10px 10px;
    box-shadow: inset -2px 2px 5px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2);
}

.bucket-handle {
    position: absolute;
    top: 5px;
    left: 20px;
    width: 40px;
    height: 30px;
    border: 3px solid #8B4513;
    border-top: none;
    border-radius: 0 0 15px 15px;
}

.funnel {
    position: absolute;
    top: -15px;
    left: 20px;
    width: 40px;
    height: 20px;
    background: linear-gradient(180deg, #C0C0C0 0%, #A9A9A9 100%);
    clip-path: polygon(0 0, 100% 0, 85% 100%, 15% 100%);
    border: 1px solid #808080;
}

/* Drops */
.drop {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    pointer-events: none;
}

.drop.good {
    background: linear-gradient(135deg, #2E9DF7 0%, #1E90FF 100%);
    box-shadow: 0 2px 8px rgba(46, 157, 247, 0.6);
}

.drop.bad {
    background: linear-gradient(135deg, #666 0%, #333 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

@keyframes dropFall {
    to {
        transform: translateY(100vh) rotate(0deg);
    }
}

/* End Screen */
#endScreen {
    background: linear-gradient(135deg, #2E9DF7 0%, #8BD1CB 100%);
    justify-content: center;
    align-items: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.end-container {
    background: rgba(255, 255, 255, 0.95);
    padding: clamp(18px, 3vh, 40px) clamp(16px, 3vw, 36px);
    border-radius: 20px;
    max-width: 600px;
    width: min(92vw, 600px);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.end-container h1 {
    font-size: clamp(2rem, 4.2vh, 3rem);
    color: #F5402C;
    text-shadow: 2px 2px 0px #FFC907;
    margin-bottom: clamp(8px, 1.6vh, 18px);
}

.broken-heart-emoji {
    font-size: clamp(2.3rem, 5.6vh, 4rem);
    margin: clamp(8px, 1.7vh, 16px) 0;
    animation: heartBreak 0.6s ease-out;
}

@keyframes heartBreak {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(1.2) rotate(-5deg);
        opacity: 0.8;
    }
}

.final-score {
    font-size: clamp(1.2rem, 2.9vh, 1.7rem);
    color: #333;
    margin: clamp(8px, 1.7vh, 16px) 0;
    font-weight: bold;
}

#finalScore {
    color: #FFC907;
    font-size: clamp(1.4rem, 3.2vh, 2rem);
}

.end-info {
    background: #E8F4FD;
    padding: clamp(10px, 1.8vh, 18px);
    border-radius: 10px;
    margin: clamp(8px, 1.7vh, 16px) 0;
    text-align: left;
}

.end-info h3 {
    color: #2E9DF7;
    margin-bottom: clamp(6px, 1vh, 10px);
    font-size: clamp(1rem, 2.2vh, 1.15rem);
}

.end-info p {
    color: #333;
    font-size: clamp(0.82rem, 1.8vh, 0.95rem);
    line-height: 1.4;
    margin-bottom: clamp(6px, 1vh, 10px);
}

.charity-link {
    display: inline-block;
    background: linear-gradient(135deg, #2E9DF7 0%, #1E90FF 100%);
    color: white;
    text-decoration: none;
    padding: clamp(8px, 1.3vh, 12px) clamp(16px, 2.3vw, 24px);
    border-radius: 25px;
    font-weight: bold;
    margin-top: clamp(6px, 1.2vh, 14px);
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(46, 157, 247, 0.4);
}

.charity-link:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(46, 157, 247, 0.6);
}

.retry-btn {
    background: linear-gradient(135deg, #FFC907 0%, #FF902A 100%);
    color: #000;
    border: none;
    padding: clamp(10px, 1.5vh, 14px) clamp(20px, 3vw, 36px);
    font-size: clamp(0.95rem, 2vh, 1.1rem);
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-top: clamp(8px, 1.6vh, 18px);
}

.retry-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.retry-btn:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 600px) {
    .start-container {
        width: 100%;
        padding: 16px;
    }

    .start-container h1 {
        font-size: 2.5rem;
    }

    .logo-placeholder {
        margin: 14px 0;
        padding: 12px;
    }

    .charity-logo {
        width: clamp(170px, 62vw, 280px);
    }

    .drop-preview-container {
        width: min(80vw, 260px);
        height: min(80vw, 260px);
    }

    .instruction-container {
        max-width: 90%;
        padding: 30px 20px;
    }

    .end-container {
        max-width: 90%;
    }

    .hud {
        top: 10px;
        right: 10px;
        padding: 10px 15px;
        gap: 8px;
    }

    .hud-item {
        font-size: 1rem;
    }

    .hud-reset-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    #heartSvg {
        width: 50px;
        height: 50px;
    }

    .speed-popup {
        font-size: 1rem;
        padding: 12px 16px;
    }

    .bucket {
        width: 84px;
        height: 84px;
    }

    .end-container h1 {
        font-size: 2.2rem;
    }

    .broken-heart-emoji {
        font-size: 3rem;
    }
}

@media (max-width: 380px) {
    .start-container h1 {
        font-size: 2rem;
        letter-spacing: 1px;
    }

    .collect-btn,
    .retry-btn {
        padding: 12px 24px;
        font-size: 1rem;
    }

    .countdown-text {
        font-size: 5.5rem;
    }

    .instruction-container,
    .end-container {
        padding: 22px 14px;
    }
}

@media (max-height: 760px) {
    .end-container {
        padding: 16px 14px;
    }

    .end-container h1 {
        font-size: 1.9rem;
        margin-bottom: 8px;
    }

    .broken-heart-emoji {
        font-size: 2.2rem;
        margin: 6px 0;
    }

    .final-score {
        font-size: 1.05rem;
        margin: 8px 0;
    }

    #finalScore {
        font-size: 1.25rem;
    }

    .end-info {
        padding: 10px;
        margin: 8px 0;
    }

    .end-info p {
        font-size: 0.8rem;
        line-height: 1.3;
        margin-bottom: 6px;
    }

    .charity-link {
        padding: 8px 14px;
        margin-top: 4px;
    }

    .retry-btn {
        margin-top: 8px;
        padding: 8px 16px;
        font-size: 0.95rem;
    }
}

@media (min-width: 1000px) and (max-height: 700px) {
    .bucket {
        width: 88px;
        height: 88px;
    }

    .countdown-text {
        font-size: 6.5rem;
    }
}