@font-face {
  font-family: Nunito;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/nunito-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: Nunito;
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("../fonts/nunito-latin-800-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --ink: #3a2418;
  --cream: #fffaf3;
  --moss: #2f6b4f;
  --moss-dark: #1e4634;
  --amber: #f2c14e;
  --fox: #c4521a;
  --card: rgba(255, 250, 243, 0.94);
  font-family: Nunito, ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8ec6e6;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button, p, h1, h2 { user-select: none; }

button {
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

#welt {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  touch-action: none;
  cursor: pointer;
}

/* The basket counts berries in the forest; a task needs the room for its buttons. */
body[data-mode="task"] .basket { display: none; }

body[data-mode="world"] #wald,
body[data-mode="world"] .board { display: none; }

body[data-mode="world"] .ui { pointer-events: none; }
body[data-mode="world"] .ui .topbar > *,
body[data-mode="world"] .ui .speakbar { pointer-events: auto; }
body[data-mode="world"] .speakbar { grid-row: 3; }
/* Nothing said: no empty bar over the forest. */
.speakbar:has(> p:empty) { visibility: hidden; }
body[data-mode="world"] .speakbar p { min-height: 0; }

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
body[data-mode="world"] .topbar .top-left { pointer-events: none; }
body[data-mode="world"] .topbar .top-left > * { pointer-events: auto; }

.basket {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 14px 4px 8px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(58, 36, 24, 0.12);
  font-weight: 800;
  font-size: 1.25rem;
}
.basket svg { width: 32px; height: 32px; }

#wald {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

.ui {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* Nothing may widen the page past the screen. */
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding:
    max(10px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}

.topbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress, .top-actions, .speakbar, .task {
  background: var(--card);
  box-shadow: 0 10px 28px rgba(58, 36, 24, 0.12);
}

.progress {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  min-height: 44px;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
}

.progress .count {
  display: none;
  font-weight: 800;
  font-size: 1.1rem;
  white-space: nowrap;
}

.berry {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(90, 60, 40, 0.16);
  box-shadow: inset 0 0 0 2px rgba(58, 36, 24, 0.12);
}

.berry.done, .berry.now {
  background: radial-gradient(circle at 35% 30%, #ffd7b0, #e24b3a 58%, #8f1d18);
}

.berry.now {
  outline: 2px solid #fff;
  transform: scale(1.18);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px;
}

.icon-btn, .text-btn, .hint-btn, .go, .turn, .choice, .way {
  border: none;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--moss);
  color: var(--cream);
  display: grid;
  place-items: center;
  text-decoration: none;
}

.icon-btn svg { width: 26px; height: 26px; fill: currentColor; }

.text-btn {
  background: transparent;
  color: var(--ink);
  min-height: 48px;
  padding: 0 14px;
  font-size: 1.05rem;
}

.text-btn.dark { color: var(--moss-dark); }

.speakbar {
  width: min(980px, 100%);
  justify-self: center;
  border-radius: 20px;
  padding: 10px 16px;
}

.speakbar p {
  margin: 0;
  font-size: clamp(1.15rem, 2.3vw, 1.6rem);
  font-weight: 800;
  line-height: 1.25;
  min-height: 2.5em;
}

.board {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(140px, 230px) minmax(0, 820px);
  justify-content: center;
  align-items: end;
  gap: 12px;
}

.fox-slot {
  height: min(46vh, 420px);
  min-height: 180px;
  position: relative;
  cursor: pointer;
}

.board.party {
  grid-template-columns: minmax(0, 880px);
  grid-template-rows: minmax(170px, 32vh) minmax(0, 1fr);
  align-items: stretch;
}

.board.party .fox-slot,
.board.party .task {
  width: 100%;
  height: 100%;
  min-height: 0;
}

#fox, #fox-fallback {
  width: 100%;
  height: 100%;
  display: block;
}

#fox-fallback[hidden] { display: none; }

.fox-slot.with-animal #fox,
.fox-slot.with-animal #fox-fallback { display: none; }
.animal-slot {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.animal-slot svg {
  height: 100%;
  width: auto;
  max-width: 100%;
  animation: bob 2.6s ease-in-out infinite;
}

/* Three acorns under the animal: how many rounds are done. */
.round-dots {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 4px 12px rgba(58, 36, 24, 0.14);
}
.round-dots i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(90, 60, 40, 0.18);
}
.round-dots i.done { background: #a56b3c; }
.round-dots i.now { background: var(--amber); transform: scale(1.2); }

.guests {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 560px;
}
.guests span { width: 54px; height: 54px; }
.guests svg { width: 100%; height: 100%; display: block; }

.fox-row {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.fox-svg {
  height: 100%;
  width: auto;
  overflow: visible;
  animation: bob 2.6s ease-in-out infinite;
}

.fox-row.party .fox-svg { height: 78%; }

.fox-fallback.is-happy .fox-svg { animation: hop 0.45s ease; }

.task {
  position: relative;
  height: min(62vh, 560px);
  min-height: 280px;
  width: 100%;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.75), transparent 42%),
    linear-gradient(180deg, rgba(255, 250, 243, 0.96), rgba(243, 230, 212, 0.96));
}

.trace {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.blooms {
  position: absolute;
  top: 12px;
  left: 14px;
  display: flex;
  gap: 6px;
  z-index: 2;
  pointer-events: none;
}

.blooms i {
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #e4d2b8;
}

.blooms i.on {
  background: radial-gradient(circle at 35% 35%, #fff, #f2c14e 42%, #e07a2f);
}

.trace-tools {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.hint-btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  box-shadow: 0 4px 0 #c4922a;
  font-size: 1.05rem;
}

.hint-btn.ghost {
  background: rgba(255, 250, 243, 0.9);
  box-shadow: 0 4px 0 rgba(90, 60, 40, 0.2);
}

.intro, .finale, .shapes, .count, .pattern, .rotate, .ways {
  height: 100%;
  min-height: 0;
}

.intro, .finale {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 18px;
}

.intro h1, .finale h2 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  letter-spacing: -0.04em;
  color: var(--fox);
  line-height: 0.95;
}

.intro p, .finale p {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  font-weight: 800;
}

.go, .turn {
  min-height: 64px;
  padding: 12px 28px;
  border-radius: 999px;
  background: var(--moss);
  color: var(--cream);
  font-size: 1.4rem;
  box-shadow: 0 6px 0 var(--moss-dark);
}

.go:active, .turn:active, .choice:active, .way:active, .hint-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--moss-dark);
}

.shapes {
  display: flex;
  flex-direction: column;
  padding: 12px 12px 16px;
  gap: 8px;
}

.holes, .tray, .choices, .turn-row, .ways, .pattern-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.holes, .tray { flex: 1; }

.piece, .hole {
  width: min(28vw, 132px);
  aspect-ratio: 1;
  background: transparent;
  padding: 0;
  touch-action: none;
}

.piece {
  border: none;
  border-radius: 24px;
}

.piece svg, .hole svg, .tile svg, .choice svg, .way svg, .picnic svg {
  width: 100%;
  height: 100%;
  display: block;
}

.piece.dragging {
  z-index: 6;
  filter: drop-shadow(0 10px 8px rgba(58, 36, 24, 0.25));
}

.piece.spacer { pointer-events: none; }

.piece.locked { pointer-events: none; }
.piece.picked {
  transform: translateY(-8px) scale(1.06);
  filter: drop-shadow(0 10px 8px rgba(58, 36, 24, 0.25));
  transition: transform 0.15s ease;
}
.hole[role="button"] { cursor: pointer; }
.hole:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.hole {
  border-radius: 24px;
  background: rgba(255, 250, 243, 0.35);
}

.hole.pulse {
  animation: pulse 0.8s ease-in-out infinite;
}

.count, .pattern, .rotate {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 12px;
  gap: 8px;
}

.acorns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
}

