/* Layout: a field-guide spread of three panels: the perch (sky + cockatoo), the aviary
   (habitat strips, one per species), and the store (a ledger of upgrades and birds).
   On phones the panels become tabs. */
:root {
  --bg: #e2ebe3;
  --surface: #f7faf5;
  --surface-2: #edf3eb;
  --surface-3: #dde7dc;
  --ink: #1c2620;
  --ink-soft: #4f5f55;
  --ink-faint: #78887e;
  --line: #c5d3c7;
  --euc: #2d684c;
  --euc-ink: #ffffff;
  --ochre: #ad5317;
  --sulphur: #f1c232;
  --sulphur-ink: #3b2c00;
  --galah: #cf5c7b;
  --good: #1f7444;
  --bad: #ad3438;
  --sky-top: #93c9ea;
  --sky-bottom: #e6f1e3;
  --sun: #ffd96b;
  --water: #4f9fc0;
  --water-deep: #2e7091;
  --scrim: rgba(18, 28, 22, 0.45);
  --shadow: 0 1px 2px rgba(28, 38, 32, 0.08), 0 6px 18px rgba(28, 38, 32, 0.1);
  --scene-filter: none;
  --focus: #1d5a3f;
  --day: 1;
  --night: 0;

  --font-display: "Alfa Slab One", "Rockwell", "Roboto Slab", Georgia, serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1411;
    --surface: #141e19;
    --surface-2: #1a2620;
    --surface-3: #22332a;
    --ink: #e5ede7;
    --ink-soft: #a3b4a9;
    --ink-faint: #71847a;
    --line: #2b3c33;
    --euc: #72c298;
    --euc-ink: #0d1411;
    --ochre: #ea9455;
    --sulphur: #f4cf5a;
    --sulphur-ink: #2e2200;
    --galah: #f08aa8;
    --good: #6fd29a;
    --bad: #f27f7f;
    --sky-top: #07112a;
    --sky-bottom: #1b2c3b;
    --sun: #f1ead0;
    --water: #2b6c88;
    --water-deep: #1a4b61;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.35);
    --scene-filter: brightness(0.72) saturate(0.85);
    --focus: #f4cf5a;
    --day: 0;
    --night: 1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1411;
  --surface: #141e19;
  --surface-2: #1a2620;
  --surface-3: #22332a;
  --ink: #e5ede7;
  --ink-soft: #a3b4a9;
  --ink-faint: #71847a;
  --line: #2b3c33;
  --euc: #72c298;
  --euc-ink: #0d1411;
  --ochre: #ea9455;
  --sulphur: #f4cf5a;
  --sulphur-ink: #2e2200;
  --galah: #f08aa8;
  --good: #6fd29a;
  --bad: #f27f7f;
  --sky-top: #07112a;
  --sky-bottom: #1b2c3b;
  --sun: #f1ead0;
  --water: #2b6c88;
  --water-deep: #1a4b61;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.35);
  --scene-filter: brightness(0.72) saturate(0.85);
  --focus: #f4cf5a;
  --day: 0;
  --night: 1;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible, [tabindex]:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--sulphur) 45%, transparent);
}

h1, h2, h3 { margin: 0; text-wrap: balance; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.num { font-variant-numeric: tabular-nums; }

.seed-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.12em;
}
.seed-icon svg { width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------------ app frame */

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  padding-block: 12px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--euc);
  white-space: nowrap;
}

.ticker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 40px;
  padding: 0 14px 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  text-align: left;
}
.ticker:hover { border-color: var(--euc); }
.ticker-label {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--euc);
  color: var(--euc-ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ticker-window { position: relative; flex: 1; min-width: 0; overflow: hidden; height: 22px; }
.ticker-text {
  position: absolute;
  inset: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 22px;
}
.ticker-text.enter { animation: ticker-in 0.5s ease-out; }
@keyframes ticker-in {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.menu { display: flex; align-items: center; gap: 6px; }
.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  font-size: 14px;
}
.menu-btn:hover { border-color: var(--euc); color: var(--euc); }
.menu-btn svg { width: 18px; height: 18px; flex: none; }
.pill {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.icon-btn:hover { border-color: var(--euc); color: var(--euc); }
.icon-btn svg { width: 20px; height: 20px; }

.minibank { display: none; }

/* ------------------------------------------------------------------ board */

.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 30%) minmax(0, 1fr) minmax(320px, 370px);
  gap: 12px;
}

.panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 14px 16px 10px;
}
.panel-head h2, .panel-head h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 19px;
  color: var(--ink);
  margin-right: auto;
}
.panel-sub { color: var(--ink-faint); font-size: 13px; }

/* ------------------------------------------------------------------ perch */

.perch {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 78%);
  isolation: isolate;
}

.sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.sky-sun {
  position: absolute;
  top: 26%;
  right: 12%;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 14px color-mix(in srgb, var(--sun) 30%, transparent), 0 0 60px 20px color-mix(in srgb, var(--sun) 35%, transparent);
  opacity: var(--day);
}
.sky-moon {
  position: absolute;
  top: 24%;
  right: 14%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  box-shadow: inset -12px -4px 0 0 var(--sun);
  transform: rotate(-20deg);
  opacity: var(--night);
}
.sky-stars { position: absolute; inset: 0; opacity: var(--night); }
.sky-stars svg { position: absolute; top: 8%; left: 8%; width: 120px; height: 140px; }
.sky-hills {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
}
.sky-hills svg { width: 100%; height: 100%; display: block; }

.seed-rain { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

.bank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 22px 16px 6px;
  text-align: center;
  z-index: 1;
}
.bank-seeds {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.05;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 color-mix(in srgb, var(--surface) 70%, transparent);
  overflow-wrap: anywhere;
  justify-content: center;
}
.bank-seeds .seed-icon { width: 0.9em; height: 0.9em; }
.bank-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.bank-sps {
  margin-top: 4px;
  padding: 3px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.bank-sps.boosted { color: var(--good); }
.bank-sps.slowed { color: var(--bad); }

.buffs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 16px;
  z-index: 1;
}
.buff {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}
.buff.good { border-color: color-mix(in srgb, var(--sulphur) 70%, var(--line)); }
.buff.bad { border-color: color-mix(in srgb, var(--bad) 60%, var(--line)); color: var(--bad); }
.buff-icon { width: 22px; height: 22px; flex: none; }
.buff-icon svg { width: 100%; height: 100%; display: block; }
.buff-time { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-weight: 600; }
.buff-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--sulphur);
  transform-origin: left;
}
.buff.bad .buff-bar { background: var(--bad); }

.cockatoo {
  position: relative;
  flex: 1 1 auto;
  min-height: 130px;
  width: min(88%, 380px);
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  z-index: 1;
}
.cockatoo:focus-visible { outline-offset: -6px; }
.cockatoo-art {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 380px;
  margin: 0 auto;
  transition: transform 0.12s cubic-bezier(0.3, 1.6, 0.6, 1);
  filter: drop-shadow(0 10px 14px rgba(20, 30, 25, 0.22));
}
.cockatoo-art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.cockatoo:hover .cockatoo-art { transform: scale(1.03); }
.cockatoo.pressed .cockatoo-art { transform: scale(0.95); transition-duration: 0.05s; }
/* The cockatoo lives in the hollow: only its crest tips show until a tap pops it up. */
.cockatoo .cc-crest {
  transform: translateY(128px);
  transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.6, 1);
}
.cockatoo.excited .cc-crest { transform: translateY(0); }
.cockatoo .cc-eyelid { transition: opacity 0.05s; }
.pigeon-ring { position: absolute; pointer-events: none; z-index: 2; }
.ring-bird { position: absolute; left: 0; top: 0; will-change: transform; }
.ring-bird svg { width: 100%; height: 100%; display: block; overflow: visible; }
.cockatoo.blink .cc-eyelid { opacity: 1; }

.hint {
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--sulphur);
  color: var(--sulphur-ink);
  font-weight: 800;
  font-size: 14px;
  z-index: 1;
  animation: hint-bob 1.6s ease-in-out infinite;
}
@keyframes hint-bob {
  50% { transform: translateY(-4px); }
}

