/* The hub's forest: a painted clearing where every game is a sign hanging from a vine.
   Art is Ludo-generated (launcher/art/). Tablet landscape is the main screen. */

/* Luckiest Guy as shipped keeps 30% of its line box under the baseline that its capitals never use,
   so every label set in it rode ~0.17em high in its box. This face is the same files with the line box
   split around the capitals (measured: caps reach 0.72em above the baseline, nothing below), so text
   centred by layout is centred to the eye. fonts.css is generated by bin/fonts, hence living here. */
@font-face {
  font-family: "Luckiest Guy Centered";
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/luckiest-guy-normal-400-latin-ext.af70abe133.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
  ascent-override: 86%;
  descent-override: 14%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Luckiest Guy Centered";
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/luckiest-guy-normal-400-latin.e463777d6d.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  ascent-override: 86%;
  descent-override: 14%;
  line-gap-override: 0%;
}

:root {
  --ink: #3a1e0c;
  --cream: #fff4dc;
  --gold: #ffd54a;
  --rope: #d4ae6e;
  --night: #1d3a2c;
  --display: "Luckiest Guy Centered", "Luckiest Guy", "Baloo 2", system-ui, sans-serif;
  --round: "Baloo 2", system-ui, sans-serif;
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ink-soft: #7a5a3f;
  --paper: #fffaf0;
  --leaf: #2f7a3d;
  --leaf-soft: #dcf2d3;
  --berry: #b3261e;
  --berry-soft: #fde3dd;
  --amber-soft: #ffefc4;
  --drop: rgb(30 20 10 / 35%);
  --card: #ffffff;
  --rule: #eadfca;
}

body:has(.forest) {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 0;
  overflow-x: hidden;
  color-scheme: light;
  background: var(--night);
}
/* The backdrop stays put and fills the screen however long the list of signs grows. */
body:has(.forest)::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/static/forest/backdrop.9e5f3eac76.webp") center 35% / cover no-repeat;
}
main:has(.forest) { flex: 1; display: flex; width: auto; margin: 0; padding: 0; }

.forest {
  position: relative;
  isolation: isolate;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--round);
  color: var(--ink);
}

/* A breathing warm light in the clearing, over the painted rays. */
.forest-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse 45% 38% at 50% 32%, rgb(255 240 190 / 45%), transparent 70%);
  mix-blend-mode: soft-light;
  animation: breathe 7s ease-in-out infinite alternate;
  pointer-events: none;
}

.fireflies { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.fireflies i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff7b0;
  box-shadow: 0 0 10px 4px rgb(255 236 120 / 70%), 0 0 26px 8px rgb(255 220 90 / 30%);
  animation: drift var(--d) ease-in-out infinite alternate, blink calc(var(--d) * 0.6) ease-in-out infinite alternate;
}
.fireflies i:nth-child(1) { --x: 8%; --y: 30%; --d: 9s; }
.fireflies i:nth-child(2) { --x: 18%; --y: 62%; --d: 11s; }
.fireflies i:nth-child(3) { --x: 27%; --y: 18%; --d: 8s; }
.fireflies i:nth-child(4) { --x: 36%; --y: 76%; --d: 12s; }
.fireflies i:nth-child(5) { --x: 44%; --y: 40%; --d: 10s; }
.fireflies i:nth-child(6) { --x: 52%; --y: 14%; --d: 9.5s; }
.fireflies i:nth-child(7) { --x: 58%; --y: 68%; --d: 13s; }
.fireflies i:nth-child(8) { --x: 66%; --y: 28%; --d: 8.5s; }
.fireflies i:nth-child(9) { --x: 73%; --y: 82%; --d: 11.5s; }
.fireflies i:nth-child(10) { --x: 81%; --y: 46%; --d: 10.5s; }
.fireflies i:nth-child(11) { --x: 89%; --y: 22%; --d: 12.5s; }
.fireflies i:nth-child(12) { --x: 93%; --y: 64%; --d: 9s; }
.fireflies i:nth-child(13) { --x: 12%; --y: 88%; --d: 14s; }
.fireflies i:nth-child(14) { --x: 86%; --y: 90%; --d: 10s; }

