/* Photo Safari — bespoke camera game styles.
 *
 * A wildlife-photography game: animals roam a living habitat scene while the
 * player looks through a camera viewfinder, focuses, and snaps the animal
 * that matches the clue. Nothing here depends on the shared moving-target
 * engine — this game renders its own scene, camera HUD and capture effects.
 */

.ps-game {
    --ps-ink: #1d2430;
    --ps-cam: #20262e;
    display: flex;
    flex-direction: column;
    gap: 12px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* ---------------- Clue banner ---------------- */
.ps-prompt {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-weight: 700;
    font-size: clamp(18px, 4.4vw, 26px);
    text-align: center;
    color: var(--ps-ink);
    background: linear-gradient(180deg, #fff, #fbf6ec);
    border: 2px solid #f0e2c6;
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.05);
    line-height: 1.25;
}
.ps-prompt strong { color: #e8792b; white-space: nowrap; }
.ps-prompt .ps-prompt-emoji { font-size: 1.15em; }

/* ---------------- Camera body + viewfinder ---------------- */
.ps-viewfinder {
    position: relative;
    width: 100%;
    height: clamp(280px, 48vh, 460px);
    border-radius: 20px;
    overflow: hidden;
    background: #0b1a24;
    border: 6px solid var(--ps-cam);
    box-shadow:
        0 0 0 2px #11151a,
        0 14px 30px rgba(0, 0, 0, 0.28),
        inset 0 0 60px rgba(0, 0, 0, 0.35);
    cursor: none;
}
/* When focus assist is off (touch), show a normal cursor. */
.ps-viewfinder.is-touch { cursor: default; }

/* ---------------- The living scene ---------------- */
.ps-scene {
    position: absolute;
    inset: 0;
    overflow: hidden;
    transition: filter 140ms ease;
}
.ps-scene.is-focusing { filter: blur(1.4px) saturate(0.9); }

.ps-sky {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #bfe3f5 0%, #dff0d8 55%, #e7c98a 100%);
    transition: background 500ms ease;
}
.ps-ground {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 26%;
    background: linear-gradient(180deg, #e7c98a, #d8b473);
    box-shadow: inset 0 6px 12px rgba(255, 255, 255, 0.25);
    transition: background 500ms ease;
}
.ps-sun {
    position: absolute;
    top: 8%; right: 12%;
    width: clamp(46px, 12vw, 84px);
    height: clamp(46px, 12vw, 84px);
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #fff3b0, #ffd24d 60%, rgba(255, 210, 77, 0) 72%);
    animation: ps-sun-pulse 5s ease-in-out infinite;
}
@keyframes ps-sun-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.ps-cloud {
    position: absolute;
    font-size: clamp(34px, 8vw, 58px);
    opacity: 0.92;
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.06));
    will-change: transform;
    animation: ps-cloud-drift linear infinite;
}
@keyframes ps-cloud-drift {
    from { transform: translateX(-140px); }
    to   { transform: translateX(calc(100% + 140px)); }
}
.ps-decor {
    position: absolute;
    bottom: 20%;
    font-size: clamp(30px, 8vw, 56px);
    line-height: 1;
    filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.12));
    pointer-events: none;
    animation: ps-sway 4.5s ease-in-out infinite;
    transform-origin: bottom center;
}
@keyframes ps-sway { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }

.ps-bubble {
    position: absolute;
    bottom: -20px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.7);
    animation: ps-bubble-up linear infinite;
}
@keyframes ps-bubble-up {
    from { transform: translateY(0) scale(0.6); opacity: 0; }
    15%  { opacity: 0.8; }
    to   { transform: translateY(-360px) scale(1.1); opacity: 0; }
}
.ps-flake {
    position: absolute;
    top: -16px;
    color: #fff;
    font-size: 14px;
    animation: ps-flake-fall linear infinite;
    text-shadow: 0 1px 2px rgba(120, 160, 200, 0.5);
}
@keyframes ps-flake-fall {
    from { transform: translateY(-20px) translateX(0) rotate(0deg); }
    to   { transform: translateY(420px) translateX(24px) rotate(240deg); }
}

