/* Betty Lou's Farm Hop: soft, rounded "toy farm" UI to match the cel-shaded world.
   Plum ink (same colour as the 3D outlines), cream panels with a gingham band,
   round candy buttons that squish when pressed. */
:root {
  --ink: #3a2442;
  --ink-soft: rgba(58, 36, 66, .35);
  --cream: #fff8ec;
  --cream-d: #f1dfc2;
  --leaf: #6bd864; --leaf-d: #2f9a3e;
  --berry: #ff7fb8; --berry-d: #d24a8a;
  --sun: #ffd24a; --sun-d: #e3a512;
  --lilac: #bd96ff; --lilac-d: #7d58d6;
  --sky: #8fd8ff;
  --gingham: repeating-linear-gradient(0deg, rgba(255, 127, 184, .55) 0 8px, transparent 8px 16px),
             repeating-linear-gradient(90deg, rgba(255, 127, 184, .55) 0 8px, #fff 8px 16px);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2f6e3a;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-family: 'Fredoka', 'Noto Sans SC', 'Nunito', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  font-weight: 600;
  color: var(--ink);
}
body { position: fixed; inset: 0; }
canvas { display: block; width: 100%; height: 100%; }
/* split screen: a chunky ink line between the two halves */
#splitLine { position: fixed; display: none; pointer-events: none; background: var(--ink); z-index: 1; }
body.split #splitLine { display: block; top: 0; bottom: 0; left: 50%; width: 6px; margin-left: -3px; }
body.split.splitV #splitLine { top: 50%; bottom: auto; left: 0; right: 0; width: auto; height: 6px; margin: -3px 0 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* White lettering with a rounded plum outline and a soft drop. */
.ink {
  color: #fff;
  text-shadow:
    0 0 1px var(--ink),
    2.5px 0 0 var(--ink), -2.5px 0 0 var(--ink), 0 2.5px 0 var(--ink), 0 -2.5px 0 var(--ink),
    1.8px 1.8px 0 var(--ink), -1.8px 1.8px 0 var(--ink), 1.8px -1.8px 0 var(--ink), -1.8px -1.8px 0 var(--ink),
    0 5px 0 var(--ink-soft);
}

/* A cream lozenge: score badge, sunflower counter, hints. */
.pill {
  background: rgba(255, 248, 236, .94);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink-soft);
}

/* ---------- round candy buttons ---------- */
.bubble {
  --c1: var(--sun); --c2: var(--sun-d);
  pointer-events: auto;
  display: grid; place-items: center;
  padding: 0; cursor: pointer;
  border: 3px solid var(--ink); border-radius: 50%;
  background:
    radial-gradient(ellipse 20% 12% at 33% 22%, rgba(255, 255, 255, .95) 0 60%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(var(--c1), var(--c2));
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12), 0 5px 0 var(--ink-soft);
  transition: transform .12s cubic-bezier(.3, 1.8, .5, 1);
}
.bubble:active { transform: scale(.9); }
.bubble:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }

.playBtn { --c1: var(--leaf); --c2: var(--leaf-d); width: 108px; height: 108px; }
.playBtn svg { width: 60px; height: 60px; }   /* each icon is centred in its own drawing */
.heroBtn { --c1: var(--berry); --c2: var(--berry-d); width: 84px; height: 84px; overflow: hidden; }
.heroBtn img { width: 78px; height: 78px; margin-top: 6px; }

#sound, #gear {
  position: fixed; top: calc(env(safe-area-inset-top) + 64px);
  width: 50px; height: 50px; display: none;
}
#sound { right: calc(env(safe-area-inset-right) + 16px); }
#gear { right: calc(env(safe-area-inset-right) + 76px); --c1: var(--lilac); --c2: var(--lilac-d); }
body.farm #sound, body.over #sound, body.farm #gear { display: grid; }
body.farm.decor #sound, body.farm.decor #gear { display: none; }
/* full screen: beside the settings, wherever the browser can do it */
#fullBtn {
  position: fixed; top: calc(env(safe-area-inset-top) + 64px); right: calc(env(safe-area-inset-right) + 136px);
  width: 50px; height: 50px; display: none; --c1: var(--sky); --c2: #4fa9dc;
}
#fullBtn svg { width: 26px; height: 26px; }
#fullBtn .in, #fullBtn.on .out { display: none; }
#fullBtn.on .in { display: inline; }
body.farm #fullBtn, body.over #fullBtn { display: grid; }
body.farm.decor #fullBtn, body.noFull #fullBtn { display: none; }
/* play with phones: top-left on the farm, under the score */
#phonesBtn {
  position: fixed; top: calc(env(safe-area-inset-top) + 64px); left: calc(env(safe-area-inset-left) + 16px);
  width: 50px; height: 50px; display: none; --c1: var(--berry); --c2: var(--berry-d);
}
#phonesBtn svg { width: 30px; height: 30px; }
#phonesBtn b:not(:empty) {
  position: absolute; right: -6px; top: -6px; min-width: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--leaf); color: #fff; border: 2px solid var(--ink); font-size: 12px; line-height: 16px;
}
body.farm #phonesBtn { display: grid; }
body.farm.decor #phonesBtn { display: none; }
#sound svg, #gear svg { width: 28px; height: 28px; }
.decorBtn { --c1: var(--leaf); --c2: var(--leaf-d); }
#sound .x { display: none; }
#sound.muted .x { display: inline; }
#sound.muted .wave { display: none; }

