/* Picnic Weather Gamble: one painted scene with the weather pinned in its sky, a sign-plank
   caption, and under it the one choice that matters. Records sit quietly in a logbook footer. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  overflow: hidden;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  background-color: var(--ak-bg);
  background-image: var(
    --ak-backdrop-layer,
    linear-gradient(color-mix(in srgb, var(--ak-bg) 87%, transparent), color-mix(in srgb, var(--ak-bg) 87%, transparent)),
    url("./art/camp-clearing.jpg")
  );
  background-size: cover;
  background-position: center;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

[hidden] {
  display: none !important;
}

/* ---------- page frame ---------- */

.play {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top"
    "scene"
    "panel";
  gap: 8px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding:
    max(6px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  touch-action: manipulation;
}

.top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 60px;
}

.logo {
  display: block;
  width: auto;
  height: 48px;
  max-width: 100%;
  object-fit: contain;
}

.mute {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 20;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 3px solid var(--ak-ink);
  border-radius: 50% 50% 50% 12px;
  background: var(--ak-bg);
  cursor: pointer;
}

.mute svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mute .mute-horn {
  fill: var(--ak-accent);
}

.mute .mute-cross,
.mute.is-muted .mute-waves {
  display: none;
}

.mute.is-muted .mute-cross {
  display: inline;
}

/* ---------- the scene ---------- */

.scene-box {
  grid-area: scene;
  container-type: size;
  display: grid;
  place-items: center;
  min-height: 0;
}

.scene {
  --cap: clamp(56px, 13cqh, 76px);
  --sky: 30cqh;
  --bl: min(80cqw, calc((100cqh - var(--cap) - var(--sky) - 3cqh) * 1.02));
  --bl-h: calc(var(--bl) * 0.979);
  --bl-left: calc(50cqw - var(--bl) / 2);
  --bl-top: calc(100cqh - var(--cap) - var(--bl-h) - 2cqh);
  position: relative;
  container-type: size;
  width: 100cqw;
  height: min(100cqh, 160cqw);
  overflow: hidden;
  border: 3px solid var(--ak-ink);
  border-radius: 3px;
  background: var(--ak-bg) url("./art/camp-clearing.jpg") center top / cover no-repeat;
}

/* the explorer's map edge: a dotted trail line just inside the frame */
.scene::after {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 12;
  border: 3px dotted var(--ak-accent-2);
  border-radius: 2px;
  pointer-events: none;
}

/* the sky darkens as the clouds build */
.shade {
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: calc(var(--sky) + 12cqh);
  background: linear-gradient(color-mix(in srgb, var(--ak-ink) 55%, transparent), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 900ms ease;
}

.scene[data-level="1"] .shade { opacity: 0.28; }
.scene[data-level="2"] .shade { opacity: 0.6; }
.scene[data-ending="sun-held"] .shade { opacity: 0; }

.sky {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 56%;
  height: var(--sky);
}

/* the sun sits behind the clouds, so a building sky swallows it */
.sun {
  position: absolute;
  left: 22cqw;
  top: 2.5cqh;
  z-index: 2;
  width: calc(var(--sky) * 0.5);
  max-width: 30cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: url("./art/sun-and-rain.png") 22.9% 51.2% / 259.5% auto no-repeat;
  clip-path: circle(50%);
  transition: opacity 600ms ease, filter 600ms ease, left 1200ms ease, top 1200ms ease, width 1200ms ease;
}

.scene[data-level="2"]:not([data-ending="sun-held"]) .sun,
.scene[data-ending="soaked"] .sun,
.scene[data-ending="damp"] .sun {
  opacity: 0.5;
  filter: saturate(0.4);
}

.cloud {
  position: absolute;
  bottom: 8%;
  background-image: url("./art/cloud-set.png");
  background-repeat: no-repeat;
  transition: height 600ms ease, opacity 400ms ease, filter 400ms ease, transform 1400ms ease-in;
}

.cloud[data-kind="puffs"] {
  aspect-ratio: 167 / 147;
  background-size: 229.94% 218.37%;
  background-position: 11.98% 100%;
  clip-path: polygon(0% 48.3%, 2.4% 35.4%, 8.4% 25.9%, 15.6% 20.4%, 24% 17%, 31.1% 15%, 35.9% 8.2%, 40.7% 2%, 50.3% 0%, 59.9% 0.7%, 67.1% 5.4%, 71.9% 12.2%, 79% 16.3%, 87.4% 19.7%, 94.6% 24.5%, 100% 27.9%, 100% 44.9%, 97.6% 57.1%, 93.4% 66.7%, 89.8% 76.2%, 86.2% 85.7%, 83.8% 100%, 0% 100%);
}

.cloud[data-kind="towers"] {
  aspect-ratio: 218 / 238;
  background-size: 176.15% 134.87%;
  background-position: 100% 100%;
  clip-path: polygon(37.6% 7.1%, 42.2% 2.1%, 48.6% 0%, 56.9% 0.4%, 62.4% 2.9%, 67% 8.8%, 71.6% 12.2%, 100% 12.2%, 100% 100%, 0% 100%, 1.8% 91.2%, 4.6% 85.3%, 7.3% 79.4%, 10.6% 73.5%, 12.4% 66%, 12.4% 55.5%, 14.7% 54.2%, 17.9% 50.4%, 17.9% 41.6%, 20.6% 31.5%, 24.3% 23.9%, 28.9% 17.2%, 33.9% 13%);
}

.cloud[data-kind="giant"] {
  aspect-ratio: 384 / 321;
  background-size: 100% 100%;
  background-position: 0 0;
}

.cloud-main {
  left: 5%;
}

.cloud-main[data-kind="puffs"] { height: 46%; bottom: 30%; }
.cloud-main[data-kind="towers"] { height: 80%; }
.cloud-main[data-kind="giant"] { height: 92%; bottom: 4%; }

.cloud-side {
  left: 48%;
  bottom: 40%;
}

.cloud-side[data-kind="puffs"] { height: 34%; }
.cloud-side[data-kind="towers"] { height: 56%; bottom: 14%; }

.cloud.is-ghost {
  opacity: 0.6;
  filter: grayscale(0.5);
}

.scene[data-ending="sun-held"] .cloud {
  transform: translateX(-160%);
  opacity: 0;
}

/* the weather tag: a map label hung into the sky on a cord */
.weather {
  position: absolute;
  right: 4cqw;
  top: 3cqh;
  z-index: 8;
  width: min(48cqw, 240px);
  max-height: calc(var(--sky) + 6cqh);
  padding: 7px 11px 8px;
  border: 3px solid var(--ak-ink);
  border-radius: 3px 3px 14px 3px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  transition: opacity 500ms ease;
}

.weather::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -3cqh;
  width: 3px;
  height: 3cqh;
  background: var(--ak-ink);
}

