/* Charity: water Brand Colors & Fonts

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

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

Fonts:
- Proxima Nova (paid; Montserrat from Google Fonts is used as a free lookalike)
- Avenir

*/

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

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px;
    background-color: #fff;
    font-family: "Montserrat", "Proxima Nova", Avenir, Arial, sans-serif;
    color: #131313;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 800px;
    max-width: 100%;
    /* Fill the screen height so the whole game is visible without scrolling.
       dvh adjusts for phone browser toolbars; vh is the fallback. */
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
}

.logo {
    width: 220px;
    max-width: 60%;
}

.game-title {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-align: center;
}

.game-tagline {
    color: #555;
    font-size: 18px;
    text-align: center;
}

.score-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background-color: #f5f5f5;
    border-top: 4px solid #FFC907;
}

.score,
.goal,
.lives,
.timer {
    font-size: 22px;
    font-weight: bold;
}

.goal {
    color: #159A48;
}

.buttons {
    display: flex;
    gap: 8px;
}

#start-btn,
#reset-btn {
    padding: 8px 18px;
    background-color: #FFC907;
    color: #131313;
    border: 2px solid #FFC907;
    border-radius: 2px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#start-btn:hover:not(:disabled) {
    background-color: #e6b400;
}

#reset-btn {
    background-color: #fff;
    border-color: #131313;
    color: #131313;
}

#reset-btn:hover {
    background-color: #131313;
    color: #fff;
}

#start-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

#game-container {
    width: 100%;
    /* Take whatever height is left on the screen, up to 600px */
    flex: 1 1 0;
    min-height: 260px;
    max-height: 600px;
    background: linear-gradient(#e6f7ff, #8BD1CB);
    border: 2px solid #131313;
    position: relative;
    overflow: hidden;
    touch-action: none;
    cursor: none;
}

#catcher {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100px;
    pointer-events: none;
    user-select: none;
}

#catcher svg {
    display: block;
    width: 100%;
}

/* Drops are teardrop-shaped: round with one pointed corner on top */
.water-drop {
    position: absolute;
    top: 0;
    background-color: #2E9DF7;
    border-radius: 0 50% 50% 50%;
    rotate: 45deg;
    box-shadow: inset -4px -4px 0 rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

.dirty-drop {
    background-color: #7a5230;
    box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.25);
}