.btnRow { display: flex; align-items: center; justify-content: center; gap: 18px; }
.side { display: flex; align-items: center; gap: inherit; }
#farmBtns {
  position: fixed; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 36px);
  display: none;
}
body.farm #farmBtns { display: grid; grid-template-columns: 1fr auto 1fr; }   /* play stays dead centre */
#farmBtns .side.left { justify-self: end; }
#farmBtns .side.right { justify-self: start; }
/* Decorate mode swaps the farm buttons for shop / done / rotate */
#decorBar { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 36px); display: none; gap: 18px; }
body.farm.decor #decorBar { display: flex; }
body.farm.decor #farmBtns, body.farm.show-logo.decor #title { display: none; }
.shopBtn { --c1: var(--berry); --c2: var(--berry-d); width: 76px; height: 76px; }
.rotateBtn { --c1: var(--sky); --c2: #3f9fd8; width: 76px; height: 76px; }
.shopBtn svg, .rotateBtn svg { width: 44px; height: 44px; }
#doneBtn svg { width: 56px; height: 56px; margin: 0; }
.pondBtn { --c1: #8fd8ff; --c2: #3f9fd8; width: 84px; height: 84px; }
.pondBtn svg { width: 50px; height: 50px; }
.bunkBtn { --c1: #ffc27a; --c2: #e08a3a; width: 84px; height: 84px; }
.bunkBtn svg { width: 50px; height: 50px; }
/* four buttons on the farm: keep them on one line on narrow phones */
#farmBtns { gap: 8px; }
#farmBtns .side .bubble { width: 60px; height: 60px; }
#farmBtns .heroBtn img { width: 54px; height: 54px; }
#farmBtns .side svg { width: 36px; height: 36px; }
#farmBtns .playBtn { width: 96px; height: 96px; }
@media (max-width: 370px) {
  #farmBtns { gap: 7px; }
  #farmBtns .side .bubble { width: 58px; height: 58px; }
  #farmBtns .heroBtn img { width: 52px; height: 52px; }
  #farmBtns .playBtn { width: 86px; height: 86px; }
}

/* Hero portraits get the same plum outline as the 3D world. */
.cutout {
  filter: drop-shadow(1.6px 0 0 var(--ink)) drop-shadow(-1.6px 0 0 var(--ink)) drop-shadow(0 1.6px 0 var(--ink)) drop-shadow(0 -1.6px 0 var(--ink));
}

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 16px) 0 calc(env(safe-area-inset-left) + 16px);
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
#scoreCard {
  display: inline-flex; flex-direction: column; align-items: center;
  min-width: 78px; padding: 2px 16px 6px;
  border-radius: 26px;
}
#score { font-size: 46px; font-weight: 700; line-height: 1.05; }
#top { font-size: 15px; font-weight: 600; opacity: .8; margin-top: -2px; }
body.farm #score { display: none; }
body.farm #scoreCard { padding-top: 6px; }
#coins {
  display: flex; align-items: center; gap: 6px;
  font-size: 24px; font-weight: 700; padding: 3px 14px 3px 6px;
}
.flower { width: 34px; height: 34px; }

/* daylight clock: a round farm clock whose sunny wedge shrinks as the day runs
   down, turning orange at dusk and lilac at night; the sunflower in the middle
   becomes a moon at the very end */
#hud .left { display: flex; align-items: center; gap: 10px; }
#sky {
  --day: 1; --wedge: #ffd24a;
  position: relative; width: 52px; height: 52px; border-radius: 50%;
  border: 3px solid var(--ink);
  background:
    radial-gradient(circle, transparent 0 58%, var(--cream) 59%),
    conic-gradient(var(--wedge) calc(var(--day) * 360deg), #4a3a6e 0);
  box-shadow: 0 4px 0 var(--ink-soft);
}
#sky::after {   /* tick marks at the quarters */
  content: ''; position: absolute; inset: 1px; border-radius: 50%;
  background:
    linear-gradient(var(--ink), var(--ink)) 50% 0 / 3px 6px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 50% / 6px 3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 50% 100% / 3px 6px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 50% / 6px 3px no-repeat;
  opacity: .5;
}
body.farm #sky { visibility: hidden; }
#sky.low { animation: pulse .7s ease-in-out infinite; }
#sunDot {
  position: absolute; inset: 11px; z-index: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg stroke='%233a2442' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M12 1.5l2.6 4.2 4.8-1.2-1.2 4.8 4.3 2.7-4.3 2.7 1.2 4.8-4.8-1.2L12 22.5l-2.6-4.2-4.8 1.2 1.2-4.8L1.5 12l4.3-2.7-1.2-4.8 4.8 1.2z' fill='%23ffcc1a'/%3E%3Ccircle cx='12' cy='12' r='4.4' fill='%237a4a1c'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .4s;
}
#sunDot.moon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 3a9 9 0 1 0 6 14A7.5 7.5 0 1 1 15 3z' fill='%23fff6c8' stroke='%233a2442' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
  transform: rotate(-15deg);
}

