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

*/
/* =========================
   BASIC PAGE
========================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #8BD1CB;
    color: #222;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
}


/* =========================
   APP
========================= */

#app {
    width: 100%;
    max-width: 430px;
    height: min(760px, calc(100vh - 72px));
    height: min(760px, calc(100dvh - 72px));
    background: white;
    border: 3px solid #333;
    border-radius: 25px;
    overflow: hidden;
    position: relative;
    flex: 0 0 auto;
}

.site-footer {
    width: 100%;
    min-height: 72px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px 14px;
    padding: 10px;
    font-size: 13px;
    text-align: center;
}

.site-footer a {
    color: #174f6b;
}

.site-footer a:focus-visible {
    outline: 2px solid #174f6b;
    outline-offset: 3px;
}


/* =========================
   SCREENS
========================= */

.screen {
    display: none;
    width: 100%;
    height: 100%;
    padding: 40px 30px;
    text-align: center;
}

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


/* =========================
   TEXT
========================= */

h1 {
    font-size: 36px;
    margin-bottom: 15px;
}

h2 {
    font-size: 28px;
}

p {
    line-height: 1.5;
}

.brand {
    font-size: 18px;
    margin-bottom: 20px;
}

.menu-water-can {
    width: 130px;
    height: 130px;
    object-fit: contain;
    margin-bottom: 12px;
}

.brand-icon {
    color: #f5c400;
}


/* =========================
   BUTTONS
========================= */

button {
    background: white;
    border: 2px solid #333;
    border-radius: 12px;
    touch-action: manipulation;
    font-family: inherit;
    width: 180px;
    min-height: 48px;
    padding: 10px 16px;
    margin: 6px;
    font-size: 16px;
    cursor: pointer;
}

button:hover {
    background: #eeeeee;
}

.big-button {
    width: 180px;
    padding: 14px;
    font-size: 18px;
}

.difficulty-description {
    margin: 0 0 12px;
}


/* =========================
   HOW TO PLAY
========================= */

.instructions {
    text-align: left;
    width: 100%;
    margin: 20px 0;
}

.instructions p {
    font-size: 17px;
    margin: 25px 0;
}

.mission-text {
    font-weight: bold;
    margin: 25px;
}


/* =========================
   GAME
========================= */

.game-screen.active {
    display: flex;
    flex-direction: column;
    padding:
        max(10px, env(safe-area-inset-top))
        max(10px, env(safe-area-inset-right))
        max(10px, env(safe-area-inset-bottom))
        max(10px, env(safe-area-inset-left));
}


/* HUD */

#hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    flex: 0 0 auto;
}

.hud-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 8px 4px;
    border: 1px solid #c5b79f;
    border-radius: 12px;
    background: linear-gradient(145deg, #fffdf8, #f2eadb);
    box-shadow: 0 2px 5px rgba(75, 54, 31, 0.12);
}

.hud-label {
    font-size: 11px;
    font-weight: bold;
}

.hud-value {
    font-size: 18px;
    font-weight: bold;
    line-height: 1.1;
}

.hud-divider {
    color: #777;
    font-size: 14px;
}

.objective-card {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2b300;
    border-radius: 12px;
    background: #fff7d6;
    text-align: left;
}

.objective-card > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.objective-card strong {
    font-size: 13px;
}

.objective-card #objectiveText {
    font-size: 13px;
    line-height: 1.3;
}

.objective-icon {
    font-size: 22px;
}

.game-feedback {
    position: absolute;
    z-index: 20;
    top: 12px;
    left: 50%;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 10px 16px;
    border: 2px solid transparent;
    border-radius: 14px;
    box-shadow: 0 3px 10px rgba(35, 27, 17, 0.2);
    font-size: 15px;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    text-align: center;
    transform: translate(-50%, -8px);
}

.feedback-success {
    color: #155724;
    border-color: #4fcb53;
    background: #efffed;
}

.feedback-warning {
    color: #842029;
    border-color: #f5402c;
    background: #fff0ed;
}

.feedback-show {
    animation: feedback-pop 1.6s ease-out forwards;
}

.stat-pop {
    animation: stat-pop 0.45s ease-out;
}

@keyframes feedback-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -8px) scale(0.95);
    }

    12%, 78% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -4px) scale(0.98);
    }
}

@keyframes stat-pop {
    50% {
        transform: scale(1.08);
        box-shadow: 0 0 0 3px rgba(255, 201, 7, 0.5);
    }
}

@media (prefers-reduced-motion: reduce) {
    .feedback-show {
        animation: none;
        opacity: 1;
        transform: translate(-50%, 0);
    }

    .stat-pop {
        animation: none;
    }
}



/* =========================
   GAME AREA
========================= */

