:root {
  --bg: #16130e;
  --panel: #201b14;
  --panel-2: #2a2319;
  --panel-3: #342b1f;
  --line: #463a29;
  --text: #f6eedb;
  --muted: #b9aa8e;
  --accent: #f2b54a;
  --accent-ink: #2b1b05;
  --green: #8fcf62;
  --bad: #e3563f;
  --radius: 12px;
  --header-h: 48px;
  --panel-w: 380px;
  /* The smallest text (docs/PLATFORMS.md, "Layout"): 14 px on a desktop, 15
     on a tablet and 13 on a phone. The canvas's floating numbers read it too. */
  --t-min: 14px;
  /* The screen's safe areas: notches, cut-outs, rounded corners and the home
     indicator. The browser tests set these to a phone's and a tablet's. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  /* Touch controls keep 16 px over the home indicator, where there is one. */
  --thumb-b: calc(var(--safe-b) + min(16px, var(--safe-b) * 1000));
  color-scheme: dark;
}

/* A touch screen is a tablet, or a phone when it is under 600 px one way. */
@media (pointer: coarse) {
  :root {
    --t-min: 15px;
  }
}

@media (pointer: coarse) and (max-width: 599px), (pointer: coarse) and (max-height: 599px) {
  :root {
    --t-min: 13px;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The page keeps the game inside the safe areas at the sides (a phone held
   sideways, its notch at one end). */
.page {
  padding: 8px max(8px, var(--safe-r)) 40px max(8px, var(--safe-l));
}

/* The game's height is the screen's under the header (which grows by the
   status bar in the home-screen app), less the home indicator and 16 px over
   it for the thumbs where there is one. */
.game-root {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: none;
  height: max(460px, calc(100dvh - var(--header-h) - var(--safe-t) - 8px - max(12px, var(--thumb-b))));
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* No panning, pinch zoom, pull-to-refresh, double-tap zoom or long-press
     menu over the game: the shop's list and the dialogs scroll themselves
     (pan-y), and the page still scrolls from the site's header. */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  /* The safe-area insets the game's contents keep inside: none on the page,
     which keeps the game inside them, and the screen's in full screen. */
  --in-t: 0px;
  --in-r: 0px;
  --in-b: 0px;
  --in-l: 0px;
}

.hw {
  position: relative;
  display: flex;
  height: 100%;
}

/* Where the safe area is, for placing the golden acorn inside it. */
.safe-probe {
  position: fixed;
  top: var(--safe-t);
  right: var(--safe-r);
  bottom: var(--safe-b);
  left: var(--safe-l);
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Scene ---------- */

/* The scene's HUD keeps --hud from the scene's edges, and a touch control
   --edge from the screen's sides, inside the insets of the edges the scene
   meets (--sc-*): side by side, the shop is on its right. */
.scene {
  --sc-t: var(--in-t);
  --sc-r: 0px;
  --sc-b: var(--in-b);
  --sc-l: var(--in-l);
  --hud: 10px;
  --edge: 10px;
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #86cdf5;
}

/* Any touch screen, a touch laptop's too: touch controls keep 16 px from the
   screen's sides, where edge swipes start. */
@media (any-pointer: coarse) {
  .scene {
    --edge: 16px;
  }
}

.scene canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
}

.scene canvas:focus-visible {
  outline-offset: -3px;
}

.counter {
  position: absolute;
  top: calc(var(--sc-t) + var(--hud));
  left: calc(50% + (var(--sc-l) - var(--sc-r)) / 2);
  transform: translateX(-50%);
  max-width: calc(100% - 2 * (var(--edge) + 52px) - var(--sc-l) - var(--sc-r)); /* clear of the tool buttons */
  padding: 6px 16px 7px;

  border-radius: 16px;
  background: rgba(26, 18, 8, 0.58);
  text-align: center;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.acorns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: clamp(21px, 3.4vw, 34px);
  font-weight: 800;
  line-height: 1.1;
  color: #fff7e2;
  white-space: nowrap;
}

.big-acorn {
  flex: none;
  width: 0.95em;
  height: 0.95em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M16 29c0 15 9 26 16 28 7-2 16-13 16-28z' fill='%23c98a4a'/%3E%3Cpath d='M11 31c0-10 10-17 21-17s21 7 21 17c-6 2-36 2-42 0z' fill='%236a4526'/%3E%3Cpath d='M32 14c1-5 4-7 8-8' stroke='%234a2f19' stroke-width='3.5' fill='none' stroke-linecap='round'/%3E%3Cellipse cx='24' cy='40' rx='3' ry='7' fill='%23fff' opacity='.35' transform='rotate(18 24 40)'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rate {
  margin-top: 1px;
  font-size: max(var(--t-min), 13px);
  color: #f1dfba;
  white-space: nowrap;
}

.effects {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.effects:not(:empty) {
  margin-top: 6px;
}

.effect {
  position: relative;
  padding: 3px 10px 5px;
  border-radius: 8px;
  font-size: var(--t-min);
  font-weight: 700;
  white-space: nowrap;
  color: #2a1a05;
  background: #ffd35a;
}

.effect.moon {
  background: #ffb35a;
}

.effect-bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.15);
}

.effect-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.45);
}

