:root {
  --sky: #cfe6d8;
  --ink: #2e2a26;
  --cream: #f7eeda;
  --gold: #f5b921;
  --shadow: 0 4px 14px rgba(0, 0, 0, .25);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--sky);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif; color: var(--ink);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; padding: 0; background: none; cursor: pointer; touch-action: manipulation; }
img { -webkit-user-drag: none; }

/* screens */
#map-screen, #feed-screen { position: fixed; inset: 0; }
body[data-screen="map"] #feed-screen, body[data-screen="feed"] #map-screen { display: none; }

/* map: panzoom moves #world inside #map (it sets touch-action: none there) */
#map { position: absolute; inset: 0; overflow: hidden; }
#world {
  position: absolute; left: 0; top: 0;
  background: url(/assets/map/habitat-world.webp) 0 0 / 100% 100% no-repeat;
  will-change: transform;            /* own GPU layer: panning moves it without repainting */
}
.bubble {
  position: absolute; width: var(--bubble); height: var(--bubble);
  transform: translate(-50%, -50%);
  border-radius: 50%; overflow: hidden; background: var(--cream);
  /* unblurred rings only: big blurred shadows on 48 bubbles were the panning cost */
  box-shadow: 0 0 0 18px rgba(255,255,255,.92), 0 12px 0 18px rgba(0,0,0,.10);
  transition: transform .12s ease;
  contain: layout paint;
}
.bubble:active { transform: translate(-50%, -50%) scale(.94); }
.bubble img, .round img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* Bubble backgrounds: a soft pattern for the animal's home zone behind its
   cut-out icon. One tile is a third of the bubble, so it scales with the map. */
[data-zone="polar"].bubble, #feed-animal[data-zone="polar"] { background-image: url(/patterns/polar.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="forest"].bubble, #feed-animal[data-zone="forest"] { background-image: url(/patterns/forest.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="jungle"].bubble, #feed-animal[data-zone="jungle"] { background-image: url(/patterns/jungle.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="farm"].bubble, #feed-animal[data-zone="farm"] { background-image: url(/patterns/farm.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="savannah"].bubble, #feed-animal[data-zone="savannah"] { background-image: url(/patterns/savannah.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="dry_lands"].bubble, #feed-animal[data-zone="dry_lands"] { background-image: url(/patterns/dry_lands.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="desert"].bubble, #feed-animal[data-zone="desert"] { background-image: url(/patterns/desert.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="beach"].bubble, #feed-animal[data-zone="beach"] { background-image: url(/patterns/beach.svg); background-size: 34% 34%; background-repeat: repeat; }
[data-zone="ocean"].bubble, #feed-animal[data-zone="ocean"] { background-image: url(/patterns/ocean.svg); background-size: 34% 34%; background-repeat: repeat; }

/* round controls */
.round {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  background: #fff; box-shadow: var(--shadow); display: grid; place-items: center;
}
.mute { position: absolute; top: calc(var(--safe-top) + 12px); right: 12px; z-index: 5; }
.mute::before { content: "\1F50A"; font-size: 30px; }
.mute.off { background: #ddd; }
.mute.off::before { content: "\1F507"; }

/* small, low-key credits link for grown-ups */
.credits-link { position: absolute; left: 10px; bottom: calc(var(--safe-bottom) + 8px); z-index: 5; font: 600 13px system-ui;
  color: rgba(46, 42, 38, .55); background: rgba(255, 255, 255, .55); border-radius: 999px; padding: 2px 8px; text-decoration: none; }

/* zone name pills on the map */
.zone {
  position: absolute; transform: translate(-50%, -50%) scale(var(--label, 1)); z-index: 2;
  padding: 8px 20px; border-radius: 999px; color: #fff;
  font-size: 18px; font-weight: 800; white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0,0,0,.12), 0 0 0 3px rgba(255,255,255,.85);
}

