:root {
  --bg: #eadfca;
  --paper: #f7f0de;
  --ink: #2f241c;
  --soft-ink: #675545;
  --accent: #8f3f2b;
  --gold: #c5a35a;
  --sky-night: #88a0b7;
  --sky-day: #f0d899;
  --grass: #7a8f61;
  --house: #d4bea0;
  --roof: #7c5138;
  --shadow: rgba(48, 36, 28, 0.14);
  --shadow-deep: rgba(48, 36, 28, 0.28);
  --redact: #2a241f;
  --good: #587245;
  --bad: #9f5a46;
  font-family: Georgia, "Times New Roman", serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.46), transparent 42%),
    linear-gradient(180deg, #d7ccb8 0%, var(--bg) 28%, #dccfb6 100%);
  color: var(--ink);
  touch-action: manipulation;
  user-select: none;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  width: min(1080px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: grid;
  gap: 14px;
  grid-template-rows: minmax(300px, 1.05fr) minmax(260px, 0.95fr);
}

.stage-shell,
.scroll {
  background: linear-gradient(180deg, rgba(255, 251, 243, 0.86), rgba(246, 236, 216, 0.95));
  border: 2px solid rgba(80, 53, 38, 0.28);
  box-shadow: 0 12px 28px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  border-radius: 24px;
}

.stage-shell {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.sky {
  position: absolute;
  inset: 0 0 42% 0;
  background: linear-gradient(180deg, var(--sky-night), #b1c0c7 62%, #d7d1bf 100%);
  transition: background 500ms ease;
}

.sun,
.moon {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  right: 12%;
  top: 14%;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.18);
  transition: transform 500ms ease, opacity 500ms ease, background 500ms ease;
}

.moon {
  background: #f3e8bd;
}

.sun {
  background: #f6d26a;
  opacity: 0;
  transform: translateY(22px) scale(0.86);
}

.cloud {
  position: absolute;
  background: rgba(255, 250, 244, 0.62);
  border-radius: 999px;
  filter: blur(0.5px);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: inherit;
}

.cloud-a {
  width: 84px;
  height: 26px;
  left: 18%;
  top: 22%;
}

.cloud-a::before {
  width: 34px;
  height: 34px;
  left: 14px;
  bottom: 10px;
}

.cloud-a::after {
  width: 42px;
  height: 42px;
  right: 12px;
  bottom: 6px;
}

.cloud-b {
  width: 74px;
  height: 24px;
  right: 24%;
  top: 28%;
}

.cloud-b::before {
  width: 32px;
  height: 32px;
  left: 9px;
  bottom: 8px;
}

.cloud-b::after {
  width: 38px;
  height: 38px;
  right: 6px;
  bottom: 5px;
}

.rain-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease;
}

.rain-layer::before {
  content: "";
  position: absolute;
  inset: 0 0 0 0;
  background-image:
    linear-gradient(transparent 0 36%, rgba(107, 133, 160, 0.85) 36% 52%, transparent 52% 100%);
  background-size: 16px 22px;
  animation: rain 650ms linear infinite;
  opacity: 0.75;
}

@keyframes rain {
  from { transform: translateY(-10px); }
  to { transform: translateY(16px); }
}

.stage {
  position: absolute;
  inset: 16px;
  border-radius: 22px;
  overflow: hidden;
}

.hill {
  position: absolute;
  inset: 48% -8% -10% -8%;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.16), transparent 22%),
    linear-gradient(180deg, #8ea16f 0%, var(--grass) 42%, #67794f 100%);
  border-radius: 50% 50% 0 0 / 18% 18% 0 0;
}

.house {
  position: absolute;
  width: min(38vw, 290px);
  max-width: 290px;
  aspect-ratio: 1.08 / 0.84;
  left: 14%;
  bottom: 13%;
  background: var(--house);
  border: 2px solid rgba(73, 49, 36, 0.28);
  border-top: 0;
  box-shadow: 0 10px 20px rgba(67, 47, 34, 0.16);
}

