/* url() paths are relative to this stylesheet, not the document — "../../assets"
   walks out of static/css/ and lands on the app root, so they keep working when
   the game is mounted under a subpath. Do not restore leading slashes. */

:root {
    --sky: #87ceeb;
    --sky-2: #62b8db;
    --sand: #e8d495;
    --sand-shadow: #c9b273;
    --text: #ffffff;
    --accent: #0481f3;
    --danger: #ff5a5a;
    --ground-h: 22%;
    /* beach.png is 58px tall; water.png is 18px tall. Beach renders at the
       matching ratio so its sand aligns with the water strip and the trees
       extend upward above the ground line. */
    --beach-h: calc(var(--ground-h) * 58 / 18);
    --izzy-size: 22vh;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    background: #000;
    font-family: "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
}

.stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: linear-gradient(180deg, var(--sky) 0%, var(--sky-2) 100%);
}

.sky {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: var(--ground-h);
    background-image: url("../../assets/sprites/sky.png");
    background-repeat: repeat-x;
    background-size: auto 100%;
    background-position: 0 0;
    will-change: background-position;
    image-rendering: pixelated;
}

.ground {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--ground-h);
    background-image: url("../../assets/sprites/water.png");
    background-repeat: repeat-x;
    background-size: auto 100%;
    background-position: 0 0;
    will-change: background-position;
    image-rendering: pixelated;
    box-shadow: inset 0 4px 0 rgba(0,0,0,0.15);
}

/* Beach: opening stretch that scrolls off to the left, revealing the water.
   Bottom-anchored to the viewport so its sand strip lines up with the water
   strip; the tree portion sits above the ground line. */
.beach {
    position: absolute;
    left: 0;
    bottom: 0;
    height: var(--beach-h);
    width: auto;
    /*z-index: 1;*/
    image-rendering: pixelated;
    pointer-events: none;
    will-change: transform;
    transform: translateX(0);
}

.izzy {
    position: absolute;
    left: 12%;
    bottom: var(--ground-h);
    width: var(--izzy-size);
    height: auto;
    transform: translateY(0);
    transform-origin: center bottom;
    will-change: transform;
    image-rendering: pixelated;
    pointer-events: none;
}

.obstacles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.obstacle {
    position: absolute;
    bottom: var(--ground-h);
    will-change: transform;
    image-rendering: pixelated;
    pointer-events: none;
}

.obstacle--wave {
    height: 14vh;
    width: auto;
}

.obstacle--pelican {
    height: 12vh;
    width: auto;
    /* pelican mid-air, offset up from ground */
    bottom: calc(var(--ground-h) + 14vh);
}

.hud {
    position: absolute;
    top: 2vh;
    left: 3vw;
    right: 3vw;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.hud__score {
    font-variant-numeric: tabular-nums;
    font-size: clamp(24px, 6vh, 56px);
    font-weight: 800;
    color: var(--text);
    text-shadow: 0 2px 0 rgba(0,0,0,0.35);
    letter-spacing: 0.05em;
}

.controls {
    position: absolute;
    bottom: calc(var(--ground-h) - 6vh);
    right: 4vw;
    display: flex;
    flex-direction: column;
    gap: 6vh;
    z-index: 10;
}

.ctrl {
    width: 18vh;
    height: 18vh;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    cursor: pointer;
    transition: transform 0.05s;
}

.ctrl:active {
    transform: scale(0.9);
}

.ctrl__arrow {
    width: 125%;
    height: 125%;
    object-fit: contain;
    pointer-events: none;
    image-rendering: pixelated;
    /* arrow.png points up by default */
}

.ctrl__arrow--flip {
    transform: rotate(180deg);
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 20;
    /*backdrop-filter: blur(4px);*/
    /*-webkit-backdrop-filter: blur(4px);*/
}

.overlay.hidden { display: none; }

.overlay__card {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 4vh 6vw;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2vh;
    align-items: center;
    max-width: 80%;
}

.overlay__title {
    color: var(--accent);
    font-size: clamp(28px, 6vh, 56px);
    letter-spacing: 0.03em;
    text-shadow: 0 4px 0 rgba(0,0,0,0.35);
}

.overlay__body {
    font-size: clamp(16px, 3vh, 28px);
    line-height: 1.3;
}

.overlay__gameover-img {
    height: 20vh;
    width: auto;
    image-rendering: pixelated;
}

.overlay__btn {
    padding: 1.5vh 5vw;
    font-size: clamp(18px, 4vh, 32px);
    font-weight: 700;
    color: #0a2a5a;
    background: var(--accent);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.25);
    transition: transform 0.05s;
}