.acorns svg { width: 68px; height: 76px; }

.acorns span:nth-child(odd) svg { transform: rotate(-8deg); }
.acorns span:nth-child(even) svg { transform: rotate(6deg); }

.choice {
  min-width: 104px;
  min-height: 108px;
  border-radius: 24px;
  background: var(--moss);
  color: var(--cream);
  box-shadow: 0 6px 0 var(--moss-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
}

.choice .num { font-size: 2.3rem; line-height: 1; }

.dots { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; max-width: 78px; }

.dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f6d48a;
}

.choice.picture, .tile {
  width: min(22vw, 104px);
  aspect-ratio: 1;
  background: #fff;
  border-radius: 22px;
}

.tile {
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 3px rgba(90, 60, 40, 0.08);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--fox);
}

.tile.missing { background: rgba(255, 250, 243, 0.7); }

.choice.help, .way.help, .hole.pulse {
  outline: 4px solid var(--amber);
  outline-offset: 2px;
}

.ways { height: 100%; padding: 12px; align-content: center; }

.way {
  width: min(30%, 220px);
  min-width: 140px;
  background: transparent;
  padding: 0;
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--moss-dark);
}

.leaf-stage {
  display: grid;
  place-items: center;
  min-height: 0;
}

.dial {
  width: min(46vw, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px dashed rgba(107, 70, 52, 0.35);
  display: grid;
  place-items: center;
  position: relative;
  touch-action: none;
}

.leaf, .leaf-shadow {
  position: absolute;
  width: 46%;
  height: 78%;
}

.leaf-shadow { opacity: 0.85; }

.leaf svg, .leaf-shadow svg { width: 100%; height: 100%; }

.picnic {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.picnic svg { width: 72px; height: 72px; }

.fall-leaf {
  position: fixed;
  top: -24px;
  width: 14px;
  height: 10px;
  border-radius: 0 80% 0 80%;
  z-index: 5;
  pointer-events: none;
  animation: fall 1.4s ease-in forwards;
}

@keyframes bob {
  50% { transform: translateY(-6px); }
}

@keyframes hop {
  0% { transform: translateY(0); }
  40% { transform: translateY(-16px); }
  100% { transform: translateY(0); }
}

@keyframes pulse {
  50% { transform: scale(1.06); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.shake { animation: shake 0.35s ease; }

/* Size order, memory, odd one out, shadows, more berries. */
.sizes, .odd, .shadow, .baskets {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  padding: 12px;
  gap: 10px;
}
.size-row { display: flex; gap: 10px; justify-content: center; }
.tile.slot { background: rgba(255, 250, 243, 0.6); box-shadow: inset 0 0 0 3px rgba(90, 60, 40, 0.18); }
.tile.slot.filled { background: #fff; }
.choice.used { visibility: hidden; }
.choice.right, .basket-choice.right { outline: 4px solid var(--moss); outline-offset: 2px; }

.memory {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, min(24vw, 128px));
  grid-auto-rows: min(24vw, 128px);
  justify-content: center;
  align-content: center;
  gap: 12px;
  padding: 12px;
}
.card {
  position: relative;
  border: none;
  border-radius: 22px;
  padding: 0;
  background: transparent;
  perspective: 600px;
}
.card .back, .card .front {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  transition: transform 0.3s ease;
}
.card .back {
  background:
    radial-gradient(circle at 30% 30%, #f2c14e 0 10%, transparent 11%),
    radial-gradient(circle at 70% 65%, #e07a2f 0 9%, transparent 10%),
    var(--moss);
  box-shadow: 0 6px 0 var(--moss-dark);
}
.card .front {
  background: #fff;
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 3px rgba(90, 60, 40, 0.1);
  padding: 10px;
}
.card .front svg { width: 100%; height: 100%; display: block; }
.memory.big {
  grid-template-columns: repeat(4, min(18vw, 104px));
  grid-auto-rows: min(18vw, 104px);
  gap: 10px;
}

/* Treasure chest button and sheet. */
.chest-btn { position: relative; background: #8b4630; }
.chest-count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 20px;
}
.chest-btn.bump { animation: hop 0.5s ease; }
.chest-grid {
  display: grid;
  grid-template-columns: repeat(5, min(15vw, 92px));
  gap: 10px;
  justify-content: center;
}
.chest-grid .tile { width: 100%; padding: 8px; }
.chest-grid .tile.hidden { background: rgba(255, 250, 243, 0.55); }
.chest-grid .tile.hidden svg { opacity: 0.25; }
.flies { padding-right: 12px; }
.card.up .back { transform: rotateY(180deg); }
.card.up .front { transform: rotateY(0deg); }
.card.found .front { box-shadow: inset 0 0 0 4px var(--moss); }

.shadow-picture { width: min(26vw, 130px); }
.silhouette * { fill: #3a2418 !important; stroke: #3a2418 !important; }

.baskets { flex-direction: row; justify-content: center; }
.basket-choice {
  width: min(38vw, 230px);
  border: none;
  border-radius: 24px;
  padding: 12px 10px 8px;
  background: rgba(255, 250, 243, 0.9);
  box-shadow: 0 6px 0 rgba(90, 60, 40, 0.2);
  display: grid;
  gap: 0;
}
.basket-choice .pile {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: center;
  gap: 2px;
  min-height: 84px;
  align-content: flex-start;
  padding: 0 12px;
}
.basket-choice .b svg { width: 38px; height: 38px; display: block; }
.basket-choice .weave { width: 100%; height: auto; display: block; margin-top: -10px; }
.basket-choice.help { outline: 4px solid var(--amber); outline-offset: 2px; }

@keyframes fall {
  to { transform: translateY(105vh) rotate(180deg); opacity: 0.15; }
}

@media (max-width: 860px), (orientation: portrait) {
  .board {
    grid-template-columns: 1fr;
    grid-template-rows: 108px minmax(0, 1fr);
    align-items: stretch;
  }

  .fox-slot {
    height: 108px;
    min-height: 0;
    width: 140px;
  }

  .board.party {
    grid-template-columns: 1fr;
    grid-template-rows: 190px minmax(0, 1fr);
  }

  .board.party .fox-slot {
    width: 100%;
    height: 190px;
  }

  .task {
    height: 100%;
    min-height: 0;
  }

  .piece, .hole { width: min(28vw, 110px); }

  /* Four across on a phone, five in the pattern row. */
  .choice.picture, .tile { width: min(19vw, 96px); }
  .pattern-row .tile { width: min(16vw, 96px); }
  .guests span { width: 34px; height: 34px; }
}

/* Narrow screens: "3 / 15" instead of fifteen berries. */
@media (max-width: 700px) {
  .progress .berry { display: none; }
  .progress .berry.now { display: block; }
  .progress .count { display: inline; }
}

@media (max-width: 480px) {
  .topbar { gap: 6px; }
  .top-left { gap: 6px; }
  .progress, .basket { min-height: 40px; padding-left: 10px; padding-right: 10px; }
  .basket svg { width: 26px; height: 26px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn svg { width: 22px; height: 22px; }
  .text-btn { min-height: 40px; padding: 0 8px; font-size: 0.95rem; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .board {
    grid-template-columns: 120px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .fox-slot { height: 100%; min-height: 0; width: auto; }
  .task { height: 100%; min-height: 0; }
  .speakbar p { min-height: 0; }
  .intro h1 { font-size: 2.2rem; }

  .board.party {
    grid-template-columns: 180px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .board.party .fox-slot { width: 100%; height: 100%; }
  .intro h1, .finale h2 { font-size: 2rem; }

  /* Tiles follow the height, so two rows always fit. */
  .choice.picture, .tile { width: min(22vw, 104px, 19vh); }
  .choice { min-height: 0; }
  .memory {
    grid-template-columns: repeat(3, min(24vw, 128px, 25vh));
    grid-auto-rows: min(24vw, 128px, 25vh);
  }
  .memory.big {
    grid-template-columns: repeat(6, min(12vw, 26vh));
    grid-auto-rows: min(12vw, 26vh);
    gap: 8px;
  }
  .chest-grid { grid-template-columns: repeat(5, min(12vw, 20vh)); gap: 6px; }
  .chest h2 { font-size: 1.7rem; }
  .chest { gap: 4px; padding: 8px; }
  .basket-choice .pile { min-height: 52px; }
  .basket-choice .b svg { width: 28px; height: 28px; }
  .guests span { width: 30px; height: 30px; }
  .picnic svg { max-height: 48px; }
}

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