.roof {
  position: absolute;
  width: 112%;
  height: 42%;
  left: -6%;
  bottom: 100%;
  background: linear-gradient(180deg, #906449, var(--roof));
  clip-path: polygon(2% 100%, 50% 0, 98% 100%);
  filter: drop-shadow(0 6px 6px rgba(66, 45, 34, 0.2));
}

.window,
.door,
.lantern,
.barrel,
.well,
.sheet,
.bell,
.cat,
.bowl,
.awning,
.reflection,
.line,
.clothesline-post,
.moth {
  position: absolute;
}

.window {
  width: 18%;
  aspect-ratio: 0.9;
  top: 24%;
  background: #6b8192;
  border: 3px solid rgba(74, 51, 38, 0.35);
  overflow: hidden;
  transition: background 350ms ease, box-shadow 350ms ease;
}

.window-left { left: 18%; }
.window-right { right: 18%; }

.glow {
  position: absolute;
  inset: 14%;
  background: radial-gradient(circle, rgba(250, 221, 123, 0.95), rgba(250, 221, 123, 0.2) 72%, transparent 80%);
  opacity: 0;
  transition: opacity 300ms ease;
}

.door {
  width: 22%;
  height: 40%;
  left: 39%;
  bottom: 0;
  background: #8e6246;
  border: 3px solid rgba(74, 51, 38, 0.35);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
}

.curtain {
  width: 14%;
  height: 22%;
  right: 30%;
  top: 26%;
  background:
    linear-gradient(90deg, #8f3f2b 0 32%, #aa6753 32% 66%, #8f3f2b 66% 100%);
  border-radius: 0 0 8px 8px;
  transform-origin: top center;
  transition: transform 350ms ease, opacity 250ms ease;
  opacity: 0.92;
}

.lantern {
  width: 18px;
  height: 26px;
  left: 62%;
  top: 14%;
  border: 2px solid rgba(74, 51, 38, 0.6);
  border-bottom-width: 4px;
  border-radius: 4px 4px 6px 6px;
  background: #774f36;
}

.lantern::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 8px;
  border: 2px solid rgba(74, 51, 38, 0.5);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  left: 0;
  top: -10px;
}

.lantern-glow {
  position: absolute;
  width: 10px;
  height: 12px;
  left: 2px;
  top: 6px;
  background: #efc75d;
  border-radius: 50% 50% 40% 40%;
  opacity: 0.15;
  transition: opacity 300ms ease, transform 300ms ease;
}

.bell {
  width: 26px;
  height: 58px;
  right: -16px;
  top: -8px;
  transform-origin: top center;
  transition: transform 220ms ease;
}

.bell::before {
  content: "";
  position: absolute;
  width: 3px;
  height: 20px;
  left: 11px;
  top: 0;
  background: rgba(74, 51, 38, 0.75);
}

.bell-body {
  position: absolute;
  width: 22px;
  height: 22px;
  left: 1px;
  top: 17px;
  background: linear-gradient(180deg, #d7b56a, #a77f3f);
  border-radius: 50% 50% 46% 46%;
  clip-path: polygon(18% 0, 82% 0, 100% 78%, 0 78%);
}

.bell-body::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 8px;
  left: 8px;
  bottom: -2px;
  background: #845d28;
  border-radius: 50%;
}

.cat {
  width: 42px;
  height: 24px;
  left: 62%;
  bottom: 8%;
  background: #5b5246;
  border-radius: 16px 18px 12px 12px;
  transform-origin: center bottom;
  transition: transform 240ms ease, bottom 240ms ease;
}

.cat::before,
.cat::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 12px;
  top: -6px;
  background: #5b5246;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.cat::before { left: 6px; }
.cat::after { left: 18px; }

.cat-tail {
  position: absolute;
  width: 20px;
  height: 8px;
  right: -8px;
  bottom: 8px;
  border-radius: 999px;
  background: #5b5246;
  transform-origin: left center;
  transition: transform 240ms ease;
}

.bowl {
  width: 24px;
  height: 10px;
  left: 54%;
  bottom: 7%;
  border: 2px solid rgba(74, 51, 38, 0.48);
  border-top: 0;
  border-radius: 0 0 999px 999px;
  background: #99664c;
}

.bowl::after {
  content: "";
  position: absolute;
  inset: 1px 2px auto;
  height: 4px;
  border-radius: 999px;
  background: #e6d7b8;
  opacity: 0;
  transition: opacity 250ms ease;
}

.bowl.full::after {
  opacity: 1;
}

.clothesline-post {
  width: 8px;
  height: 116px;
  bottom: 18%;
  background: #77583f;
  border-radius: 6px 6px 0 0;
}

.post-left { left: 58%; }
.post-right { right: 11%; }

.line {
  left: calc(58% + 7px);
  right: calc(11% + 7px);
  bottom: calc(18% + 100px);
  height: 2px;
  background: rgba(76, 57, 44, 0.6);
  transform-origin: left center;
}

.sheet {
  width: 70px;
  height: 64px;
  left: 66%;
  bottom: calc(18% + 40px);
  background:
    linear-gradient(90deg, rgba(137, 97, 82, 0.12), rgba(255, 255, 255, 0) 28% 72%, rgba(137, 97, 82, 0.12)),
    #f2ede2;
  border: 2px solid rgba(104, 78, 63, 0.16);
  border-radius: 6px;
  box-shadow: 0 6px 10px rgba(57, 42, 34, 0.08);
  transform-origin: top center;
  transition: transform 300ms ease, filter 300ms ease, opacity 300ms ease;
}

.sheet::before,
.sheet::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  top: -5px;
  background: #c69460;
  border-radius: 50%;
}

