@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;
  --honey: #d99a2b;
  font-family: Nunito, ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8fb56a;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button, a, input { font: inherit; font-weight: 800; }
button { cursor: pointer; border: none; color: inherit; }

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

#wald {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Top bar. */
.top {
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding:
    max(10px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    0
    max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.top .spacer { flex: 1; pointer-events: none; }

.icon, .code {
  position: relative;
  min-width: 52px;
  height: 52px;
  border-radius: 999px;
  background: var(--moss);
  color: var(--cream);
  display: grid;
  place-items: center;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--moss-dark);
}
.icon svg { width: 26px; height: 26px; fill: currentColor; }
.icon[aria-pressed="false"] { background: #7c8a80; box-shadow: 0 4px 0 #56625a; }
.code {
  padding: 0 16px;
  background: var(--cream);
  color: var(--moss-dark);
  box-shadow: 0 4px 0 rgba(90, 60, 40, 0.25);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 22px;
  text-align: center;
}
.badge.pop { animation: pop 0.5s ease; }
@keyframes pop {
  40% { transform: scale(1.5); }
}

/* A short message from the forest. */
.toast {
  position: fixed;
  z-index: 3;
  left: 50%;
  top: calc(max(10px, env(safe-area-inset-top)) + 64px);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 30rem);
  margin: 0;
  padding: 10px 18px;
  border-radius: 20px;
  background: rgba(255, 250, 243, 0.96);
  box-shadow: 0 8px 24px rgba(58, 36, 24, 0.18);
  font-size: 1.1rem;
  text-align: center;
}
.toast[hidden] { display: none; }

/* The big button for what can be done here. */
.act {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-height: 64px;
  padding: 10px 26px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  font-size: 1.3rem;
  box-shadow: 0 6px 0 #b8892a, 0 12px 26px rgba(58, 36, 24, 0.2);
  animation: nudge 1.6s ease-in-out infinite;
}
.act[hidden] { display: none; }
.act.locked { background: #d9d0c2; box-shadow: 0 6px 0 #a89c8a; animation: none; }
@keyframes nudge {
  50% { transform: translateX(-50%) translateY(-4px); }
}

/* Lobby. */
.lobby {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(58, 36, 24, 0.25);
}
.lobby[hidden] { display: none; }

.paper {
  width: min(640px, 100%);
  max-height: min(88dvh, 760px);
  overflow: auto;
  padding: 22px 18px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.75), transparent 42%),
    linear-gradient(180deg, #fffaf3, #f3e6d4);
  box-shadow: 0 16px 40px rgba(58, 36, 24, 0.2);
  text-align: center;
}
.paper h1, .paper h2 { margin: 0 0 6px; color: #8b5a34; }
.paper h1 { font-size: 2.2rem; }
.paper h2 { font-size: 1.7rem; }
.paper p { margin: 0 0 12px; font-size: 1.15rem; line-height: 1.35; }
.paper .small { font-size: 0.95rem; opacity: 0.75; }

.roles, .coats, .row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 10px 0;
}
.role {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 112px;
  padding: 8px;
  border-radius: 22px;
  background: var(--cream);
  box-shadow: 0 4px 0 rgba(90, 60, 40, 0.2);
}
.role svg { width: 72px; height: 72px; }
.role[aria-checked="true"], .coat[aria-checked="true"] {
  outline: 4px solid var(--amber);
  transform: translateY(-2px);
}
.coat {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15), 0 3px 0 rgba(90, 60, 40, 0.2);
}

.go {
  min-height: 58px;
  min-width: 150px;
  padding: 8px 22px;
  border-radius: 20px;
  background: var(--moss);
  color: var(--cream);
  font-size: 1.2rem;
  box-shadow: 0 5px 0 var(--moss-dark);
}
.go.light { background: var(--cream); color: var(--ink); box-shadow: 0 5px 0 rgba(90, 60, 40, 0.25); }
.go:disabled { opacity: 0.55; }