/* Germs (hard mode): a red, spotted ball with a spiky edge. Catching one ends the game. */
.germ {
    position: absolute;
    top: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 35%, #ff8a7a 0 12%, transparent 13%),
        radial-gradient(circle at 65% 60%, #a3150a 0 10%, transparent 11%),
        radial-gradient(circle at 35% 70%, #a3150a 0 8%, transparent 9%),
        #F5402C;
    border: 4px dotted #a3150a;
    box-shadow: 0 0 8px rgba(245, 64, 44, 0.7);
    animation: germSpin 1.5s linear infinite;
    pointer-events: none;
}

@keyframes germSpin {
    to { rotate: 360deg; }
}

/* Splash shown where a drop lands in the bucket. It's a zero-size anchor;
   the dots and label are positioned around it. */
.splash {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

.splash-dot {
    position: absolute;
    left: -6px;
    top: -6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: splashBurst 0.6s ease-out forwards;
}

.splash-clean .splash-dot { background-color: #2E9DF7; }
.splash-dirty .splash-dot { background-color: #7a5230; width: 14px; height: 10px; }
.splash-germ .splash-dot  { background-color: #F5402C; box-shadow: 0 0 6px #F5402C; }

.splash-label {
    position: absolute;
    left: 0;
    top: -20px;
    translate: -50% 0;
    font-size: 24px;
    font-weight: bold;
    white-space: nowrap;
    text-shadow: 0 1px 2px #fff;
    animation: splashLabel 0.8s ease-out forwards;
}

.splash-clean .splash-label { color: #159A48; }
.splash-germ .splash-label  { font-size: 32px; }

/* Stay fully visible for most of the animation, then fade out at the end */
@keyframes splashBurst {
    60% { opacity: 1; }
    to {
        translate: var(--dx) var(--dy);
        scale: 0.3;
        opacity: 0;
    }
}

@keyframes splashLabel {
    50% { opacity: 1; }
    to {
        translate: -50% -50px;
        opacity: 0;
    }
}

/* Milestone message: pops up in the middle of the game, then fades away */
.milestone {
    position: absolute;
    top: 40%;
    left: 50%;
    translate: -50% -50%;
    padding: 10px 24px;
    background-color: #FFC907;
    border: 2px solid #131313;
    color: #131313;
    font-size: 28px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    width: max-content;
    max-width: 90%;
    pointer-events: none;
    z-index: 5;
    animation: milestonePop 1.6s ease-out forwards;
}

@keyframes milestonePop {
    0%   { scale: 0.5; opacity: 0; }
    15%  { scale: 1.1; opacity: 1; }
    25%  { scale: 1; }
    70%  { opacity: 1; translate: -50% -50%; }
    100% { opacity: 0; translate: -50% -90%; }
}

.difficulty {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.difficulty-btn {
    flex: 1;
    max-width: 110px;
    padding: 6px 10px;
    background-color: #fff;
    border: 2px solid #131313;
    border-radius: 2px;
    color: #131313;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.difficulty-btn:hover {
    background-color: #f5f5f5;
}

.difficulty-btn.selected {
    background-color: #131313;
    color: #fff;
}

.difficulty-btn[data-level="hard"].selected {
    background-color: #F5402C;
    border-color: #F5402C;
}

.message {
    position: absolute;
    inset: 0;
    margin: auto;
    width: min(420px, 90%);
    height: fit-content;
    max-height: 92%;
    overflow-y: auto;
    padding: 24px;
    background-color: #fff;
    border: 2px solid #131313;
    border-top: 6px solid #FFC907;
    text-align: center;
    line-height: 1.6;
    cursor: default;
}

.message h2 {
    font-weight: 800;
    margin-bottom: 8px;
}

.hidden {
    display: none;
}

.flash-catch {
    animation: flashCatch 0.3s;
}

.flash-hit {
    animation: flashHit 0.4s;
}

@keyframes flashCatch {
    from { box-shadow: inset 0 0 40px #4FCB53; }
    to   { box-shadow: none; }
}

@keyframes flashHit {
    from { box-shadow: inset 0 0 60px #F5402C; }
    to   { box-shadow: none; }
}

/* Footer with info about charity: water and a donate link */
.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 0 4px;
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
    color: #555;
}

.site-footer a {
    color: #131313;
    font-weight: 700;
    text-decoration-color: #FFC907;
    text-decoration-thickness: 3px;
}

.site-footer .donate-btn {
    flex-shrink: 0;
    padding: 8px 18px;
    background-color: #FFC907;
    color: #131313;
    border-radius: 2px;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 13px;
}

.site-footer .donate-btn:hover {
    background-color: #e6b400;
}

/* Confetti pieces for a perfect game */
.confetti {
    position: fixed;
    top: -20px;
    width: 10px;
    height: 16px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 10;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    to {
        transform: translate(var(--drift), 105vh) rotate(720deg);
    }
}

/* Phones and small tablets */
@media (max-width: 850px) {
    body {
        padding: 8px;
    }

    .game-wrapper {
        gap: 8px;
        height: calc(100vh - 16px);
        height: calc(100dvh - 16px);
    }

    .logo {
        width: 150px;
    }

    .game-title {
        font-size: 30px;
    }

    .game-tagline {
        font-size: 14px;
    }

    .score-panel {
        padding: 8px 12px;
    }

    .score,
    .goal,
    .lives,
    .timer {
        font-size: 14px;
    }

    .buttons {
        width: 100%;
    }

    #start-btn,
    #reset-btn {
        flex: 1;
        padding: 10px;
    }

    .milestone {
        font-size: 20px;
        padding: 8px 16px;
    }

    .site-footer {
        font-size: 12px;
        padding: 4px 0;
    }

    .site-footer .donate-btn {
        padding: 6px 12px;
    }

    .message {
        padding: 16px;
        font-size: 15px;
        line-height: 1.5;
    }

    #catcher {
        width: 80px;
    }
}

/* Short screens, like a phone turned sideways: hide the extras */
@media (max-height: 500px) {
    .logo,
    .game-tagline {
        display: none;
    }

    .game-title {
        font-size: 22px;
    }

    #game-container {
        min-height: 200px;
    }
}