/* Title and controls */

.forest-top {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
  padding: max(2.2dvh, env(safe-area-inset-top)) max(3vw, env(safe-area-inset-right)) 0 max(3vw, env(safe-area-inset-left));
}
.forest-logo { grid-column: 2; }
.forest-logo img {
  display: block;
  width: auto;
  height: clamp(97px, 22dvh, 232px); /* the sign plus the "by NumFox" plaque below it */
  max-width: min(64vw, 600px);
  object-fit: contain;
  filter: drop-shadow(0 8px 0 rgb(20 30 15 / 30%)) drop-shadow(0 0 30px rgb(255 230 150 / 35%));
  animation: logo-in 0.9s var(--pop) both, bob 5s ease-in-out 0.9s infinite alternate;
}
.forest-hud { grid-column: 3; justify-self: end; display: flex; gap: 12px; }

/* The painted face of button.webp (170x180) is a disc centred 10px above the picture's centre, the rim
   and its shadow below it: the bottom padding moves the content's centre onto the disc. Sizes are
   fractions of --b, never percentages of the grid area, which Safari resolves differently. */
.wood-button {
  --b: clamp(56px, 7.5dvh, 72px);
  display: grid;
  place-items: center;
  width: var(--b);
  height: calc(var(--b) * 180 / 170);
  padding: 0 0 calc(var(--b) * 0.118);
  background: url("/static/forest/button.2393e81a21.webp") center / contain no-repeat;
  font: 400 clamp(18px, 2.6dvh, 24px) / 1 var(--display);
  color: var(--ink);
  text-transform: uppercase;
  text-decoration: none;
  text-shadow: 0 2px 0 rgb(255 240 200 / 70%);
  filter: drop-shadow(0 5px 0 rgb(30 20 10 / 35%));
  transition: transform 0.15s var(--pop);
}
button.wood-button { border: 0; cursor: pointer; }
button.wood-button[hidden] { display: none; }
.sound-slash { display: none; }
.wood-button[aria-checked="false"] .sound-slash { display: inline; }
.wood-button[aria-checked="false"] .sound-waves { display: none; }
.wood-button:hover { transform: rotate(-6deg) scale(1.06); }
.wood-button:active { transform: scale(0.9); }

/* The signs. Every row hangs from its own run of vine: rows have a fixed height, so the vine
   is one background layer per row. */

