/* Shared City World renderer for iOS Safari and Android Chromium. */
:root {
    --city-viewport-height: 100vh;
    --city-safe-top: env(safe-area-inset-top, 0px);
    --city-safe-right: env(safe-area-inset-right, 0px);
    --city-safe-bottom: env(safe-area-inset-bottom, 0px);
    --city-safe-left: env(safe-area-inset-left, 0px);
}

@supports (height: 100svh) {
    :root { --city-viewport-height: 100svh; }
}

html,
body {
    width: 100%;
    min-height: var(--city-viewport-height);
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.farm-game {
    height: var(--city-viewport-height);
    min-height: var(--city-viewport-height);
    padding-left: var(--city-safe-left);
    padding-right: var(--city-safe-right);
}

.city-world-viewport,
.city-world-surface,
.city-world-canvas {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.city-world-surface {
    isolation: isolate;
}

.city-world-fallback {
    position: absolute;
    inset: 0;
    z-index: 3;
    overflow: hidden;
    pointer-events: auto;
    touch-action: manipulation;
}

.city-world-engine-ready .city-world-fallback {
    display: none;
}

.city-world-fallback-animal {
    position: absolute;
    left: var(--animal-x, 50%);
    top: var(--animal-y, 65%);
    z-index: var(--animal-z, 10);
    display: block;
    width: var(--animal-size, 78px);
    height: var(--animal-size, 78px);
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    transform: translate3d(-50%, -94%, 0);
    transform-origin: 50% 94%;
    animation: cityFallbackRoam var(--animal-duration, 7s) ease-in-out var(--animal-delay, 0s) infinite alternate;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

.city-world-fallback-animal[data-animal-type="cow"] {
    --fs0:1; --fs1:1.120; --fs2:1.120; --fs3:1.120; --fs4:1.120;
    --fs5:1; --fs6:1; --fs7:1; --fs8:1;
}
.city-world-fallback-animal[data-animal-type="goose"] {
    --fs0:1; --fs1:1.020; --fs2:1.020; --fs3:1.020; --fs4:1.020;
    --fs5:1; --fs6:1; --fs7:1; --fs8:1;
}
.city-world-fallback-animal[data-animal-type="chicken"] {
    --fs0:1; --fs1:1.025; --fs2:1.025; --fs3:1.025; --fs4:1.025;
    --fs5:1; --fs6:1; --fs7:1; --fs8:1;
}
.city-world-fallback-animal[data-animal-type="chick"] {
    --fs0:1; --fs1:1.025; --fs2:1.025; --fs3:1.025; --fs4:1.025;
    --fs5:1; --fs6:1; --fs7:1; --fs8:1;
}

.city-world-fallback-sprite {
    position: absolute;
    inset: 0;
    display: block;
    background-color: transparent;
    background-image: var(--animal-atlas);
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: 500% 200%;
    filter: drop-shadow(0 4px 3px rgba(46, 68, 22, .18));
    transform-origin: 50% 95.3%;
    animation: cityFallbackWalkFrames .96s steps(1, end) var(--animal-delay, 0s) infinite;
}

.city-world-fallback-animal[data-animal-type="ostrich"] .city-world-fallback-sprite {
    animation-name: cityFallbackOstrichWalkFrames;
}

.city-world-fallback-shadow {
    position: absolute;
    left: 19%;
    right: 19%;
    bottom: 2%;
    height: 9%;
    border-radius: 50%;
    background: rgba(39, 75, 24, .2);
}

.city-world-fallback-animal::after {
    content: attr(data-action-label);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 7px);
    display: none;
    min-width: 76px;
    padding: 7px 12px;
    border: 2px solid #fff0bd;
    border-radius: 18px;
    background: #70401e;
    box-shadow: 0 4px 8px rgba(43, 24, 8, .32);
    color: #fff;
    font: 700 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    text-align: center;
    white-space: nowrap;
    transform: translateX(-50%);
}

.city-world-fallback-animal.is-selected::after {
    display: block;
}

@keyframes cityFallbackRoam {
    0% { transform: translate3d(calc(-50% - 11px), -94%, 0) rotate(-1deg); }
    48% { transform: translate3d(-50%, -96%, 0) rotate(.6deg); }
    100% { transform: translate3d(calc(-50% + 12px), -94%, 0) rotate(-.5deg); }
}

@keyframes cityFallbackWalkFrames {
    0%, 24% { background-position: 25% 0; }
    25%, 49% { background-position: 50% 0; }
    50%, 74% { background-position: 75% 0; }
    75%, 100% { background-position: 100% 0; }
}

@keyframes cityFallbackOstrichWalkFrames {
    0%, 24% { background-position: 25% 0; }
    25%, 49% { background-position: 50% 0; }
    50%, 74% { background-position: 100% 0; }
    75%, 100% { background-position: 50% 0; }
}

.farm-game .mobile-bottom-nav {
    height: calc(60px + env(safe-area-inset-bottom, 0px));
}
.farm-game .mobile-bottom-nav__item {
    gap: 1px;
    padding-top: 2px;
    padding-bottom: 2px;
    font-size: 10px;
}
.farm-game .mobile-bottom-nav__item .farm-icon {
    width: 22px;
    height: 22px;
}

.city-world-canvas {
    pointer-events: auto !important;
    touch-action: manipulation;
    cursor: pointer;
    image-rendering: auto;
    background: transparent !important;
}

.city-world-surface[data-world-ready="loading"] .city-world-canvas {
    cursor: progress;
}

.city-world-dom-layer {
    position: absolute;
    inset: 0;
    z-index: 4;
    overflow: hidden;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.city-world-dom-entity {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    pointer-events: none;
    will-change: transform;
}

.city-world-dom-shadow {
    position: absolute;
    left: 50%;
    top: 0;
    border-radius: 50%;
    background: rgba(39, 75, 24, .2);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.city-world-dom-sprite {
    position: absolute;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background-color: transparent;
    background-repeat: no-repeat;
    background-size: 500% 200%;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    pointer-events: auto;
    transform-origin: 50% 50%;
    will-change: transform, background-position;
}

.city-world-dom-entity.is-selected .city-world-dom-shadow {
    box-shadow: 0 0 0 2px rgba(255, 241, 169, .95);
}

.city-world-dom-bubble {
    position: absolute;
    z-index: 9999;
    min-width: 102px;
    height: 47px;
    margin: 0;
    padding: 0 15px;
    border: 2px solid #fff0bd;
    border-radius: 18px;
    background: #70401e;
    box-shadow: 0 4px 8px rgba(43, 24, 8, .32);
    color: #fff;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    text-align: center;
    white-space: nowrap;
    appearance: none;
    -webkit-appearance: none;
    transform: translate3d(-9999px, -9999px, 0);
}

.city-world-dom-bubble__title,
.city-world-dom-bubble__subtitle {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.city-world-dom-bubble__title {
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 17px;
}

.city-world-dom-bubble__subtitle {
    color: #ffeabd;
    font-size: 10px;
    font-weight: 700;
    line-height: 13px;
}

.city-world-dom-bubble.is-ready .city-world-dom-bubble__subtitle {
    color: #e8ffe9;
}

.city-world-dom-bubble.is-ready {
    background: #2f9844;
}

@media (orientation: landscape) and (max-height: 520px) {
    .farm-hud { top: max(4px, var(--city-safe-top)); }
}