/* ---------------- Habitat palettes ---------------- */
.ps-viewfinder[data-habitat="forest"]  .ps-sky    { background: linear-gradient(180deg, #cbe9df 0%, #d6efc4 60%, #9ccc8f 100%); }
.ps-viewfinder[data-habitat="forest"]  .ps-ground { background: linear-gradient(180deg, #8dc07f, #6ea85f); }
.ps-viewfinder[data-habitat="ocean"]   .ps-sky    { background: linear-gradient(180deg, #86d6f2 0%, #3f9fd4 45%, #1f6fb2 100%); }
.ps-viewfinder[data-habitat="ocean"]   .ps-ground { background: linear-gradient(180deg, #2f80bd, #14568c); }
.ps-viewfinder[data-habitat="desert"]  .ps-sky    { background: linear-gradient(180deg, #ffe6b0 0%, #ffd591 55%, #edc478 100%); }
.ps-viewfinder[data-habitat="desert"]  .ps-ground { background: linear-gradient(180deg, #ecd39a, #dbb96f); }
.ps-viewfinder[data-habitat="arctic"]  .ps-sky    { background: linear-gradient(180deg, #dcefff 0%, #eaf6ff 55%, #ffffff 100%); }
.ps-viewfinder[data-habitat="arctic"]  .ps-ground { background: linear-gradient(180deg, #f2f9ff, #d8ecfb); }
.ps-viewfinder[data-habitat="farm"]    .ps-sky    { background: linear-gradient(180deg, #cfeafd 0%, #dff0d0 55%, #b7d98f 100%); }
.ps-viewfinder[data-habitat="farm"]    .ps-ground { background: linear-gradient(180deg, #aed685, #8cbf63); }
.ps-viewfinder[data-habitat="home"]    .ps-sky    { background: linear-gradient(180deg, #f6e7d2 0%, #efd9bd 60%, #e7c9a3 100%); }
.ps-viewfinder[data-habitat="home"]    .ps-ground { background: linear-gradient(180deg, #d8b48a, #c39d6f); }
/* Ocean & arctic hide the sun; ocean animals float higher. */
.ps-viewfinder[data-habitat="ocean"]  .ps-sun,
.ps-viewfinder[data-habitat="arctic"] .ps-sun { display: none; }

/* ---------------- Roaming animals ---------------- */
.ps-animal {
    position: absolute;
    top: 0; left: 0;
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    will-change: transform;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
}
.ps-animal-inner {
    display: block;
    animation: ps-bob 1.6s ease-in-out infinite;
    transform-origin: bottom center;
}
.ps-animal-img {
    display: block;
    width: clamp(58px, 13vw, 96px);
    height: clamp(58px, 13vw, 96px);
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.22));
}
.ps-animal-emoji {
    font-size: clamp(48px, 11vw, 84px);
    line-height: 1;
    pointer-events: none;
    filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.22));
}
@keyframes ps-bob {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-7px) rotate(1deg); }
}
/* Each animal gets a random-ish delay via nth-child so they don't sync. */
.ps-animal:nth-child(2n) .ps-animal-inner { animation-duration: 1.9s; }
.ps-animal:nth-child(3n) .ps-animal-inner { animation-duration: 1.4s; }
.ps-animal:nth-child(4n) .ps-animal-inner { animation-delay: -0.6s; }

.ps-animal.is-hunted .ps-animal-inner { animation-duration: 0.5s; }
.ps-animal.is-captured .ps-animal-inner { animation: ps-pose 0.5s ease; }
@keyframes ps-pose {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.28) rotate(-4deg); }
    100% { transform: scale(1) rotate(0); }
}
.ps-animal.is-missed .ps-animal-inner { animation: ps-runaway 0.6s ease forwards; }
@keyframes ps-runaway {
    to { transform: translateY(-40px) scale(0.4); opacity: 0; }
}
.ps-animal.is-blurred .ps-animal-inner { animation: ps-shake 0.4s ease; }
@keyframes ps-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-7px) rotate(-3deg); }
    75% { transform: translateX(7px) rotate(3deg); }
}

/* ---------------- Camera HUD overlay ---------------- */
.ps-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
/* Corner focus brackets */
.ps-corner {
    position: absolute;
    width: 30px; height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.85);
}
.ps-corner.tl { top: 14px; left: 14px; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.ps-corner.tr { top: 14px; right: 14px; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.ps-corner.bl { bottom: 14px; left: 14px; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.ps-corner.br { bottom: 14px; right: 14px; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }

/* Rule-of-thirds grid */
.ps-grid { position: absolute; inset: 0; opacity: 0.28; }
.ps-grid::before, .ps-grid::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
}
.ps-grid::before { left: 33.33%; right: 33.33%; top: 0; bottom: 0; border-left: 1px solid rgba(255,255,255,0.7); border-right: 1px solid rgba(255,255,255,0.7); background: none; }
.ps-grid::after  { top: 33.33%; bottom: 33.33%; left: 0; right: 0; border-top: 1px solid rgba(255,255,255,0.7); border-bottom: 1px solid rgba(255,255,255,0.7); background: none; }

/* Top status row: REC + shot counter */
.ps-rec {
    position: absolute;
    top: 20px; left: 52px;
    display: flex; align-items: center; gap: 7px;
    color: #fff;
    font: 700 13px/1 'DM Sans', monospace;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.ps-rec-dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: #ff3b3b;
    box-shadow: 0 0 8px #ff3b3b;
    animation: ps-blink 1s steps(2, start) infinite;
}
@keyframes ps-blink { 50% { opacity: 0.15; } }

.ps-count {
    position: absolute;
    top: 20px; right: 52px;
    color: #fff;
    font: 700 13px/1 'DM Sans', monospace;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Battery / focus timer bar along the bottom of the viewfinder */
.ps-timer-wrap {
    position: absolute;
    left: 52px; right: 52px; bottom: 18px;
    height: 8px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    overflow: hidden;
}
.ps-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #7ee08a, #f5d94a);
    transform-origin: left center;
    transition: transform 100ms linear, background 200ms linear;
}
.ps-timer-fill.is-low { background: linear-gradient(90deg, #ff9d4d, #ff5b5b); }

/* Digital-camera autofocus frame that follows the pointer */
.ps-reticle {
    position: absolute;
    width: 84px; height: 84px;
    margin: -42px 0 0 -42px;
    left: 50%; top: 50%;
    pointer-events: none;
    transition: left 90ms ease-out, top 90ms ease-out, transform 120ms ease,
        width 120ms ease, height 120ms ease, margin 120ms ease, opacity 150ms;
    z-index: 6;
}
/* four L-shaped corner brackets = camera AF frame */
.ps-af {
    position: absolute;
    width: 20px; height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.95);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
    transition: border-color 120ms ease;
}
.ps-af.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 5px 0 0 0; }
.ps-af.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 5px 0 0; }
.ps-af.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 5px; }
.ps-af.br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 5px 0; }
/* tiny center AF point */
.ps-reticle::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: 6px; height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.ps-reticle.is-locked .ps-af { border-color: #57e08a; box-shadow: 0 0 10px rgba(87, 224, 138, 0.7); }
.ps-reticle.is-locked::after { background: #57e08a; }
.ps-reticle.is-locked { animation: ps-lock 0.3s ease; }
@keyframes ps-lock { 0% { transform: scale(1.22); } 60% { transform: scale(0.94); } 100% { transform: scale(1); } }

/* Shutter flash + aperture blink */
.ps-flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 8;
}
.ps-flash.is-firing { animation: ps-flash 0.34s ease; }
@keyframes ps-flash {
    0% { opacity: 0; }
    12% { opacity: 0.92; }
    100% { opacity: 0; }
}

/* ---------------- Filmstrip / photo album ---------------- */
.ps-filmstrip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 112px;
    padding: 10px 12px;
    background: repeating-linear-gradient(90deg, #23282f 0 16px, #1a1e24 16px 23px);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
.ps-filmstrip::-webkit-scrollbar { height: 6px; }
.ps-filmstrip::-webkit-scrollbar-thumb { background: #4a5563; border-radius: 6px; }
.ps-film-hint {
    color: #9aa6b4;
    font: 600 14px/1.3 'DM Sans', sans-serif;
    padding: 0 6px;
    white-space: nowrap;
}
.ps-polaroid {
    flex: 0 0 auto;
    width: 90px;
    background: #fff;
    border-radius: 5px;
    padding: 6px 6px 10px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
    transform: rotate(var(--ps-tilt, -2deg));
}
.ps-polaroid img { display: block; width: 100%; height: 66px; object-fit: contain; }
.ps-polaroid .ps-polaroid-cap { font-size: 13px; font-weight: 600; text-align: center; color: #2a2f37; margin-top: 4px; font-family: 'DM Sans', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-polaroid.is-new { animation: ps-develop 0.6s ease; }
@keyframes ps-develop {
    0% { opacity: 0; filter: brightness(2.2) contrast(0.3); transform: rotate(var(--ps-tilt, -2deg)) scale(0.6); }
    100% { opacity: 1; filter: none; transform: rotate(var(--ps-tilt, -2deg)) scale(1); }
}

/* Flying polaroid used during the capture -> album animation */
.ps-fly {
    position: fixed;
    z-index: 90;
    background: #fff;
    border-radius: 6px;
    padding: 6px 6px 14px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transition: transform 620ms cubic-bezier(0.5, 0, 0.3, 1), opacity 620ms ease;
}
.ps-fly img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ps-fly.is-blur img { filter: blur(3px) contrast(0.8); }

/* Floating "+points" / star popover */
.ps-pop {
    position: fixed;
    z-index: 95;
    font: 800 22px/1 'DM Sans', sans-serif;
    color: #ffb300;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    animation: ps-pop-up 0.9s ease forwards;
    white-space: nowrap;
}
@keyframes ps-pop-up {
    0% { opacity: 0; transform: translateY(0) scale(0.6); }
    20% { opacity: 1; transform: translateY(-8px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-52px) scale(1); }
}

/* Confetti burst */
.ps-confetti {
    position: fixed;
    z-index: 92;
    width: 10px; height: 14px;
    border-radius: 2px;
    pointer-events: none;
    will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
    .ps-animal-inner,
    .ps-sun, .ps-cloud, .ps-decor, .ps-bubble, .ps-flake, .ps-rec-dot { animation: none !important; }
}