/* ---------- title ---------- */
#title {
  position: fixed; left: 0; right: 0;
  top: calc(env(safe-area-inset-top) + 64px);
  display: none; justify-content: center;
  pointer-events: none;
}
body.farm.show-logo #title { display: flex; }
.logo { text-align: center; transform: rotate(-5deg) scale(.72); transform-origin: 50% 0; }
.l1 {
  display: inline-block; font-size: 24px; font-weight: 700;
  padding: 2px 18px 4px; margin-bottom: 4px;
  background: var(--cream); color: var(--berry-d);
  border: 3px solid var(--ink); border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink-soft);
  transform: rotate(3deg);
}
.l2 { font-size: 64px; font-weight: 700; line-height: .95; white-space: nowrap; }
.l3 { font-size: 80px; margin-top: -4px; }
.l2 span {
  display: inline-block; margin: 0 -1px;
  /* puffy letters: plum rim, then a stacked plum "thickness" below */
  text-shadow:
    3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink),
    2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink),
    0 6px 0 var(--ink), 0 8px 0 var(--ink), 0 12px 4px rgba(58, 36, 66, .3);
  animation: bob 1.8s ease-in-out infinite;
}
.l2 span:nth-child(odd) { rotate: -4deg; }
.l2 span:nth-child(even) { rotate: 4deg; }
.l2 span:nth-child(6n+1) { color: #ff6b6b; animation-delay: 0s; }
.l2 span:nth-child(6n+2) { color: #ffa24a; animation-delay: .1s; }
.l2 span:nth-child(6n+3) { color: #ffd84a; animation-delay: .2s; }
.l2 span:nth-child(6n+4) { color: #6bd864; animation-delay: .3s; }
.l2 span:nth-child(6n+5) { color: #5bb4ff; animation-delay: .4s; }
.l2 span:nth-child(6n+6) { color: #bd96ff; animation-delay: .5s; }
.l3 span:nth-child(1) { color: #ff7fb8; }
.l3 span:nth-child(2) { color: #ffd84a; }
.l3 span:nth-child(3) { color: #5bb4ff; }
.l3 span:nth-child(4) { color: #6bd864; }
@keyframes bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-7px) } }

#hint {
  position: fixed; left: 50%;
  top: calc(env(safe-area-inset-top) + 124px);   /* up top, below the corner buttons, clear of the farm and the hopper */
  translate: -50% 0;
  text-align: center; font-size: 22px; font-weight: 700; white-space: nowrap;
  padding: 6px 22px 8px;
  display: none; pointer-events: none;
  animation: pulse 1.2s ease-in-out infinite;
}
#hint small { display: block; font-size: 14px; font-weight: 600; opacity: .75; }
body.farm #hint, body.ready #hint { display: block; }
body.ready #hint { top: calc(env(safe-area-inset-top) + 92px); }   /* the road has no corner buttons, just the score */
body.show-logo #hint { display: none; }   /* the logo greets you first; the tip comes once you touch the screen */
body.farm:not(.decor) #hint { display: none; }   /* on the farm, Betty Lou gives the tips instead */
/* Betty Lou's tips on the farm: a speech bubble over her head, now and then */
#tip {
  position: fixed; left: 0; top: 0; z-index: 4;
  max-width: min(260px, calc(100vw - 32px)); width: max-content;
  padding: 8px 16px 10px; border-radius: 20px;
  background: #fff4e0; border: 3px solid #3a2442; color: #3a2442;
  font-size: 17px; font-weight: 700; line-height: 1.25; text-align: center;
  pointer-events: none; opacity: 0; scale: 0.6;
  transform-origin: var(--tail, 50%) 100%;
  transition: opacity .2s, scale .25s cubic-bezier(.3, 1.6, .5, 1);
}
#tip::after {   /* the tail, pointing down at her */
  content: ''; position: absolute; top: 100%; left: var(--tail, 50%);
  width: 14px; height: 14px; translate: -50% -50%; rotate: 45deg;
  background: #fff4e0; border: solid #3a2442; border-width: 0 3px 3px 0;
}
#tip.show { opacity: 1; scale: 1; }
@keyframes pulse { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.06) } }

/* ---------- game over: a little farm-stand sign ---------- */
#over {
  position: fixed; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 36px);
  display: none; flex-direction: column; align-items: center; gap: 18px;
  pointer-events: none; padding: 0 16px; text-align: center;
}
#over.show { display: flex; animation: pop .4s cubic-bezier(.3, 1.6, .5, 1); }
.sign {
  position: relative; max-width: 330px;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 26px;
  box-shadow: 0 6px 0 var(--ink-soft);
  padding: 30px 22px 14px;
  overflow: hidden;
}
.sign::before {                              /* gingham band along the top */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 16px;
  background: var(--gingham); border-bottom: 3px solid var(--ink);
}
#overMsg { font-size: 22px; font-weight: 700; line-height: 1.2; }
#overGain { margin-top: 6px; font-size: 16px; font-weight: 600; opacity: .8; }
#newTop {
  display: none; margin: 10px auto 0; width: max-content;
  font-size: 16px; font-weight: 700; color: var(--ink);
  background: var(--sun); border: 3px solid var(--ink); border-radius: 999px; padding: 2px 14px 4px;
  animation: pulse .8s ease-in-out infinite;
}
#over.record #newTop { display: block; }
@keyframes pop { from { transform: translateY(40px) scale(.6); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- character picker ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(58, 36, 66, .5);
  display: none; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 26px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 16px);
  /* panels taller than the screen (phones on their side) scroll; "safe" keeps the top reachable */
  overflow-y: auto; align-items: safe center; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.sheet.show { display: flex; animation: pop .3s cubic-bezier(.3, 1.6, .5, 1); }
.sheet .panel {
  position: relative; width: 100%; max-width: 420px;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 30px;
  box-shadow: 0 8px 0 var(--ink-soft); padding: 34px 14px 16px;
}
.sheet .panel::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 20px;
  background: var(--gingham); border-bottom: 3px solid var(--ink);
  border-radius: 26px 26px 0 0;
}
.sheet h2 { margin: 0 0 14px; text-align: center; font-size: 26px; font-weight: 700; }
#heroGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#heroGrid .gridHead { grid-column: 1 / -1; margin: 8px 0 -4px; font-size: 16px; text-align: left; }
.heroCard {
  position: relative; display: flex; flex-direction: column; align-items: center;
  border: 3px solid var(--ink); border-radius: 22px; padding: 6px 4px 10px; cursor: pointer;
  box-shadow: 0 4px 0 var(--ink-soft);
  transition: transform .15s cubic-bezier(.3, 1.8, .5, 1);
}
.heroCard:active { transform: scale(.95); }
.heroCard img { width: 100%; max-width: 150px; aspect-ratio: 1; }
.heroCard span {
  font-size: 15px; font-weight: 700; line-height: 1.1;
  background: var(--cream); border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 2px 12px 3px; margin-top: -4px;
}
.heroCard.on { box-shadow: 0 0 0 4px var(--sun), 0 4px 0 var(--ink-soft); }
.heroCard.on::after {                        /* a sunflower badge marks the chosen hopper */
  content: ''; position: absolute; top: -14px; right: -12px; width: 40px; height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg stroke='%233a2442' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M12 1.5l2.6 4.2 4.8-1.2-1.2 4.8 4.3 2.7-4.3 2.7 1.2 4.8-4.8-1.2L12 22.5l-2.6-4.2-4.8 1.2 1.2-4.8L1.5 12l4.3-2.7-1.2-4.8 4.8 1.2z' fill='%23ffcc1a'/%3E%3Ccircle cx='12' cy='12' r='4.4' fill='%237a4a1c'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  animation: spin 6s linear infinite;
}
@keyframes spin { to { rotate: 360deg } }
.closeBtn { --c1: var(--berry); --c2: var(--berry-d); position: absolute; top: -20px; right: -14px; width: 48px; height: 48px; font-size: 20px; font-weight: 700; color: #fff; }
/* controller / arrow-key highlight */
body.pad .heroCard.focus, body.keys .heroCard.focus, .heroCard:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; transform: scale(1.04); }

