.story-mode > :is(.top, .side, .stripwrap),
.story-mode .stagearea > .nav,
.story-mode .hint { display: none; }

body:has(.story-mode:not(.sample-story)) { overflow: hidden; }
body:has(.story-mode:not(.sample-story)) > .site-header { display: none; }
.app.story-mode:not(.sample-story) {
  display: block;
  width: 100%;
  height: 100dvh;
  padding: 0;
  overflow: hidden;
}
.story-mode:not(.sample-story) :is(.stagearea, .fit) {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.story-mode:not(.sample-story) .card {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  container-type: size;
  isolation: isolate;
}
.story-mode:not(.sample-story) .card > :is(#scratch, #line, #paint, #peek) {
  /* Keep the four artwork layers and the pointer area in the same crop. */
  --art-width: max(100cqw, calc(100cqh * var(--ar)));
  --art-height: calc(var(--art-width) / var(--ar));
  inset: auto;
  width: var(--art-width);
  height: var(--art-height);
  left: clamp(calc(100cqw - var(--art-width)), calc(50cqw - var(--art-width) * var(--face-x, .5)), 0px);
  top: clamp(calc(100cqh - var(--art-height)), calc(46cqh - var(--art-height) * var(--face-y, .42)), 0px);
}
.story-mode .card #paint { pointer-events: none; }
.story-mode:not(.sample-story) .animal-introduction { top: calc(var(--top) + 65px); left: calc(env(safe-area-inset-left, 0px) + 14px); }

#storyOverlay { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.story-header {
  position: absolute;
  top: calc(var(--top) + 12px);
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.story-header a, .story-header button, .story-footer button {
  pointer-events: auto;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid var(--plum);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font-weight: 950;
  text-decoration: none;
}
.story-header a { background: var(--blush); border-color: var(--blush); }
.story-footer {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bottom) + 12px);
  transform: translateX(-50%);
  width: min(440px, calc(100% - 24px));
  padding: 12px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
}
#storyCaption .story-step { text-align: left; margin: 0 0 8px; }
#storyHint { margin: 5px 0 10px; font-weight: 800; }
.story-nav, .story-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.story-nav { margin-top: 9px; }
.story-count { font-weight: 900; }
.story-footer .story-primary, .story-footer #storyNext { background: var(--plum); color: var(--white); }
.story-footer #storyColor:not(.story-primary) { text-decoration: underline; }
.sample-finish-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.story-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr)); gap: 8px; margin-top: 12px; }
#storyPicker .story-list button { text-align: left; }
#storyPicker .story-list [aria-current="page"] { background: var(--mint); font-weight: 900; }
@media (min-aspect-ratio: 6/5) and (min-width: 750px) {
  .story-mode:not(.sample-story) .story-footer { left: calc(env(safe-area-inset-left, 0px) + 16px); transform: none; width: min(350px, 46vw); }
}