.billabong {
  position: relative;
  flex: none;
  width: 100%;
  height: 54px;
  margin-top: 10px;
  background: color-mix(in srgb, var(--surface-3) 70%, transparent);
  overflow: hidden;
  z-index: 1;
}
.billabong-water {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6%;
  background: linear-gradient(180deg, var(--water) 0%, var(--water-deep) 100%);
  transition: height 1.2s ease;
}
.billabong-water::before {
  content: "";
  position: absolute;
  left: -40px;
  right: -40px;
  top: -6px;
  height: 12px;
  background: radial-gradient(ellipse 20px 7px at 20px 7px, var(--water) 98%, transparent 100%) repeat-x;
  background-size: 40px 12px;
  animation: waves 6s linear infinite;
}
@keyframes waves {
  to { transform: translateX(40px); }
}
.billabong-label {
  position: absolute;
  left: 12px;
  bottom: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}
.billabong-label b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ aviary */

.aviary-panel { display: flex; flex-direction: column; }
.aviary {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
}
.aviary-empty {
  margin: 8px 4px;
  padding: 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-align: center;
}
.aviary-row {
  position: relative;
  flex: none;
  height: 100px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-3);
}
.aviary-scene { position: absolute; inset: 0; filter: var(--scene-filter); }
.aviary-scene svg { width: 100%; height: 100%; display: block; }
.aviary-label {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}
.aviary-label .count { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.aviary-sprites { position: absolute; inset: 0; }
.sprite {
  position: absolute;
  bottom: 13px;
  width: 46px;
  height: 46px;
  animation: sprite-bob 2.8s ease-in-out infinite;
}
.sprite svg { width: 100%; height: 100%; display: block; overflow: visible; }
.sprite.flip svg { transform: scaleX(-1); }
.sprite.new { animation: sprite-arrive 0.5s cubic-bezier(0.3, 1.6, 0.6, 1), sprite-bob 2.8s ease-in-out 0.5s infinite; }
@keyframes sprite-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes sprite-arrive {
  from { transform: translateY(-40px) scale(0.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ------------------------------------------------------------------ store */

.store { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.store-section { flex: none; }
.store-section + .store-section { border-top: 1px solid var(--line); }

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface-3);
}
.segmented button {
  min-width: 38px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.segmented button[data-mode="sell"][aria-pressed="true"] { color: var(--bad); }

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 60px));
  gap: 6px;
  padding: 0 16px 14px;
}
.upgrades-empty { margin: 0; padding: 0 16px 16px; color: var(--ink-faint); font-size: 13px; }
.upgrade {
  position: relative;
  aspect-ratio: 1;
  max-width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: transform 0.1s, border-color 0.15s;
}
.upgrade svg { width: 100%; height: 100%; display: block; }
.upgrade .tier-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border-radius: 999px;
  border: 1.5px solid var(--surface);
  color: #1c1c1c;
  font-size: 10px;
  font-weight: 900;
  line-height: 14px;
  text-align: center;
}
.upgrade .kind-badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  padding: 2px;
}
.upgrade.cant { opacity: 0.5; }
.upgrade.can { border-color: color-mix(in srgb, var(--sulphur) 80%, var(--line)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sulphur) 35%, transparent); }
.upgrade.can:hover { transform: translateY(-2px); }