.signs {
  --cols: 2;
  --gap: clamp(14px, 2.4vw, 34px);
  --sign: min(calc((100vw - 8vw - (var(--cols) - 1) * var(--gap)) / var(--cols)), 24dvh, 220px);
  --vine: clamp(26px, calc(var(--sign) * 0.24), 52px);
  --row: calc(var(--sign) * 1.66);
  --vines: url("/static/forest/branch.64c99f10c3.webp");
  width: 100%;
  margin-block: auto;
  padding: 1.5dvh max(4vw, env(safe-area-inset-right)) 0 max(4vw, env(safe-area-inset-left));
  list-style: none;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--sign));
  grid-auto-rows: var(--row);
  justify-content: center;
  column-gap: var(--gap);
  /* One run of vine per row; more layers than any hub can fill (21 signs on 2 columns is 11 rows). */
  background:
    var(--vines) 0% 1.5dvh / auto var(--vine) repeat-x,
    var(--vines) 37% calc(1.5dvh + 1 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 71% calc(1.5dvh + 2 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 13% calc(1.5dvh + 3 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 55% calc(1.5dvh + 4 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 28% calc(1.5dvh + 5 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 83% calc(1.5dvh + 6 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 6% calc(1.5dvh + 7 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 46% calc(1.5dvh + 8 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 64% calc(1.5dvh + 9 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 19% calc(1.5dvh + 10 * var(--row)) / auto var(--vine) repeat-x,
    var(--vines) 76% calc(1.5dvh + 11 * var(--row)) / auto var(--vine) repeat-x;
  filter: drop-shadow(0 6px 4px rgb(10 30 20 / 35%));
}
@media (min-width: 560px) { .signs { --cols: 3; } }
@media (min-width: 900px) and (min-aspect-ratio: 1 / 1) { .signs { --cols: 6; } }
@media (max-height: 520px) and (min-aspect-ratio: 1 / 1) { .signs { --cols: 6; } }

.sign-slot {
  --glow: #a8f0cf;
  --label: #ffffff;
  padding-top: calc(var(--vine) * 0.45);
  display: flex;
  justify-content: center;
  animation: drop-in 0.9s var(--pop) both;
  animation-delay: calc(0.25s + var(--i, 0) * 0.09s);
}
.sign-slot:nth-child(2) { --i: 1; }
.sign-slot:nth-child(3) { --i: 2; }
.sign-slot:nth-child(4) { --i: 3; }
.sign-slot:nth-child(5) { --i: 4; }
.sign-slot:nth-child(6) { --i: 5; }
.sign-slot:nth-child(n+7) { --i: 6; }
.sign-slot[data-slug="dale"] { --glow: #ffa64a; --label: #ffd9a8; }
.sign-slot[data-slug="clac"] { --glow: #5cc8ff; --label: #c9eeff; }
.sign-slot[data-slug="brochita"] { --glow: #bf8cff; --label: #e6d6ff; }
.sign-slot[data-slug="fosilito"] { --glow: #ffd84d; --label: #fff1a8; }
.sign-slot[data-slug="pompon"] { --glow: #ff7eb6; --label: #ffcde3; }
.sign-slot[data-slug="orbita"] { --glow: #7aa8ff; --label: #d3e2ff; }
.sign-slot[data-slug="hornito"] { --glow: #ff9f45; --label: #ffe0b8; }
.sign-slot[data-slug="pescadito"] { --glow: #4fc3d9; --label: #cdf1f6; }
.sign-slot[data-slug="bandita"] { --glow: #ff4fa3; --label: #ffd3ea; }
.sign-slot[data-slug="relojito"] { --glow: #4f86e0; --label: #d6e4ff; }
.sign-slot[data-slug="rebanadita"] { --glow: #3fcf9e; --label: #c8f3e3; }
.sign-slot[data-slug="subibaja"] { --glow: #a6d84a; --label: #e6f6c6; }
.sign-slot[data-slug="monarca"] { --glow: #f39a3d; --label: #ffe4c7; }
.sign-slot[data-slug="tiendita"] { --glow: #ff4f9a; --label: #ffd6e8; }
.sign-slot[data-slug="chapuzon"] { --glow: #2ec9dc; --label: #ccf4f8; }
.sign-slot[data-slug="pasito"] { --glow: #7cc242; --label: #e2f5cf; }
.sign-slot[data-slug="huevitos"] { --glow: #ffb72e; --label: #fff0c8; }
.sign-slot[data-slug="camitas"] { --glow: #8f8ae8; --label: #e6e4ff; }
.sign-slot[data-slug="casita"] { --glow: #f27a7d; --label: #ffe1df; }
.sign-slot[data-slug="parejitas"] { --glow: #3fb4c9; --label: #d2f1f6; }
.sign-slot[data-slug="guardadito"] { --glow: #ff8f6b; --label: #ffe3d8; }

.sign {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--sign);
  color: inherit;
  text-decoration: none;
  transform-origin: 50% calc(var(--vine) * -0.45);
  animation: sway var(--sway, 3.6s) ease-in-out infinite alternate;
  -webkit-tap-highlight-color: transparent;
}
.sign-slot:nth-child(2n) .sign { --sway: 4.2s; animation-delay: -1.3s; }
.sign-slot:nth-child(3n) .sign { --sway: 3.2s; animation-delay: -2.1s; }

.sign::before {
  content: "";
  width: 67%;
  height: calc(var(--sign) * 0.14);
  margin-bottom: calc(var(--sign) * -0.05);
  background:
    linear-gradient(var(--rope), var(--rope)) left / 5px 100% no-repeat,
    linear-gradient(var(--rope), var(--rope)) right / 5px 100% no-repeat;
}

.sign-board {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 408 / 440;
  padding: 18% 13% 9%;
  background: url("/static/forest/sign.506d74019e.webp") center / contain no-repeat;
  filter: drop-shadow(0 calc(var(--sign) * 0.04) 0 rgb(30 18 8 / 35%));
  transition: transform 0.25s var(--pop);
}
.sign-board::before {
  content: "";
  position: absolute;
  inset: -16%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  opacity: 0.55;
  animation: glow 2.8s ease-in-out infinite alternate;
}
.sign-initial {
  font: 400 calc(var(--sign) * 0.42) / 1 var(--display);
  color: var(--label);
  text-shadow: 0 4px 0 var(--ink), 0 0 18px var(--glow);
}
.sign-art {
  position: absolute;
  inset: 18% 13% 9%;
  width: 74%;
  height: 73%;
  object-fit: contain;
  filter: drop-shadow(0 4px 0 rgb(58 30 12 / 25%));
  transition: transform 0.3s var(--pop);
}

.sign-name {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  width: 100%;
  height: calc(var(--sign) * 0.24);
  margin-top: calc(var(--sign) * 0.02);
  font: 400 clamp(18px, calc(var(--sign) * 0.17), 36px) / 1 var(--display);
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--label);
  text-shadow:
    3px 0 var(--ink), -3px 0 var(--ink), 0 3px var(--ink), 0 -3px var(--ink),
    2px 2px var(--ink), -2px 2px var(--ink), 2px -2px var(--ink), -2px -2px var(--ink),
    0 6px 0 var(--ink), 0 0 22px var(--glow);
}

a.sign:hover .sign-board, a.sign:focus-visible .sign-board { transform: translateY(-5%) scale(1.05); }
a.sign:hover .sign-art, a.sign:focus-visible .sign-art { transform: scale(1.1) rotate(-4deg); }
a.sign:hover .sign-board::before, a.sign:focus-visible .sign-board::before { opacity: 1; }
a.sign:active .sign-board { transform: scale(0.94); transition-duration: 0.08s; }
a.sign:focus-visible { outline: none; }
a.sign:focus-visible .sign-name { outline: 4px solid var(--cream); outline-offset: 6px; border-radius: 12px; }

.is-soon .sign { animation-duration: 5s; }
.is-soon .sign-board { filter: saturate(0.75) brightness(0.92); }
.is-soon .sign-board::before { --glow: rgb(255 255 255 / 55%); opacity: 0.35; }
.is-soon .sign-name { --label: var(--cream); font-size: clamp(16px, calc(var(--sign) * 0.14), 30px); }

/* Tapped: the sign flares and the scene fills with its colour from where it was tapped. */
.sign.is-picked { animation: none; }
.sign.is-picked .sign-board { animation: picked 0.5s var(--pop) both; }
.sign.is-picked .sign-board::before { opacity: 1; animation: none; inset: -40%; }
.forest::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--leave, var(--cream));
  clip-path: circle(0 at var(--ox, 50%) var(--oy, 50%));
  transition: clip-path 0.55s cubic-bezier(0.6, 0, 0.4, 1) 0.12s;
  pointer-events: none;
}
.forest.is-leaving::after { clip-path: circle(150% at var(--ox, 50%) var(--oy, 50%)); }

/* Mathew: one whole picture per Outfit and pose (app/dress shows the one he wears). Every picture is the same
   3:4 frame with his feet on its bottom edge, so swapping Outfits never moves him. */
.mathew { position: relative; display: block; aspect-ratio: 3 / 4; }
.mathew-base { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; pointer-events: none; }

/* The fox */

.fox {
  align-self: flex-start;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 0 max(1.5dvh, env(safe-area-inset-bottom)) max(4vw, env(safe-area-inset-left));
  pointer-events: none;
}
.fox-art {
  width: auto;
  height: clamp(110px, 21dvh, 230px);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 6px 0 rgb(20 30 15 / 30%));
  animation: fox-in 0.8s var(--pop) 0.7s both, breathe-fox 3.4s ease-in-out 1.5s infinite;
}
/* Game chrome (issue 19): every panel, button and badge a child sees is Ludo art from
   forest/ui/, stretched by border-image so the painted ends keep their shape at any width.
   CSS only lays the art out and moves it (docs/conventions.md, UI). */

/* Acorns: a wooden plaque in the top-left corner of the forest (issue 22). */
.acorns {
  grid-column: 1;
  justify-self: start;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 8px 0 14px;
  font: 400 clamp(26px, 3.6dvh, 34px) / 1 var(--display);
  color: var(--cream);
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink), 0 4px 0 var(--ink);
  text-decoration: none;
  border: solid transparent;
  border-width: 18px 30px 18px 30px;
  border-image: url("/static/forest/ui/plaque.3598fa3d23.webp") 60 90 60 90 fill / 18px 30px 18px 30px stretch;
  filter: drop-shadow(0 5px 0 var(--drop));
  transition: transform 0.15s var(--pop);
  -webkit-tap-highlight-color: transparent;
}
.acorns img { width: auto; height: clamp(40px, 5.6dvh, 52px); margin: -14px 0 -14px -10px; filter: drop-shadow(0 2px 0 var(--drop)); }
.acorns-n { font-variant-numeric: tabular-nums; }
.acorns[hidden] { display: none; }
a.acorns:hover { transform: rotate(-3deg) scale(1.05); }
a.acorns:active { transform: scale(0.94); }
a.acorns:focus-visible { outline: 4px solid var(--cream); outline-offset: 4px; }
/* New acorns fly in over the plaque: a burst of real acorns and a +n in the same lettering. */
.acorns-gained {
  position: absolute;
  left: 100%;
  top: 50%;
  margin-left: 4px;
  font-size: 0.85em;
  color: var(--gold);
  white-space: nowrap;
  translate: 0 -50%;
  animation: pop-in 0.6s var(--pop) 0.6s both, float-up 1.6s ease-out 2.4s both;
}

/* With the plaque and three HUD buttons the title row is too wide for a phone in portrait:
   plaque and buttons share the top row and the logo drops below them. */
@media (max-width: 899px), (max-aspect-ratio: 1 / 1) {
  .forest-top:has(.acorns):has(.forest-hud) { grid-template-columns: auto 1fr; row-gap: 0; }
  .forest-top:has(.acorns):has(.forest-hud) .forest-logo { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .forest-top:has(.acorns):has(.forest-hud) .forest-logo img { height: clamp(74px, 13dvh, 174px); }
  .forest-top:has(.acorns):has(.forest-hud) .forest-hud { grid-column: 2; grid-row: 1; gap: 8px; }
}

/* Mathew's lines: a paper scroll, never a speech-bubble box. */
.scroll-says {
  display: grid;
  place-items: center;
  min-height: 72px;
  margin: 0;
  padding: 0 6px;
  font: 400 clamp(20px, 3dvh, 28px) / 1.1 var(--display);
  letter-spacing: 0.02em;
  text-align: center;
  text-wrap: balance;
  color: var(--ink);
  border: solid transparent;
  border-width: 20px 44px;
  /* Width 1 paints the rolled ends exactly over border-width, so the smaller scrolls below (Mathew's,
     phones) never draw their curls over the text. */
  border-image: url("/static/forest/ui/scroll.e1bd80fe2d.webp") 60 100 60 100 fill / 1 stretch;
  filter: drop-shadow(0 5px 0 var(--drop));
  animation: unroll 0.6s var(--pop) both;
}

/* The one big action: a painted plank (honey, or leaf-green for "yes, do it"). */
.plank-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 200px;
  min-height: 76px;
  padding: 0 6px;
  font: 400 clamp(24px, 3.4dvh, 32px) / 1 var(--display);
  letter-spacing: 0.02em;
  color: var(--cream);
  text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink), 0 4px 0 var(--ink);
  text-decoration: none;
  background: none;
  border: solid transparent;
  border-width: 20px 32px 24px;
  border-image: url("/static/forest/ui/plank.c288ebf48f.webp") 60 90 70 fill / 20px 32px 24px stretch;
  filter: drop-shadow(0 6px 0 var(--drop));
  cursor: pointer;
  transition: transform 0.12s var(--pop);
  -webkit-tap-highlight-color: transparent;
}
.plank-button.is-leaf { border-image-source: url("/static/forest/ui/leaf-button.7b53cbbbe2.webp"); }
.plank-button:hover { transform: scale(1.04) rotate(-1deg); }
.plank-button:active { transform: translateY(4px) scale(0.97); }
.plank-button:focus-visible { outline: 4px solid var(--cream); outline-offset: 6px; }
.plank-button img { width: auto; height: 44px; margin-block: -10px; filter: drop-shadow(0 2px 0 var(--drop)); }

/* A round wooden button carrying a Ludo emblem (back arrow, key, padlock). */
.wood-button > img, .wood-button > svg { width: calc(var(--b) * 0.5); height: calc(var(--b) * 0.5); object-fit: contain; pointer-events: none; }

/* Mathew stays on screen however far the signs scroll (his acorn reward plays in him), standing in the
   bottom-left corner with his line on a scroll. At the end of the scroll he sits below the last row. */
.fox.is-pinned {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 4dvh;
  align-items: flex-end;
  gap: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.fox.is-pinned .fox-link { padding: 0 6px; background: url("/static/forest/ui/stump.7b35479de8.webp") center bottom / 100% auto no-repeat; }
.fox.is-pinned .fox-art { height: clamp(120px, 18dvh, 230px); margin-bottom: clamp(16px, 2.6dvh, 30px); }
.fox.is-pinned .scroll-says {
  min-height: 76px;
  max-width: min(54vw, 360px);
  margin: 0 0 clamp(80px, 12dvh, 150px) -6px;
  font-size: clamp(18px, 2.6dvh, 26px);
  border-width: 14px 34px;
  animation-delay: 1.2s;
}
/* No padding under the last row: the grid paints a vine at every row edge, so padding would show one more. */
.signs:has(+ .fox.is-pinned) { padding-bottom: 0; }
/* The legal links close the hub: one centred row of small planks under everything, past Mathew. */
.forest-legal { width: 100%; padding: 12px 16px max(20px, env(safe-area-inset-bottom)); }
.forest-legal .legal-links { justify-content: center; padding-top: 0; border-top: 0; }
/* On phones Mathew and his scroll shrink so they never cover the signs; tablets (the primary target)
   keep the size above. */
@media (max-width: 599px), (max-height: 520px) {
  .fox.is-pinned .fox-art { height: clamp(84px, 12dvh, 120px); margin-bottom: clamp(10px, 1.8dvh, 18px); }
  .fox.is-pinned .scroll-says {
    min-height: 52px;
    max-width: min(44vw, 230px);
    margin-bottom: clamp(46px, 7dvh, 80px);
    font-size: clamp(14px, 2.1dvh, 18px);
    border-width: 10px 24px;
  }
}

/* Mathew opens his Wardrobe (issue 23): the little open wardrobe at his side says so. */
.fox-link {
  position: relative;
  display: block;
  pointer-events: auto;
  border-radius: 24px;
  -webkit-tap-highlight-color: transparent;
}
.fox-link .fox-art { display: block; }
.fox-link:active .fox-art { transform: scale(0.95); }
.fox-link:focus-visible { outline: 4px solid var(--cream); outline-offset: 4px; }
.fox-tag {
  position: absolute;
  right: -14px;
  bottom: 6%;
  width: clamp(48px, 7dvh, 72px);
  height: auto;
  filter: drop-shadow(0 4px 0 var(--drop));
  transform-origin: 50% 100%;
  animation: pop-in 0.6s var(--pop) 1.6s both, nudge 2.6s ease-in-out 3s infinite;
}

/* A Pro-only Game without Pro: the sign still hangs, with a padlock on its board (issue 21). */
.sign[hidden] { display: none; }
.sign-lock {
  position: absolute;
  right: 2%;
  bottom: 0;
  width: 40%;
  height: auto;
  filter: drop-shadow(0 4px 0 var(--drop));
  transform: rotate(8deg);
}
.is-locked .sign-art { filter: saturate(0.55) brightness(0.9); }
.is-locked .sign-board::before { opacity: 0.25; }

.wood-button svg { display: block; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@keyframes unroll { from { opacity: 0; transform: scaleX(0.3); } }
@keyframes float-up { to { opacity: 0; translate: 0 -160%; } }
@keyframes nudge { 0%, 80%, 100% { transform: rotate(0); } 86% { transform: rotate(-12deg); } 93% { transform: rotate(10deg); } }
@keyframes breathe { from { opacity: 0.7; } to { opacity: 1; } }
@keyframes drift {
  from { transform: translate(0, 0); }
  50% { transform: translate(18px, -26px); }
  to { transform: translate(-14px, -8px); }
}
@keyframes blink { from { opacity: 0.15; } to { opacity: 1; } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes logo-in { from { opacity: 0; transform: translateY(-40%) scale(0.8); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-70%); } }
@keyframes sway { from { transform: rotate(-2.2deg); } to { transform: rotate(2.2deg); } }
@keyframes glow { from { opacity: 0.4; } to { opacity: 0.75; } }
@keyframes picked {
  40% { transform: scale(1.16) rotate(-3deg); }
  to { transform: scale(1.1); }
}
@keyframes fox-in { from { opacity: 0; transform: translateX(-60%) rotate(-8deg); } }
@keyframes breathe-fox { 50% { transform: scale(1.015, 1.035); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.6) translateY(20px); } }

@media (prefers-reduced-motion: reduce) {
  .forest *, .forest *::before, .forest::after { animation: none !important; transition: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .acorns, .acorns-gained, .scroll-says, .plank-button { animation: none; transition: none; }
}

/* The Album button on the home page (ADR 0016): the count of stickers the device holds hangs off its corner. */
.album-link { position: relative; }
.album-link .album-icon { width: calc(var(--b) * 0.52); height: calc(var(--b) * 0.52); }
.album-link-n {
  position: absolute;
  right: -6px;
  bottom: 2px;
  min-width: 26px;
  padding: 3px 6px 4px;
  font: 400 15px / 1 var(--display);
  text-align: center;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  border-radius: 999px;
  text-shadow: none;
}
.album-link-n[hidden] { display: none; }

/* Four round buttons beside the acorn plaque (language, sound, Album, grown-ups) outgrow a 390px phone. */
@media (max-width: 480px) {
  .forest-hud { gap: 6px; }
  .forest-hud .wood-button { --b: 50px; }
}

/* Issue 28 (prototype): with no Pro, the six free Games hang first and the Pro-only ones in their own
   grove under a scroll, so the hub reads as six open games plus more behind a grown-up, not as a wall
   of padlocks. A locked sign keeps its art bright; its padlock hangs small from the top corner. */
.grove-locked { width: 100%; display: flex; flex-direction: column; align-items: center; margin-top: 2dvh; }
.grove-locked > .signs { margin-block: 0; }
.scroll-says.grove-plaque {
  grid-auto-flow: column;
  gap: 10px;
  max-width: min(92vw, 560px);
  min-height: 64px;
  font-size: clamp(17px, 2.4dvh, 24px);
}
.grove-plaque img { width: auto; height: 1.5em; filter: drop-shadow(0 2px 0 var(--drop)); }
.is-locked-grove .is-locked .sign-art { filter: saturate(0.8); }
.is-locked-grove .is-locked .sign-board::before { opacity: 0.4; }
.is-locked-grove .sign-lock { top: -6%; right: -8%; bottom: auto; width: 30%; transform: rotate(12deg); }

/* Saved for offline play (app/saved). A sign's rope fills while its Game saves; with no connection,
   a Game the tablet has not saved yet greys under a crossed-out cloud. Nothing shows without data-saved. */
.sign-saving, .sign-cloud { display: none; }
.sign-saving {
  position: absolute; left: 17%; right: 17%; bottom: 10%; z-index: 1;
  height: max(10px, calc(var(--sign) * 0.07));
  border: 2px solid var(--ink); border-radius: 999px;
  background: #8a5a2e; overflow: hidden;
  box-shadow: inset 0 2px 0 rgb(0 0 0 / 25%);
}
.sign-saving i {
  position: absolute; inset: 0 auto 0 0; width: var(--saved, 0%);
  background: repeating-linear-gradient(-45deg, var(--gold) 0 8px, #ffc226 8px 16px);
  transition: width 0.4s ease;
}
.sign-slot[data-saved="saving"] .sign-saving { display: block; }
.sign-slot[data-saved="saving"] .sign-art { opacity: 0.8; }
.sign-cloud {
  position: absolute; right: -6%; top: 2%; z-index: 1;
  place-items: center; width: 32%; aspect-ratio: 1;
  border: 3px solid var(--ink); border-radius: 50%;
  background: var(--cream); box-shadow: 0 3px 0 var(--drop);
}
.sign-cloud svg { width: 62%; height: auto; }
.is-offline .sign-slot:not([data-saved="saved"])[data-saved] .sign-cloud { display: grid; }
.is-offline .sign-slot:not([data-saved="saved"])[data-saved] .sign-saving { display: none; }
.is-offline .sign-slot:not([data-saved="saved"])[data-saved] .sign-art { filter: grayscale(1); opacity: 0.45; }
.is-offline .sign-slot:not([data-saved="saved"])[data-saved] .sign-name { opacity: 0.6; }

.saved-pill {
  position: absolute; z-index: 2;
  top: calc(max(2.2dvh, env(safe-area-inset-top)) + clamp(58px, 8dvh, 76px));
  left: max(3vw, env(safe-area-inset-left));
  margin: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 4px;
  border: 3px solid var(--ink); border-radius: 999px;
  background: var(--cream); color: var(--ink);
  font: 400 clamp(13px, 1.9dvh, 16px) / 1.1 var(--display); letter-spacing: 0.03em; white-space: nowrap;
  box-shadow: 0 4px 0 var(--drop);
  animation: drop-in 0.5s var(--pop) both;
}
.saved-pill[hidden] { display: none; }
.saved-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 2px solid var(--ink); }
.saved-pill[data-state="saving"] .saved-dot { animation: glow 0.9s ease-in-out infinite alternate; }
.saved-pill[data-state="done"] .saved-dot { background: var(--leaf); }
.saved-pill[data-state="offline"] .saved-dot { background: var(--berry); }

/* Mathew's word on a tap at a Game that cannot play offline. */
.saved-talk { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; }
.saved-talk[hidden] { display: none; }
.saved-veil { position: absolute; inset: 0; background: rgb(20 14 8 / 55%); }
.saved-card {
  position: relative; display: grid; justify-items: center; gap: 6px;
  width: min(460px, 100%); padding: 16px 22px 20px;
  border: 3px solid var(--ink); border-radius: 26px;
  background: var(--cream); color: var(--ink); text-align: center;
  box-shadow: 0 6px 0 var(--drop);
  animation: drop-in 0.45s var(--pop) both;
}
.saved-mathew { width: auto; height: clamp(110px, 18dvh, 160px); margin-top: -70px; filter: drop-shadow(0 6px 0 var(--drop)); }
.saved-card h2 { margin: 0; font: 400 clamp(21px, 3dvh, 26px) / 1.15 var(--display); letter-spacing: 0.02em; }
.saved-card p { margin: 0; font: 700 16px / 1.4 var(--round); color: var(--ink-soft); }
.saved-card .saved-note { margin-top: 4px; padding-top: 8px; border-top: 2px dashed var(--rule); font: 600 14px / 1.45 var(--round); color: var(--ink); text-align: left; }
.saved-note b { font-weight: 800; }
.saved-ok {
  min-width: 120px; min-height: 48px; margin-top: 8px; padding: 6px 24px 2px;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--gold); color: var(--ink);
  font: 400 20px / 1 var(--display); letter-spacing: 0.03em; cursor: pointer;
  box-shadow: 0 4px 0 var(--drop);
}
@media (prefers-reduced-motion: reduce) {
  .saved-pill, .saved-card, .saved-pill .saved-dot { animation: none !important; }
}
@media (max-width: 700px) {
  /* A phone's header is one row of buttons over the logo: the pill hangs just under the header. */
  .saved-pill { top: auto; bottom: 0; left: 50%; transform: translate(-50%, 70%); animation: none; }
}