/* ---------- feed (prototype look: dark teal, gold active, pink hearts) ---------- */
#feed-screen { --teal: #0c2522; --teal2: #14342f; --line: #24524a; background: var(--teal); color: #fff; display: flex; flex-direction: column; }
.feed-head { padding: calc(var(--safe-top) + 10px) 0 8px; background: var(--teal); z-index: 3; }
.animal-row { display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px; scrollbar-width: none; align-items: center; min-height: 80px; }
.animal-row::-webkit-scrollbar { display: none; }
.row-bubble { flex: 0 0 auto; width: 50px; height: 50px; margin: 3px; border-radius: 50%; overflow: hidden; background: var(--cream);
  box-shadow: 0 0 0 3px #3e4f4b; transition: width .2s, height .2s; background-size: 34% 34%; }
.row-bubble img { width: 100%; height: 100%; display: block; }
.row-bubble.selected { width: 66px; height: 66px; box-shadow: 0 0 0 4px var(--gold); }
.row-bubble.globe { background: #cfe6f3; }
.row-bubble[data-zone="polar"] { background-image: url(/patterns/polar.svg); }
.row-bubble[data-zone="forest"] { background-image: url(/patterns/forest.svg); }
.row-bubble[data-zone="jungle"] { background-image: url(/patterns/jungle.svg); }
.row-bubble[data-zone="farm"] { background-image: url(/patterns/farm.svg); }
.row-bubble[data-zone="savannah"] { background-image: url(/patterns/savannah.svg); }
.row-bubble[data-zone="dry_lands"] { background-image: url(/patterns/dry_lands.svg); }
.row-bubble[data-zone="desert"] { background-image: url(/patterns/desert.svg); }
.row-bubble[data-zone="beach"] { background-image: url(/patterns/beach.svg); }
.row-bubble[data-zone="ocean"] { background-image: url(/patterns/ocean.svg); }
.media-bar { margin: 4px 8px 0; display: grid; grid-template-columns: 1.15fr 1fr 1fr .75fr; gap: 4px; background: var(--teal2);
  border: 2px solid var(--line); border-radius: 999px; padding: 3px; }
.media-bar button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border-radius: 999px;
  font-size: 15px; font-weight: 800; color: #fff; white-space: nowrap; min-width: 0; }
.media-bar svg { width: 20px; height: 20px; flex: 0 0 auto; fill: currentColor; }
.media-bar button[data-media="photo"] svg { color: #6fe0c3; fill: none; }
.media-bar button[data-media="video"] svg { color: #7cc4ff; fill: none; }
.media-bar .fav svg { fill: #ff5a7a; }
.media-bar button.active { background: var(--gold); color: var(--ink); }
.media-bar button.active svg { color: var(--ink); }
.feed-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 12px 12px 40px; }
.grid { display: flex; gap: 12px; align-items: flex-start; }
.col { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tile { position: relative; border-radius: 22px; overflow: hidden; background: var(--teal2); box-shadow: 0 0 0 2px var(--line);
  content-visibility: auto; }
.tile .frame { position: absolute; inset: 0; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.tile.ready img { opacity: 1; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.play-badge { position: absolute; left: 12px; bottom: 12px; width: 52px; height: 52px; border-radius: 50%; z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.5 7.5l7 4.5-7 4.5z' fill='%232e2a26'/%3E%3C/svg%3E") 55% 50% / 55% no-repeat; }
.t-heart { z-index: 3; }
.t-heart { position: absolute; top: 8px; right: 8px; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20, 30, 28, .45); }
.t-heart svg, .z-heart svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 2.2; }
.t-heart.on svg, .z-heart.on svg { fill: #ff5a7a; stroke: #ff5a7a; }
.sentinel { height: 1px; }
.end { text-align: center; padding: 28px 0 10px; }
.end[hidden] { display: none; }
.chip { position: sticky; bottom: 14px; margin: 0 auto; width: 92px; height: 56px; border-radius: 999px; background: #fff;
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.chip[hidden] { display: none; }
.runner.small { width: 64px; }
.pull { position: absolute; left: 50%; top: 0; width: 92px; height: 56px; margin-left: -46px; border-radius: 999px; background: #fff;
  display: grid; place-items: center; transform: translateY(-80px); transition: transform .2s; z-index: 4; pointer-events: none; }
.pull.armed { background: var(--gold); }
.feed-scroll { position: relative; }
.zoom { touch-action: none; }
.loader { display: grid; place-items: center; padding: 60px 0; }
.runner { width: min(60vw, 260px); background-repeat: no-repeat; background-size: 400% 100%; animation: run .6s steps(4) infinite; }
@keyframes run { from { background-position: 0 0; } to { background-position: 133.333% 0; } }
#feed-screen .empty { padding-top: 15vh; display: grid; justify-items: center; gap: 20px; }
#feed-screen .empty[hidden], .grid[hidden], .loader[hidden], .zoom[hidden] { display: none; }
.more { font-size: 28px; font-weight: 800; margin: 0; }
.empty-globe { width: 96px; height: 96px; background: #cfe6f3; }
.empty-actions { display: flex; gap: 24px; }
.try-again { width: 96px; height: 96px; font-size: 48px; background: var(--gold); color: var(--ink); }
/* enlarged view: controls in their own layer above the stage */
.zoom { position: fixed; inset: 0; z-index: 20; background: #06130f; }
.zoom-stage { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 16px; }
.zoom-stage video { max-width: 100%; max-height: calc(100dvh - 220px); border-radius: 22px; display: block; background: #000; }
.zoom-stage [hidden] { display: none; }
.zoom-stage img { max-width: 100%; max-height: calc(100dvh - 220px); border-radius: 22px; display: block; }
.credit { margin: 10px 0 0; font-size: 12px; opacity: .7; text-align: center; }
.zoom-controls { position: absolute; left: 0; right: 0; top: calc(var(--safe-top) + 16px); display: flex; gap: 12px;
  padding: 0 16px; pointer-events: none; z-index: 2; }
.zoom-controls button { pointer-events: auto; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: #22332f; color: #fff; }
.z-sound::before { content: "\1F50A"; font-size: 30px; }
.z-sound.off::before { content: "\1F507"; }
.z-close { margin-left: auto; background: var(--gold) !important; color: var(--ink) !important; }
.z-close svg { width: 34px; height: 34px; }