.overlay__btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.25); }

/* ---------- Landing ---------- */
.landing {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    transform: translateY(0);
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.landing.revealing { transform: translateY(-100%); }
.landing.hidden    { display: none; }

.landing__bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    image-rendering: pixelated;
    /* Promote to its own compositing layer. Combined with the transform-driven
       scroll on the strip below, this is what makes Safari/WebKit re-sample the
       popup's backdrop-filter every frame — animating background-position does
       not trigger that resample, so the blurred region freezes. */
    transform: translateZ(0);
}

.landing__bg-strip {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;               /* JS overrides: viewport height + one tile */
    background-image: url("../../assets/sprites/landing.png");
    background-repeat: repeat-y;
    background-size: 100% auto;
    background-position: 0 0;
    will-change: transform;
    transform: translateY(0);
    image-rendering: pixelated;
}

.landing__popup {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2vh;
    padding: 4vh 6vw;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transform-origin: center;
    transform: scale(1);
    opacity: 1;
    transition: transform 0.35s cubic-bezier(0.55, 0, 0.55, 0.2), opacity 0.35s ease-in;
}

.landing__popup.shrink {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.landing__title {
    color: var(--accent);
    font-size: clamp(28px, 6vh, 56px);
    letter-spacing: 0.03em;
    text-align: center;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;}

.landing__sub {
    font-size: clamp(14px, 2.5vh, 22px);
    text-align: center;
    opacity: 0.9;
}

.landing__hint {
    font-size: clamp(12px, 2vh, 18px);
    text-align: center;
    opacity: 0.7;
}

.landing__name {
    padding: 1.3vh 2vw;
    min-width: 60vw;
    max-width: 340px;
    font-size: clamp(18px, 3.5vh, 32px);
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    outline: none;
    text-align: center;
    font-family: inherit;
}

.landing__name:focus       { border-color: var(--accent); }
.landing__name::placeholder{ color: rgba(255, 255, 255, 0.5); }
.landing__name.input-error { border-color: var(--danger); }

.landing__error {
    min-height: 1.2em;
    color: var(--danger);
    font-size: clamp(13px, 2.2vh, 20px);
    text-align: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.landing__error.show { opacity: 1; }

.landing__btn {
    padding: 1.5vh 6vw;
    font-size: clamp(20px, 4vh, 32px);
    font-weight: 700;
    color: #0a2a5a;
    background: var(--accent);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.25);
    transition: transform 0.05s;
}

.landing__btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.25); }

.landing__btn2 {
    text-decoration: none;
    padding: 1vh 3vw;
    font-size: clamp(10px, 2vh, 25px);
    font-weight: 700;
    color: #0d3a1e;
    background: #26b55f;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.25);
    transition: transform 0.05s;
}

.landing__btn2:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.25); }

/* Force landscape on phones — if portrait, ask user to rotate. */
@media (orientation: portrait) and (max-width: 900px) {
    .stage::after {
        content: "Rotate your device for best experience";
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(0,0,0,0.85);
        color: var(--accent);
        font-size: 6vw;
        text-align: center;
        padding: 10vw;
        z-index: 100;
    }
}
