/* Bianca's Farm. The interface is the Santana house from the title painting:
   whitewashed walls, blue window frames, a red door frame, thatch gold. */

@font-face { font-family: "Berkshire Swash"; src: url("../fonts/berkshire-swash.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Figtree"; src: url("../fonts/figtree-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("../fonts/figtree-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("../fonts/figtree-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --whitewash: #FBF7EE;
  --window-blue: #1F4E9E;
  --window-blue-deep: #163A78;
  --door-red: #C62828;
  --door-red-deep: #8E1C1C;
  --thatch: #DFA83A;
  --laurel: #2E5E3A;
  --basalt: #3A3334;

  --font-sign: "Berkshire Swash", Georgia, serif;
  --font-body: "Figtree", -apple-system, "Helvetica Neue", sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--window-blue-deep);
  color: var(--basalt);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Clip, not hidden: a hidden box can still be scrolled by a focus, the keyboard or a
   sheet sliding in, and the whole farm would stay shifted up. main.js guards older
   Safari, which ignores clip. */
#app { position: fixed; inset: 0; overflow: hidden; overflow: clip; }

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

#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* The sign at the top: whitewash with a blue window frame. */
.hud {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.hud-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 4px 14px 4px 6px;
  background: var(--whitewash);
  border: 3px solid var(--window-blue);
  border-radius: 24px;
  box-shadow: 0 3px 0 rgba(22, 58, 120, 0.55), 0 6px 14px rgba(40, 22, 40, 0.25);
  font-weight: 700;
  font-size: 21px;
  color: var(--basalt);
  font-variant-numeric: tabular-nums;
}
.hud-pill.bump { animation: hud-bump 260ms ease-out; }
.hud-pill.full { border-color: var(--door-red); }
.bag-of { font-weight: 500; font-size: 16px; color: #7A6E6A; margin-left: -4px; }
@keyframes hud-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
.coin {
  width: 34px;
  height: 34px;
  background: url("../art/coin.webp") center / contain no-repeat;
}
.bag-icon {
  width: 32px;
  height: 32px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%236B4426' stroke-width='2' d='M7 10C7 3 17 3 17 10'/%3E%3Cpath fill='%23B47A3C' d='M4 10h16l-2 11a2 2 0 0 1-2 1.6H8A2 2 0 0 1 6 21z'/%3E%3Cpath stroke='%238A5A2C' stroke-width='1.3' d='M5 13.5h14M5.5 17h13M9 10v12M15 10v12'/%3E%3C/svg%3E") center / contain no-repeat;
}

.hud-sound {
  width: 44px;
  height: 44px;
  padding: 5px;
  flex: none;
  pointer-events: auto;
  background: var(--whitewash);
  border: 3px solid var(--window-blue);
  border-radius: 50%;
  box-shadow: 0 3px 0 rgba(22, 58, 120, 0.55), 0 6px 14px rgba(40, 22, 40, 0.25);
}
.hud-sound svg { display: block; width: 100%; height: 100%; }
.hud-sound.off { opacity: 0.82; }
.hud-sound:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(22, 58, 120, 0.55); }

.bubbles { position: absolute; inset: 0; overflow: hidden; overflow: clip; pointer-events: none; }

/* The map, zoomed right out: plaques like the stall's sign, gold counts, faces. */
.map { position: absolute; inset: 0; overflow: hidden; overflow: clip; pointer-events: none; }
.map[hidden] { display: none; }
.map > button { position: absolute; left: 0; top: 0; margin: 0; pointer-events: none; touch-action: manipulation; white-space: nowrap; }
.map.touchable > button { pointer-events: auto; }
.map > button[hidden] { display: none; }
.map-label {
  padding: 3px 11px 5px;
  border: 2px solid var(--window-blue);
  border-radius: 6px;
  background: var(--whitewash);
  box-shadow: 0 2px 0 rgba(22, 58, 120, 0.5), 0 4px 10px rgba(30, 20, 40, 0.3);
  font-family: var(--font-sign);
  font-size: 18px;
  line-height: 1.1;
  color: var(--window-blue);
}
.map-terrace { border-color: transparent; background: rgba(251, 247, 238, 0.88); color: var(--laurel); font-size: 16px; box-shadow: 0 2px 8px rgba(30, 20, 40, 0.25); }
.map-sale { border-style: dashed; border-color: var(--door-red); color: var(--door-red); font-size: 16px; }
.map-count {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 2px 10px 2px 5px;
  border: 2px solid #B57E18;
  border-radius: 17px;
  background: #FFF3C9;
  box-shadow: 0 2px 6px rgba(30, 20, 40, 0.3);
  font-weight: 700;
  font-size: 17px;
  color: var(--basalt);
}
.map-icon { width: 26px; height: 26px; }
.map-icon svg { width: 100%; height: 100%; display: block; }
.map-pin { display: flex; flex-direction: column; align-items: center; padding: 0; border: 0; background: transparent; }
.map-face { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--whitewash); outline: 2px solid var(--window-blue); box-shadow: 0 3px 8px rgba(30, 20, 40, 0.4); display: block; }
.map-name { margin-top: 3px; padding: 0 6px; border-radius: 8px; background: var(--window-blue); color: var(--whitewash); font-weight: 700; font-size: 13px; line-height: 1.5; }
.bubble {
  position: absolute;
  left: 0;
  top: 0;
  padding: 5px 11px;
  background: var(--whitewash);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(40, 22, 40, 0.35);
  font-weight: 700;
  font-size: 15px;
  color: var(--basalt);
  white-space: nowrap;
  will-change: transform;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: var(--whitewash);
  transform: rotate(45deg);
}

.heart {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23D9352B' stroke='%23FBF7EE' stroke-width='2' d='M12 21C5 15 2 11.500 2 7.500 2 4.500 4.300 2.500 7 2.500c2 0 3.800 1 5 3 1.200-2 3-3 5-3 2.700 0 5 2 5 5 0 4-3 7.500-10 13.500z'/%3E%3C/svg%3E") center / contain no-repeat;
  will-change: transform;
}

.card {
  position: absolute;
  top: calc(var(--safe-top) + 64px);
  left: 12px;
  right: 12px;
  width: fit-content;
  margin: 0 auto;
  transform: translateY(-8px);
  padding: 8px 16px;
  background: var(--window-blue);
  color: var(--whitewash);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--window-blue-deep), 0 6px 14px rgba(40, 22, 40, 0.25);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.25;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.card.shown { opacity: 1; transform: none; }
/* Dona Ilda's lessons carry her face, a little round portrait at the start of the line. */
.card.with-face { display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 6px; text-align: left; }
.card-face { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 2px solid var(--whitewash); object-fit: cover; }

/* Dona Ilda's list (D4), after the first sale: a bundle of papers at the end of her card
   with how many things are on it, and a tap on the card opens the list in its place. */
.card.with-quests.shown { pointer-events: auto; cursor: pointer; padding-right: 8px; }
.card.shown.under-list { opacity: 0; pointer-events: none; }
.card-words { flex: 1; min-width: 0; }
.card-quests {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: 2px;
  border-radius: 12px;
  background: var(--whitewash);
  box-shadow: inset 0 0 0 2px var(--window-blue-deep);
}
.card-quests-art { width: 34px; height: 34px; }
.card-quests-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border-radius: 11px;
  background: var(--window-blue);
  color: var(--whitewash);
  font-size: 13px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--whitewash);
}
/* Something on the list done: the tick, for a moment, over the bundle. */
.card-quests.ticked::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--whitewash) url("../art/ui/quest-tick.webp") center / 38px no-repeat;
  animation: quest-tick 2.6s ease forwards;
}
@keyframes quest-tick {
  0% { opacity: 0; transform: scale(0.6); }
  12% { opacity: 1; transform: scale(1.18); }
  22% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.quests { position: absolute; inset: 0; pointer-events: none; }
.quests.open { pointer-events: auto; }
/* A tap anywhere off the list folds it away, and does nothing else. */
.quests-catch { position: absolute; inset: 0; display: none; }
.quests.open .quests-catch { display: block; }
.quests-panel {
  position: absolute;
  top: calc(var(--safe-top) + 58px);
  left: 12px;
  right: 12px;
  max-width: 420px;
  margin: 0 auto;
  padding: 6px 8px 8px;
  background: var(--whitewash);
  border: 3px solid var(--window-blue);
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(22, 58, 120, 0.55), 0 10px 24px rgba(40, 22, 40, 0.3);
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  transform-origin: top center;
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}
.quests.open .quests-panel { opacity: 1; transform: none; pointer-events: auto; }
.quests-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 7px;
  color: var(--window-blue-deep);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  cursor: pointer;
}
.quests-head .card-face { border-color: var(--window-blue); }
.quests-says { flex: 1; }
.quests-fold { flex: none; width: 24px; height: 24px; }
.quests-fold::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  margin: 9px auto 0;
  border-left: 3px solid var(--window-blue);
  border-top: 3px solid var(--window-blue);
  transform: rotate(45deg);
}
.quests-rows { display: flex; flex-direction: column; gap: 6px; }
.quest {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 6px 8px 6px 6px;
  border: 0;
  border-radius: 12px;
  background: #F1EADA;
  color: var(--basalt);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.quest:active { background: #E6DCC5; }
.quest-art { width: 52px; height: 52px; flex: none; }
.quest-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.quest-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.quest-bar { position: relative; height: 8px; border-radius: 4px; background: rgba(31, 78, 158, 0.16); overflow: hidden; }
.quest-fill { position: absolute; inset: 0; border-radius: 4px; background: var(--window-blue); transform-origin: left center; transform: scaleX(0); transition: transform 300ms ease; }
.quest-progress { font-size: 14px; line-height: 1.2; color: #6B605C; }
.quest-reward {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px 3px 4px;
  border-radius: 12px;
  background: var(--whitewash);
  box-shadow: inset 0 0 0 2px #E2BE5E;
  color: #7A5A12;
  font-weight: 700;
  font-size: 14px;
}
.toast-icon { width: 52px; height: 52px; flex: none; }

/* Her list, where the card was, with one small button to clear it. */
.jobs-chip {
  position: absolute;
  top: calc(var(--safe-top) + 62px);
  left: 0;
  right: 0;
  width: fit-content;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 6px 4px 16px;
  background: var(--whitewash);
  border: 3px solid var(--window-blue);
  border-radius: 24px;
  box-shadow: 0 3px 0 rgba(22, 58, 120, 0.55), 0 6px 14px rgba(40, 22, 40, 0.25);
  color: var(--basalt);
  font-weight: 700;
  font-size: 18px;
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.jobs-chip.shown { opacity: 1; transform: none; pointer-events: auto; }
.jobs-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(22, 58, 120, 0.55); }
.jobs-x {
  display: block;
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 50%;
  background: var(--window-blue);
  color: var(--whitewash);
}
.jobs-x svg { display: block; width: 100%; height: 100%; }
.jobs-x path { stroke: var(--whitewash); }

.book-about { margin: 6px 18px 18px; font-size: 13px; color: #7A6E6A; text-align: center; }
.title-build { order: 99; margin: 4px 0 0; font-size: 11px; color: var(--whitewash); opacity: 0.55; text-align: center; letter-spacing: 0.02em; }

/* A new version is ready: one tap saves the farm and opens the new version. */
.update-chip { position: absolute; left: 12px; bottom: calc(var(--safe-bottom) + var(--bar) + 12px); min-height: 44px; padding: 6px 16px; background: var(--whitewash); border: 3px solid var(--window-blue); border-radius: 22px; box-shadow: 0 3px 0 rgba(22, 58, 120, 0.55); color: var(--basalt); font-weight: 700; font-size: 16px; z-index: 20; }

/* Another copy of the game has played this farm since: this one pauses, never overwriting. */
.elsewhere { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(22, 30, 60, 0.55); z-index: 50; }
.elsewhere-card { max-width: 320px; padding: 20px 22px; background: var(--whitewash); border: 4px solid var(--window-blue); border-radius: 18px; text-align: center; font-size: 19px; }
.elsewhere-card p { margin: 0 0 16px; }
.elsewhere-card button { min-height: 52px; padding: 0 22px; border: 0; border-radius: 26px; background: var(--window-blue); color: var(--whitewash); font-weight: 700; font-size: 19px; }

/* Dona Ilda's ghost finger, showing a swipe. Its fingertip is the point it shows. */
.finger { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; opacity: 0; will-change: transform, opacity; z-index: 3; }
.finger svg { position: absolute; left: -24px; top: -4px; width: 52px; height: 68px; filter: drop-shadow(0 4px 6px rgba(30, 20, 40, 0.35)); }
.finger-dot { position: absolute; left: -13px; top: -13px; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 233, 166, 0.55); box-shadow: 0 0 0 3px rgba(251, 247, 238, 0.85); }

/* Her face at the edge of the phone when she has walked off it, pointing her way. */
.finder {
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  will-change: transform;
}
.finder.shown { opacity: 1; pointer-events: auto; }
.finder-face {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--whitewash);
  outline: 3px solid var(--window-blue);
  box-shadow: 0 4px 10px rgba(30, 20, 40, 0.45);
  object-fit: cover;
}
.finder:active .finder-face { transform: scale(0.94); }
.finder-arrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-origin: 0 0; }
.finder-arrow::after {
  content: "";
  position: absolute;
  left: 33px;
  top: -9px;
  border-left: 13px solid var(--window-blue);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.toast {
  position: absolute;
  left: 16px;
  right: 16px;
  width: fit-content;
  margin: 0 auto;
  bottom: calc(var(--safe-bottom) + 112px);
  transform: translateY(14px);
  padding: 11px 18px;
  background: var(--whitewash);
  border: 3px solid var(--window-blue);
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(22, 58, 120, 0.55);
  font-weight: 500;
  font-size: 18px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.toast.shown { opacity: 1; transform: none; }
.toast.with-face { display: flex; align-items: center; gap: 12px; padding: 8px 18px 8px 8px; text-align: left; }
.toast-face { width: 52px; height: 52px; flex: none; border-radius: 50%; border: 3px solid var(--window-blue); object-fit: cover; }

/* The title: a painting seen from the house, with the name plaque hung from the vine. */
.title {
  position: absolute;
  inset: 0;
  background: var(--window-blue-deep);
  transition: opacity 500ms ease;
}
.title.leaving { opacity: 0; pointer-events: none; }

.title-painting {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: calc(100% - 104px - var(--safe-bottom));
  object-fit: cover;
  object-position: 44% 60%;
  display: block;
}

.plaque-hang {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(86vw, 340px);
  height: calc(var(--safe-top) + 148px);
  transform: translateX(-50%);
  transform-origin: 50% 0;
  animation: plaque-sway 7s ease-in-out infinite;
}

.rope {
  position: absolute;
  top: 0;
  width: 4px;
  height: calc(var(--safe-top) + 72px);
  border-radius: 2px;
  background: repeating-linear-gradient(170deg, #8a6a3c 0 3px, #5f4525 3px 5px);
}
.rope-left { left: 16%; }
.rope-right { right: 16%; }

.plaque {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 12px 10px 14px;
  text-align: center;
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: clamp(34px, 11.4vw, 46px);
  line-height: 1.05;
  color: var(--window-blue);
  background: var(--whitewash);
  border: 5px solid var(--window-blue);
  border-radius: 6px;
  outline: 3px solid var(--whitewash);
  box-shadow: 2px 6px 14px rgba(40, 22, 40, 0.42);
}

@keyframes plaque-sway {
  0%, 100% { transform: translateX(-50%) rotate(-0.6deg); }
  50% { transform: translateX(-50%) rotate(0.6deg); }
}

.title-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 20px calc(18px + var(--safe-bottom));
  background: var(--window-blue-deep);
  border-top: 5px solid var(--whitewash);
  box-shadow: 0 -2px 0 var(--window-blue);
}

.name-sheet { display: flex; flex-direction: column; gap: 10px; }
.name-sheet[hidden], #start[hidden] { display: none; }
/* The door to the farm appears when the farm behind it is ready, so that no tap is lost. */
html:not([data-ready]) .title-foot { opacity: 0; pointer-events: none; }
.title-foot { transition: opacity 320ms ease; }
/* If the farm cannot open, it says so in the foot's place, never a silent title (js/boot-guard.js). */
.title-trouble {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  max-height: 70%;
  overflow-y: auto;
  padding: 16px 20px calc(18px + var(--safe-bottom));
  background: var(--window-blue-deep);
  border-top: 5px solid var(--whitewash);
  box-shadow: 0 -2px 0 var(--window-blue);
  color: var(--whitewash);
}
.title-trouble[hidden] { display: none; }
.trouble-head { margin: 0 0 6px; font-family: var(--font-sign); font-size: 26px; text-align: center; }
.trouble-words { margin: 0 0 10px; font-size: 17px; line-height: 1.35; }
.trouble-error {
  margin: 0 0 14px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
}
.trouble-error:empty { display: none; }
.btn-door:disabled { opacity: 0.7; }
.name-label { font-family: var(--font-sign); font-size: 24px; color: var(--whitewash); text-align: center; }
.name-input {
  width: 100%;
  min-height: 54px;
  padding: 8px 14px;
  border: 4px solid var(--window-blue);
  border-radius: 8px;
  background: var(--whitewash);
  color: var(--window-blue);
  font-family: var(--font-sign);
  font-size: 26px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

.btn-door {
  display: block;
  width: 100%;
  min-height: 62px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  font-family: var(--font-sign);
  font-size: 28px;
  color: var(--whitewash);
  background: var(--door-red);
  box-shadow: 0 4px 0 var(--door-red-deep);
}
.btn-door:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--door-red-deep); }

@media (prefers-reduced-motion: reduce) {
  .plaque-hang { animation: none; }
}

/* The strip along the bottom: a row of azulejos laid edge to edge, so that the blue
   quarter-rounds in the corners of neighbouring tiles join up into whole rounds. */
:root { --bar: 88px; }

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: var(--safe-bottom);
  background: var(--window-blue-deep);
  box-shadow: 0 -3px 0 var(--whitewash), 0 -6px 0 var(--window-blue);
}

.tile {
  position: relative;
  height: var(--bar);
  margin: 0;
  padding: 0;
  border: 0;
  background:
    radial-gradient(circle at 0 0, var(--window-blue) 0 11px, transparent 11.6px),
    radial-gradient(circle at 100% 0, var(--window-blue) 0 11px, transparent 11.6px),
    radial-gradient(circle at 0 100%, var(--window-blue) 0 11px, transparent 11.6px),
    radial-gradient(circle at 100% 100%, var(--window-blue) 0 11px, transparent 11.6px),
    linear-gradient(160deg, #FFFDF8 0%, var(--whitewash) 55%, #EFE9DA 100%);
  box-shadow: inset 0 0 0 1px rgba(22, 58, 120, 0.3);
  perspective: 400px;
  transition: filter 120ms ease;
}
.tile:disabled { color: inherit; opacity: 1; }
.tile:not(:disabled):active { filter: brightness(0.93); }
.tile.open { filter: brightness(0.93); }
.tile:focus-visible { outline: 3px solid var(--thatch); outline-offset: -4px; }

.tile-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Each face hides itself as the tile goes edge-on, so the flip never depends on the
     browser honouring backface-visibility. */
  transition: transform 640ms cubic-bezier(0.3, 1.3, 0.5, 1), visibility 0s linear 150ms;
}
.tile-face svg { width: 44px; height: 44px; display: block; }
.tile-art { width: 50px; height: 50px; display: block; object-fit: contain; margin-bottom: -3px; -webkit-user-drag: none; user-select: none; -webkit-user-select: none; pointer-events: none; }
.tile.pressed .tile-verb .tile-art { animation: tile-press 260ms ease-out; }
.tile-blank svg { width: 54px; height: 54px; opacity: 0.8; }
.tile-verb { transform: rotateY(180deg); visibility: hidden; }
.tile-word {
  font-family: var(--font-sign);
  font-size: 20px;
  line-height: 1;
  color: var(--window-blue);
}
.tile.turning .tile-blank, .tile.shown .tile-blank { transform: rotateY(-180deg); visibility: hidden; }
.tile.turning .tile-verb, .tile.shown .tile-verb { transform: rotateY(0deg); visibility: visible; }
.tile.pressed .tile-verb svg { animation: tile-press 260ms ease-out; }
@keyframes tile-press {
  40% { transform: scale(0.88); }
  100% { transform: scale(1); }
}

.tile-pip {
  position: absolute;
  top: 9px;
  right: calc(50% - 34px);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #FFE9A6, #EDBB3C 58%, #C48A1E);
  box-shadow: inset 0 0 0 2px #B57E18, 0 0 0 2px var(--whitewash);
  transform: scale(0);
  transition: transform 300ms cubic-bezier(0.3, 1.8, 0.5, 1);
}
.tile.has-pip .tile-pip { transform: scale(1); }

/* The Buy sheet rises from behind the tiles, like a ledger taken out of a drawer. */
.scrim {
  position: absolute;
  inset: 0;
  display: none;
  background: rgba(22, 30, 60, 0.18);
  touch-action: none;
}
.scrim.open { display: block; }

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + var(--bar) + 6px);
  display: flex;
  flex-direction: column;
  max-height: calc(100% - var(--safe-top) - var(--bar) - 84px);
  background: var(--whitewash);
  border-top: 5px solid var(--window-blue);
  box-shadow: 0 -2px 0 var(--whitewash), 0 -10px 22px rgba(30, 20, 40, 0.32);
  transform: translateY(calc(100% + var(--bar) + var(--safe-bottom)));
  visibility: hidden;
  transition: transform 280ms cubic-bezier(0.22, 0.9, 0.3, 1), visibility 0s linear 280ms;
}
.sheet.open { transform: none; visibility: visible; transition: transform 280ms cubic-bezier(0.22, 0.9, 0.3, 1); }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 4px 18px;
}
.sheet-head h2 {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: 30px;
  color: var(--window-blue);
}
.sheet-close {
  width: 52px;
  height: 52px;
  padding: 10px;
  border: 0;
  background: transparent;
}
.sheet-close svg { width: 100%; height: 100%; display: block; }