.bird-list { display: flex; flex-direction: column; padding: 0 8px 12px; gap: 2px; }
.bird-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}
.bird-row:hover:not(.locked) { background: var(--surface-2); border-color: var(--line); }
.bird-icon { width: 52px; height: 52px; }
.bird-icon svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bird-text { min-width: 0; display: flex; flex-direction: column; }
.bird-name { font-weight: 800; font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; }
.bird-cost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--good);
}
.bird-row.cant .bird-cost { color: var(--bad); }
.bird-row.cant .bird-icon, .bird-row.cant .bird-name { opacity: 0.6; }
.bird-row.sell .bird-cost { color: var(--ochre); }
.bird-each { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; display: none; }
.bird-owned {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}
/* Night theme: a faint halo keeps black birds (bowerbird, black cockatoos) readable on dark panels. */
:root[data-theme="dark"] .bird-row:not(.locked) .bird-icon svg,
:root[data-theme="dark"] .upgrade > svg,
:root[data-theme="dark"] .tip-icon svg {
  filter: drop-shadow(0 0 1.5px rgba(235, 245, 238, 0.45));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bird-row:not(.locked) .bird-icon svg,
  :root:not([data-theme="light"]) .upgrade > svg,
  :root:not([data-theme="light"]) .tip-icon svg {
    filter: drop-shadow(0 0 1.5px rgba(235, 245, 238, 0.45));
  }
}
.bird-row.locked { cursor: default; }
.bird-row.locked .bird-icon { filter: brightness(0); opacity: 0.35; }
:root[data-theme="dark"] .bird-row.locked .bird-icon { filter: brightness(0) invert(0.75); opacity: 0.3; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bird-row.locked .bird-icon { filter: brightness(0) invert(0.75); opacity: 0.3; }
}
.bird-row.locked .bird-name { color: var(--ink-faint); }
.bird-row.bought { animation: row-pop 0.3s ease-out; }
@keyframes row-pop {
  40% { transform: scale(0.98); background: color-mix(in srgb, var(--sulphur) 22%, transparent); }
}

/* ------------------------------------------------------------------ tabbar (phones) */

.tabbar { display: none; }

/* ------------------------------------------------------------------ fx layers */

.fx, .spawn-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.spawn-layer { z-index: 35; }

.float-num {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink);
  text-shadow: 0 2px 0 var(--surface), 0 0 8px var(--surface);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  animation: float-up 1s ease-out forwards;
  will-change: transform, opacity;
}
.float-num.big { font-size: 30px; color: var(--ochre); }
@keyframes float-up {
  from { opacity: 1; transform: translate(var(--x), var(--y)) translate(-50%, -50%); }
  to { opacity: 0; transform: translate(var(--x), var(--y)) translate(-50%, -150%); }
}
.burst-seed {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  animation: burst 0.7s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
  will-change: transform, opacity;
}
.burst-seed svg { width: 100%; height: 100%; display: block; }
@keyframes burst {
  from { opacity: 1; transform: translate(var(--x), var(--y)) rotate(0deg); }
  to { opacity: 0; transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) rotate(var(--r)); }
}

.spawn {
  position: absolute;
  left: 0;
  top: 0;
  width: 88px;
  height: 88px;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: auto;
  border-radius: 50%;
  transform: translate(var(--x), var(--y));
  animation: spawn-in 0.6s ease-out;
}
.spawn svg { width: 100%; height: 100%; display: block; overflow: visible; }
.spawn-inner { display: block; width: 100%; height: 100%; animation: flutter 1.1s ease-in-out infinite; }
.spawn.whistler .spawn-inner { filter: drop-shadow(0 0 10px rgba(255, 205, 60, 0.85)); }
.spawn.magpie { width: 96px; height: 96px; animation: swoop-in 0.9s cubic-bezier(0.3, 0.8, 0.4, 1); }
.spawn.magpie .spawn-inner { animation: hover-swoop 1.4s ease-in-out infinite; }
.spawn.leaving { animation: spawn-out 0.8s ease-in forwards; }
.spawn.fading { opacity: 0.55; transition: opacity 2s; }
@keyframes spawn-in {
  from { opacity: 0; transform: translate(var(--x), var(--y)) scale(0.4); }
  to { opacity: 1; transform: translate(var(--x), var(--y)); }
}
@keyframes swoop-in {
  from { opacity: 0; transform: translate(calc(var(--x) - 260px), calc(var(--y) - 220px)) rotate(-20deg) scale(0.7); }
  to { opacity: 1; transform: translate(var(--x), var(--y)); }
}
@keyframes spawn-out {
  to { opacity: 0; transform: translate(calc(var(--x) + 160px), calc(var(--y) - 200px)) scale(0.6); }
}
@keyframes flutter {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-10px) rotate(4deg); }
}
@keyframes hover-swoop {
  0%, 100% { transform: translate(0, 0) rotate(-6deg); }
  50% { transform: translate(-8px, 8px) rotate(4deg); }
}