.sheet::before { left: 12px; }
.sheet::after { right: 12px; }

.awning {
  width: 92px;
  height: 38px;
  left: 7%;
  bottom: 36%;
  background:
    repeating-linear-gradient(90deg, #c05038 0 14px, #f1dcb7 14px 28px);
  transform-origin: left top;
  clip-path: polygon(0 0, 100% 10%, 96% 100%, 6% 86%);
  filter: drop-shadow(0 5px 4px rgba(49, 36, 28, 0.12));
  transition: transform 350ms ease, opacity 350ms ease;
}

.barrel {
  width: 58px;
  height: 76px;
  right: 13%;
  bottom: 10%;
  border-radius: 10px 10px 14px 14px;
  background:
    linear-gradient(90deg, #83583f 0 16%, #a17354 16% 84%, #83583f 84% 100%);
  border: 3px solid rgba(78, 54, 40, 0.28);
  overflow: hidden;
}

.barrel::before,
.barrel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(66, 45, 34, 0.42);
}

.barrel::before { top: 18px; }
.barrel::after { top: 46px; }

.barrel-water {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 4px;
  height: 0;
  background: linear-gradient(180deg, #83a6b2, #4a7b8b);
  border-radius: 6px 6px 10px 10px;
  transition: height 320ms ease;
}

.barrel-lid {
  position: absolute;
  width: 100%;
  height: 8px;
  top: 0;
  left: 0;
  background: #6f4e39;
  transform-origin: right center;
  transition: transform 280ms ease;
}

.well {
  width: 78px;
  height: 46px;
  left: 7%;
  bottom: 10%;
  border-radius: 999px / 70%;
  background: #8f6c54;
  border: 3px solid rgba(78, 54, 40, 0.3);
  overflow: hidden;
  box-shadow: 0 8px 14px rgba(60, 44, 35, 0.12);
}

.well-water {
  position: absolute;
  inset: 10px 10px 8px;
  border-radius: 999px;
  background: #557f8d;
  box-shadow: inset 0 3px 5px rgba(255, 255, 255, 0.25);
}

.reflection {
  width: 20px;
  height: 20px;
  left: 15.5%;
  bottom: 17%;
  background: radial-gradient(circle, rgba(244, 233, 188, 0.92), rgba(244, 233, 188, 0) 72%);
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
}

.moth {
  width: 16px;
  height: 12px;
  left: 58%;
  top: 20%;
  opacity: 0;
  transition: opacity 280ms ease, transform 280ms ease;
}

.moth::before,
.moth::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 8px;
  top: 2px;
  background: rgba(243, 236, 216, 0.88);
  border-radius: 90% 30% 90% 30%;
  border: 1px solid rgba(90, 73, 57, 0.22);
}

.moth::before {
  left: 0;
  transform: rotate(-16deg);
}

.moth::after {
  right: 0;
  transform: scaleX(-1) rotate(-16deg);
}

.target-strip {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 3;
}

.sigil {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(247, 240, 222, 0.86);
  border: 1px solid rgba(74, 51, 38, 0.18);
  font-size: 0.9rem;
  color: var(--soft-ink);
}

.sigil-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
  transition: background 220ms ease;
}