.sheet-rows {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-bottom: 6px;
}
.sheet-empty { margin: 8px 18px 22px; font-size: 18px; }

.offer {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px 12px 16px;
  border-top: 2px solid rgba(31, 78, 158, 0.16);
}
.offer-art { width: 54px; height: 54px; }
.offer-art svg { width: 100%; height: 100%; display: block; }
.offer-text h3 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--basalt); }
.offer-text p { margin: 3px 0 0; font-size: 15.5px; line-height: 1.3; color: #5B5250; }

.offer-buy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 56px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: var(--door-red);
  box-shadow: 0 4px 0 var(--door-red-deep);
  color: var(--whitewash);
  font-family: var(--font-sign);
  font-size: 24px;
}
.offer-buy:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--door-red-deep); }
.offer-wait { text-align: center; }
.offer-price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-weight: 700;
  font-size: 20px;
  color: var(--basalt);
}
.offer-left { display: block; font-size: 15px; color: #5B5250; }
.coin-small { flex: none; width: 24px; height: 24px; display: inline-block; }

/* The card for a building: a picture of it as it will stand, what it gives, and Build. */
.build-body {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 2px 16px 6px;
}
.build-picture {
  width: 132px;
  height: 132px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--whitewash);
  box-shadow: inset 0 0 0 3px rgba(31, 78, 158, 0.16);
}
.build-picture img { display: block; width: 100%; height: 100%; object-fit: cover; }
.build-picture[hidden] { display: none; }
.build-text { min-width: 0; }
.build-name { margin: 2px 0 0; font-family: var(--font-sign); font-weight: 400; font-size: 27px; line-height: 1.1; color: var(--basalt); }
.build-says { margin: 4px 0 0; font-size: 15.5px; line-height: 1.3; color: #5B5250; }
.build-gifts { display: flex; align-items: center; gap: 2px; margin: 8px 0 0; height: 34px; }
.build-gifts svg { width: 32px; height: 32px; display: block; }
.build-gifts .build-give { width: 34px; height: 34px; display: block; object-fit: contain; }
.build-gifts .coin-small { width: 30px; height: 30px; }
.build-arrow { margin: 0 4px; font-size: 22px; font-weight: 700; color: var(--window-blue); }
.build-gives { margin: 4px 0 0; font-size: 16px; font-weight: 600; line-height: 1.3; color: var(--basalt); }
.build-foot { padding: 6px 16px 16px; }
.build-go {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 60px;
  border: 0;
  border-radius: 10px;
  background: var(--door-red);
  box-shadow: 0 4px 0 var(--door-red-deep);
  color: var(--whitewash);
  font-family: var(--font-sign);
  font-size: 28px;
}
.build-go:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--door-red-deep); }
.build-go .coin-small { width: 30px; height: 30px; }
.build-word { margin-left: 10px; }
/* A gift from Dona Ilda: no coin, only what she does. */
.build-go.gift .build-word { margin-left: 0; }
.build-wait { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 60px; border-radius: 10px; background: rgba(31, 78, 158, 0.08); }
.build-wait .offer-left { display: inline; font-size: 17px; }