.weather p {
  margin: 0;
}

.weather-hour {
  font-family: var(--ak-font-display);
  font-size: clamp(20px, 6cqw, 28px);
  line-height: 1;
}

.weather-chance {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 5px;
  margin-top: 4px !important;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
}

.weather-chance strong {
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: clamp(20px, 6cqw, 26px);
}

.weather-drop {
  flex: none;
  width: 20px;
  height: 20px;
  fill: var(--ak-accent);
  stroke: var(--ak-ink);
  stroke-width: 2.5;
}

.weather-read {
  margin-top: 5px !important;
  padding-top: 5px;
  border-top: 2px dotted var(--ak-ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.weather-rumble {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px !important;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--ak-accent-2);
  color: var(--ak-ink);
  font-size: 14px;
  font-weight: 800;
}

.weather-rumble svg {
  flex: none;
  width: 26px;
  height: 18px;
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scene[data-ending] .weather {
  opacity: 0;
  pointer-events: none;
}

.ghost-tag {
  position: absolute;
  left: 4cqw;
  top: calc(var(--sky) + 1cqh);
  z-index: 9;
  margin: 0;
  padding: 4px 12px;
  border: 2px dashed var(--ak-ink);
  border-radius: 3px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
  white-space: nowrap;
}

/* the blanket and its five plates */

.blanket {
  position: absolute;
  left: var(--bl-left);
  top: var(--bl-top);
  z-index: 4;
  width: var(--bl);
  aspect-ratio: 384 / 376;
  background: url("./art/picnic-blanket.png") center / 100% 100% no-repeat;
  transform-origin: 50% 0;
  transition: transform 700ms ease, opacity 700ms ease;
}

.plates {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plate {
  position: absolute;
  top: 41.76%;
  width: 18.75%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.plate:nth-child(1) { left: 4.69%; --px: 5.77%; }
.plate:nth-child(2) { left: 22.4%; --px: 27.56%; }
.plate:nth-child(3) { left: 40.36%; --px: 49.68%; }
.plate:nth-child(4) { left: 58.33%; --px: 71.79%; }
.plate:nth-child(5) { left: 76.56%; --px: 94.23%; }

.plate-food {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: url("./art/picnic-blanket.png") var(--px) 51.64% / 533.33% 522.22% no-repeat;
  clip-path: circle(50%);
  transform-origin: 50% 80%;
  transition: transform 500ms ease, filter 500ms ease;
}

/* an eaten plate is drawn plain: the empty plate with a few crumbs */
.plate-crumbs {
  position: absolute;
  inset: 4%;
  border: 3px solid var(--ak-ink);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 42%, var(--ak-accent-2) 0 5%, transparent 6%),
    radial-gradient(circle at 60% 58%, var(--ak-accent-2) 0 4%, transparent 5%),
    radial-gradient(circle at 55% 34%, var(--ak-accent-2) 0 3%, transparent 4%),
    radial-gradient(circle, var(--ak-bg) 0 58%, var(--ak-ink) 59% 62%, var(--ak-bg) 63%);
  opacity: 0;
  transform: scale(0.6);
}

.plate[data-state="eaten"] .plate-food {
  transform: scale(0);
}

.plate[data-state="eaten"] .plate-crumbs {
  opacity: 1;
  transform: scale(1);
}

.scene[data-ending="soaked"] .plate[data-state="full"] .plate-food {
  transform: translateY(10%) scaleY(0.72) skewX(-8deg);
  filter: saturate(0.5) brightness(0.8);
}

/* the crew */

.crew {
  position: absolute;
  left: calc(var(--bl-left) + var(--bl) * 0.07);
  top: calc(var(--bl-top) + var(--bl-h) * 0.62);
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: calc(var(--bl) * 0.86);
  transition: left 900ms ease, top 900ms ease, width 900ms ease;
}

.critter {
  width: 31%;
  aspect-ratio: 122 / 99;
}

.critter svg {
  display: block;
  width: 100%;
  height: 100%;
}

.scene.is-packed .crew {
  left: 3cqw;
  top: calc(var(--bl-top) + var(--bl-h) * 0.42);
  width: calc(var(--bl) * 0.7);
}

.scene.is-packed .blanket {
  transform: scaleY(0.12);
  opacity: 0;
}

.treat-pop {
  position: absolute;
  left: calc(var(--bl-left) + var(--bl) / 2);
  top: calc(var(--bl-top) + var(--bl-h) * 0.66);
  z-index: 7;
  width: calc(var(--bl) * 0.2);
  aspect-ratio: 1;
  transform: translate(-50%, -100%);
  opacity: 0;
  pointer-events: none;
}

.treat-pop svg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--ak-bg);
  outline: 3px solid var(--ak-ink);
  padding: 12%;
}

/* rain sweeps across in slanted streaks */

.rain {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  background-image:
    repeating-linear-gradient(105deg, transparent 0 16px, color-mix(in srgb, var(--ak-bg) 85%, transparent) 16px 19px, transparent 19px 34px),
    linear-gradient(color-mix(in srgb, var(--ak-ink) 34%, transparent), color-mix(in srgb, var(--ak-ink) 20%, transparent));
  background-size: 120px 120px, 100% 100%;
  transition: opacity 500ms ease;
}

.rain[data-mode="on"] { opacity: 1; }
.rain[data-mode="ghost"] { opacity: 0.5; }

/* ---------- the ending moment: each story lands its own way ---------- */

.finale {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.finale > * {
  position: absolute;
  opacity: 0;
  transition: opacity 600ms ease, transform 900ms cubic-bezier(0.34, 1.56, 0.64, 1), clip-path 1400ms ease;
}

/* sun held: party bunting drops across the sky */
.bunting {
  left: 0;
  top: 0;
  width: 100%;
  height: 13cqh;
  transform: translateY(-100%);
}

.bunting-line {
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 3;
}

.flag-a,
.flag-b {
  stroke: var(--ak-ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.flag-a { fill: var(--ak-accent-2); }
.flag-b { fill: var(--ak-accent); }

.scene[data-ending="sun-held"] .bunting {
  opacity: 1;
  transform: none;
}

.scene[data-ending="sun-held"] .sun {
  left: auto;
  right: 6cqw;
  top: 12cqh;
  width: min(26cqw, 120px);
  max-width: none;
  opacity: 1;
  filter: none;
}

/* packed endings: a trail of footprints from the empty spot back to the tent */
.footprints {
  left: calc(var(--bl-left) + var(--bl) * 0.28);
  top: calc(var(--bl-top) + var(--bl-h) * 0.5);
  width: calc(var(--bl) * 0.62);
  height: calc(var(--bl-h) * 0.32);
  overflow: visible;
  clip-path: inset(0 0 0 100%);
}

.footprints path {
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 2 16;
  vector-effect: non-scaling-stroke;
}

.footprints .footprints-halo {
  stroke: var(--ak-bg);
  stroke-width: 12;
}

.scene[data-ending="just-in-time"] .footprints,
.scene[data-ending="too-early"] .footprints,
.scene[data-ending="damp"] .footprints {
  opacity: 1;
  clip-path: inset(0 0 0 0);
}

/* wet endings: puddles spread around the blanket */
.puddles {
  left: 6cqw;
  bottom: calc(var(--cap) + 1cqh);
  width: 88cqw;
  height: 8cqh;
  transform: scaleX(0.3);
}

.puddles ellipse {
  fill: color-mix(in srgb, var(--ak-ink) 30%, transparent);
  stroke: var(--ak-bg);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.scene[data-ending="soaked"] .puddles,
.scene[data-ending="damp"] .puddles {
  opacity: 1;
  transform: none;
}

.scene[data-ending="damp"] .puddles {
  transform: scale(0.6);
  transform-origin: 70% 50%;
}

/* the story's seal: stamped where the weather tag hung */
.seal {
  left: 4cqw;
  top: 2cqh;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: min(27cqw, 116px);
  aspect-ratio: 1;
  padding: 8px;
  border: 4px solid var(--ak-ink);
  border-radius: 50%;
  outline: 3px dashed var(--ak-accent-2);
  outline-offset: -11px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  text-align: center;
  transform: scale(1.8);
}

.seal-icon {
  width: 42%;
  height: auto;
}

.seal strong {
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: clamp(13px, 3.8cqw, 18px);
  line-height: 1.05;
}

.scene.is-story .seal {
  opacity: 1;
  transform: none;
}

/* ---------- the sign-plank caption ---------- */

.plank {
  position: absolute;
  left: 2.5cqw;
  right: 2.5cqw;
  bottom: 1.5cqh;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: var(--cap);
  padding: 6px 26px;
  border: 3px solid var(--ak-ink);
  border-radius: 4px 10px 4px 10px;
  background: var(--ak-bg);
}

/* rope lashings at each end of the plank */
.plank::before,
.plank::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  width: 10px;
  border: 2px solid var(--ak-ink);
  border-radius: 3px;
  background: repeating-linear-gradient(160deg, var(--ak-accent-2) 0 4px, var(--ak-bg) 4px 6px);
}

.plank::before { left: 7px; }
.plank::after { right: 7px; }

.caption {
  width: 100%;
  margin: 0;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(16px, 4.6cqw, 21px);
  line-height: 1.22;
  text-align: center;
}

.caption[data-tone="story"] {
  font-family: var(--ak-font-body);
  font-weight: 800;
  font-size: clamp(15px, 4.2cqw, 20px);
  line-height: 1.28;
}

.scene.is-story {
  --cap: clamp(92px, 24cqh, 132px);
  --sky: 16cqh;
}

.scene.is-story .ghost-tag {
  left: auto;
  right: 4cqw;
  top: 3cqh;
}

.scene.is-story .plank {
  border-width: 4px;
  border-color: var(--ak-accent-2);
  outline: 3px solid var(--ak-ink);
}

/* while teaching, the plank holds the guide line and points toward the choice */
.plank-arrow {
  display: none;
  flex: none;
  width: 38px;
  height: 38px;
  margin-left: 8px;
}

.plank-arrow circle {
  fill: var(--ak-accent-2);
  stroke: var(--ak-ink);
  stroke-width: 3;
}

.plank-arrow path {
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plank.is-guide {
  padding-right: 8px;
  border-color: var(--ak-accent-2);
  outline: 3px solid var(--ak-ink);
}

.plank.is-guide::after {
  display: none;
}

.plank.is-guide .plank-arrow {
  display: block;
}

.plank.is-guide .caption {
  font-family: var(--ak-font-body);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
}

/* the hint card sits over the meadow, never over the sky it talks about */
.hint {
  position: absolute;
  left: 4cqw;
  right: 4cqw;
  top: 3cqh;
  bottom: calc(var(--cap) + 3cqh);
  z-index: 13;
  overflow: auto;
  padding: 12px 14px;
  border: 3px solid var(--ak-ink);
  border-radius: 4px 14px 4px 14px;
  background: var(--ak-surface);
}

.hint p {
  margin: 0 0 10px;
  color: var(--ak-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.hint-close {
  min-width: 96px;
  min-height: 48px;
  padding: 0 18px;
  border: 3px solid var(--ak-ink);
  border-radius: 4px 14px 4px 14px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 18px;
  cursor: pointer;
}

/* ---------- the decision ---------- */

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.decide {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* the goal: one plain sentence on a notebook strip, flagged like a trail marker */
.goal-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px 6px 4px 10px;
  border-left: 6px solid var(--ak-accent-2);
  background: var(--ak-bg);
  color: var(--ak-ink);
}

.goal-line p {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.goal-line strong {
  font-family: var(--ak-font-display);
  font-weight: 400;
}

.goal-flag {
  flex: none;
  width: 22px;
  height: 26px;
}

.goal-pole {
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.goal-pennant {
  fill: var(--ak-accent-2);
  stroke: var(--ak-ink);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.goal-line.is-reached {
  border-left-color: var(--ak-accent);
}

.goal-line.is-reached .goal-pennant {
  fill: var(--ak-accent);
}

.hint-btn {
  flex: none;
  min-width: 60px;
  min-height: 48px;
  padding: 0 10px;
  border: 3px solid var(--ak-ink);
  border-radius: 50% 50% 12px 50%;
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
  cursor: pointer;
}

.hint-btn[aria-expanded="true"] {
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
}

.choices {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choices.is-guided::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 4px solid var(--ak-accent-2);
  border-radius: 10px 24px 10px 24px;
  pointer-events: none;
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 76px;
  padding: 6px 6px 8px;
  border: 3px solid var(--ak-ink);
  border-radius: 6px 22px 6px 22px;
  box-shadow: 0 4px 0 var(--ak-ink);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.choice:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ak-ink);
}

.choice:disabled {
  cursor: default;
  opacity: 0.6;
}

.choice-stay {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.choice-pack {
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  border-radius: 22px 6px 22px 6px;
}

.choice-word {
  font-family: var(--ak-font-display);
  font-size: 25px;
  line-height: 1.05;
}

.choice-cost {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

/* what rain this very hour would cost on each path */
.choice-risk {
  margin-top: 2px;
  padding-top: 3px;
  border-top: 2px dotted currentColor;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

@media (hover: hover) {
  .choice-stay:hover:not(:disabled) { background: var(--ak-btn-hover); }
  .choice-pack:hover:not(:disabled) { border-color: var(--ak-btn-active); }
}

/* the moment a choice lands: the buttons step aside for a plain "you chose" card */
.moment {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border: 3px solid var(--ak-ink);
  border-radius: 6px 22px 6px 22px;
  background: var(--ak-surface);
  color: var(--ak-ink);
}

.moment-mark {
  flex: none;
  width: 40px;
  height: 40px;
}

.moment-mark circle {
  fill: var(--ak-accent);
  stroke: var(--ak-ink);
  stroke-width: 2.5;
}

.moment-mark path {
  fill: none;
  stroke: var(--ak-btn-ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.moment p {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}

.moment strong {
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.1;
}

.moment span {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.choices.is-moment .choice {
  visibility: hidden;
}

/* ---------- the logbook footer: the day's trail and the records ---------- */

.logbook {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  border-top: 3px dotted var(--ak-accent-2);
}

.trail {
  position: relative;
  display: grid;
  flex: 1;
  grid-template-columns: repeat(5, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}

.trail::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 17px;
  border-top: 3px dotted var(--ak-ink-muted);
}

.stop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.stop-dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px dashed var(--ak-ink-muted);
  border-radius: 50%;
  background: var(--ak-bg);
}

.stop-icon {
  width: 22px;
  height: 22px;
}

.stop-mark {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 18px;
  height: 18px;
}

.stop-mark:empty {
  display: none;
}

.stop-mark svg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--ak-ink);
}

/* a pennant on the stop your best dry day reached */
.stop-flag {
  position: absolute;
  left: -7px;
  top: -10px;
  width: 16px;
  height: 20px;
  overflow: visible;
}

.stop-flag path:first-child {
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.stop-flag path:last-child {
  fill: var(--ak-accent-2);
  stroke: var(--ak-ink);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.stop-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ak-ink);
}

.stop[data-state="now"] .stop-dot {
  border: 3px solid var(--ak-accent);
  background: var(--ak-surface);
}

.stop[data-state="enjoyed"] .stop-dot,
.stop[data-state="packed"] .stop-dot {
  border: 2px solid var(--ak-ink);
  background: var(--ak-choice-bg);
}

.stop[data-state="missed"] .stop-dot,
.stop[data-state="rain"] .stop-dot {
  border: 2px dashed var(--ak-ink);
  background: transparent;
}

.stop[data-state="missed"] .stop-icon,
.stop[data-state="rain"] .stop-icon {
  opacity: 0.55;
}

.stop[data-state="rain"] .stop-dot {
  background: color-mix(in srgb, var(--ak-ink) 14%, transparent);
}

.record {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  color: var(--ak-ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
  text-align: right;
}

.record.is-new #record-best,
.record.is-lost #record-streak {
  padding: 0 5px;
  border-radius: 3px;
  background: var(--ak-accent-2);
}

/* icon parts */
.i-fill-0 { fill: var(--ak-bg); stroke: var(--ak-ink); stroke-width: 2.2; stroke-linejoin: round; }
.i-fill-1 { fill: var(--ak-accent); stroke: var(--ak-ink); stroke-width: 2.2; stroke-linejoin: round; }
.i-fill-2 { fill: var(--ak-accent-2); stroke: var(--ak-ink); stroke-width: 2.2; stroke-linejoin: round; }
.i-line { fill: none; stroke: var(--ak-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.i-mark { fill: none; stroke: var(--ak-bg); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.i-drop { fill: var(--ak-bg); stroke: var(--ak-bg); stroke-width: 1; transform: scale(0.72); transform-origin: 50% 55%; }
.stop-mark .i-fill-0 { fill: var(--ak-bg); stroke: var(--ak-bg); transform: scale(0.7); transform-origin: 50% 50%; }
.stop-mark .i-line { stroke: var(--ak-ink); transform: scale(0.7); transform-origin: 50% 50%; }

/* ---------- the ending notes ---------- */

.result {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.why {
  margin: 0;
  padding-left: 10px;
  border-left: 4px solid var(--ak-accent-2);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.tally {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.tally-side {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
}

.tally-side + .tally-side {
  border-left: 3px dotted var(--ak-accent-2);
}

.tally h2 {
  max-width: 5.5em;
  margin: 0;
  color: var(--ak-ink-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-transform: uppercase;
}

.tally-big {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: 24px;
  line-height: 1.1;
  white-space: nowrap;
}

.tally-big strong {
  font-weight: 400;
}

.dry-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ak-ink);
}

.dry-icon .i-fill-0 { fill: var(--ak-bg); stroke: var(--ak-bg); transform: scale(0.7); transform-origin: 50% 50%; }
.dry-icon .i-line { stroke: var(--ak-ink); transform: scale(0.7); transform-origin: 50% 50%; }
.dry-icon .i-drop { transform: scale(0.72); }

.tradeoffs {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.tradeoffs li {
  position: relative;
  padding-left: 18px;
}

.tradeoffs li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.35em;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--ak-ink);
  border-radius: 0 60% 0 60%;
  background: var(--ak-accent);
}

.tradeoffs li.is-goal {
  font-weight: 800;
}

.tradeoffs li.is-goal::before {
  width: 0;
  height: 0;
  border: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid var(--ak-ink);
  border-radius: 0;
  background: none;
}

.tradeoffs li.is-goal.is-met::before {
  border-left-color: var(--ak-accent);
}

/* the story collection: five endings to find */
.stories {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stories-label {
  flex: 1;
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.stamps {
  display: flex;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stamp {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px dashed var(--ak-ink-muted);
  border-radius: 50%;
  color: var(--ak-ink-muted);
  font-family: var(--ak-font-display);
  font-size: 16px;
}

.stamp svg {
  width: 22px;
  height: 22px;
}

.stamp[data-state="found"] {
  border: 2px solid var(--ak-ink);
  background: var(--ak-bg);
}

.stamp.is-today {
  outline: 3px solid var(--ak-accent-2);
  outline-offset: 1px;
}

.end-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.end-btn {
  min-height: 52px;
  padding: 0 12px;
  border: 3px solid var(--ak-ink);
  border-radius: 6px 22px 6px 22px;
  box-shadow: 0 4px 0 var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 19px;
  cursor: pointer;
}

.end-again {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.end-settings {
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  border-radius: 22px 6px 22px 6px;
}

.end-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ak-ink);
}

/* Phones: once the day is over, the scene keeps the room. The skipped hours replay in the sky
   and the notes name them, so the trail steps aside; the records stay. */
@media (max-height: 900px) {
  .panel.is-ended .trail {
    display: none;
  }

  .panel.is-ended .logbook {
    justify-content: flex-end;
  }

  .panel.is-ended .record {
    flex-direction: row;
    gap: 14px;
  }
}

/* ---------- narrow upright phones ---------- */

@media (max-width: 380px) {
  .goal-line p {
    font-size: 15px;
  }

  .choice {
    min-height: 70px;
    padding: 5px 4px 6px;
  }

  .choice-word {
    font-size: 22px;
  }

  .choice-cost {
    font-size: 14px;
  }

  .choice-risk {
    font-size: 13px;
  }

  .stop-dot {
    width: 34px;
    height: 34px;
  }

  .trail::before {
    top: 16px;
  }

  .why,
  .tradeoffs {
    font-size: 14px;
  }

  .tally-big {
    font-size: 21px;
  }

  .stories-label {
    font-size: 13px;
  }

  .end-btn {
    font-size: 17px;
  }
}

/* ---------- sideways: scene on the left, notebook on the right ---------- */

@media (orientation: landscape) {
  .play {
    grid-template-columns: minmax(0, 1fr) clamp(300px, 42%, 460px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "scene top"
      "scene panel";
    column-gap: 14px;
    row-gap: 6px;
    max-width: 1180px;
  }

  /* the day is over: scene and story notes share the width evenly */
  .play.is-ended {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }

  .top {
    min-height: 48px;
    padding: 0 56px 0 0;
    justify-content: flex-start;
  }

  .logo {
    height: 44px;
  }

  .scene-box {
    place-items: center end;
  }

  .scene {
    --cap: clamp(52px, 15cqh, 74px);
    --sky: 42cqh;
    --bl: min(58cqw, calc((100cqh - var(--cap) - 8cqh) * 1.02));
    --bl-left: calc(97cqw - var(--bl));
    height: 100cqh;
    width: min(calc(100cqw - 60px), 130cqh);
  }

  .scene.is-story {
    --cap: clamp(84px, 26cqh, 118px);
    --sky: 40cqh;
    --bl: min(66cqw, calc((100cqh - var(--cap) - 8cqh) * 1.02));
  }

  .scene.is-story .ghost-tag {
    left: 3cqw;
    right: auto;
    top: auto;
    bottom: calc(var(--cap) + 3cqh);
  }

  .sky {
    width: calc(100cqw - var(--bl) - 4cqw);
  }

  .shade {
    height: 100cqh;
    width: calc(100cqw - var(--bl));
    background: linear-gradient(color-mix(in srgb, var(--ak-ink) 55%, transparent), transparent 70%);
  }

  .sun {
    left: 22cqw;
    width: calc(var(--sky) * 0.38);
  }

  .cloud-main { left: 3%; }
  .cloud-main[data-kind="puffs"] { height: 44%; bottom: 30%; }
  .cloud-main[data-kind="towers"] { height: 78%; }
  .cloud-main[data-kind="giant"] { height: 70%; bottom: 14%; }

  .cloud-side {
    display: none;
  }

  /* the weather tag hangs over the tent, below the clouds it describes */
  .weather {
    left: 3cqw;
    right: auto;
    top: auto;
    bottom: calc(var(--cap) + 3cqh);
    width: calc(100cqw - var(--bl) - 9cqw);
    max-height: none;
    padding: 6px 9px 7px;
  }

  .weather::before {
    display: none;
  }

  .weather-hour {
    font-size: clamp(18px, 5cqw, 24px);
  }

  .weather-chance strong {
    font-size: clamp(18px, 5cqw, 24px);
  }

  .weather-chance,
  .weather-read,
  .weather-rumble {
    font-size: 13px;
  }

  .ghost-tag {
    left: auto;
    right: 4cqw;
    top: 3cqh;
  }

  .seal {
    left: 3cqw;
    top: 3cqh;
    width: min(28cqw, 112px);
  }

  .scene[data-ending="sun-held"] .sun {
    left: 4cqw;
    right: auto;
    top: auto;
    bottom: calc(var(--cap) + 4cqh);
    width: min(26cqw, 100px);
  }

  .bunting {
    height: 14cqh;
  }

  .caption {
    font-size: clamp(15px, 3.9cqw, 20px);
  }

  .plank-arrow {
    transform: rotate(-90deg);
  }

  .hint {
    left: 3cqw;
    right: 3cqw;
  }

  .panel {
    overflow-y: auto;
  }

  .goal-line p {
    font-size: 15px;
  }

  .choice {
    min-height: 96px;
  }

  .choice-word {
    font-size: 27px;
  }

  /* the wider ending reads bigger */
  .panel.is-ended .why {
    font-size: 18px;
  }

  .panel.is-ended .tally-big {
    font-size: 28px;
  }

  .panel.is-ended .tradeoffs {
    font-size: 16px;
  }

  .panel.is-ended .stories-label {
    font-size: 15px;
  }

  .panel.is-ended .end-btn {
    min-height: 56px;
    font-size: 20px;
  }
}

/* short sideways phones keep the notebook tight */
@media (orientation: landscape) and (max-height: 430px) {
  .panel,
  .decide,
  .result {
    gap: 6px;
  }

  .top {
    min-height: 44px;
  }

  .choice {
    min-height: 88px;
    padding: 4px 4px 6px;
  }

  .choice-word {
    font-size: 24px;
  }

  .choice-cost {
    font-size: 13.5px;
  }

  .choice-risk {
    font-size: 13px;
  }

  .stories-more {
    display: none;
  }

  .panel.is-ended .tradeoffs {
    font-size: 15px;
    line-height: 1.25;
  }

  .panel.is-ended .why {
    font-size: 16.5px;
  }

  .panel.is-ended .end-btn {
    min-height: 50px;
  }

  .panel.is-ended .logbook {
    padding-top: 3px;
  }
}

@media (orientation: landscape) and (max-height: 375px) {
  .stop-label {
    display: none;
  }

  .logo {
    height: 38px;
  }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .cloud.is-arriving {
    animation: drift-in 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .scene.has-rumble .weather-rumble svg {
    animation: rumble 700ms ease-in-out infinite alternate;
  }

  .critter {
    animation: bob 2.4s ease-in-out infinite;
    animation-delay: calc(var(--n) * -0.8s);
  }

  .crew[data-face="glance"] .critter {
    animation: jitter 1.1s ease-in-out infinite;
    animation-delay: calc(var(--n) * -0.3s);
  }

  .crew[data-face="cheer"] .critter {
    animation: hop 520ms ease-out 2;
    animation-delay: calc(var(--n) * 90ms);
  }

  .scene.is-packed .critter {
    animation: march 360ms ease-in-out 3;
    animation-delay: calc(var(--n) * 60ms);
  }

  .scene.is-story[data-ending="sun-held"] .critter {
    animation: hop 620ms ease-out infinite;
    animation-delay: calc(var(--n) * 140ms);
  }

  .plate.is-bitten .plate-food {
    animation: bite 420ms ease-in both;
  }

  .treat-pop.is-up {
    animation: treat-up 1300ms ease-out both;
  }

  .rain[data-mode="on"] {
    animation: sweep 900ms ease-out both, pour 500ms linear infinite;
  }

  .rain[data-mode="ghost"] {
    animation: sweep 700ms ease-out both, pour 700ms linear infinite;
  }

  .caption.is-new {
    animation: settle 420ms ease-out both;
  }

  .weather-hour.is-new {
    animation: hour-in 520ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .choices.is-guided::after,
  .stop[data-state="now"] .stop-dot {
    animation: ring 1.3s ease-in-out infinite;
  }

  .plank.is-guide .plank-arrow {
    animation: point 1.1s ease-in-out infinite;
  }

  .moment {
    animation: moment-in 260ms ease-out both;
  }

  .stamp.is-new,
  .record.is-new #record-best {
    animation: stamp-in 700ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .bunting .flag-a,
  .bunting .flag-b {
    transform-box: fill-box;
    transform-origin: 50% 0;
    animation: flutter 1.6s ease-in-out infinite alternate;
  }

  .bunting .flag-b {
    animation-delay: -0.8s;
  }

  body.is-paused * {
    animation-play-state: paused !important;
  }
}

@media (prefers-reduced-motion: no-preference) and (orientation: landscape) {
  .plank.is-guide .plank-arrow {
    animation-name: point-side;
  }
}

@keyframes drift-in {
  from { transform: translateX(-70%) scale(0.75); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes rumble {
  from { transform: translateX(-2px) rotate(-6deg); }
  to { transform: translateX(2px) rotate(6deg); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4%); }
}

@keyframes jitter {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-3%) rotate(-2deg); }
  60% { transform: translateY(0) rotate(2deg); }
}

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-22%); }
}

@keyframes march {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-10%) rotate(-5deg); }
  75% { transform: translateY(-10%) rotate(5deg); }
}

@keyframes bite {
  0% { transform: scale(1); }
  40% { transform: scale(1.12) rotate(-8deg); }
  100% { transform: scale(0); }
}

@keyframes treat-up {
  0% { opacity: 0; transform: translate(-50%, -60%) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -120%) scale(1.05); }
  75% { opacity: 1; transform: translate(-50%, -130%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.9); }
}

@keyframes sweep {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes pour {
  from { background-position: 0 0, 0 0; }
  to { background-position: -32px 120px, 0 0; }
}

@keyframes settle {
  from { opacity: 0.2; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes hour-in {
  from { transform: translateY(8px) scale(0.8); opacity: 0.3; }
  to { transform: none; opacity: 1; }
}

@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ak-accent-2) 70%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ak-accent-2) 0%, transparent); }
}

@keyframes point {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 4px; }
}

@keyframes point-side {
  0%, 100% { translate: 0 0; }
  50% { translate: 4px 0; }
}

@keyframes moment-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}

@keyframes stamp-in {
  from { transform: scale(1.8) rotate(-20deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes flutter {
  from { transform: rotate(-6deg); }
  to { transform: rotate(6deg); }
}

/* Short upright phones: at the end, the goal line already says what happened to the streak, so
   the logbook steps aside and the scene keeps the room. */
@media (orientation: portrait) and (max-height: 800px) {
  .panel.is-ended .logbook,
  .stories-more {
    display: none;
  }

  .scene.is-story {
    --cap: clamp(88px, 23cqh, 120px);
  }
}