/* ------------------------------------------------------------------ tooltip */

.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 75;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  width: min(340px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), 0 12px 30px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  font-size: 13.5px;
}
.tooltip.pinned { pointer-events: auto; }
.tip-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tip-icon { width: 40px; height: 40px; flex: none; }
.tip-icon svg { width: 100%; height: 100%; display: block; }
.tip-title { font-weight: 800; font-size: 15px; line-height: 1.2; }
.tip-sub { color: var(--ink-faint); font-size: 12px; }
.tip-cost { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tip-cost.can { color: var(--good); }
.tip-cost.cant { color: var(--bad); }
.tip-desc { margin: 0 0 6px; }
.tip-flavor { margin: 0; color: var(--ink-soft); font-style: italic; }
.tip-fact { margin: 8px 0 0; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-soft); font-size: 12.5px; }
.tip-fact b { color: var(--euc); font-weight: 800; }
.tip-stats { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.tip-stats b { color: var(--ink); }
.tip-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 800;
  font-size: 14px;
}
.btn:hover { border-color: var(--euc); }
.btn.primary { background: var(--euc); border-color: var(--euc); color: var(--euc-ink); }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 14px 10px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), 0 10px 26px rgba(0, 0, 0, 0.16);
  animation: toast-in 0.35s cubic-bezier(0.3, 1.4, 0.6, 1);
}
.toast.out { animation: toast-out 0.3s ease-in forwards; }
.toast-icon { width: 40px; height: 40px; }
.toast-icon svg { width: 100%; height: 100%; display: block; }
.toast-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--euc); }
.toast.bad .toast-eyebrow { color: var(--bad); }
.toast-title { font-weight: 800; line-height: 1.25; }
.toast-text { color: var(--ink-soft); font-size: 13px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(12px); }
}

/* ------------------------------------------------------------------ sheets (dialogs) */

.sheet-backdrop { position: fixed; inset: 0; z-index: 70; background: var(--scrim); animation: fade-in 0.2s; }
.sheet {
  position: fixed;
  z-index: 71;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px));
  max-height: min(84vh, 820px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  animation: sheet-in 0.25s cubic-bezier(0.3, 1.3, 0.6, 1);
}
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-family: var(--font-display); font-weight: 400; font-size: 24px; margin-right: auto; }
.sheet-body { overflow-y: auto; padding: 16px 20px 22px; overscroll-behavior: contain; }
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, -46%) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }

.sheet-section + .sheet-section { margin-top: 22px; }
.sheet-section h3 {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  margin: 0;
}
.stat-grid > div { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); min-width: 0; }
.stat-grid dt { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.stat-grid dd { margin: 2px 0 0; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.badge {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  text-align: left;
}
.badge-icon { width: 34px; height: 34px; }
.badge-icon svg { width: 100%; height: 100%; display: block; }
.badge-name { font-weight: 800; line-height: 1.2; }
.badge-desc { color: var(--ink-faint); font-size: 12px; line-height: 1.3; }
.badge.locked { background: transparent; border-style: dashed; }
.badge.locked .badge-icon { filter: grayscale(1); opacity: 0.35; }
.badge.locked .badge-name { color: var(--ink-faint); }

.owned-upgrades { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.owned-upgrades .upgrade { cursor: default; }

.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--water); border-radius: inherit; }

.options-list { display: grid; gap: 14px; }
.option { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.option-label { font-weight: 700; }
.option-help { display: block; color: var(--ink-faint); font-size: 12.5px; font-weight: 400; }
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--euc); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
input[type="range"] { accent-color: var(--euc); width: 160px; }
.save-code {
  width: 100%;
  min-height: 90px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
  word-break: break-all;
}
.form-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.form-msg { font-size: 13px; color: var(--ink-soft); }
.form-msg.error { color: var(--bad); }
.form-msg.ok { color: var(--good); }

.away-hero { display: flex; align-items: center; gap: 16px; }
.away-hero .away-icon { width: 72px; height: 72px; flex: none; }
.away-hero .away-icon svg { width: 100%; height: 100%; }
.away-amount { font-family: var(--font-display); font-size: 30px; color: var(--ink); line-height: 1.1; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1180px) {
  .board { grid-template-columns: minmax(280px, 34%) minmax(0, 1fr) minmax(300px, 340px); }
  .menu-btn { padding: 0 11px; }
}

@media (max-width: 1100px) {
  .menu-btn .label { display: none; }
  .menu-btn { padding: 0 11px; }
}

@media (max-width: 980px) {
  .brand-name { font-size: 19px; }
}

@media (max-width: 860px) {
  body { font-size: 15px; }
  .app { gap: 8px; padding-block: 8px 0; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .ticker { grid-column: 1 / -1; grid-row: 2; height: 36px; }
  .menu { gap: 4px; }
  .menu-btn { height: 36px; padding: 0 9px; font-size: 13px; }
  .icon-btn { width: 36px; height: 36px; }
  .minibank {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    font-size: 15px;
  }
  .minibank .sps { color: var(--ink-soft); font-weight: 600; font-size: 13px; }
  .app[data-tab="perch"] .minibank { display: none; }
  .board { display: block; position: relative; }
  .panel { position: absolute; inset: 0; display: none; }
  .app[data-tab="perch"] .perch,
  .app[data-tab="aviary"] .aviary-panel,
  .app[data-tab="store"] .store { display: flex; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    flex: none;
    margin-left: calc(-1 * var(--gutter-l));
    margin-right: calc(-1 * var(--gutter-r));
    padding: 8px var(--gutter-r) calc(8px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .tabbar button {
    position: relative;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    font-weight: 800;
    font-size: 14px;
    color: var(--ink-soft);
  }
  .tabbar button[aria-current="page"] { background: var(--surface-3); color: var(--ink); }
  .tabbar .dot { position: absolute; top: 8px; right: calc(50% - 34px); width: 8px; height: 8px; border-radius: 50%; background: var(--ochre); }
  .bird-each { display: block; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .sheet { width: calc(100vw - 16px); max-height: calc(100% - 24px); }
  .cockatoo { width: min(86%, 340px); }
}

@media (max-width: 440px) {
  .brand-mark { display: none; }
  .brand-name { font-size: 17px; overflow: hidden; text-overflow: ellipsis; }
  .menu-btn { padding: 0 8px; }
  .badge-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .toast { grid-template-columns: 30px minmax(0, 1fr); padding: 8px 12px 8px 8px; }
  .toast-icon { width: 30px; height: 30px; }
  .toast-text { display: none; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 14px; }
  .menu { gap: 3px; }
  .menu-btn { padding: 0 7px; }
}

/* Short screens: tighten the perch so the cockatoo keeps its room. */
@media (max-height: 640px) {
  .bank { padding-top: 12px; }
  .bank-seeds { font-size: 28px; }
  .buffs { min-height: 0; padding-block: 2px; }
  .billabong { height: 36px; margin-top: 4px; }
  .hint { font-size: 12px; padding: 3px 10px; }
}

/* Phone landscape: one-row header, and the perch splits into numbers on the left, cockatoo on the right. */
@media (max-width: 860px) and (max-height: 500px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ticker { grid-column: auto; grid-row: auto; height: 34px; }
  .menu-btn, .icon-btn { height: 34px; }
  .icon-btn { width: 34px; }
  .tabbar { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
  .tabbar button { height: 36px; }
  .app[data-tab="perch"] .perch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    align-items: center;
  }
  .perch .bank { grid-column: 1; grid-row: 1; }
  .perch .buffs { grid-column: 1; grid-row: 2; }
  .perch .hint { grid-column: 1; grid-row: 3; justify-self: center; align-self: start; }
  .perch .cockatoo { grid-column: 2; grid-row: 1 / 5; width: 100%; height: 100%; min-height: 0; }
  .perch .billabong { grid-column: 1; grid-row: 4; align-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .float-num { animation: fade-only 1s forwards !important; transform: translate(var(--x), var(--y)) translate(-50%, -50%); }
  @keyframes fade-only { from { opacity: 1; } to { opacity: 0; } }
}