.hint {
  position: absolute;
  left: calc(50% + (var(--sc-l) - var(--sc-r)) / 2);
  top: 38%;
  transform: translate(-50%, -50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(26, 18, 8, 0.72);
  color: #fff7e2;
  font-weight: 700;
  font-size: max(var(--t-min), 14px);
  width: max-content;
  max-width: calc(100% - 2 * (var(--edge) + 52px) - var(--sc-l) - var(--sc-r)); /* clear of the tool buttons on the left */
  text-align: center;
  pointer-events: none;
  animation: hint-bob 1.8s ease-in-out infinite;
}

@keyframes hint-bob {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 5px));
  }
}

/* Thumb-sized, 8 px apart, for every pointer: a touch laptop has them from
   its first touch. */
.scene-tools {
  position: absolute;
  top: calc(var(--sc-t) + var(--hud));
  left: calc(var(--sc-l) + var(--edge));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(26, 18, 8, 0.55);
  color: #fff7e2;
}

.tool:hover {
  background: rgba(26, 18, 8, 0.75);
}

.tool svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool svg .fill {
  fill: currentColor;
}

.tool[aria-pressed='true'] .off,
.tool[aria-pressed='false'] .on {
  display: none;
}

.tool[aria-pressed='false'] {
  color: #c9b99a;
}

/* Golden acorn */

.golden {
  position: absolute;
  z-index: 5; /* over the toasts */
  width: 62px;
  height: 62px;
  margin: -31px 0 0 -31px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 226, 120, 0.55) 0%, rgba(255, 210, 80, 0.18) 45%, rgba(255, 210, 80, 0) 70%);
  animation: golden-bob 1.5s ease-in-out infinite;
}

.golden svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 6px rgba(255, 214, 90, 0.95));
  animation: golden-tilt 2.4s ease-in-out infinite;
}

.golden.fading {
  animation:
    golden-bob 1.5s ease-in-out infinite,
    golden-fade 0.5s ease-in-out infinite alternate;
}

@keyframes golden-bob {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-7px) scale(1.06);
  }
}

@keyframes golden-tilt {
  0%,
  100% {
    transform: rotate(-9deg);
  }
  50% {
    transform: rotate(9deg);
  }
}

@keyframes golden-fade {
  to {
    opacity: 0.35;
  }
}

/* Year bar */

.year {
  position: absolute;
  left: calc(var(--sc-l) + var(--hud));
  right: calc(var(--sc-r) + var(--hud));
  bottom: calc(var(--sc-b) + var(--hud));
  padding: 7px 10px 8px;
  border-radius: 12px;
  background: rgba(26, 18, 8, 0.6);
  color: #fff7e2;
  pointer-events: none;
}

.year-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: max(var(--t-min), 13px);
  line-height: 1.2;
}

.year-label {
  display: flex;
  align-items: center;
  gap: 18px; /* 8 px beyond the help target's negative 10 px margin */
  font-weight: 800;
  white-space: nowrap;
}

/* The round "?" buttons: a 24 px circle in the layout, in a 44 px target
   that reaches 10 px past it all round, or, for the year's, 20 px above it:
   "Bury the hoard" sits just below. */
.year-info,
.help-btn {
  --fill: rgba(255, 255, 255, 0.12);
  --ring: rgba(255, 255, 255, 0.35);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--fill) 0 10.5px, var(--ring) 11px 12px, transparent 12.5px);
  color: #fff7e2;
  font-size: var(--t-min);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.year-info {
  margin: -20px -10px 0;
  background: radial-gradient(circle at 50% calc(100% - 12px), var(--fill) 0 10.5px, var(--ring) 11px 12px, transparent 12.5px);
  place-items: end center;
  padding-bottom: 5px;
  pointer-events: auto;
}