/* The farm book: the same drawer as the Buy sheet, with calm rows. */
.book-farm { padding: 2px 18px 10px; }
.book-farm h3 { margin: 0; font-family: var(--font-sign); font-weight: 400; font-size: 26px; color: var(--basalt); }
.book-farm p { margin: 2px 0 0; font-size: 16px; color: #5B5250; }
.book-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-top: 2px solid rgba(31, 78, 158, 0.16);
}
.book-row[hidden] { display: none; }
.book-icon { width: 48px; height: 48px; }
.book-icon svg { width: 100%; height: 100%; display: block; }
.book-row h3 { margin: 2px 0 0; font-size: 18px; font-weight: 700; color: var(--basalt); }
.book-row p { margin: 4px 0 0; font-size: 16px; line-height: 1.35; color: #5B5250; }
#book-fly.ready h3 { color: var(--laurel); }
.book-steps { margin: 10px 0 0; padding: 0; list-style: none; counter-reset: step; }
.book-steps li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; margin: 0 0 8px; font-size: 16px; line-height: 1.3; }
.step-icon { width: 34px; height: 34px; }
.step-icon svg { width: 100%; height: 100%; display: block; }
.book-note { font-size: 15px; }
.book-btn {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--door-red);
  box-shadow: 0 4px 0 var(--door-red-deep);
  color: var(--whitewash);
  font-weight: 700;
  font-size: 18px;
}
.book-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--door-red-deep); }
.book-btn[hidden] { display: none; }
.book-btn-quiet { background: var(--window-blue); box-shadow: 0 4px 0 var(--window-blue-deep); }
.book-btn-quiet:active { box-shadow: 0 1px 0 var(--window-blue-deep); }
.book-text {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 2px solid rgba(31, 78, 158, 0.4);
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--basalt);
  font: 15px/1.3 ui-monospace, Menlo, monospace;
  word-break: break-all;
  resize: none;
  -webkit-user-select: text;
  user-select: text;
}
.book-text[hidden] { display: none; }
.book-said { font-weight: 700; color: var(--window-blue) !important; }
.book-said:empty { display: none; }
.book-confirm { margin-top: 10px; padding: 12px; border-radius: 8px; background: #F1EADB; }
.book-confirm[hidden] { display: none; }
.book-confirm p { margin: 0; color: var(--basalt); }
.book-confirm .book-again-note { margin-top: 12px; font-size: 15px; color: #5B5250; }
.book-confirm .book-said { margin-top: 8px; }
#book-again-yes { margin-top: 18px; }

/* On the title: quiet words under the door, never a pop-up. */
.title-note {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: var(--whitewash);
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.title-note[hidden], .title-steps[hidden], .title-bring[hidden], .title-fly[hidden] { display: none; }
.title-steps { margin-top: 4px; padding: 10px 12px 2px; border-radius: 8px; background: var(--whitewash); }
.title-bring { margin-top: 6px; }
.btn-small { min-height: 52px; font-size: 22px; margin-top: 8px; }
.title-said { margin: 8px 0 0; color: var(--whitewash); font-size: 16px; }
.title-said:empty { display: none; }
.title-fly { margin: 10px 0 0; text-align: center; color: #CFE2C4; font-size: 15px; font-weight: 700; }

/* The seed tray, there and gone beside the tiles. */
.tray {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bottom) + var(--bar) + 16px);
  display: flex;
  justify-content: center;
  gap: 8px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 200ms ease;
}
.tray.open { opacity: 1; transform: none; pointer-events: auto; }
.seed {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 58px;
  padding: 5px 13px 5px 7px;
  background: var(--whitewash);
  border: 3px solid rgba(31, 78, 158, 0.3);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(22, 58, 120, 0.4);
  text-align: left;
}
.seed.chosen { border-color: var(--window-blue); background: #EAF0FB; }
.seed-art { width: 40px; height: 40px; flex: none; }
.seed-art svg { width: 100%; height: 100%; display: block; }
.seed-text { display: flex; flex-direction: column; }
.seed-name { font-weight: 700; font-size: 16px; line-height: 1.15; color: var(--basalt); }
.seed-note { font-size: 14px; line-height: 1.2; color: #5B5250; }

/* The plaque for a big moment. It hangs where it always has, and more words take it further
   down, never up off the top of the screen, and never lower than just above the tiles: there
   they scroll inside it (Devin, 8 November: the word on coming back ran off the top of his
   screen and began mid-sentence). */
:root { --banner-drop: calc(var(--safe-top) + 122px); }
.banner {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(84vw, 330px);
  max-height: calc(100% - var(--bar) - var(--safe-bottom) - 12px);
  display: flex;
  flex-direction: column;
  margin-left: calc(min(84vw, 330px) / -2);
  transform: translateY(-110%);
  transform-origin: 50% 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 420ms cubic-bezier(0.5, 0, 0.75, 0), visibility 0s linear 420ms;
}
.banner.down {
  transform: none;
  visibility: visible;
  transition: transform 620ms cubic-bezier(0.25, 1.4, 0.45, 1);
}
.banner .rope { height: calc(var(--safe-top) + 130px); }
.banner-plaque {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: var(--banner-drop);
  padding: 10px 12px 12px;
  text-align: center;
  background: var(--whitewash);
  border: 5px solid var(--window-blue);
  border-radius: 6px;
  outline: 3px solid var(--whitewash);
  box-shadow: 2px 6px 14px rgba(40, 22, 40, 0.42);
}
.banner-name { flex: none; margin: 0; font-family: var(--font-sign); font-size: 32px; line-height: 1.1; color: var(--window-blue); }
.banner-line { min-height: 0; margin: 2px 0 0; font-size: 17px; font-weight: 500; color: var(--basalt); white-space: pre-line; overflow-y: auto; overscroll-behavior: contain; }
/* A long word of several lines (the one on coming back): read line by line from the left,
   and it can be scrolled, held to read, or tapped away. */
.banner.long .banner-plaque { pointer-events: auto; }
.banner.long .banner-line { text-align: left; line-height: 1.35; }
.banner-row { display: block; }
.banner-row + .banner-row { margin-top: 7px; }
.banner-row:first-child { font-weight: 700; color: var(--window-blue); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet.open, .tile-face { transition-duration: 1ms; }
}

/* The noticeboard: someone's face and her own words, not a price list. */
.person {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
  padding: 12px 16px 14px;
  border-top: 2px solid rgba(31, 78, 158, 0.16);
}
.person-face {
  width: 84px;
  height: 84px;
  display: block;
  border-radius: 4px;
  border: 3px solid var(--window-blue);
  outline: 2px solid var(--whitewash);
  background: #D7E4F6;
}
.person-text h3 { margin: 0; font-family: var(--font-sign); font-weight: 400; font-size: 26px; line-height: 1.1; color: var(--window-blue); }
.person-says { margin: 4px 0 0; font-size: 16px; line-height: 1.3; color: var(--basalt); }
.person-foot {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.person-foot .offer-buy, .person-foot .offer-wait { width: 92px; }
.person-does { margin: 0; font-size: 15.5px; line-height: 1.3; color: #5B5250; }
.person-note { margin: 0; font-size: 16px; font-weight: 500; color: var(--laurel); }
/* What someone does for the whole farm, said plainly: "40% more people stop". */
.person-gives {
  display: inline-block;
  margin: 6px 0 0;
  padding: 2px 10px 3px;
  border-radius: 999px;
  border: 2px solid var(--laurel);
  background: #FFF6D6;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--laurel);
}
/* A title under the name, for someone who gave himself one. */
.person-title { margin: 2px 0 0; font-size: 15px; font-style: italic; line-height: 1.2; color: #5B5250; }

/* Landscape (L1): the phone on its side. The tiles become a slim strip down the right,
   inside the safe area; the sign, the card and the toast keep to the farm beside it;
   sheets open from the side, next to the strip; and the farm stays just as close, because
   stage.js narrows the view so that a metre is as many points across as when upright. */
@media (orientation: landscape) and (max-height: 540px) {
  :root {
    --strip: calc(86px + env(safe-area-inset-right, 0px));
    --safe-left: env(safe-area-inset-left, 0px);
  }
  .bar {
    left: auto;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--strip);
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    padding: var(--safe-top) env(safe-area-inset-right, 0px) var(--safe-bottom) 0;
    box-shadow: -3px 0 0 var(--whitewash), -6px 0 0 var(--window-blue);
  }
  .tile { height: auto; min-height: 0; }
  .tile-art { width: 40px; height: 40px; margin-bottom: -2px; }
  .tile-face svg { width: 36px; height: 36px; }
  .tile-blank svg { width: 44px; height: 44px; }
  .tile-word { font-size: 17px; }
  .tile-pip { top: 5px; right: calc(50% - 30px); width: 18px; height: 18px; }
  .hud { left: calc(12px + var(--safe-left)); right: calc(var(--strip) + 12px); }
  .card, .jobs-chip { left: calc(12px + var(--safe-left)); right: calc(var(--strip) + 12px); max-width: 520px; }
  .toast { left: calc(16px + var(--safe-left)); right: calc(var(--strip) + 16px); bottom: calc(var(--safe-bottom) + 14px); max-width: 560px; }
  .update-chip { left: calc(12px + var(--safe-left)); bottom: calc(var(--safe-bottom) + 12px); }
  .tray { left: calc(12px + var(--safe-left)); right: calc(var(--strip) + 12px); bottom: calc(var(--safe-bottom) + 14px); }
  .banner { left: calc((100% - var(--strip)) / 2); max-height: calc(100% - var(--safe-bottom) - 12px); }
  .banner .rope { height: calc(var(--safe-top) + 96px); }
  :root { --banner-drop: calc(var(--safe-top) + 88px); }
  .sheet {
    left: auto;
    top: 0;
    right: var(--strip);
    bottom: 0;
    width: min(440px, 56vw);
    max-height: none;
    padding: var(--safe-top) 0 var(--safe-bottom);
    border-top: 0;
    border-left: 5px solid var(--window-blue);
    box-shadow: -2px 0 0 var(--whitewash), -10px 0 22px rgba(30, 20, 40, 0.32);
    transform: translateX(calc(100% + var(--strip)));
  }
  .sheet.open { transform: none; }
  .sheet-rows { flex: 1; min-height: 0; }

  /* The title: the painting fills the screen, framed on Bianca and Brian, with the door
     and the name on a panel at the right and the plaque over the painting. */
  .title-painting { width: calc(100% - min(340px, 42vw)); height: 100%; object-position: 50% 44%; }
  .title-foot {
    left: auto;
    top: 0;
    width: min(340px, 42vw);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: calc(14px + var(--safe-top)) calc(18px + env(safe-area-inset-right, 0px)) calc(14px + var(--safe-bottom)) 18px;
    justify-content: flex-end;
    padding-top: calc(var(--safe-top) + 122px);
    border-top: 0;
    border-left: 5px solid var(--whitewash);
    box-shadow: -2px 0 0 var(--window-blue);
    overflow-y: auto;
  }
  /* The plaque hangs over the door's panel, so it never covers her face. */
  .plaque-hang { left: calc(100% - min(340px, 42vw) / 2); width: min(300px, 36vw); height: calc(var(--safe-top) + 110px); z-index: 2; }
  .plaque-hang .rope { height: calc(var(--safe-top) + 44px); }
  .plaque { font-size: clamp(26px, 4.4vw, 36px); padding: 8px 10px 10px; }

  /* Dona Ilda's list keeps to the farm beside the strip, and its rows are a little
     shorter, so that three fit on a phone on its side. */
  .quests-panel { left: calc(12px + var(--safe-left)); right: calc(var(--strip) + 12px); max-width: 460px; top: calc(var(--safe-top) + 54px); }
  .quests-head { padding-bottom: 5px; font-size: 15px; }
  .quests-head .card-face { width: 32px; height: 32px; }
  .quest { min-height: 52px; padding: 4px 8px 4px 4px; }
  .quest-art { width: 42px; height: 42px; }
  .quest-title { font-size: 15px; }
  .quest-progress { font-size: 13px; }
}