.app.sample-story { display: block; }
.sample-story .stagearea {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr);
  grid-template-areas: "heading heading" "picture controls";
  align-items: center;
  gap: clamp(12px, 2.3vw, 28px);
  isolation: isolate;
}
.sample-story .stagearea::before {
  content: "";
  grid-area: 2 / 1 / 3 / -1;
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--mint);
  border-radius: 24px;
}
.sample-story #storyOverlay { display: contents; pointer-events: auto; }
.sample-story .story-header { grid-area: heading; position: static; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.sample-title { position: relative; justify-self: center; margin: 0; font-size: clamp(1.6rem, 4.1vw, 3.6rem); text-align: center; }
.sample-title::before, .sample-title::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 19px;
  height: 4px;
  border-radius: 999px;
  background: var(--gold, #efa93a);
  box-shadow: 5px -10px 0 -1px var(--gold, #efa93a), 5px 10px 0 -1px var(--gold, #efa93a);
  pointer-events: none;
}
.sample-title::before { right: calc(100% + 12px); }
.sample-title::after { left: calc(100% + 12px); transform: scaleX(-1); }
@media (max-width: 520px) {
  .sample-title { font-size: clamp(1.12rem, 6vw, 1.65rem); }
  .sample-title::before, .sample-title::after { width: 10px; height: 3px; box-shadow: none; }
  .sample-title::before { right: calc(100% + 4px); transform: rotate(15deg); }
  .sample-title::after { left: calc(100% + 4px); transform: rotate(-15deg); }
}
.sample-story .fit { grid-area: picture; padding: clamp(9px, 2.1vw, 26px); }
.sample-story .card { width: min(100%, calc(clamp(250px, 63dvh, 630px) * var(--ar))); outline-color: white; }
.sample-story .story-footer {
  grid-area: controls;
  position: static;
  transform: none;
  width: auto;
  align-self: stretch;
  align-content: center;
  margin: 22px 24px 22px 0;
  padding: clamp(14px, 2.4vw, 30px);
  border: 0;
}
.sample-story .animal-introduction {
  position: static;
  max-width: none;
  padding: 0;
  margin: 0 0 10px;
  border-radius: 0;
  background: transparent;
}
.sample-story .animal-introduction strong { display: block; font-size: clamp(1.8rem, 3.7vw, 3.35rem); line-height: 1; font-weight: 1000; letter-spacing: -.04em; }
.sample-story .animal-introduction span { display: inline-block; margin: 7px 0 0; padding: 3px 11px; border-radius: 999px; background: var(--butter); font-size: .94rem; font-weight: 900; }
.sample-story .animal-introduction span::before { content: none; }
.sample-story .story-step { font-size: clamp(1rem, 2vw, 1.25rem); }
.sample-story .story-phase { margin-top: 9px; }
.sample-story #storyCaption { padding-bottom: 8px; border-bottom: 1px solid var(--rule); margin-bottom: 7px; }
.sample-story .story-actions .story-primary { width: 100%; font-size: clamp(1rem, 2.1vw, 1.4rem); }
.sample-story .story-actions { justify-content: center; }
.sample-story #storyColor:not(.story-primary) { background: transparent; border: 0; }
.sample-story .story-nav { justify-content: space-between; border-top: 1px solid var(--rule); padding-top: 9px; }

@media (max-width: 740px) {
  body:has(.sample-story) .site-header nav { display: none; }
  .sample-story .stagearea {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "heading" "picture" "controls";
    gap: 10px;
  }
  .sample-story .stagearea::before { grid-area: picture; }
  .sample-story .story-header { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 8px; }
  .sample-story #chooseStory { justify-self: end; }
  .sample-story .story-header a { justify-self: start; }
  .sample-title { grid-column: 1 / -1; grid-row: 2; }
  .sample-story .card { width: min(100%, calc(clamp(180px, 40dvh, 490px) * var(--ar))); }
  .sample-story .story-footer { width: min(100%, 470px); margin: 0; justify-self: center; padding: 10px 12px; }
  .sample-story .story-phase { margin-top: 0; }
  .sample-story .story-actions { gap: 3px; }
  .sample-story .story-nav { padding-top: 5px; margin-top: 5px; }
}
@media (max-width: 380px) and (max-height: 670px) {
  .sample-story .card { width: min(100%, calc(37dvh * var(--ar))); }
}
@media (max-width: 380px) and (max-height: 670px) {
  body:has(.sample-story) .site-header { padding-block: 4px; }
  body:has(.sample-story) .site-header .brand img { width: 158px; }
  .sample-story .stagearea { gap: 6px; }
  .sample-story .story-header { gap: 4px; padding-bottom: 5px; }
  .sample-story .story-header :is(a, button) { padding-inline: 8px; font-size: .8rem; white-space: nowrap; }
  .sample-story .fit { padding: 6px; }
  .sample-story .card { width: min(100%, calc(32dvh * var(--ar))); }
  .sample-story .story-footer { padding: 6px 8px; }
  .sample-story .animal-introduction { margin-bottom: 4px; }
  .sample-story .animal-introduction strong { display: inline; font-size: 1.36rem; }
  .sample-story .animal-introduction span { margin: 0 0 0 5px; font-size: .76rem; }
  .sample-story #storyCaption { padding-bottom: 4px; margin-bottom: 3px; }
  .sample-story #storyCaption .story-step { margin-bottom: 2px; font-size: .9rem; }
  .sample-story #storyHint { margin: 4px 0 6px; font-size: .9rem; }
}
