:root {
  --deep: #041b2d;
  --deep2: #06263f;
  --teal: #12d3c6;
  --teal-dk: #0b8f88;
  --sun: #ffd166;
  --text: #eaf6ff;
  --muted: #9fc2d6;
  --you: #123a52;
  --guide: #0d4c47;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(120% 90% at 50% -10%, #0a3350 0%, var(--deep2) 45%, var(--deep) 100%);
  overflow: hidden;
}
.layout {
  height: 100dvh;
  display: flex;
  justify-content: center;
  gap: 22px;
}
.app {
  height: 100dvh;
  flex: 1 1 auto;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 18px calc(12px + env(safe-area-inset-bottom));
}

/* ---- How-this-works panel ------------------------------------------------
   Phone: a slide-up sheet behind the "How this works" button (there is no side
   on a phone). Desktop (>=1000px): a permanent sidebar and the button is hidden.
   One block of markup, two presentations — so the copy can never drift apart. */
.help {
  margin-top: 10px;
  border: 1px solid #17466a; background: #082a41; color: var(--muted);
  border-radius: 999px; padding: 7px 14px; font-size: 12px; font-weight: 700;
  font-family: inherit; cursor: pointer;
}
.help:active { border-color: var(--teal); color: var(--teal); }

/* Top actions row: "How this works" + "About this project", side by side under the subtitle. */
.hero-actions { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.hero-actions .help { margin-top: 0; }
.pill-link {
  display: inline-block; text-decoration: none;
  border: 1px solid #17466a; background: #082a41; color: var(--teal);
  border-radius: 999px; padding: 7px 14px; font-size: 12px; font-weight: 700;
}
.pill-link:hover, .pill-link:active { border-color: var(--teal); }

.scrim {
  position: fixed; inset: 0; background: rgba(2,12,20,.6);
  z-index: 20; border: 0;
}
.scrim[hidden] { display: none; }

.howto {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  max-height: 82dvh;
  overflow-y: auto;
  background: linear-gradient(170deg, #0a3350 0%, #072839 100%);
  border-top: 1px solid #17466a;
  border-radius: 20px 20px 0 0;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(101%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: rgba(18,211,198,.45) transparent;   /* Firefox */
}
/* Same slim, on-brand scrollbar as the card stage, instead of the OS default. */
.howto::-webkit-scrollbar { width: 8px; }
.howto::-webkit-scrollbar-track { background: transparent; }
.howto::-webkit-scrollbar-thumb {
  background: rgba(18,211,198,.35); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
.howto::-webkit-scrollbar-thumb:hover { background: rgba(18,211,198,.6); background-clip: content-box; }
.howto.open { transform: translateY(0); }

.howto-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.howto-head h2 { margin: 0; font-size: 17px; }
.howto-close {
  border: none; background: none; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 4px 6px; cursor: pointer;
}

.howto-intro {
  margin: 12px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--text);
}
.howto-intro + .howto-intro { margin-top: 8px; color: var(--muted); }
.howto-intro b { color: var(--teal); }

.howto-list {
  list-style: none; margin: 16px 0 0; padding: 16px 0 0;
  border-top: 1px solid #17466a;
  display: flex; flex-direction: column; gap: 13px;
}
.howto-list li { display: flex; gap: 11px; align-items: flex-start; }
.howto-list .ico { font-size: 17px; line-height: 1.3; width: 22px; flex: none; text-align: center; }
.howto-list b { font-size: 14px; }
.howto-list p { margin: 2px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.howto-foot {
  margin: 16px 0 0; padding-top: 12px; border-top: 1px solid #17466a;
  font-size: 11.5px; line-height: 1.45; color: #6f97ad;
}

@media (min-width: 1000px) {
  .help, .howto-close { display: none; }
  .scrim { display: none !important; }
  .howto {
    position: static;
    transform: none;
    width: 320px; flex: none;
    max-height: none;
    height: 100dvh;
    border: none;
    border-left: 1px solid #17466a;
    border-radius: 0;
    background: rgba(4,27,45,.55);
    padding: 30px 22px;
  }
  .app { margin: 0; }
}

.hero { text-align: center; padding: 22px 0 6px; }
.kicker { letter-spacing: .18em; text-transform: uppercase; font-size: 12px; color: var(--teal); font-weight: 700; }
.hero h1 { margin: 6px 0 2px; font-size: 30px; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

/* The stage scrolls: with a growing roster (dozens of animals) the card grid must scroll
   within the middle region while the hero stays on top and the composer stays pinned below.
   overscroll-behavior stops the scroll chaining to the page/body behind it. */
.stage {
  flex: 1; display: flex; flex-direction: column; align-items: stretch;
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: 10px; padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: rgba(18,211,198,.45) transparent;   /* Firefox */
}
/* WebKit (Chrome/Edge/Safari): a slim, rounded, on-brand scrollbar instead of the OS default. */
.stage::-webkit-scrollbar { width: 8px; }
.stage::-webkit-scrollbar-track { background: transparent; }
.stage::-webkit-scrollbar-thumb {
  background: rgba(18,211,198,.35); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
.stage::-webkit-scrollbar-thumb:hover { background: rgba(18,211,198,.6); background-clip: content-box; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.card {
  position: relative;
  border: 1px solid #17466a;
  background: linear-gradient(165deg, #0a3350 0%, #072839 100%);
  color: var(--text);
  border-radius: 16px;
  padding: 16px 8px 13px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:active { transform: scale(.97); }
.card .emoji { width: 56px; height: 56px; display: block; }   /* animal badge icon (was an emoji glyph) */
.card .name { font-weight: 800; font-size: 16px; }
.card .exhibit { font-size: 10.5px; color: var(--muted); text-align: center; }
.card.active {
  border-color: var(--teal);
  box-shadow: 0 10px 30px rgba(18,211,198,.28);
  background: linear-gradient(165deg, #0d4b46 0%, #0a3f3a 100%);
}
.card.active::after {
  content: ''; position: absolute; top: 9px; right: 9px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--teal);
  box-shadow: 0 0 0 0 rgba(18,211,198,.6); animation: ring 1.4s ease-out infinite;
}
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(18,211,198,.55); } 100% { box-shadow: 0 0 0 12px rgba(18,211,198,0); } }

/* Arrived from an exhibit QR: breathe gently until they tap. */
.card.invite { border-color: var(--sun); animation: invite 1.9s ease-in-out infinite; }
@keyframes invite {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,209,102,.0); }
  50%      { box-shadow: 0 6px 26px rgba(255,209,102,.30); }
}

.status { margin-top: 14px; color: var(--muted); font-size: 13px; min-height: 18px; text-align: center; }

/* Mode switch. Always visible — the room can get loud between one visitor and the next,
   and it has to be reachable before anyone taps an animal. */
.ptt-toggle {
  align-self: center;
  margin-top: 10px;
  border: 0; background: none; padding: 4px 6px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.ptt-hint { font-weight: 400; opacity: .75; }
.ptt-track {
  width: 34px; height: 20px; border-radius: 999px;
  background: #082a41; border: 1px solid #17466a;
  display: inline-flex; align-items: center; padding: 2px;
  transition: background .2s ease, border-color .2s ease;
}
.ptt-knob {
  width: 14px; height: 14px; border-radius: 50%;
  background: #6f97ad;
  transition: transform .18s ease, background .2s ease;
}
.ptt-toggle[aria-checked="true"] { color: var(--teal); }
.ptt-toggle[aria-checked="true"] .ptt-track { background: rgba(18,211,198,.16); border-color: var(--teal); }
.ptt-toggle[aria-checked="true"] .ptt-knob { transform: translateX(14px); background: var(--teal); }

.controls { display: flex; justify-content: center; gap: 8px; }
/* The pills sit side by side, so they have to read as a pair: one shared size, and a
   width fixed wide enough for the longest label — otherwise the row reflows under the
   visitor's thumb the moment a label changes. align-self overrides the centring the
   buttons set for their standalone use, so flex can stretch them to a common height. */
.controls > button {
  align-self: stretch;
  min-width: 176px;    /* clears the widest label ("Hold to talk", 170px) so text never
                          pushes a pill wider than its twin */
  justify-content: center;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 800;
}

/* Hold-to-talk. Big enough to hit without looking, since the visitor is watching the
   animal and not the phone. touch-action:none so a hold never turns into a page scroll. */
.talk {
  align-self: center;
  margin-top: 10px;
  border: 1px solid var(--teal);
  background: rgba(18,211,198,.12);
  color: var(--teal);
  border-radius: 999px;
  padding: 13px 26px;
  font-size: 15px; font-weight: 800;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease;
}
.talk[hidden] { display: none; }
/* While idle (visible but not held) the pill breathes an expanding ring, so it reads as
   "press me" — the visitor is watching the animal, not hunting for a control. The ring
   stops the instant they press (.holding wins), and honours reduced-motion. */
.talk:not(.holding) { animation: talkPulse 1.8s ease-out infinite; }
@keyframes talkPulse {
  0%   { box-shadow: 0 0 0 0 rgba(18,211,198,.40); }
  70%  { box-shadow: 0 0 0 13px rgba(18,211,198,0); }
  100% { box-shadow: 0 0 0 0 rgba(18,211,198,0); }
}
@media (prefers-reduced-motion: reduce) { .talk:not(.holding) { animation: none; } }
.talk.holding {
  background: var(--teal);
  color: #04212c;
  transform: scale(1.04);
  box-shadow: 0 0 0 6px rgba(18,211,198,.18);
}

.pause {
  align-self: center;
  margin-top: 10px;
  border: 1px solid #17466a;
  background: #082a41;
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: transform .12s ease, border-color .2s ease, background .2s ease;
}
.pause[hidden] { display: none; }
.pause:active { transform: scale(.96); }
.pause .pause-icon { font-size: 12px; line-height: 1; }
.pause.paused {
  border-color: var(--sun);
  background: rgba(255,209,102,.14);
  color: var(--sun);
}

.captions {
  margin-top: 14px; width: 100%;
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 2px;
}
.bubble {
  max-width: 85%; padding: 10px 13px; border-radius: 15px;
  font-size: 15px; line-height: 1.35; white-space: pre-wrap;
}
.bubble.you { align-self: flex-end; background: var(--you); border-bottom-right-radius: 5px; }
.bubble.guide { align-self: flex-start; background: var(--guide); border-bottom-left-radius: 5px; }

.composer { display: flex; gap: 8px; padding-top: 10px; }
.composer input {
  flex: 1; border: 1px solid #17466a; background: #082a41;
  color: var(--text); border-radius: 12px; padding: 13px 14px; font-size: 16px; outline: none;
}
.composer input::placeholder { color: #6f97ad; }
.composer input:focus { border-color: var(--teal); }
.send {
  border: none; background: var(--sun); color: #3a2a00; font-weight: 800;
  border-radius: 12px; padding: 0 18px; font-size: 15px; cursor: pointer;
}
.visitor-tag {
  text-align: center; color: #4d7186; font-size: 11px; padding-top: 6px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.linkish {
  border: none; background: none; padding: 2px 4px;
  color: var(--muted); font-size: 11px; font-family: inherit;
  text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer; opacity: .75;
}
.linkish:active { opacity: 1; color: var(--teal); }

/* "About this project" — promoted from a plain link to an accent pill so stakeholders
   spot it, without shouting over the animal cards. */
.about-cta {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--teal); background: rgba(18,211,198,.12);
  color: var(--teal); font-weight: 700; font-size: 12.5px; font-family: inherit;
  padding: 7px 15px; border-radius: 999px; text-decoration: none;
  transition: background .15s ease, transform .1s ease;
}
.about-cta:hover { background: rgba(18,211,198,.2); }
.about-cta:active { transform: scale(.97); }
