:root {
  --parchment: #f3ead6;
  --parchment-dark: #e4d6b8;
  --ink: #2a2418;
  --ink-soft: #5c5346;
  --olive: #4f5d34;
  --olive-deep: #3d4f32;
  --gold: #c4a35a;
  --gold-soft: #e8d5a3;
  --sea: #3a6a78;
  --clay: #8a5a3a;
  --sky: #d7e4ef;
  --rose: #a65b4a;
  --good: #3f6b3a;
  --shadow: 0 10px 30px rgba(42, 36, 24, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 50% -80px, #efe3c4 0%, transparent 60%),
    var(--parchment);
  color: var(--ink);
  font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", serif;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 12px 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}
.brand {
  flex: 1;
  text-align: center;
  min-width: 0;
}
.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  margin: 0;
}
.version {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-style: italic;
}
.topbar-spacer { width: 64px; }
.text-btn {
  border: 0;
  background: transparent;
  color: var(--olive);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 8px 4px;
  width: 64px;
  text-align: left;
}
.hidden { display: none !important; }

.screen { display: none; animation: fade 0.25s ease; }
.screen.active { display: block; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.lead, .hint, .footnote, .prompt {
  text-align: center;
  color: var(--ink-soft);
  line-height: 1.45;
}
.lead { font-size: 1.05rem; margin: 8px 0 20px; }
.hint { margin: 0 0 10px; font-size: 0.98rem; }
.footnote { margin-top: 28px; font-size: 0.88rem; }
.prompt { margin: 0 0 12px; font-size: 0.95rem; }

.status-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--olive);
  margin-bottom: 10px;
}