.join { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.join input {
  width: 6.4em;
  min-height: 58px;
  border-radius: 18px;
  border: 3px solid #d9c3a0;
  background: #fffaf3;
  color: var(--ink);
  font-size: 1.6rem;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
  user-select: text;
  -webkit-user-select: text;
}
.error { min-height: 1.3em; color: #c4521a; }

/* Story and dialogue: a card at the bottom with who speaks. */
.story {
  position: fixed;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 12px max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: linear-gradient(180deg, transparent, rgba(40, 24, 14, 0.35));
}
.story[hidden] { display: none; }
.story.scene { top: 0; align-items: flex-end; background: linear-gradient(180deg, rgba(20, 12, 8, 0.1), rgba(20, 12, 8, 0.55)); }
.card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: start;
  width: min(760px, 100%);
  padding: 16px 18px;
  border-radius: 26px;
  background: linear-gradient(180deg, #fffaf3, #f3e6d4);
  box-shadow: 0 14px 34px rgba(40, 24, 14, 0.3);
}
.face {
  grid-row: span 2;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #efe0c8;
  font-size: 2.6rem;
  overflow: hidden;
}
.face svg { width: 70px; height: 70px; }
.speaker { font-size: 0.95rem; letter-spacing: 0.04em; text-transform: uppercase; color: #8b5a34; }
.words { margin: 0; font-size: 1.3rem; line-height: 1.4; }
.card .row { grid-column: 1 / -1; justify-content: flex-end; margin: 6px 0 0; }
.card .row .go { min-width: 0; min-height: 52px; }
.dots { display: flex; gap: 6px; align-items: center; margin-right: auto; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: #dccbb0; }
.dots i.on { background: var(--honey); }

.choices { grid-column: 1 / -1; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.choice {
  width: min(26vw, 104px);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(90, 60, 40, 0.2);
}
.choice svg { width: 100%; height: 100%; display: block; }
.choice.shake { animation: shake 0.4s; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Sheets: journal, backpack, dance, the end. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(58, 36, 24, 0.3);
}
.sheet[hidden] { display: none; }
.quests { list-style: none; margin: 8px 0 14px; padding: 0; text-align: left; display: grid; gap: 10px; }
.quests li {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 2px 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
}
.quests li b { font-size: 1.15rem; }
.quests li .detail { grid-column: 2; font-size: 1rem; opacity: 0.85; }
.quests li .mark { grid-row: span 2; font-size: 1.6rem; text-align: center; }
.quests li.done { opacity: 0.6; }
.items { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 10px 0 14px; }
.item {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 96px;
  padding: 10px 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
}
.item .big { font-size: 2.2rem; line-height: 1; }

.dance { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.petal {
  width: min(20vw, 96px);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.15), 0 5px 0 rgba(90, 60, 40, 0.2);
  transition: transform 0.15s, filter 0.15s;
  filter: saturate(0.75) brightness(0.95);
}
.petal.lit { transform: scale(1.18); filter: saturate(1.2) brightness(1.15); box-shadow: 0 0 0 6px #fff, 0 0 26px 8px rgba(255, 240, 170, 0.9); }
.petal:disabled { cursor: default; }
.steps { display: flex; gap: 8px; justify-content: center; margin: 4px 0 10px; }
.steps i { width: 16px; height: 16px; border-radius: 50%; background: #dccbb0; }
.steps i.on { background: var(--honey); }

.party svg { width: 84px; height: 84px; }

@media (max-width: 560px) {
  .icon, .code { min-width: 46px; height: 46px; }
  .code { padding: 0 12px; font-size: 1rem; }
  .words { font-size: 1.15rem; }
  .face { width: 58px; height: 58px; font-size: 2rem; }
  .face svg { width: 54px; height: 54px; }
  .role { width: 96px; }
  .role svg { width: 60px; height: 60px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .card { padding: 10px 14px; }
  .words { font-size: 1.05rem; }
  .face { width: 48px; height: 48px; }
  .face svg { width: 44px; height: 44px; }
}

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