.story-game {
  --story-ink: #2b2040;
  --story-muted: #625775;
  --story-accent: #6139a1;
  --story-soft: #f3edff;
  --story-outline: #e2d8f1;
  --story-font: "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--story-ink);
  padding-bottom: clamp(1.5rem, 4vw, 3rem);
}

.story-game [hidden] { display: none !important; }
.story-game button { font: inherit; }
.story-game :is(button, a):focus-visible {
  outline: 3px solid #9250df;
  outline-offset: 3px;
}
.story-game :is(h1, h2, h3, strong) { font-family: var(--story-font); }

.story-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 0.82fr 1.3fr;
  min-height: clamp(24rem, 38vw, 30rem);
  border-radius: 1.75rem;
  overflow: hidden;
  background: #201632;
  color: #fff;
}

.story-hero__body {
  z-index: 1;
  align-self: center;
  padding: clamp(2rem, 5vw, 4.5rem) 0 clamp(2rem, 5vw, 4.5rem) clamp(1.75rem, 5vw, 4.5rem);
}
.story-hero h1 {
  color: #fff4d9;
  font-size: clamp(3.15rem, 7vw, 6.1rem);
  line-height: 1.12;
  letter-spacing: -.055em;
  margin: 0;
}
.story-hero p {
  color: #f0e4ff;
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  max-width: 23rem;
  line-height: 1.58;
  margin: 1rem 0 1.4rem;
}
.story-hero img {
  position: absolute;
  inset: 0 0 0 auto;
  width: 70%;
  height: 100%;
  object-fit: cover;
  object-position: center 65%;
  mask-image: linear-gradient(to right, transparent, #000 30%);
}
.story-primary, .story-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: fit-content;
  min-height: 2.875rem;
  padding: .58rem 1rem;
  border: 1px solid transparent;
  border-radius: .8rem;
  font-size: .94rem;
  font-weight: 750 !important;
  text-decoration: none;
  cursor: pointer;
}
.story-primary svg, .story-secondary svg { width: 1.12rem; height: 1.12rem; flex: none; }
.story-primary { background: var(--story-accent); color: white; }
.story-primary:hover { background: #4b2887; color: white; }
.story-hero .story-primary { background: #ffda8e; color: #30203e; }
.story-hero .story-primary:hover { background: #ffe8b8; }
.story-secondary { border-color: var(--story-outline); color: #4b2e74; background: #fff; }
.story-secondary:hover { background: var(--story-soft); }

.story-shelf {
  margin-top: clamp(1.8rem, 4vw, 3rem);
  scroll-margin-top: 5rem;
}
.story-shelf__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 0 0 1.15rem;
}
.story-shelf h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  margin: 0 0 .25rem;
  color: var(--story-ink);
}
.story-shelf__header p { margin: 0; color: var(--story-muted); }
.story-shelf__header .story-total {
  padding: .35rem .8rem;
  border-radius: 2rem;
  color: #52347c;
  background: var(--story-soft);
  font-weight: 700;
}
.story-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.story-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--story-outline);
  border-radius: 1rem;
  background: #fff;
  color: var(--story-ink);
  text-align: left;
  cursor: pointer;
  transition: box-shadow .18s, border-color .18s;
}
.story-card:disabled { cursor: default; }
.story-card:not(:disabled):hover { border-color: #b69cde; box-shadow: 0 7px 20px #39255b19; }
.story-card img { display: block; width: 100%; height: auto; aspect-ratio: 1.5; object-fit: cover; background: var(--story-soft); }
.story-card__body { display: grid; gap: .53rem; padding: .9rem .95rem 1rem; }
.story-card__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .27rem .6rem;
  color: #603b91;
  font-size: .875rem;
  font-weight: 700;
}
.story-card__meta span + span { color: var(--story-muted); font-weight: 550; }
.story-card strong { line-height: 1.34; font-size: clamp(1.05rem, 1.55vw, 1.24rem); }
.story-card__desc { color: var(--story-muted); line-height: 1.5; }

