:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff1dc;
  background: #241a30;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at 50% 25%, #674660, #241a30 78%); }
/* The scene spans the entire viewport; only the HTML player sits above it. */
.story {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 23rem;
  margin: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #30203f;
  box-shadow: 0 0 5rem #100c1670;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.scene { position: absolute; inset: 0; z-index: -1; background: #30203f; }
.scene img, .scene video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.scene video { visibility: hidden; }
.scene.video-visible video { visibility: visible; }
.player {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  min-height: 22%;
  padding: clamp(.45rem, 1.5vh, 1rem) max(3.3%, env(safe-area-inset-right, 0px)) max(.35rem, env(safe-area-inset-bottom, 0px)) max(3.3%, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, #32213ff5, #2b1e38f5);
}
button, a, input { -webkit-tap-highlight-color: transparent; }
button {
  font: inherit; cursor: pointer; color: #fff1dc;
  border: 1.5px solid #a17aa9;
  border-radius: 1rem;
  background: #4d345b;
  min-height: 48px;
  padding: .65rem .4rem;
}
button:hover { background: #60436e; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #ffdb9c; outline-offset: 3px; }
.timeline { display: flex; align-items: center; gap: clamp(.6rem, 2vw, 1rem); font-size: clamp(.8rem, 2.8vw, 1rem); font-variant-numeric: tabular-nums; }
.timeline span { min-width: 2.8rem; }
#duration { text-align: right; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; width: 100%; height: 44px;
  margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 8px; background: #17131c; border: 1px solid #100d15; box-shadow: inset 0 1px 2px #0006; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 8px; background: #17131c; border: 1px solid #100d15; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 18px; margin-top: -7px; border-radius: 10px; background: #fff; border: 1px solid #fff; box-shadow: 0 1px 4px #0003; }
input[type="range"]::-moz-range-thumb { width: 24px; height: 18px; border-radius: 10px; background: #fff; border: 1px solid #fff; box-shadow: 0 1px 4px #0003; }
input[type="range"]:disabled { opacity: .5; cursor: default; }
.buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(.45rem, 2vw, .75rem); margin-top: clamp(.35rem, 1vh, .75rem); }
.buttons button { display: flex; align-items: center; justify-content: center; gap: .45rem; min-height: clamp(48px, 7vh, 64px); font-size: clamp(.9rem, 3.5vw, 1.3rem); }
.buttons svg { width: 1.1em; height: 1.1em; flex: 0 0 auto; fill: currentColor; }
button.primary { background: #f2c487; border-color: #f2c487; color: #35233f; font-weight: 700; }
button.primary:hover { background: #ffdaa5; }
#status { min-height: 2.6em; margin: .65rem 0 0; font-size: clamp(.75rem, 2.7vw, .95rem); line-height: 1.3; text-align: center; color: #f1e3d9; }
footer { text-align: center; font-size: clamp(.58rem, 1.9vw, .8rem); line-height: 1.6; color: #e0d0dc; }
footer a { display: inline-flex; align-items: center; min-height: 44px; color: #f6d3a0; text-underline-offset: 4px; }
audio { width: 100%; margin-top: .5rem; }
.no-script { font-size: .8rem; text-align: center; }
[hidden] { display: none !important; }
@media (max-height: 42rem) and (orientation: portrait) {
  .buttons button { min-height: 48px; }
  #status { margin-top: .4rem; }
  .player { padding-top: 0; }
}
/* Keep an actual 9:16 composition centered on wide screens. */
@media (min-width: 48rem) and (min-height: 36rem) {
  .story { width: min(100%, calc(100vh * 9 / 16)); width: min(100%, calc(100dvh * 9 / 16)); }
}
@media (orientation: landscape) and (max-height: 36rem) {
  .story { min-height: 19rem; }
  .scene img, .scene video { object-fit: contain; object-position: left top; }
  .player { width: min(50%, 24rem); min-width: 19rem; margin-left: auto; }
  .buttons button { min-height: 48px; font-size: 1rem; }
}
@media (max-width: 22rem) {
  .player { padding-left: max(.5rem, env(safe-area-inset-left, 0px)); padding-right: max(.5rem, env(safe-area-inset-right, 0px)); }
  .buttons { gap: .35rem; }
  .buttons button { gap: .2rem; font-size: .85rem; }
  .timeline { gap: .35rem; }
  footer { font-size: .58rem; }
}