.year-info:hover {
  --fill: rgba(255, 255, 255, 0.25);
}

.help-btn {
  --fill: var(--panel-3);
  --ring: var(--line);
  margin-left: -6px; /* 4 px after the heading */
  vertical-align: middle;
  color: var(--text);
}

.help-btn:hover {
  filter: brightness(1.2);
}

.num-help {
  margin: 0 0 10px;
}

.num-help summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 0;
  font-weight: 700;
  cursor: pointer;
}

.num-names {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 12px;
  margin: 0 0 10px;
  font-size: max(var(--t-min), 13.5px);
}

.num-names div {
  display: flex;
  gap: 6px;
}

.num-names dt {
  min-width: 34px;
  font-weight: 800;
}

.num-names dd {
  margin: 0;
  color: var(--muted);
}

.year-note {
  color: #eadbb8;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.year-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.year-bar {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.year-fill {
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: #9be07a;
  transition:
    width 0.3s linear,
    background-color 1s;
}

[data-season='1'] .year-fill {
  background: #5fbf4a;
}

[data-season='2'] .year-fill {
  background: #ef9a3a;
}

[data-season='3'] .year-fill {
  background: #e4eef7;
}

/* The snowy winter scene is bright, so the year box darkens to keep its text
   readable. */
[data-season='3'] .year {
  background: rgba(26, 18, 8, 0.78);
}

.year-bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: rgba(0, 0, 0, 0.35);
}

.spring-btn {
  flex: none;
  min-height: 44px;
  pointer-events: auto;
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: max(var(--t-min), 13.5px);
  white-space: nowrap;
}

.spring-btn:hover {
  background: #ffc766;
}

/* In-game toasts sit above the year bar, away from the site's own toasts. */
.toasts {
  position: absolute;
  z-index: 4;
  left: calc(50% + (var(--sc-l) - var(--sc-r)) / 2);
  bottom: 84px;
  transform: translateX(-50%);
  width: min(calc(100% - 2 * (var(--edge) + 52px) - var(--sc-l) - var(--sc-r)), 440px); /* clear of the tool buttons */

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(30, 23, 14, 0.94);
  color: var(--text);
  font-size: max(var(--t-min), 13.5px);
  line-height: 1.3;

  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  animation: toast-in 0.25s ease-out;
  transition:
    opacity 0.4s,
    transform 0.4s;
}

.toast.t-gold {
  border-color: #d9a63a;
  color: #ffe7a6;
}

.toast.t-trophy {
  border-color: #b98a3a;
}

.toast.t-good {
  border-color: #5f8f45;
}

.toast.t-bad {
  border-color: var(--bad);
}