.story-reader {
  overflow: hidden;
  scroll-margin-top: 5.5rem;
  border: 1px solid var(--story-outline);
  border-radius: 1.5rem;
  background: #fff;
  box-shadow: 0 14px 45px #39255b0d;
}
.story-reader__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .6rem;
  padding: .68rem clamp(.9rem, 3vw, 1.6rem);
  background: #f8f3ff;
  border-bottom: 1px solid var(--story-outline);
  color: #4e3670;
  font-weight: 750;
}
.story-step { justify-self: end; font-size: .875rem; }
.story-reader__page { display: grid; grid-template-columns: 1fr 1fr; }
.story-scene-art { margin: 0; min-width: 0; background: #e8dff4; }
.story-scene-art picture { display: block; width: 100%; height: 100%; }
.story-scene-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.story-scene { min-width: 0; padding: clamp(1.1rem, 3vw, 2.2rem); }
.story-scene__label { font-size: .9rem; color: #603b91; font-weight: 750; }
.story-scene h2 {
  color: var(--story-ink);
  font-size: clamp(1.55rem, 3.1vw, 2.35rem);
  line-height: 1.24;
  margin: .32rem 0 .7rem;
  scroll-margin-top: 5.5rem;
}
.story-scene__text { margin: 0 0 .9rem; font-size: clamp(1.025rem, 1.55vw, 1.2rem); line-height: 1.65; }
.story-listen { background: var(--story-soft); }
.story-audio-status { margin: .4rem 0 0; color: var(--story-muted); }
.story-audio-status:empty { margin: 0; }
.story-choice, .story-finish { margin: 1.1rem 0 0; }
.story-choice h3 { color: var(--story-ink); margin: 0 0 .55rem; font-size: 1rem; }
.story-choice__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(.55rem, 2vw, .9rem); }
.story-choice__button {
  display: block;
  overflow: hidden;
  padding: 0;
  border: .25rem solid #8b60c3;
  border-radius: .9rem;
  background: #f3edff;
  cursor: pointer;
}
.story-choice__button:nth-child(2) {
  border-color: #d7a12e;
  background: #fff6e4;
}
.story-choice__button:hover { box-shadow: 0 0 0 2px #6a488e; }
.story-choice__button img { display: block; width: 100%; height: auto; aspect-ratio: 1.5; object-fit: cover; }
.story-finish { background: #fff6e4; border-radius: .85rem; padding: .9rem; }
.story-finish p { margin: 0 0 .7rem; line-height: 1.5; }
.story-previous { margin-top: .8rem; }
.story-credits { margin: 1rem 0 0; font-size: .875rem; color: var(--story-muted); }
.story-credits a { color: inherit; text-decoration: underline; }

@media (max-width: 900px) {
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .story-hero { display: flex; flex-direction: column-reverse; min-height: auto; }
  .story-hero img { position: static; width: 100%; height: auto; aspect-ratio: 1.65; mask-image: none; }
  .story-hero__body { padding: 1.1rem 1.25rem 1.35rem; align-self: stretch; }
  .story-hero h1 { font-size: clamp(2.2rem, 10vw, 3.4rem); }
  .story-hero__break { display: none; }
  .story-hero p { margin: .55rem 0 .9rem; }
  .story-reader__page { grid-template-columns: minmax(0, 1fr); }
  .story-reader__bar { grid-template-columns: auto 1fr; }
  .story-reader__bar [data-active-book] { grid-column: 1 / -1; grid-row: 2; }
  .story-scene-art img { height: auto; aspect-ratio: 1.75; }
}

@media (max-width: 450px) {
  .story-grid { gap: .65rem; }
  .story-card__body { gap: .38rem; padding: .65rem; }
  .story-card__meta { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  .story-card { transition: none; }
}