.sigil.done .sigil-dot {
  background: var(--good);
}

.act-banner {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  text-align: center;
  font-style: italic;
  color: var(--soft-ink);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 260ms ease, transform 260ms ease;
  pointer-events: none;
}

.act-banner.show {
  opacity: 1;
  transform: translateY(0);
}

.replay-seal {
  position: absolute;
  right: 18px;
  bottom: 14px;
  border: 0;
  width: 110px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.24), transparent 22%),
    radial-gradient(circle, #a63f2e 0 58%, #7c251c 58% 100%);
  color: #f6eadc;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.1;
  padding: 12px;
  box-shadow: 0 10px 24px rgba(69, 28, 24, 0.28);
}

.replay-seal.hidden {
  display: none;
}

.scroll {
  padding: 18px 18px 20px;
  position: relative;
  overflow: hidden;
}

.scroll::before,
.scroll::after {
  content: "";
  position: absolute;
  width: 26px;
  top: 18px;
  bottom: 18px;
  background: linear-gradient(180deg, #d5ba8d, #b89461, #d5ba8d);
  border-radius: 999px;
  opacity: 0.42;
}

.scroll::before { left: -10px; }
.scroll::after { right: -10px; }

.scroll-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.73rem;
  color: var(--soft-ink);
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.05;
}

.hint,
.goal-text {
  margin: 0;
  color: var(--soft-ink);
}

.hint {
  max-width: 18ch;
  text-align: right;
  font-style: italic;
  transition: opacity 260ms ease;
}

.hint.gone {
  opacity: 0;
}

.goal-text {
  margin-top: 12px;
  font-size: 1rem;
}

.rows {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.row {
  background: rgba(255, 251, 243, 0.66);
  border: 1px solid rgba(70, 48, 35, 0.16);
  border-radius: 18px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.row-label {
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--soft-ink);
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option {
  position: relative;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  min-height: 44px;
  background: #f6edd8;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  box-shadow: inset 0 -2px 0 rgba(79, 53, 38, 0.08);
  transition: transform 120ms ease, background 220ms ease, color 220ms ease, box-shadow 220ms ease;
}

.option:active {
  transform: scale(0.98);
}

.option.selected {
  background: #f6edd8;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(143, 63, 43, 0.34), inset 0 -2px 0 rgba(79, 53, 38, 0.08);
}

.option.selected::before,
.option.selected::after {
  display: none;
}

.option:not(.selected) {
  background: var(--redact);
  color: #f3ebdc;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.option:not(.selected)::before,
.option:not(.selected)::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  background: rgba(245, 237, 221, 0.3);
}

.option:not(.selected)::before { top: 15px; }
.option:not(.selected)::after { bottom: 15px; }

.option:not(.selected) {
  opacity: 0.92;
}

.finale .sky {
  background: linear-gradient(180deg, #f3d58e, #f2c17d 58%, #e7c7a0 100%);
}

.finale .sun {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.finale .moon {
  opacity: 0;
  transform: translateY(-26px) scale(0.7);
}

.finale .cloud {
  opacity: 0.45;
}

.finale .hill {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 22%),
    linear-gradient(180deg, #9eaf6d 0%, #859655 42%, #6d7d44 100%);
}

@media (max-width: 760px) {
  .app {
    grid-template-rows: minmax(280px, 1fr) minmax(320px, auto);
  }

  .stage-shell,
  .scroll {
    border-radius: 20px;
  }

  .scroll-head {
    flex-direction: column;
  }

  .hint {
    text-align: left;
    max-width: none;
  }

  .house {
    width: min(52vw, 252px);
    left: 11%;
  }

  .sheet {
    left: 64%;
    width: 58px;
    height: 52px;
  }

  .clothesline-post {
    height: 100px;
  }

  .line {
    bottom: calc(18% + 88px);
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .app {
    grid-template-columns: 1.08fr 0.92fr;
    grid-template-rows: 1fr;
    align-items: stretch;
  }

  .scroll {
    overflow: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