.toast.out {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Panel ---------- */

/* The shop keeps inside the insets of the edges it meets (--pn-*): side by
   side, the scene is on its left. Its controls keep --edge from the screen's
   sides. */
.panel {
  --pn-t: var(--in-t);
  --pn-r: var(--in-r);
  --pn-b: var(--in-b);
  --pn-l: 0px;
  --edge: 10px;
  flex: 0 0 var(--panel-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: var(--pn-t) var(--pn-r) var(--pn-b) var(--pn-l);
  background: var(--panel);
  border-left: 1px solid var(--line);
}

@media (any-pointer: coarse) {
  .panel {
    --edge: 16px;
  }
}

.tabs {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 9px 8px; /* selected tab extends 1 px toward the list */
  padding: 6px var(--edge) 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.tabs button {
  flex: 1;
  min-height: 44px;
  padding: 9px 6px 8px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: none;
  color: var(--muted);
  font-weight: 700;
  font-size: max(var(--t-min), 14px);
}

.tabs button[aria-selected='true'] {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
  margin-bottom: -1px;
}

.tab {
  container-type: inline-size;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: none;
  touch-action: pan-y;
  padding: 10px var(--edge) 16px;
  -webkit-overflow-scrolling: touch;
}

.tab h3 {
  margin: 4px 2px 8px;
  font-size: max(var(--t-min), 12px);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.shop-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.shop-head h3 {
  margin: 0 2px;
}

/* How many to hire: four buttons, thumb-sized and 8 px apart. */
.amount {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 8px;
}

.amount button {
  min-width: 44px;
  min-height: 44px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: max(var(--t-min), 12.5px);
  font-weight: 700;
}

.amount button[aria-pressed='true'] {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--muted);
}

.acorn-ico {
  flex: none;
  display: inline-block;
  vertical-align: -2px;
}

/* Critter rows */

.crit {
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 8px;
  padding: 7px 12px 9px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  text-align: left;
  overflow: hidden;
}

.crit:not(:disabled):hover {
  background: var(--panel-3);
}

.crit:not(:disabled):active {
  transform: translateY(1px);
}

/* Rows the player can't buy yet stay readable: muted colours of at least
   4.5:1 contrast, with only the picture dimmed. */
.crit:disabled {
  background: #1c1811;
}

.crit:disabled .crit-name {
  color: #cfc2a6;
}

.crit:disabled .crit-info {
  color: #a89a80;
}

.crit:disabled .crit-cost,
.crit:disabled .crit-owned {
  color: #b9aa8e;
}

.crit:disabled .crit-icon,
.upg:disabled .upg-icon {
  opacity: 0.5;
}

.crit-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
}

.crit-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.crit-name {
  font-weight: 800;
  font-size: 15px;
}

.crit-info {
  font-size: max(var(--t-min), 12px);
  line-height: 1.3;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.crit-cost {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: max(var(--t-min), 13px);
  font-weight: 700;
  color: #f3d9a0;
  font-variant-numeric: tabular-nums;
}

.crit-owned {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.crit-ms {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
}

.crit-ms-fill {
  display: block;
  height: 100%;
  width: 0;
  background: rgba(242, 181, 74, 0.6);
}

.crit.mystery {
  color: var(--muted);
  border-style: dashed;
  background: transparent;
  cursor: default;
}

.mystery-ico {
  font-size: 24px;
  font-weight: 800;
  color: var(--muted);
}

/* Upgrades */

.upgrades {
  margin-bottom: 12px;
  container-type: inline-size;
}

.upgrade-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.more {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: max(var(--t-min), 12.5px);
  font-weight: 700;
}

.more:hover {
  color: var(--text);
}

.upg {
  min-height: 44px;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 2px 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  text-align: left;
  min-width: 0;
}

.upg:not(:disabled):hover {
  background: var(--panel-3);
}

.upg:disabled {
  background: #1c1811;
}

.upg:disabled .upg-text b {
  color: #cfc2a6;
}

.upg:disabled .upg-text small {
  color: #a89a80;
}

.upg:disabled .upg-cost {
  color: #b9aa8e;
}

.upg-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
}

.upg-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.upg-text b {
  font-size: max(var(--t-min), 13px);
  line-height: 1.2;
  overflow-wrap: break-word;
}

.upg-text small {
  font-size: max(var(--t-min), 11.5px);
  line-height: 1.25;
  color: var(--muted);
  overflow-wrap: break-word;
}

.upg-cost {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: max(var(--t-min), 12px);
  font-weight: 700;
  color: #f3d9a0;
}

/* Grove */

.grove-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grove-stat {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.grove-stat b {
  font-size: 22px;
  color: var(--green);
}

.grove-stat span {
  font-size: max(var(--t-min), 12px);
  color: var(--muted);
}

.grove-stat em {
  font-style: normal;
  color: var(--text);
  font-weight: 700;
}

.note {
  margin: 8px 2px 10px;
  font-size: max(var(--t-min), 12.5px);
  color: var(--muted);
  line-height: 1.4;
}

.grove-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.grove-item.planted {
  border-color: rgba(143, 207, 98, 0.45);
  background: linear-gradient(90deg, rgba(143, 207, 98, 0.1), var(--panel-2) 60%);
}

.grove-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
}

.roots-icon {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 44'%3E%3Cpath d='M22 4v18M22 22c-4 6-10 8-16 9M22 22c4 6 10 8 16 9M22 24c-2 7-2 11-6 16M22 24c2 7 2 11 6 16M22 22v18' stroke='%23b98a55' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cpath d='M4 20h36' stroke='%235f9c46' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E")
    center / 38px no-repeat;
}

.grove-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.grove-main b {
  font-size: max(var(--t-min), 14.5px);
}

.grove-desc {
  font-size: max(var(--t-min), 12.5px);
  color: var(--muted);
  line-height: 1.3;
}

.grove-cost {
  font-size: max(var(--t-min), 12.5px);
  font-weight: 700;
  color: var(--green);
}

.grove-item.roots {
  margin-top: 12px;
}

.grove-item.roots.locked .grove-cost {
  color: var(--muted);
  font-weight: 600;
}

.roots-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--text);
  font-weight: 700;
  font-size: max(var(--t-min), 14px);
}

.btn:not(:disabled):hover {
  filter: brightness(1.12);
}

.btn:disabled {
  opacity: 0.5;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.btn.danger {
  background: #5a2219;
  border-color: #8a3325;
  color: #ffd9d0;
}

.btn.plant {
  min-width: 78px;
  padding: 8px 10px;
}

.grove-item.planted .btn.plant {
  background: none;
  border-color: transparent;
  color: var(--green);
  opacity: 1;
}

/* Trophies */

.trophy-count {
  margin: 2px 2px 10px;
  font-weight: 700;
}

.trophy-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.trophy {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #1c1811;
  color: #b9aa8e;
  min-width: 0;
}

.trophy .trophy-ico {
  filter: grayscale(1) brightness(0.8);
  opacity: 0.5;
}

.trophy.got {
  background: var(--panel-2);
  color: var(--text);
  border-color: rgba(242, 181, 74, 0.45);
}

.trophy.got .trophy-ico {
  filter: none;
  opacity: 1;
}

.trophy-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.trophy-text b {
  font-size: max(var(--t-min), 13px);
}

.trophy-text small {
  font-size: max(var(--t-min), 11.5px);
  color: var(--muted);
  line-height: 1.25;
}

.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  margin: 0 2px;
  font-size: max(var(--t-min), 13.5px);
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Dialogs ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--in-t) + 14px) calc(var(--in-r) + 14px) calc(var(--in-b) + 14px) calc(var(--in-l) + 14px);
  background: rgba(12, 9, 5, 0.62);
}

.dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  overflow: hidden;
  padding: 18px 18px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: dialog-in 0.18s ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.dialog h2 {
  flex: none;
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.25;
}

/* The body scrolls when the dialog is taller than the game, so the title and
   the buttons stay in view. */
.dialog-body {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: none;
  touch-action: pan-y;
  /* Scroll shadows: a dark edge shows at the top or bottom only while there
     is more to scroll that way. The panel-coloured covers scroll with the
     content and hide the shadows at each end. */
  background:
    linear-gradient(var(--panel) 30%, rgba(32, 27, 20, 0)) center top / 100% 36px no-repeat local,
    linear-gradient(rgba(32, 27, 20, 0), var(--panel) 70%) center bottom / 100% 36px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0)) center top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0)) center bottom / 100% 12px no-repeat scroll;
}

.dialog p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.dialog .muted {
  color: var(--muted);
  font-size: max(var(--t-min), 13.5px);
}

.dialog .error {
  color: #ff9a86;
  font-size: max(var(--t-min), 13.5px);
}

.dialog-buttons {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* While a dialog settles (buttons briefly disabled so a tap meant for the
   game can't hit them), they fade in rather than blink. */
.dialog-buttons .btn {
  transition: opacity 0.25s;
}

/* The card takes focus only to hold it while the buttons settle; it isn't a
   control, so it shows no focus ring. */
.dialog:focus,
.dialog:focus-visible {
  outline: none;
}

.keeps {
  margin: 0 0 6px;
  padding-left: 18px;
  line-height: 1.45;
  font-size: max(var(--t-min), 14px);
  color: #e6dac2;
}

.away-time {
  color: var(--muted);
}

.away-gain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 4px 0 12px;
  font-size: 15px;
}

.away-gain b {
  font-size: 26px;
  color: #ffe7a6;
  white-space: nowrap;
}

.away-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.away-top li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: max(var(--t-min), 14px);
}

.away-top li b {
  margin-left: auto;
  color: var(--muted);
}

.menu-group {
  margin-bottom: 10px;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  margin: 0 0 8px;
  padding: 8px 2px;

  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font-size: 15px;
}

.switch i {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: #4a4030;
  transition: background 0.15s;
}

.switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f6eedb;
  transition: transform 0.15s;
}

.switch[aria-checked='true'] i {
  background: #5f9c46;
}

.switch[aria-checked='true'] i::after {
  transform: translateX(18px);
}

