:root {
  --paper: #f7f3e8;
  --white: #fffdf7;
  --ink: #172c24;
  --muted: #4c6256;
  --forest: #203d30;
  --sage: #e5eddb;
  --line: #d7dacc;
  --gold: #efb657;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: Inter, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 1rem/1.6 var(--sans); }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
a { color: inherit; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 3px solid #a45433;
  outline-offset: 3px;
}
.sr-only, .skip:not(:focus) { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.skip:focus { position: absolute; z-index: 5; padding: 10px 16px; background: white; }
.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.08; }
h2 { font-size: clamp(1.9rem, 3.5vw, 2.8rem); }
h3 { line-height: 1.25; }
.topbar { color: var(--paper); background: #14271f; border-bottom: 1px solid #34493b; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-inner { min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 600 1.55rem var(--serif); }
.brand img { display: block; }
nav { display: flex; gap: clamp(12px, 3vw, 31px); align-items: center; }
nav a { display: inline-flex; align-items: center; min-height: 44px; white-space: nowrap; font-size: .89rem; font-weight: 600; text-decoration: none; }
nav a:hover { text-decoration: underline; }

.hero {
  color: var(--paper);
  background: #14271f url("../images/field-guide.webp") center 6% / cover no-repeat;
}
.hero-inner { display: flex; min-height: 330px; flex-direction: column; justify-content: center; padding-block: 42px 50px; }
.eyebrow { text-transform: uppercase; font-weight: 750; letter-spacing: .17em; font-size: .73rem; color: var(--gold); }
.hero h1 { font-size: clamp(4.1rem, 8vw, 7.6rem); font-weight: 500; letter-spacing: -.075em; margin: 5px 0 12px; }
.hero p:last-child { font-size: clamp(1rem, 1.6vw, 1.24rem); max-width: 35rem; color: #eceddb; }

.game-section { padding-block: 27px 48px; scroll-margin-top: 12px; }
.game-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.mode-switch { display: inline-flex; border-radius: 11px; padding: 4px; background: #eae9dc; }
.mode-switch button { border: 0; border-radius: 8px; padding: 6px 15px; min-height: 44px; font-size: .91rem; font-weight: 700; color: var(--muted); background: transparent; }
.mode-switch button[aria-pressed=true] { color: white; background: var(--forest); }
.puzzle-label { color: var(--muted); font-size: .86rem; }
.board {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 8px 24px #172c240c;
}
.guess-panel, .tree-panel { min-width: 0; padding: 28px 32px; }
.guess-panel > p:first-of-type, .tree-panel > p { color: var(--muted); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.panel-heading h2 { font-size: clamp(1.65rem, 3vw, 2.5rem); }
.counter { background: var(--sage); color: var(--forest); padding: 4px 11px; border-radius: 100px; white-space: nowrap; font-size: .84rem; font-weight: 750; }
.search-row { display: flex; gap: 8px; margin-block: 18px 8px; }
.search-field { position: relative; flex: 1; min-width: 0; }
#animal-search { color: var(--ink); width: 100%; min-height: 49px; border: 1px solid #abb7a6; border-radius: 9px; padding: 9px 12px; background: #fff; }
#animal-search::placeholder { color: #536459; opacity: 1; }
.primary { min-height: 47px; color: white; background: var(--forest); border: 1px solid var(--forest); border-radius: 9px; padding: 8px 15px; font-weight: 700; }
.primary:hover:not(:disabled) { background: #2c543f; }
.primary span { padding-left: 5px; }
.suggestions { position: absolute; z-index: 2; inset: calc(100% + 4px) 0 auto; max-height: 235px; overflow-y: auto; list-style: none; padding: 4px; margin: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--white); box-shadow: 0 8px 24px #172c2420; }
.suggestions li { display: flex; align-items: center; gap: 9px; cursor: pointer; min-height: 49px; padding: 5px 8px; border-radius: 6px; font-size: .95rem; line-height: 1.3; }
.suggestions small { display: block; color: var(--muted); font-size: .77rem; font-style: italic; }
.suggestions .already-guessed { color: #783e28; font-style: normal; }
.suggestions li:hover, .suggestions li[aria-selected=true] { background: var(--sage); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quiet { color: var(--forest); min-height: 44px; background: transparent; border: 0; border-radius: 7px; padding: 4px 8px; font-size: .87rem; font-weight: 700; }
.quiet:hover:not(:disabled) { background: var(--sage); }
.quiet small { margin-left: 3px; font-size: .76rem; color: var(--muted); }
.guess-panel .feedback { color: #783e28; font-size: .91rem; }
.feedback:not(:empty) { margin-top: 3px; }
.starter-guesses { padding-block: 5px 8px; }
.starter-guesses p { margin-bottom: 5px; color: var(--muted); font-size: .8rem; }
.starter-options { display: flex; flex-wrap: wrap; gap: 6px; }
.starter-guess {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 8px 4px 4px;
  color: var(--forest);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: .83rem;
  font-weight: 700;
}
.starter-guess:hover { background: var(--sage); }
.starter-guess .animal-image { flex: 0 0 30px; height: 30px; border-radius: 4px; }
.next-guess {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid #c9d7bd;
  border-left: 3px solid #69855f;
  border-radius: 7px;
  background: #f1f6ea;
}
.next-guess-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 12px;
}
.next-guess-summary p { font-size: .93rem; font-weight: 750; }
.next-guess .quiet { padding-inline: 5px; text-decoration: underline; }
.clue-summary { margin: 3px 0 0; padding-top: 8px; border-top: 1px solid #c9d7bd; font-size: .86rem; }
.clue-summary > div { display: grid; grid-template-columns: minmax(7.5rem, 1fr) minmax(0, 2fr); gap: 6px 10px; }
.clue-summary > div + div { margin-top: 5px; }
.clue-summary dt { color: var(--muted); font-weight: 650; }
.clue-summary dd { margin: 0; overflow-wrap: anywhere; }
.friend-challenge { margin-bottom: 8px; padding: 7px 9px; border-radius: 6px; background: var(--sage); font-size: .9rem; font-weight: 650; }
.tree-panel { background: var(--sage); border-left: 1px solid var(--line); border-radius: 0 17px 17px 0; }
.tree-panel h3 { font: 600 1.63rem var(--serif); margin-bottom: 5px; }
.tree-panel p { font-size: .9rem; }
.tree { padding: 0; margin: 16px 0 6px; list-style: none; }
.tree li { display: flex; align-items: center; gap: 11px; position: relative; min-height: 37px; padding-left: 6px; font-weight: 700; font-size: .93rem; overflow-wrap: anywhere; }
.tree li:not(:last-child)::after { content: ""; position: absolute; top: 50%; bottom: -50%; left: 13px; width: 2px; background: #818f75; }
.node { z-index: 1; flex: 0 0 16px; height: 16px; border: 2px solid #607d58; border-radius: 50%; background: var(--sage); }
.latest .node, .solved .node { background: var(--forest); border-color: var(--forest); }
.tree small { display: inline-block; margin-left: 7px; color: var(--muted); font-style: italic; font-weight: 450; }
.branch-link { min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--forest); text-align: left; font-weight: inherit; text-decoration: underline; text-decoration-color: #869b80; text-underline-offset: 3px; }
.tree-branch { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding-block: 5px; }
.branch-guesses { display: flex; flex-wrap: wrap; gap: 4px; border-left: 1px solid #818f75; padding-left: 9px; }
.branch-guesses > .clue-animal { max-width: 100%; background: #f6f8ef; color: var(--muted); border-radius: 6px; padding: 3px 7px 3px 3px; font-size: .8rem; font-weight: 600; }
.tree-branch, .clue-animal { min-width: 0; }
.tree-empty { padding-left: 32px; }
.puzzle-meta, .clue-heading, .result-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clue-heading { justify-content: space-between; }
.clue-heading h3 { margin: 0; }
.view-switch { display: flex; padding: 3px; border: 1px solid #a7b59e; border-radius: 8px; }
.view-switch button { min-height: 44px; padding: 4px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--forest); font-size: .84rem; font-weight: 700; }
.view-switch button[aria-pressed=true] { background: var(--forest); color: white; }
.clue-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .86rem; text-align: left; }
.clue-table th, .clue-table td { padding: 8px 6px 8px 0; border-bottom: 1px solid #b4c0a8; vertical-align: top; overflow-wrap: anywhere; }
.clue-table tr > :last-child { width: 3.2rem; padding-right: 0; text-align: right; white-space: nowrap; }
.clue-table .correct { color: var(--forest); }
.clue-animal { display: flex; align-items: center; gap: 6px; }
.clue-animal .animal-image { flex: 0 0 30px; height: 30px; border-radius: 5px; }
.tree-panel .tree-empty { margin-top: 10px; padding-left: 0; }
.archive-form { display: grid; gap: 8px; margin-top: 14px; }
.archive-form input, #browse-search { width: 100%; min-height: 44px; border: 1px solid #abb7a6; border-radius: 8px; padding: 8px; background: white; color: var(--ink); }
#browse-search { margin-top: 14px; }
.match-filter { display: flex; gap: 8px; align-items: center; min-height: 44px; font-size: .88rem; cursor: pointer; }
.match-filter input { width: 17px; height: 17px; accent-color: var(--forest); }
#browse-count { margin: 8px 0; color: var(--muted); font-size: .88rem; }
#browse-dialog { width: min(800px, calc(100% - 26px)); }
.browse-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-height: 48vh; overflow: auto; padding: 2px; margin: 0; list-style: none; }
.browse-list li { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.browse-list button { display: block; width: 100%; padding: 0; min-height: 44px; background: none; border: 0; border-radius: 8px; text-align: left; color: var(--ink); }
.browse-list button:disabled { opacity: 1; cursor: default; }
.browse-list button:hover:not(:disabled) { background: var(--sage); }
.browse-list button:focus-visible { outline-offset: -3px; }
.browse-list small { display: block; color: var(--muted); font-style: italic; }
.animal-image { display: grid; place-items: center; overflow: hidden; min-width: 0; background: var(--sage); color: var(--muted); font-size: .72rem; }
.animal-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.suggestions .animal-image { flex: 0 0 37px; height: 37px; border-radius: 5px; }
.browse-list .animal-image { aspect-ratio: 4 / 3; border-radius: 7px 7px 0 0; }
.gallery-animal-name { display: block; padding: 6px 8px 4px; line-height: 1.35; font-size: .89rem; overflow-wrap: anywhere; }
.photo-credit { display: block; color: var(--muted); font-size: .72rem; line-height: 1.35; overflow-wrap: anywhere; }
.browse-list .photo-credit { padding: 3px 8px 8px; }
.gallery-pager { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; font-size: .84rem; }
.result-photo { margin: 10px 0 14px; }
.result-photo .animal-image { max-width: 320px; aspect-ratio: 4 / 3; border-radius: 8px; }
.result-photo img { object-fit: contain; }
.result-photo figcaption { margin-top: 5px; }
#learn-animal { display: inline-flex; align-items: center; min-height: 44px; font-size: .85rem; }
.result .share-status { color: var(--forest); font-size: .88rem; margin: 4px 0; }
.result .share-status:empty { display: none; }
.result .score-strip { letter-spacing: .1em; overflow-wrap: anywhere; }
#challenge-outcome { font-weight: 700; }
.result-lineage { display: block; margin-top: 4px; font-size: .85rem; color: var(--muted); }
.field-example { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px 28px; align-items: start; max-width: 880px; margin-block: 12px 16px; }
.field-example > div > p:first-child { margin-top: 0; }
.field-photo { margin: 0; max-width: 420px; }
.field-photo img { display: block; width: 100%; height: auto; border-radius: 10px; }
.field-photo figcaption { margin-top: 4px; color: var(--muted); font-size: .84rem; }
.result { padding: 13px 15px; margin-top: 10px; border-radius: 9px; background: var(--sage); }
.result p { margin: 4px 0 11px; }
#share-fallback { margin-top: 8px; }
textarea { display: block; width: 100%; border: 1px solid #abb7a6; border-radius: 6px; padding: 8px; }
dialog { color: var(--ink); background: var(--white); width: min(460px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
dialog::backdrop { background: #13291db5; }
.close { float: right; margin-top: -10px; font-size: 1.4rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 5px; margin: 16px 0; }
.stats div { background: var(--sage); border-radius: 8px; padding: 8px 4px; }
.stats dt { font-size: .78rem; }
.stats dd { margin: 0; font-size: 1.3rem; font-weight: 700; }

.guide { padding-block: 35px 54px; border-top: 1px solid var(--line); }
.guide > p, .faq > p { color: var(--muted); margin-top: 10px; max-width: 70ch; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; gap: 14px; padding: 0; margin: 23px 0 34px; counter-reset: step; }
.steps li { counter-increment: step; border: 1px solid var(--line); border-radius: 13px; padding: 20px; background: var(--white); }
.steps li::before { content: counter(step); display: grid; place-items: center; border-radius: 50%; width: 30px; height: 30px; margin-bottom: 11px; color: var(--forest); background: var(--sage); font-size: .85rem; font-weight: 800; }
.steps p, .reading p { margin-top: 8px; }
.reading > :not(.field-example) { max-width: 73ch; }
.reading h3 { margin-top: 25px; }
.example { border: 1px solid var(--line); border-radius: 12px; background: var(--sage); padding: 18px 20px; margin: 18px 0 21px; }
.example ol { margin: 6px 0 0; padding-left: 20px; }
.example li { padding-block: 4px; }
.faq-shell { background: #eeeedd; padding-block: 39px 55px; }
.faq > details { border-bottom: 1px solid #c6cebc; }
.faq > details:first-of-type { margin-top: 15px; }
summary { cursor: pointer; font-weight: 730; padding: 12px 0; }
details p { padding-bottom: 14px; max-width: 73ch; }
.back-to-play { display: inline-block; padding-block: 12px; margin-top: 10px; font-weight: 750; }
.footer { background: linear-gradient(180deg, #1d362a, #14271f); color: var(--paper); padding: 36px 0 20px; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; align-items: start; gap: 24px; }
.footer-brand p, .footer-note p { color: #c8d5c6; font-size: .86rem; }
.footer-brand p { margin-block: 8px 2px; }
.footer-contact { display: inline-flex; align-items: center; min-height: 44px; color: #c8d5c6; font-size: .86rem; }
.footer-nav { display: block; }
.footer-nav p { font-size: .9rem; font-weight: 750; }
.footer-nav ul { margin: 4px 0 0; padding: 0; list-style: none; }
.footer-nav a { min-height: 44px; color: #c8d5c6; font-weight: 500; white-space: normal; }
.footer a:hover { color: var(--gold); }
.footer-note { border-top: 1px solid #456453; text-align: center; margin-top: 20px; padding-top: 15px; }
.footer-note p + p { margin-top: 3px; }
.legal { max-width: 810px; min-height: 65vh; padding-block: 50px 66px; }
.legal h1 { font-size: clamp(2.3rem, 6vw, 4rem); }
.legal h2 { font-size: 1.65rem; margin-top: 24px; }
.legal p { margin-top: 12px; overflow-wrap: anywhere; }

@media (max-width: 680px) {
  .wrap { width: calc(100% - 32px); }
  .topbar-inner { min-height: 59px; }
  .brand { gap: 6px; font-size: 1.27rem; }
  .brand img { width: 29px; height: 29px; }
  nav { gap: 12px; }
  nav a { font-size: .79rem; }
  .hero { background-image: linear-gradient(90deg, #111e16d0, #111e1610), url("../images/field-guide.webp"); background-position: 73% 43%; }
  .hero-inner { min-height: 200px; padding-block: 24px; }
  .hero h1 { font-size: clamp(3.5rem, 13vw, 5.2rem); }
  .hero .eyebrow { max-width: 17rem; letter-spacing: .12em; }
  .hero p:last-child { max-width: 15rem; }
  .game-section { padding-block: 20px 30px; }
  .browse-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-example { grid-template-columns: 1fr; }
  .board, .steps { grid-template-columns: 1fr; }
  .guess-panel, .tree-panel { padding: 20px 15px; }
  .panel-heading h2 { font-size: clamp(1.38rem, 6vw, 1.65rem); }
  .tree-panel { border-left: 0; border-top: 1px solid var(--line); border-radius: 0 0 17px 17px; }
  .search-row { gap: 6px; }
  .starter-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .starter-guess { gap: 4px; padding-right: 3px; text-align: left; line-height: 1.1; font-size: .76rem; }
  .starter-guess .animal-image { flex-basis: 24px; height: 24px; }
  .primary { padding-inline: 11px; }
  .steps { margin-bottom: 23px; }
  .guide { padding-block: 28px 39px; }
  .footer-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
  .footer-brand { grid-column: 1 / -1; }
}