#gameArea {
    position: relative;

    width: 100%;
    flex: 1;
    min-height: 0;

    overflow: hidden;

    border: 2px solid #333;

    background-color: #4FCB53;
    background-size: 47px 53px, 61px 67px, 39px 43px, 100% 100%;
}

#gameArea::before {
    content: "";
    position: absolute;
    z-index: 0;
    left: -15%;
    top: 42%;
    width: 130%;
    height: 22%;
    border: 1px solid rgba(116, 84, 49, 0.25);
    border-radius: 50%;
    background:
        linear-gradient(
            180deg,
            rgba(114, 81, 46, 0.15),
            rgba(239, 214, 170, 0.72) 18%,
            #d4b17d 50%,
            rgba(239, 214, 170, 0.72) 82%,
            rgba(114, 81, 46, 0.15)
        );
    box-shadow: 0 2px 5px rgba(77, 54, 30, 0.12);
    transform: rotate(-18deg);
    pointer-events: none;
}


/* =========================
   PLAYER
========================= */

#player {
    position: absolute;

    width: 42px;
    height: 42px;

    font-size: 32px;

    left: 20px;
    top: 480px;

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 10;
    filter: drop-shadow(0 3px 2px rgba(35, 27, 17, 0.35));

    transition:
        left 0.05s linear,
        top 0.05s linear;
}


/* =========================
   WATER
========================= */

.water {
    position: absolute;

    width: 34px;
    height: 34px;

    font-size: 27px;

    display: flex;
    justify-content: center;
    align-items: center;
    filter: drop-shadow(0 3px 2px rgba(35, 27, 17, 0.35));
}


/* =========================
   OBSTACLES
========================= */

.obstacle {
    position: absolute;

    width: 45px;
    height: 45px;

    font-size: 34px;

    display: flex;
    justify-content: center;
    align-items: center;
    filter: drop-shadow(0 4px 2px rgba(35, 27, 17, 0.35));
}


/* =========================
   WELL
========================= */

.well {
    position: absolute;

    width: 45px;
    height: 45px;

    font-size: 34px;
    filter: drop-shadow(0 3px 2px rgba(35, 27, 17, 0.35));
}


/* =========================
   VILLAGE
========================= */

#village {
    position: absolute;

    right: 15px;
    top: 15px;

    font-size: 38px;
    min-width: 70px;
    padding: 7px;
    border: 1px solid rgba(119, 88, 54, 0.35);
    border-radius: 12px;
    background: rgba(255, 248, 229, 0.8);
    box-shadow: 0 4px 8px rgba(58, 43, 27, 0.2);
    z-index: 10;
}

#village span {
    display: block;
    font-size: 11px;
    font-weight: bold;
}


/* =========================
   CONTROLS
========================= */

#controls {
    flex: 0 0 clamp(90px, 16dvh, 110px);

    display: flex;

    justify-content: space-between;
    align-items: center;
    gap: 80px;
}

.movement-buttons button {
    width: 50px;
    min-height: 42px;
    font-size: 24px;
    padding: 0;
    margin: 1px;
}

.pause-button {
    border-radius: 50%;
    width: 55px;
    min-height: 55px;
    font-size: 25px;
}


/* =========================
   PAUSE POPUP
========================= */

.overlay-screen {
    position: absolute;

    left: 0;
    top: 0;

    background: rgba(255,255,255,0.94);

    z-index: 100;
}

.popup {
    border: 2px solid #333;

    width: 280px;

    padding: 30px;
}

.popup button {
    display: block;
    width: 150px;
    margin: 12px auto;
}


/* =========================
   RESULTS
========================= */

.results {
    text-align: left;
    border: 2px solid #333;
    padding: 20px;
    margin: 20px 0;
}

.fact {
    width: 100%;
    margin: 12px 0;
    padding: 12px 14px;
    border: 1px solid #8bd1cb;
    border-radius: 12px;
    background: #effaf9;
    text-align: left;
}

.fact p {
    margin: 6px 0;
}

.fact a {
    color: #174f6b;
    font-size: 13px;
}

.final-fact {
    max-width: 320px;
}


/* =========================
   CONFETTI
========================= */

#confetti {
    font-size: 28px;
    animation: bounce 0.7s infinite alternate;
}

@keyframes bounce {

    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10px);
    }

}


/* =========================
   THANK YOU
========================= */

.big-drop {
    font-size: 60px;
    margin-top: 30px;
}

.thank-you-water-can {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 12px;
}


/* =========================
   SMALL SCREENS
========================= */

@media (max-width: 500px), (max-height: 500px) and (max-width: 900px) {

    body {
        align-items: flex-start;
    }

    #app {
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 72px);
        height: calc(100dvh - 72px);
        border: none;
        border-radius: 0;
    }
}