.menu-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.code {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: max(var(--t-min), 12px);
  line-height: 1.4;
  resize: vertical;
  word-break: break-all;
  /* The one place to select, copy and paste: the save code. */
  touch-action: pan-y;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

.dialog-open .scene canvas {
  cursor: default;
}

/* ---------- Below the game ---------- */

.ad-below {
  max-width: 1180px;
  margin: 16px auto 0;
}

@media (pointer: coarse) {
  /* Keep the ad well clear of the shop buttons at the bottom of the game. */
  .ad-below {
    margin-top: 56px;
  }
}

.about {
  max-width: 820px;
  margin: 24px auto 0;
  padding: 0 8px;
  line-height: 1.55;
  color: #ddd2c4;
}

.about h1,
.about h2 {
  color: var(--text);
}

.about li {
  margin-bottom: 4px;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel);
  font-size: max(var(--t-min), 12px);
}

/* ---------- Smaller screens ---------- */

@media (max-width: 1000px) {
  :root {
    --panel-w: 340px;
  }
}

/* Every portrait screen: the scene on top, the shop below. */
@media (orientation: portrait) {
  .hw {
    flex-direction: column;
  }
  .scene {
    --sc-r: var(--in-r);
    --sc-b: 0px;
    flex: 0 0 47%;
  }
  .panel {
    --pn-t: 0px;
    --pn-l: var(--in-l);
    flex: 1 1 auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .game-root {
    height: calc(100dvh - var(--header-h) - var(--safe-t) - max(12px, 8px + var(--thumb-b)));
    min-height: 0;
    max-height: none;
  }
}

@media (orientation: portrait) and (min-width: 600px) {
  .scene {
    flex-basis: 50%;
  }
  .critters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 8px;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 4px var(--safe-r) 30px var(--safe-l);
  }
  .game-root {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .scene {
    --hud: 8px;
  }
  .counter {
    padding: 5px 12px 6px;
  }
  .rate {
    font-size: max(var(--t-min), 12px);
  }
  .year {
    padding: 6px 9px 7px;
  }
  .year-top {
    font-size: max(var(--t-min), 12px);
  }
  .toasts {
    bottom: 74px;
  }
  .toast {
    padding: 5px 10px;
    font-size: max(var(--t-min), 13px);
  }
  .hint {
    padding: 7px 12px;
    font-size: max(var(--t-min), 13px);
  }
  .tab {
    padding: 8px var(--edge) 14px;
  }
  .crit {
    padding: 6px 10px 8px 6px;
    gap: 8px;
  }
  .crit-name {
    font-size: max(var(--t-min), 14.5px);
  }
  .crit-owned {
    font-size: 21px;
  }
  .upgrade-list {
    grid-template-columns: 1fr 1fr;
  }
}

/* Too narrow for two tiles side by side without breaking long names such as
   "Architecture" mid-word: one tile per row. */
@container (max-width: 340px) {
  .upgrade-list {
    grid-template-columns: 1fr;
  }
}

/* A narrow shop beside a camera cut-out still keeps every action readable
   and thumb-sized. Let the text and the action use separate rows. */
@container (max-width: 280px) {
  .grove-item {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .grove-main {
    overflow-wrap: anywhere;
  }
  .grove-item > .plant,
  .roots-btns {
    grid-column: 1 / -1;
    justify-self: end;
  }
  .crit {
    grid-template-columns: 46px minmax(0, 1fr);
  }
  .crit-owned {
    grid-column: 2;
    justify-self: end;
  }
  .crit-cost .num {
    overflow-wrap: anywhere;
  }
}

/* Landscape phones: the game fills the screen, the shop on the right. */
@media (orientation: landscape) and (max-height: 520px) {
  .page {
    padding-top: 0;
  }
  .game-root {
    height: calc(100dvh - var(--header-h) - var(--safe-t) - max(2px, var(--thumb-b)));
    min-height: 240px;
    border-radius: 0;
  }
  :root {
    --panel-w: min(46%, 400px);
  }
  .scene {
    --hud: 6px;
  }
  .counter {
    padding: 4px 12px 5px;
  }
  .acorns {
    font-size: 21px;
  }
  .rate {
    font-size: max(var(--t-min), 12px);
  }
  .year {
    padding: 5px 8px 6px;
  }
  .year-top {
    font-size: max(var(--t-min), 12px);
  }
  /* Winter's "Bury the hoard" goes up beside the year's name, in place of
     the note it repeats, so the year box stays short. */
  .year {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    align-items: center;
  }
  .year-row {
    display: contents;
  }
  .year-top {
    grid-area: 1 / 1;
  }
  .spring-btn {
    grid-area: 1 / 2;
  }
  .year-bar {
    grid-area: 2 / 1 / 3 / 3;
    margin-top: 8px;
  }
  .year.ready .year-note {
    display: none;
  }
  .toasts {
    bottom: 64px;
  }

  .tabs button {
    padding: 6px 6px 5px;
  }
  .tab {
    padding: 8px var(--edge) 10px;
  }

  .crit {
    padding: 5px 10px 7px 6px;
  }
  .crit-icon {
    width: 40px;
    height: 40px;
  }
  .hint {
    top: 44%;
  }
  .overlay {
    padding: calc(var(--in-t) + 8px) calc(var(--in-r) + 8px) calc(var(--in-b) + 8px) calc(var(--in-l) + 8px);
  }
  .dialog {
    padding: 12px 14px 10px;
  }
  .dialog h2 {
    margin-bottom: 6px;
    font-size: 17px;
  }
  .dialog p {
    margin-bottom: 6px;
    line-height: 1.35;
  }
  .dialog-buttons {
    margin-top: 8px;
  }
  .away-gain {
    margin: 0 0 6px;
  }
  .away-gain b {
    font-size: 22px;
  }
  /* The menu goes side by side so the save buttons fit without scrolling. */
  .dialog.menu,
  .dialog.help {
    max-width: min(640px, 100%);
  }
  .menu .dialog-body {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 0 18px;
    align-items: start;
  }
  .menu .menu-group {
    grid-row: span 2;
    margin: 0;
  }
  .menu .switch {
    padding: 6px 2px;
    font-size: max(var(--t-min), 14px);
  }
  .menu .dialog-body p {
    margin-top: 4px;
  }
  .menu .menu-row .btn {
    padding: 8px 10px;
    font-size: max(var(--t-min), 13px);
  }
}

/* ---------- Full screen (the site's button, docs/PLATFORMS.md) ---------- */

/* The game fills the screen edge to edge; what the player reads or touches
   keeps inside the safe areas. */
.game-root:fullscreen {
  --in-t: var(--safe-t);
  --in-r: var(--safe-r);
  --in-b: var(--safe-b);
  --in-l: var(--safe-l);
  border: 0;
  border-radius: 0;
}

/* "Leave full screen" is the site's 44 px button at the top in the middle,
   over the counter: the counter, and a dialog, start in a band below it. */
.game-root:fullscreen .counter {
  top: calc(max(8px, var(--sc-t)) + 52px);
}

.game-root:fullscreen .overlay {
  padding-top: calc(max(8px, var(--in-t)) + 52px);
}

/* In full screen the scene takes more of the screen (docs/PLATFORMS.md, "The
   play area in full screen"): beside it, the shop is a narrower column, 256 to
   380 px (on the page 340 to 400, or 46% of a phone held sideways); above
   it, upright, the scene takes 60% of the height (47% on the page). */
.game-root:fullscreen {
  --panel-w: clamp(256px, 26%, 380px);
}
@media (orientation: portrait) {
  .game-root:fullscreen .scene {
    flex-basis: 60%;
  }
}
@media (orientation: portrait) and (min-width: 901px), (orientation: portrait) and (pointer: fine) {
  .game-root:fullscreen .scene {
    flex-basis: 70%;
  }
}

/* On a touch screen the shop's list ends 16 px over the bottom edge, where
   the home gesture starts. */
@media (any-pointer: coarse) {
  .game-root:fullscreen .panel {
    --pn-b: calc(var(--in-b) + 16px);
  }
}

/* A phone's corners are rounded, and Android doesn't report them: the HUD
   and the shop keep 24 px from the screen's sides. */
@media (pointer: coarse) and (max-width: 599px), (pointer: coarse) and (max-height: 599px) {
  .game-root:fullscreen .scene {
    --hud: 24px;
    --edge: 24px;
  }
  .game-root:fullscreen .panel {
    --edge: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .golden,
  .golden svg,
  .golden.fading,
  .hint,
  .toast,
  .dialog {
    animation: none;
  }

  /* A still dim in place of the blinking fade, so the player can still see
     the golden acorn is about to go. */
  .golden.fading {
    opacity: 0.6;
  }
}