/* ---------- Fish Pond panel ---------- */
.pondPanel { display: grid; justify-items: center; gap: 10px; text-align: center; max-width: 340px !important; }
.pondPanel h2 { margin-bottom: 0 !important; }
.pondLevel { font-size: 17px; font-weight: 600; opacity: .75; margin-top: -6px; }
.pondNextRow {
  display: flex; align-items: center; gap: 10px;
  font-size: 19px; font-weight: 700;
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 8px 16px;
}
.pondNextRow .label {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--sky); border: 2px solid var(--ink); border-radius: 999px; padding: 1px 8px;
}
.buyBtn {
  --c1: var(--leaf); --c2: var(--leaf-d);
  border-radius: 999px !important; width: auto; height: auto;
  padding: 10px 22px 12px; display: inline-flex; align-items: center; gap: 12px;
  font-size: 22px; font-weight: 700; color: #fff;
  text-shadow: 0 2px 0 rgba(58, 36, 66, .45);
}
.buyBtn .price {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--cream); color: var(--ink); text-shadow: none;
  border: 2.5px solid var(--ink); border-radius: 999px; padding: 1px 12px 2px 4px;
}
.buyBtn .flower { width: 28px; height: 28px; }
.buyBtn:disabled { --c1: #c9c1cf; --c2: #a49aab; cursor: not-allowed; }
.buyBtn.yay { animation: yay .5s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes yay { 0% { transform: scale(.85) } 60% { transform: scale(1.12) } 100% { transform: scale(1) } }
.pondNeed { margin: 0; min-height: 1.2em; font-size: 15px; font-weight: 600; opacity: .75; }

/* ---------- Bunkhouse panel ---------- */
.bunkPanel { display: grid; justify-items: center; gap: 10px; text-align: center; }
.bunkPanel h2 { margin-bottom: 0 !important; }
.bunkPlan { display: grid; justify-items: center; gap: 12px; }
.bunkPlan p, .bunkWho { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; max-width: 300px; }
.bunkWho { font-size: 14px; opacity: .75; margin: 0 auto 10px; }
#bunkHome { width: 100%; }
#shopGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; width: 100%; }
#bunkGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; width: 100%; }
#bunkGrid .heroCard { cursor: default; }
#bunkGrid .heroCard.locked { cursor: pointer; }
#bunkGrid .heroCard.locked img { filter: grayscale(.75) brightness(.92); opacity: .8; }
#shopGrid .heroCard .tag, #bunkGrid .heroCard .tag {                   /* owned: a green check; locked: the price */
  position: absolute; top: -12px; right: -10px;
  display: inline-flex; align-items: center; gap: 2px;
  height: 34px; min-width: 34px; box-sizing: border-box; justify-content: center;
  border: 2.5px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink-soft);
}
:is(#bunkGrid, #shopGrid) .heroCard .tag.check { background: var(--leaf); }
:is(#bunkGrid, #shopGrid) .heroCard .tag.check svg { width: 20px; height: 20px; }
:is(#bunkGrid, #shopGrid) .heroCard .tag.cost { background: var(--cream); padding: 0 9px 0 3px; font-size: 16px; font-weight: 700; }
:is(#bunkGrid, #shopGrid) .heroCard .tag.cost .flower { width: 24px; height: 24px; }
:is(#bunkGrid, #shopGrid) .heroCard.short .tag.cost { opacity: .7; }
/* ---------- Farm Buildings menu ---------- */
:is(#buildGrid, #bookGrid) { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 168px)); justify-content: center; gap: 12px; width: 100%; }
:is(#buildGrid, #bookGrid) .heroCard { background: #ffe9c7; }
:is(#buildGrid, #bookGrid) .lvl { font-size: 13px; font-weight: 700; opacity: .75; margin-top: 4px; background: none; border: 0; padding: 0; }
:is(#buildGrid, #bookGrid) .heroCard.unbuilt { background: #ddd6e2; }
:is(#buildGrid, #bookGrid) .heroCard.unbuilt img { filter: grayscale(1) brightness(.6) contrast(.5); opacity: .5; }   /* just a grey shape until it's built */
:is(#buildGrid, #bookGrid) .heroCard.unbuilt .heroName { background: #ece7f0; color: #8a7f92; }
:is(#buildGrid, #bookGrid) .heroCard .tag {
  position: absolute; top: -12px; right: -10px;
  display: inline-flex; align-items: center; gap: 2px; height: 34px; box-sizing: border-box;
  background: var(--cream); padding: 0 9px 0 3px; font-size: 16px; font-weight: 700;
  border: 2.5px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink-soft);
}
:is(#buildGrid, #bookGrid) .heroCard .tag .flower { width: 24px; height: 24px; }
:is(#buildGrid, #bookGrid) .heroCard .tag:empty { display: none; }
#bookGrid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
#bookGrid .heroCard { background: #d8f1ff; cursor: default; }
#bookGrid .heroCard img { max-width: 110px; }
#bookGrid .heroCard .tag { padding: 0 10px; }
#bookGrid .heroCard.unbuilt img { filter: brightness(0) opacity(.25); }   /* not caught yet: just its shadow */
#bookCount { margin: -4px auto 6px; }
.buildActs { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 6px; }
.actBtn {
  border-radius: 999px !important; width: auto; height: auto;
  padding: 8px 18px 10px 10px; display: inline-flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 rgba(58, 36, 66, .45);
}
.actBtn svg { width: 34px; height: 34px; }
#arrangeBtn { --c1: var(--leaf); --c2: var(--leaf-d); }
#fishGo { --c1: #8fd8ff; --c2: #3f9fd8; }
#fishBookBtn { --c1: var(--berry); --c2: var(--berry-d); }
/* ---------- Fishing ---------- */
#fishBar { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 36px); display: none; }
body.farm.fishing #fishBar { display: flex; }
body.farm.fishing #farmBtns { display: none; }
#bookBtn { --c1: var(--berry); --c2: var(--berry-d); width: 76px; height: 76px; }
#bookBtn svg { width: 46px; height: 46px; }
#fishStop svg { width: 56px; height: 56px; margin: 0; }
.fishUi, .fishCatch { position: fixed; left: 0; top: 0; z-index: 4; width: 0; height: 0; pointer-events: none; }
body:not(.farm) :is(.fishUi, .fishCatch), :is(.fishUi, .fishCatch).away { display: none; }
.fishSay {
  position: absolute; bottom: 10px; left: 0; translate: -50% 0; width: max-content; max-width: 220px;
  padding: 6px 14px 8px; border-radius: 18px; background: #fff4e0; border: 3px solid #3a2442; color: #3a2442;
  font-size: 16px; font-weight: 700; line-height: 1.2; text-align: center;
}
.fishSay:empty { display: none; }
.fishSay.bite { font-size: 30px; line-height: 1; padding: 4px 16px 6px; background: #ffd23f; animation: yay .3s cubic-bezier(.3, 1.8, .5, 1); }
.reel { position: absolute; bottom: 60px; left: 0; translate: -50% 0; display: none; }
.fishUi.reeling .reel { display: block; }
.lane {
  position: relative; width: 240px; height: 46px; box-sizing: border-box; overflow: hidden;
  border: 3px solid #3a2442; border-radius: 999px; background: linear-gradient(#8edcf6, #3f9fd8);
}
.fishUi.big .lane { width: min(520px, calc(100vw - 48px)); height: 62px; }   /* in the fishing camera: a big strip near the bottom */
.fishUi.big .lane .ring { width: 38px; height: 38px; left: 24px; }
.fishUi.big .lane .note { width: 30px; height: 30px; }
.lane .ring { position: absolute; left: 22px; top: 50%; width: 30px; height: 30px; translate: -50% -50%; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px #3a2442; }
.lane .note { position: absolute; top: 50%; width: 22px; height: 22px; translate: -50% -50%; box-sizing: border-box; border-radius: 50%; background: #ffd23f; border: 2.5px solid #3a2442; }
.lane .note.eighth { background: #ff9a3c; }
.lane .note.sixteenth { background: #ff7fb8; scale: .82; }
.lane .note.hit { animation: notePop .25s ease-out forwards; }
.lane .note.missed { background: #c9c1cf; opacity: .55; }
@keyframes notePop { to { scale: 1.9; opacity: 0; } }
.reel .count {
  position: absolute; right: -10px; top: -14px; padding: 1px 9px 2px; font-size: 14px; color: #3a2442;
  background: #fff4e0; border: 2.5px solid #3a2442; border-radius: 999px;
}
.fishCatch .card {
  position: absolute; bottom: 10px; left: 0; translate: -50% 0; width: max-content; max-width: 200px;
  display: grid; justify-items: center; gap: 1px; padding: 4px 14px 10px; text-align: center;
  background: #fff4e0; border: 3px solid #3a2442; border-radius: 20px; box-shadow: 0 4px 0 var(--ink-soft); color: #3a2442;
  animation: yay .45s cubic-bezier(.3, 1.8, .5, 1);
}
.fishCatch img { width: 92px; height: 92px; }
.fishCatch b { font-size: 17px; line-height: 1.1; }
.fishCatch .cm { font-size: 14px; font-weight: 600; opacity: .75; }
.fishCatch .gain { display: inline-flex; align-items: center; gap: 2px; margin-top: 3px; font-size: 15px; font-weight: 700; }
.fishCatch .gain .flower { width: 20px; height: 20px; }
.fishCatch .badge {
  position: absolute; top: -12px; right: -14px; rotate: 8deg; padding: 2px 10px 3px; font-style: normal;
  font-size: 14px; font-weight: 700; color: #fff; background: var(--berry); border: 2.5px solid #3a2442; border-radius: 999px;
}
#decorShopBtn { --c1: var(--berry); --c2: var(--berry-d); }
body.pad .actBtn.focus, body.keys .actBtn.focus { outline: 4px solid var(--sky); outline-offset: 3px; }
#bunkGrid .heroCard.yay { animation: yay .5s cubic-bezier(.3, 1.8, .5, 1); }

/* ---------- Jam Stage ----------
   Phones upright: the stage on top, the pads below. Sideways or on a computer:
   the stage on the left, the pads on the right. */
#jam {
  position: fixed; inset: 0; z-index: 12; display: none;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #241830;
}
#jam.show { display: grid; animation: pop .3s cubic-bezier(.3, 1.6, .5, 1); }
.jamStage {
  position: relative; overflow: hidden; min-height: 0;
  background:
    radial-gradient(ellipse 45% 70% at 50% 0%, rgba(255, 238, 170, .55), rgba(255, 238, 170, 0) 100%),
    linear-gradient(#5b3f8a, #3a2442 78%);
}
.jamStage::after {   /* wooden stage floor */
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 24%;
  background: repeating-linear-gradient(90deg, #b07a46 0 46px, #9c6b3c 46px 48px);
  border-top: 4px solid var(--ink);
}
#jamCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;
  filter: drop-shadow(2.5px 0 0 var(--ink)) drop-shadow(-2.5px 0 0 var(--ink)) drop-shadow(0 2.5px 0 var(--ink)) drop-shadow(0 -2.5px 0 var(--ink));
}
#jamTitle {
  position: absolute; z-index: 2; left: calc(env(safe-area-inset-left) + 16px); top: calc(env(safe-area-inset-top) + 12px);
  margin: 0; padding: 4px 16px 6px; font-size: 20px; transform: rotate(-3deg);
}
#jamNotes { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
/* jam with phones: the button under the title, friends' chips, the QR panel */
.partyBtn {
  position: absolute; z-index: 3; left: calc(env(safe-area-inset-left) + 14px); top: calc(env(safe-area-inset-top) + 56px);
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 5px 8px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--ink);
}
.partyBtn svg { width: 22px; height: 22px; }
.partyBtn.live { background: #e4ffd9; }
.partyBtn b:not(:empty) { background: var(--leaf); color: #fff; border-radius: 999px; padding: 0 7px; text-shadow: 0 1px 0 var(--ink-soft); }
#partyChips { position: absolute; z-index: 2; left: calc(env(safe-area-inset-left) + 14px); top: calc(env(safe-area-inset-top) + 98px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.partyChip {
  display: inline-flex; align-items: center; gap: 6px; width: max-content;
  background: var(--cream); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 1px 10px 2px 3px; font-size: 13px; font-weight: 700;
}
.partyChip .path {
  font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border-radius: 999px; padding: 0 6px; margin-left: 2px; border: 1.5px solid var(--ink);
}
.partyChip .path.local { background: var(--leaf); color: #fff; }
.partyChip .path.direct { background: var(--sky); }
.partyChip .path.relay { background: var(--cream-d); }
/* a guest on a friend's farm: just hopping, no shops or building */
body.guest #buildBtn, body.guest #start, body.guest #pondBtn,
body.guest #phonesBtn, body.guest #partyBtn, body.guest #play { display: none !important; }
#guestWait {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(36, 24, 48, .55);
}
#guestWait[hidden] { display: none; }
.guestCard {
  max-width: 340px; display: flex; align-items: center; gap: 12px; padding: 16px 20px;
  background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 20px;
  font: 600 17px/1.35 Fredoka, 'Noto Sans SC', system-ui, sans-serif;
}
.guestCard p { margin: 0; }
.guestDot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--leaf); animation: guestPulse 1.2s ease-in-out infinite; }
@keyframes guestPulse { 50% { transform: scale(.6); opacity: .5; } }
.partyChip b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--c); border: 2px solid var(--ink); font-size: 11px; }
/* The frame stays put with its title and buttons; only what's between them scrolls.
   A tap on the dark backdrop closes it. */
.partyPanel {
  position: fixed; inset: 0; z-index: 14; display: flex; align-items: center; justify-content: center; background: rgba(36, 24, 48, .7);
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 16px);
}
.partyPanel .panel {
  position: relative; width: 100%; max-width: 380px; max-height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 30px; box-shadow: 0 8px 0 var(--ink-soft); padding: 34px 18px 18px;
}
.partyBody {
  flex: 1 1 auto; min-height: 0; width: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: grid; justify-items: center; gap: 10px; padding: 2px 2px 6px; box-sizing: border-box;
}
.partyPanel .partyActions { flex: none; }
.partyPanel .panel::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 20px; background: var(--gingham); border-bottom: 3px solid var(--ink); border-radius: 26px 26px 0 0; }
.partyPanel h2 { margin: 0; font-size: 24px; }
.partyQr { width: min(220px, 60vw, 40vh); aspect-ratio: 1; background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 6px; display: grid; place-items: center; overflow-wrap: anywhere; font-size: 11px; }
.partyQr svg { width: 100%; height: 100%; }
.partyScan { margin: 0; font-size: 15px; line-height: 1.3; opacity: .8; }
.partyScan:empty { display: none; }
.partyHere { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 10px; border-top: 2px dashed rgba(58, 36, 66, .2); }
.partyHere h3 { margin: 0; font-size: 16px; }
.partyHere .partyScan { margin: 0; }
.localChip { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.localChip .partyChip { pointer-events: none; }
.localChip .x { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--cream-d); border: 2px solid var(--ink); font-size: 12px; font-weight: 700; }
.partyChip .path.screen { background: #fff; }
.partyList { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 26px; }
.partyNone { font-size: 14px; opacity: .6; }
.partyCode { margin: 0; font-size: 15px; font-weight: 600; }
.partyCode b { font-size: 24px; letter-spacing: .12em; margin-left: 4px; }
.partyCode b:empty, .partyCode:has(b:empty) { display: none; }
.partyJoin { width: 100%; }
.joinRow { display: flex; gap: 8px; justify-content: center; }
#joinCode {
  width: 8.5em; padding: 5px 12px 7px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink);
  font: inherit; font-size: 18px; font-weight: 700; letter-spacing: .1em; text-align: center; text-transform: uppercase;
}
#joinCode::placeholder { color: rgba(58, 36, 66, .3); }
/* a friend opened the invite in Safari: they may rather play from their Home Screen */
#homeNote {
  position: fixed; left: 50%; translate: -50% 0; top: calc(env(safe-area-inset-top) + 12px); z-index: 30;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 32px); box-sizing: border-box;
  padding: 8px 8px 8px 16px; font-size: 15px; font-weight: 600; line-height: 1.3; text-align: left;
}
#homeNote[hidden] { display: none; }
#homeNote b { letter-spacing: .08em; }
#homeNoteX { flex: none; width: 34px; height: 34px; font-size: 14px; font-weight: 700; --c1: var(--berry); --c2: var(--berry-d); color: #fff; }
.partyActions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chipBtn {
  border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); cursor: pointer;
  padding: 5px 16px 7px; font-size: 15px; font-weight: 700; box-shadow: 0 3px 0 var(--ink-soft);
}
.chipBtn.go { background: var(--leaf); color: #fff; text-shadow: 0 1px 0 var(--ink-soft); }
.jamNote {
  position: absolute; bottom: 30%; font-size: 38px; font-weight: 700;
  text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink);
  animation: noteUp 1.4s ease-out forwards;
}
@keyframes noteUp { from { transform: translateY(0) scale(.6); opacity: 1; } to { transform: translateY(-38vh) rotate(18deg) scale(1.1); opacity: 0; } }
.jamDeck {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px calc(env(safe-area-inset-right) + 12px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 12px);
  background: linear-gradient(#3a2f45, #241830); border-top: 4px solid var(--ink);
  touch-action: none;
}
#jamPads {
  /* six pads and the octave column fit across a phone */
  --pad: min(60px, calc((100vw - 132px - env(safe-area-inset-left) - env(safe-area-inset-right)) / 6));
  display: grid; grid-template-columns: repeat(6, var(--pad)); gap: 7px; align-items: center;
}
.pad {
  width: var(--pad); height: calc(var(--pad) * 1.15); padding: 0; cursor: pointer;
  display: grid; place-items: center;
  border: 3px solid var(--ink); border-radius: 10px;
  background: var(--c); opacity: .82;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18), 0 3px 0 rgba(0, 0, 0, .4);
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.pad.root { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .75), inset 0 -5px 0 rgba(0, 0, 0, .18), 0 3px 0 rgba(0, 0, 0, .4); }
.pad.hit { animation: padHit .25s ease-out; }
@keyframes padHit { 0% { opacity: 1; filter: brightness(1.5); transform: scale(.88); box-shadow: 0 0 22px var(--c); } 100% { opacity: .82; filter: none; transform: none; } }
.pad:focus-visible { outline: 4px solid #fff; outline-offset: 2px; }
.pad .k { font-size: 15px; font-weight: 700; color: rgba(58, 36, 66, .78); pointer-events: none; }
#jam[data-input="pad"] .pad:not(.live) { opacity: .45; }   /* the controller plays one row at a time */
#jam[data-input="pad"] .pad.live { opacity: 1; }
/* little key / button hints on the octave and close buttons */
.octBtn, #jamClose, .instBtn { position: relative; }
.instBtn { overflow: visible; }
:is(.octBtn, #jamClose, .instBtn)[data-hint]:not([data-hint=""])::after {
  content: attr(data-hint); position: absolute; right: -8px; bottom: -8px;
  min-width: 18px; padding: 1px 5px; border-radius: 999px;
  background: var(--cream); color: var(--ink); border: 2px solid var(--ink);
  font-size: 11px; font-weight: 700; line-height: 1.3; text-shadow: none;
}
.octave { display: flex; flex-direction: column; align-items: center; gap: 8px; }
/* drums: two rows of four bigger pads; the octave and sustain controls step aside */
#drumPads { display: grid; grid-template-columns: repeat(4, calc(var(--pad, 48px) * 1.45)); gap: 8px; --pad: min(60px, calc((100vw - 132px) / 6)); }
#jam:not(.drums) #drumPads, #jam.drums #jamPads, #jam.drums .sustainRow, #jam.drums #octUp, #jam.drums #octDown, #jam.drums .octBox { display: none; }
.drumPad { width: 100%; height: calc(var(--pad) * 1.6); align-content: center; gap: 2px; }
.drumPad .dn { font-size: 11px; font-weight: 700; line-height: 1.1; color: var(--ink); padding: 0 3px; text-align: center; }
.instBtn { --c1: var(--berry); --c2: var(--berry-d); width: 50px; height: 50px; overflow: hidden; }
.instBtn img { width: 46px; height: 46px; }
.jamMain { display: flex; flex-direction: column; gap: 12px; }
.sustainRow {
  position: relative; display: flex; align-items: center; gap: 10px;
  color: var(--cream); font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.sustainRow .vol { flex: 1; margin: 0; touch-action: pan-x; }
.sustainRow[data-hint]:not([data-hint=""])::after {
  content: attr(data-hint); position: absolute; right: 0; top: -16px;
  padding: 1px 6px; border-radius: 999px; background: var(--cream); color: var(--ink); border: 2px solid var(--ink);
  font-size: 10px; line-height: 1.3; text-transform: none; letter-spacing: 0;
}
.octBtn { --c1: var(--sky); --c2: #3f9fd8; width: 46px; height: 46px; font-size: 30px; font-weight: 700; color: #fff; line-height: 1; text-shadow: 0 2px 0 rgba(58, 36, 66, .5); }
.octBtn:disabled { --c1: #8a7f96; --c2: #6c6278; cursor: default; }
.octBox {
  display: flex; flex-direction: column; align-items: center; min-width: 46px;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 2px 6px 4px;
}
#octN { font-size: 22px; font-weight: 700; line-height: 1.1; }
.octBox small { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .7; }
#jamClose { position: absolute; z-index: 3; top: calc(env(safe-area-inset-top) + 12px); right: calc(env(safe-area-inset-right) + 14px); }
@media (orientation: landscape) {
  #jam { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) auto; }
  .jamDeck { border-top: 0; border-left: 4px solid var(--ink); padding: calc(env(safe-area-inset-top) + 70px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 16px) 16px; }
  #jamPads { --pad: min(72px, calc((100vh - 170px) / 3.8), calc((50vw - 132px) / 6)); }
  #drumPads { --pad: min(72px, calc((100vh - 120px) / 3.2), calc((50vw - 132px) / 6)); }
}

/* ---------- barn doors (farm -> road at sunrise, road -> farm at dusk) ----------
   Two big red barn doors, white X trim like the barn in the yard, slam shut with a
   little bounce; a badge pops up on the seam (a crowing rooster in the morning, a
   moon going home), then the doors swing open onto the new scene. */
#wipe { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; visibility: hidden; }
#wipe .door { position: absolute; top: 0; bottom: 0; width: 50.5%; }
#wipe .door svg { display: block; width: 100%; height: 100%; }
#wipe .door.left { left: 0; transform: translateX(-101%); }
#wipe .door.right { right: 0; transform: translateX(101%) scaleX(-1); }
#wipe .badge {
  position: absolute; left: 50%; top: 50%; width: 38vmin; height: 38vmin; margin: -19vmin 0 0 -19vmin;
  border-radius: 50%; border: 5px solid var(--ink); box-shadow: 0 8px 0 var(--ink-soft), inset 0 0 0 7px var(--cream);
  background: linear-gradient(#8fd8ff, #ffe9a8);
  display: grid; place-items: center; transform: scale(0);
}
#wipe .badge svg { width: 78%; height: 78%; grid-area: 1 / 1; }
#wipe .moon, #wipe.dusk .rooster { display: none; }
#wipe.dusk .moon { display: block; }
#wipe.dusk .badge { background: linear-gradient(#3b2a6e, #6a3f86); }
#wipe.sunrise, #wipe.dusk { visibility: visible; }
#wipe.sunrise .left { animation: doorL 2.1s both; }
#wipe.sunrise .right { animation: doorR 2.1s both; }
#wipe.sunrise .badge { animation: badge 2.1s both; }
#wipe.sunrise .rooster { animation: crow .3s ease-in-out .8s 3 alternate; transform-origin: 50% 90%; }
#wipe.dusk .left { animation: doorLq 1s both; }
#wipe.dusk .right { animation: doorRq 1s both; }
#wipe.dusk .badge { animation: badgeQ 1s both; }
@keyframes doorL {
  0% { transform: translateX(-101%); animation-timing-function: cubic-bezier(.5, 0, .9, .6); }
  20% { transform: translateX(0); } 24% { transform: translateX(-3%); } 28%, 72% { transform: translateX(0); animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
  100% { transform: translateX(-101%); }
}
@keyframes doorR {
  0% { transform: translateX(101%) scaleX(-1); animation-timing-function: cubic-bezier(.5, 0, .9, .6); }
  20% { transform: translateX(0) scaleX(-1); } 24% { transform: translateX(3%) scaleX(-1); } 28%, 72% { transform: translateX(0) scaleX(-1); animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
  100% { transform: translateX(101%) scaleX(-1); }
}
@keyframes badge { 0%, 24% { transform: scale(0) rotate(-20deg); } 34% { transform: scale(1.12) rotate(4deg); } 40%, 62% { transform: scale(1) rotate(0); } 70%, 100% { transform: scale(0) rotate(15deg); } }
@keyframes crow { from { rotate: -6deg; } to { rotate: 6deg; } }
@keyframes doorLq { 0% { transform: translateX(-101%); } 32%, 64% { transform: translateX(0); } 100% { transform: translateX(-101%); } }
@keyframes doorRq { 0% { transform: translateX(101%) scaleX(-1); } 32%, 64% { transform: translateX(0) scaleX(-1); } 100% { transform: translateX(101%) scaleX(-1); } }
@keyframes badgeQ { 0%, 30% { transform: scale(0); } 42%, 58% { transform: scale(1); } 66%, 100% { transform: scale(0); } }
@media (prefers-reduced-motion: reduce) {
  #wipe.sunrise .rooster { animation: none; }
}

/* ---------- settings ---------- */
.setPanel { display: grid; gap: 14px; max-width: 380px !important; margin-top: 12px; }
.setPanel h2 { margin-bottom: 0 !important; }
.setRow {
  display: grid; gap: 7px;
  padding: 10px 12px 12px; border-radius: 18px;
  background: #fff; border: 3px solid var(--ink-soft);
  transition: border-color .15s;
}
.setRow.focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(143, 216, 255, .5); }
.setLabel { font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.setNote { margin: 0; font-size: 13px; font-weight: 500; line-height: 1.35; opacity: .75; }
/* pill choices: wrap freely, sized by their words (labels grow in other languages) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.segBtn {
  flex: 1 1 auto; min-width: 0;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 6px 12px 7px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink);
  background: var(--cream); border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink-soft);
  transition: transform .12s cubic-bezier(.3, 1.8, .5, 1), background .15s;
}
.segBtn:active { transform: scale(.94); }
.segBtn[aria-checked="true"] { background: var(--sun); font-weight: 700; }
.segBtn:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
/* volume sliders: a cream track that fills with leaf green, a sunny knob */
.vol {
  -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 4px 0;
  border-radius: 999px; border: 2.5px solid var(--ink);
  background: linear-gradient(90deg, var(--leaf) 0 var(--fill, 80%), var(--cream) var(--fill, 80%) 100%);
}
.vol::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #fff6c8 0 18%, var(--sun) 19%); border: 3px solid var(--ink);
}
.vol::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--sun); border: 3px solid var(--ink); }
.vol:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

/* ---------- phones on their side: short and wide ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .sheet .panel { max-width: 640px; padding: 28px 14px 14px; }
  .sheet h2 { font-size: 22px; margin-bottom: 10px; }
  #heroGrid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .heroCard img { max-width: 104px; }
  .setPanel { max-width: 640px !important; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 0; }
  .setPanel h2 { grid-column: 1 / -1; }
  .setRow[data-row="lang"], .setRow[data-row="view"] { grid-column: 1 / -1; }
  #sound, #gear { top: calc(env(safe-area-inset-top) + 12px); }
  #sound { right: calc(env(safe-area-inset-right) + 140px); }
  #gear { right: calc(env(safe-area-inset-right) + 200px); }
  #fullBtn { top: calc(env(safe-area-inset-top) + 12px); right: calc(env(safe-area-inset-right) + 320px); }
  #phonesBtn { top: calc(env(safe-area-inset-top) + 12px); left: auto; right: calc(env(safe-area-inset-right) + 260px); }
  #decorBar { bottom: calc(env(safe-area-inset-bottom) + 14px); }
  .shopBtn, .rotateBtn { width: 64px; height: 64px; }
  #title { top: calc(env(safe-area-inset-top) + 4px); }
  .logo { transform: rotate(-5deg) scale(.5); }
  .playBtn { width: 84px; height: 84px; }
  .playBtn svg { width: 48px; height: 48px; }
  .bunkPanel { max-width: 640px; }
  #farmBtns .playBtn { width: 84px; height: 84px; }
  #bunkGrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  #farmBtns, #over { bottom: calc(env(safe-area-inset-bottom) + 14px); }
  #hint, body.ready #hint { top: calc(env(safe-area-inset-top) + 72px); }
  .sign { padding: 24px 18px 10px; }
}