.menu {
  display: grid;
  gap: 12px;
}
.menu-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 12px;
  text-align: left;
  border: 1px solid #d9cba8;
  background: #fffaf0;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.menu-card:hover, .menu-card:focus {
  outline: 2px solid var(--gold);
  border-color: var(--gold);
}
.menu-icon {
  grid-row: 1 / span 3;
  font-size: 1.8rem;
  align-self: center;
}
.menu-name { font-size: 1.15rem; font-weight: 700; }
.menu-blurb { color: var(--ink-soft); font-size: 0.92rem; }
.menu-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.pill {
  font-size: 0.72rem;
  font-family: system-ui, sans-serif;
  padding: 2px 8px;
  border-radius: 999px;
  background: #efe4c4;
  color: var(--ink-soft);
}
.pill.read-low { background: #dce8d4; color: var(--good); }
.pill.read-mid { background: #e8d5a3; color: #6b5428; }
.pill.read-high { background: #ead8c8; color: #6b3a32; }
.legend {
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: -8px 0 16px;
}
.lamp-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 14px;
}
.oil-lamp {
  width: 44px;
  text-align: center;
  filter: grayscale(0.85) brightness(0.65);
  transition: filter 0.3s ease, transform 0.3s ease;
}
.oil-lamp.on {
  filter: none;
  transform: translateY(-2px);
}
.oil-lamp .flame { font-size: 1.15rem; }
.oil-lamp .bowl { font-size: 1.35rem; }

.actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
button.primary, button.ghost {
  font: inherit;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid var(--olive-deep);
}
button.primary {
  background: var(--olive-deep);
  color: #f7f1e1;
}
button.ghost {
  background: transparent;
  color: var(--olive-deep);
}
button.chosen {
  outline: 2px solid var(--gold);
  background: #efe4c4;
  opacity: 1;
}
button:disabled { opacity: 0.55; cursor: default; }
button:disabled.chosen { opacity: 1; }

.result-msg {
  text-align: center;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #efe4c4;
}
.result-msg.good { background: #dce8d4; color: var(--good); }
.result-msg.bad { background: #f0ddd6; color: var(--rose); }

/* Lost Sheep */
.hill {
  position: relative;
  height: min(58vh, 420px);
  border-radius: 24px 24px 12px 12px;
  overflow: hidden;
  background:
    linear-gradient(#9ec0d6 0%, #c5d9a8 38%, #7a9a55 70%, #5f7a3f 100%);
  box-shadow: var(--shadow);
}
.hill::after {
  content: "";
  position: absolute;
  width: 70px;
  height: 70px;
  right: 18px;
  top: 16px;
  background: radial-gradient(circle at 30% 30%, #fff6d2, #f0d27a 60%, #e0b24a);
  border-radius: 50%;
  opacity: 0.9;
}
.hide {
  position: absolute;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1.7rem;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
  transform-origin: center bottom;
}
.hide:active { transform: scale(0.92); }
.hide.revealed { cursor: default; }
.sheep-found {
  font-size: 2rem;
  animation: pop 0.35s ease;
}
@keyframes pop {
  from { transform: scale(0.4); }
  to { transform: scale(1); }
}

/* Two Houses */
.story {
  margin: 0 0 12px;
  padding: 14px 16px;
  background: #fffaf0;
  border-left: 4px solid var(--gold);
  border-radius: 0 12px 12px 0;
  font-size: 1.05rem;
  line-height: 1.4;
}
.house-scene {
  position: relative;
  height: 230px;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(#b9d3e6, #e7e0c8 55%, #cbb98a);
  box-shadow: var(--shadow);
}
.house-scene.storm {
  background: linear-gradient(#6b7c8c, #8a8f7a 55%, #6e6248);
}
.house-scene.storm::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    185deg,
    transparent 0 12px,
    rgba(180, 210, 230, 0.35) 12px 14px
  );
  animation: rain 0.35s linear infinite;
  pointer-events: none;
}
@keyframes rain { to { background-position: 0 18px; } }
.ground-wrap {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  height: 160px;
  padding: 0 8px 8px;
}
.plot {
  width: 42%;
  text-align: center;
  position: relative;
}
.house {
  width: 78px;
  margin: 0 auto 0;
  opacity: 0.35;
  transform: translateY(8px);
  transition: transform 0.45s ease, opacity 0.3s ease;
}
.house.built { opacity: 1; transform: none; }
.house.fall {
  animation: fall 0.7s ease forwards;
}
@keyframes fall {
  40% { transform: rotate(-8deg) translateY(6px); }
  100% { transform: rotate(18deg) translateY(70px); opacity: 0.15; }
}
.roof {
  height: 0;
  border-left: 39px solid transparent;
  border-right: 39px solid transparent;
  border-bottom: 28px solid #7a3f2e;
}
.wall {
  height: 48px;
  background: #e8d9b8;
  border: 2px solid #6a4a32;
  border-top: 0;
  position: relative;
}
.wall::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 22px;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  background: #6a4a32;
}
.foundation {
  height: 14px;
  margin: 0 auto;
  width: 90px;
  border-radius: 2px;
}
.foundation.rock { background: #6d6a67; box-shadow: 0 -2px 0 #8a8783; }
.foundation.sand { background: #e2c37a; box-shadow: inset 0 -3px 0 #c9a65c; }
.plot-label {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.choice-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* Bookcase */
.shelf {
  background: linear-gradient(#8b5a3c, #6e432c);
  border-radius: 8px 8px 4px 4px;
  padding: 12px 10px 18px;
  display: flex;
  gap: 6px;
  min-height: 120px;
  align-items: flex-end;
  box-shadow: var(--shadow);
  position: relative;
}
.shelf::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 8px;
  height: 8px;
  background: #5a3420;
  border-radius: 2px;
}
.slot {
  flex: 1;
  min-height: 88px;
  border: 2px dashed rgba(255,255,255,0.28);
  border-radius: 4px 4px 0 0;
  background: rgba(0,0,0,0.08);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer;
}
.slot.selected { outline: 2px solid var(--gold-soft); }
.book-pile, .stone-pile {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  min-height: 52px;
}
.book {
  border: 0;
  color: #f7f1e1;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 10px 6px;
  min-height: 88px;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.book.selected { outline: 3px solid var(--gold); }
.book.c0 { background: #6b3a32; }
.book.c1 { background: #3d4f32; }
.book.c2 { background: #3a4e6b; }
.book.c3 { background: #6b5428; }
.book.c4 { background: #4a3b5c; }
.book.c5 { background: #2f5e56; }
.book.c6 { background: #7a3e55; }
.book.in-slot {
  writing-mode: vertical-rl;
  min-height: 80px;
  width: 100%;
}

/* Stones */
.river {
  background:
    linear-gradient(#7aa3b0, #4e7d8a 40%, #c9b48a 41%, #b39a6a);
  border-radius: var(--radius);
  min-height: 150px;
  padding: 16px 10px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-content: center;
  box-shadow: var(--shadow);
}
.stone-slot {
  width: 72px;
  height: 52px;
  border: 2px dashed rgba(255,255,255,0.45);
  border-radius: 40% 40% 36% 36%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255,255,255,0.08);
}
.stone-slot.selected { outline: 2px solid #fff6d2; }
.stone {
  border: 0;
  background: #8d8476;
  background-image: radial-gradient(circle at 30% 30%, #b2aa9c, #6f675c);
  color: #f4efe4;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  width: 72px;
  min-height: 48px;
  border-radius: 40% 42% 38% 40%;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1.15;
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
}
.stone.selected { outline: 3px solid var(--gold); }
.stone-slot .stone { width: 100%; height: 100%; }

@media (max-width: 420px) {
  .book { font-size: 0.64rem; min-height: 78px; }
  .stone, .stone-slot { width: 64px; }
}

/* Pair the Animals */
.ark-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.card {
  aspect-ratio: 3 / 4;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(#5a4630, #3d4f32);
  color: #f7f1e1;
  font: inherit;
  box-shadow: var(--shadow);
  position: relative;
  padding: 6px;
}
.card-back, .card-front {
  position: absolute;
  inset: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  backface-visibility: hidden;
}
.card-back {
  background: repeating-linear-gradient(135deg, #4a3a28 0 8px, #3d4f32 8px 16px);
  color: var(--gold-soft);
  font-size: 1.4rem;
}
.card-front {
  background: #fffaf0;
  color: var(--ink);
  display: none;
}
.card.face .card-back { display: none; }
.card.face .card-front { display: flex; }
.card.matched {
  outline: 2px solid var(--gold);
  cursor: default;
}
.card-emoji { font-size: 1.6rem; line-height: 1; }
.card-name { font-size: 0.72rem; margin-top: 4px; text-align: center; }

/* Mustard Seed */
.garden {
  height: 200px;
  border-radius: var(--radius);
  background: linear-gradient(#b9d3e6 0%, #d7e8c8 55%, #8aa45a 56%, #6e8344 100%);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.soil {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 28px;
  background: #6b4a2e;
}
.plant {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 160px;
}
.plant-seed {
  color: #5a3a16;
  font-size: 0.9rem;
  z-index: 2;
}
.plant-stem {
  width: 6px;
  height: 0;
  background: #3f6b3a;
  border-radius: 3px;
  transition: height 0.45s ease;
}
.plant-canopy {
  width: 12px;
  height: 12px;
  background: #4f7a38;
  border-radius: 50%;
  opacity: 0;
  transition: all 0.45s ease;
}
.plant.stage-1 .plant-stem { height: 18px; }
.plant.stage-1 .plant-canopy { opacity: 1; width: 16px; height: 16px; }
.plant.stage-2 .plant-stem { height: 36px; }
.plant.stage-2 .plant-canopy { opacity: 1; width: 28px; height: 24px; }
.plant.stage-3 .plant-stem { height: 54px; }
.plant.stage-3 .plant-canopy { opacity: 1; width: 48px; height: 36px; border-radius: 40%; }
.plant.stage-4 .plant-stem { height: 72px; }
.plant.stage-4 .plant-canopy { opacity: 1; width: 78px; height: 52px; border-radius: 45%; }
.plant.stage-5 .plant-stem { height: 88px; }
.plant.stage-5 .plant-canopy { opacity: 1; width: 110px; height: 70px; border-radius: 48%; }
.plant.stage-6 .plant-stem { height: 100px; }
.plant.stage-6 .plant-canopy { opacity: 1; width: 140px; height: 88px; border-radius: 50%; }
.plant-birds {
  position: absolute;
  top: -8px;
  font-size: 1.1rem;
}
.plant.wilt .plant-canopy { background: #8a7a38; }
#mustardChoices { flex-direction: column; align-items: stretch; }
#mustardChoices button { width: 100%; }

/* Fishers */
.sea {
  position: relative;
  height: min(48vh, 340px);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.18), transparent 40%),
    linear-gradient(#4e8aa0, #2f5d6e);
  box-shadow: var(--shadow);
}
.boat {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  z-index: 2;
}
.fish {
  position: absolute;
  border: 0;
  background: rgba(247, 241, 225, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  animation: none;
  max-width: 28%;
}
.fish.keeper,
.fish.junk { background: #f7f1e1; color: var(--ink); }
.fish.caught { animation: none; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
@keyframes swim {
  from { transform: translateX(0); }
  to { transform: translateX(40px); }
}

.choice-row.col {
  flex-direction: column;
  align-items: stretch;
}
.choice-row.col button { width: 100%; }

.who-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}
.who-face {
  width: 88px;
  height: 110px;
  border-radius: 44px 44px 18px 18px;
  background: #2a2418;
  color: #f7f1e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  transition: background 0.4s ease, color 0.4s ease;
}
.who-face.clue-1 { background: #4a4032; }
.who-face.clue-2 { background: #6b5a3a; }
.who-face.clue-3 { background: #c4a35a; color: #2a2418; }
.who-clues {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.who-clues li { margin-bottom: 6px; }

.panel { margin-top: 12px; }

.story-map, .sea-map {
  position: relative;
  height: 220px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.story-map {
  background:
    linear-gradient(#d7e4ef 0 38%, #c5d5a0 38% 70%, #cbb98a 70% 100%);
}
.sea-map {
  background:
    radial-gradient(circle at 30% 40%, #7eb0b8 0 18%, transparent 19%),
    linear-gradient(#9ec4d0, #4e7d8a);
}
.map-node {
  position: absolute;
  border: 0;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}
.map-node:disabled {
  opacity: 0.45;
  cursor: default;
}
.map-node.done {
  background: var(--olive-deep);
  color: #f7f1e1;
  opacity: 1;
}
.map-node.open {
  outline: 2px solid var(--gold);
}
