/* Credits page + shared scroll styles (credits/ only). */

*, *::before, *::after { box-sizing: border-box; }

html, body.cr-page {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: #05080e;
  color: #eaf2fb;
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
}

.cr-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Same gate as shell pages: hide UI until JSON + images + music are fully ready. */
body.cr-page:not(.ready) .cr-topbar,
body.cr-page:not(.ready) .cr-stage {
  opacity: 0;
  visibility: hidden;
}
body.cr-page.ready .cr-topbar,
body.cr-page.ready .cr-stage {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  body.cr-page.ready .cr-topbar,
  body.cr-page.ready .cr-stage { transition: none; }
}

.cr-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: linear-gradient(to bottom, rgba(5, 8, 14, 0.95), transparent);
  position: relative;
  z-index: 2;
}

/* Same compact sizing as the global menu Home button (.gm .btn). */
.cr-topbar .btn {
  --s: 3px;
  --s2: 6px;
  min-height: 36px;
  padding: 7px 11px;
  gap: 6px;
  white-space: nowrap;
  font-size: clamp(0.5rem, 1.15vw, 0.62rem);
  letter-spacing: 0.3px;
}
.cr-topbar .btn-ico {
  width: 16px;
  height: 16px;
  top: 0;
}

.cr-skip {
  appearance: none;
  border: 0;
  background: none;
  color: #8ba0b8;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 4px 2px;
  font: 600 0.85rem/1.2 Inter, system-ui, sans-serif;
  cursor: pointer;
}
.cr-skip:hover { color: #7ef7d4; }

.cr-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 12%, #000 88%, transparent 100%);
}

.cr-scroll {
  position: absolute;
  left: 0;
  right: 0;
  width: min(1200px, 94vw);
  margin: 0 auto;
  text-align: center;
  will-change: transform;
  padding-bottom: 40vh;
  padding-left: max(0px, env(safe-area-inset-left));
  padding-right: max(0px, env(safe-area-inset-right));
}

.cr-loading {
  margin: 30vh 0 0;
  color: #7e8fa6;
  font-size: 0.95rem;
}

.cr-title {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  color: #fff;
  margin: 0 0 0.75rem;
  line-height: 1.4;
  text-transform: uppercase;
}
.cr-subtitle {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(0.65rem, 2.2vw, 0.85rem);
  color: #00e5ab;
  margin: 0 0 2.5rem;
  line-height: 1.5;
}

.cr-block {
  margin: 0 auto 0.85rem;
  max-width: 100%;
  overflow: hidden;
}
.cr-block.is-empty { height: 1.1rem; }
.cr-block.is-spacer { width: 100%; }
.cr-text {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cr-text.bold { font-weight: 700; }
.cr-text i { font-style: italic; }
.cr-ending {
  padding: 1.25rem 0 2rem;
  width: min(1200px, 94vw);
  margin: 0 auto;
  text-align: center;
}
.cr-ending .cr-text { margin-top: 0.75rem; }
.cr-ending.is-pinned-source {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Parked finale — stays centered after the scrolling ending reaches mid-screen */
.cr-ending-layer {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
  text-align: center;
  width: 100%;
  padding: 0;
  /* Avoid a flash while the parked copy attaches */
  opacity: 1;
  will-change: top;
}
.cr-ending-layer.is-parked {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Match .cr-ending so the swap doesn’t shift content */
  padding: 1.25rem 0 2rem;
  box-sizing: border-box;
}
.cr-ending-layer .cr-img {
  display: block;
  margin: 0.5rem auto 1rem;
  max-width: min(900px, 100%);
  height: auto;
}
.cr-ending-layer .cr-text {
  margin: 0.75rem auto 0;
  max-width: min(1200px, 94vw);
}
.cr-img {
  display: block;
  margin: 0.5rem auto 1rem;
  max-width: min(900px, 100%);
  width: auto;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
}

@media (max-width: 720px) {
  .cr-scroll { width: min(1200px, 96vw); }
  .cr-img { max-width: 100%; }
}

/* Match shell pages: pixel mute button injected by js/audio.js */
body #mute-btn {
  --s: 3px;
  --s2: 6px;
  gap: 6px;
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 101;
  min-height: 34px;
  height: auto;
  padding: 7px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #dfe9f5;
  font: 400 0.5rem/1 'Press Start 2P', 'Segoe UI', monospace;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
body #mute-btn:hover { background: transparent; }
body #mute-btn:focus-visible { outline: 3px solid #7ef7d4; outline-offset: 2px; }
body #mute-btn .mi { font-size: 0.95rem; line-height: 1; display: inline-flex; }
body #mute-btn .mi img { width: 20px; height: 20px; display: block; image-rendering: pixelated; }
body #mute-btn .ml { white-space: nowrap; }
@media (max-width: 480px) {
  body #mute-btn .ml { display: none; }
  body #mute-btn { padding: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  html, body.cr-page { overflow: auto; }
  .cr-stage {
    overflow: auto;
    mask-image: none;
    -webkit-mask-image: none;
  }
  .cr-scroll {
    position: relative;
    padding: 24px 0 80px;
  }
}
