/* ---------- Constellation drawing ---------- */
.constellation-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.constellation-draw {
  position: fixed;
  inset: 0;
  z-index: 30;
  cursor: pointer;
  background: rgba(8, 6, 24, 0.18);
}
.constellation-draw-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.constellation-pattern-card {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  min-width: min(420px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: 38px 72px 1fr 38px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 214, 107, 0.28);
  border-radius: 14px;
  background: rgba(14, 12, 32, 0.8);
  color: var(--ink);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.36);
}
.constellation-pattern-card svg {
  width: 72px;
  height: 54px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
}
.constellation-pattern-card strong,
.constellation-pattern-card span {
  display: block;
}
.constellation-pattern-card strong {
  color: var(--accent);
  font-size: 14px;
}
.constellation-pattern-card span {
  color: var(--ink-dim);
  font-size: 12px;
  font-weight: 700;
}
.constellation-pattern-nav {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.constellation-toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.constellation-tip {
  font-size: 12px;
  color: var(--ink-dim);
  margin-right: 4px;
}
@media (max-width: 720px) {
  .constellation-toolbar {
    left: 14px;
    right: 14px;
    bottom: 14px;
    transform: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-radius: 18px;
  }
  .constellation-pattern-card {
    top: 10px;
    grid-template-columns: 34px 58px 1fr 34px;
    gap: 7px;
    padding: 8px;
  }
  .constellation-pattern-card svg {
    width: 58px;
    height: 44px;
  }
  .constellation-pattern-nav {
    width: 34px;
    height: 34px;
  }
  .constellation-tip {
    grid-column: 1 / -1;
    margin-right: 0;
    text-align: center;
  }
  .constellation-toolbar button {
    min-height: 48px;
  }
  .constellation-toolbar .btn-tour {
    grid-column: 1 / -1;
  }
}
.constellation-clear-btn {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 40;
  background: rgba(14, 12, 32, 0.7);
  color: var(--ink-dim);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}
.constellation-clear-btn:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 900px) {
  .header {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(
      180deg,
      rgba(5, 4, 20, 0.78) 0%,
      rgba(5, 4, 20, 0.46) 72%,
      transparent 100%
    );
  }
  .subtitle {
    max-width: 260px;
    line-height: 1.35;
  }
  .field-journal {
    grid-template-columns: 1fr;
    gap: 7px;
    align-items: start;
    border-radius: 14px;
  }
  .field-journal-worlds {
    flex-wrap: wrap;
  }
  .actions {
    max-width: 100%;
    justify-content: flex-start;
  }
  .action-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: max(86px, env(safe-area-inset-top));
    width: auto;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
  }
  .hint {
    bottom: 92px;
    width: calc(100vw - 32px);
    text-align: center;
    line-height: 1.45;
  }
  .kid-panel.active {
    left: 14px;
    right: 14px;
    bottom: 14px;
    flex-direction: column;
    align-items: flex-start;
  }
  .kid-panel.active .kid-mission {
    width: 100%;
  }
  .treasure-hud {
    left: 14px;
    right: 14px;
    top: 14px;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }
  .treasure-title-block {
    grid-column: 1 / -1;
    order: 2;
  }
  .treasure-title {
    font-size: 38px;
  }
  .treasure-subtitle {
    font-size: 12px;
  }
  .treasure-count {
    min-width: 96px;
  }
  .treasure-next-card {
    left: 14px;
    top: 150px;
    max-width: calc(100vw - 28px);
    grid-template-columns: auto 36px minmax(0, auto);
    gap: 7px;
    padding: 7px 10px;
  }
  .treasure-next-card img {
    width: 36px;
    height: 36px;
  }
  .treasure-next-card strong {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .treasure-level .kid-star-button {
    width: 68px;
    height: 68px;
  }
  .treasure-tap-helper {
    width: 68px;
    height: 68px;
  }
  .treasure-tap-helper span {
    margin-bottom: -30px;
    font-size: 12px;
    padding: 7px 10px;
  }
  .treasure-progress {
    bottom: 72px;
  }
  .treasure-tray {
    bottom: 14px;
    max-width: calc(100vw - 28px);
    gap: 5px;
    border-radius: 18px;
  }
  .treasure-tray-item {
    width: 38px;
    height: 38px;
  }
  .treasure-complete {
    padding: 18px;
  }
  .treasure-complete strong {
    font-size: 23px;
    text-align: center;
  }
  .storybook-close {
    left: 14px;
    top: 14px;
    padding: 12px 18px;
    min-height: 60px;
  }
  .storybook-shelf-top {
    left: auto;
    right: 14px;
    top: 14px;
    padding: 12px 16px;
  }
  .storybook-shell {
    width: min(96vw, 560px);
    max-height: calc(100svh - 92px);
    overflow-y: auto;
    padding: 2px 0 6px;
    scrollbar-width: none;
  }
  .storybook-shell::-webkit-scrollbar {
    display: none;
  }
  .storybook-card {
    padding: 10px;
    gap: 10px;
    border-radius: 14px;
  }
  .storybook-card img {
    border-radius: 10px;
    max-height: 46svh;
  }
  .storybook-shell.moon-seed .storybook-card img {
    max-height: 44svh;
  }
  .storybook-character-badge {
    left: 12px;
    top: 10px;
    width: 54px;
  }
  .storybook-card p {
    min-height: 92px;
    padding: 0 10px 6px;
    font-size: clamp(25px, 7vw, 38px);
  }
  .storybook-big-next {
    min-height: 56px;
    margin-top: 10px;
    font-size: 17px;
  }
  .storybook-nav {
    top: 38%;
    width: 52px;
    height: 52px;
    font-size: 34px;
  }
  .storybook-nav.prev {
    left: 8px;
  }
  .storybook-nav.next {
    right: 8px;
  }
  .storybook-audio-tools {
    right: 14px;
    top: 76px;
  }
  .storybook-replay {
    padding: 12px 18px;
    min-height: 48px;
  }
  .storybook-dots {
    bottom: 12px;
  }
  .story-shelf-page {
    place-items: start center;
    padding: 76px 14px 20px;
  }
  .story-shelf-panel {
    gap: 16px;
  }
  .story-shelf-heading h1 {
    font-size: 46px;
  }
  .story-shelf-heading p {
    max-width: 280px;
    font-size: 13px;
  }
  .story-shelf-stage {
    min-height: 0;
    aspect-ratio: 3 / 2;
    border-radius: 18px;
  }
  .story-shelf-art {
    object-fit: contain;
    object-position: 50% 50%;
    background: rgba(7, 7, 20, 0.92);
    transform: none;
  }
  .story-shelf-hotspot {
    width: 16.4%;
    height: 23%;
  }
  .story-shelf-hotspot.star-home {
    left: 21.6%;
    top: 10%;
  }
  .story-shelf-hotspot.moon-seed {
    left: 41.4%;
    top: 10%;
  }
  .story-shelf-hotspot.comet-hat {
    left: 61.1%;
    top: 10%;
  }
  .story-shelf-hotspot.rocket-pajamas {
    left: 21.6%;
    top: 36.8%;
  }
  .story-shelf-hotspot.saturn-ring {
    left: 41.4%;
    top: 36.8%;
  }
  .story-shelf-hotspot.black-hole-peekaboo {
    left: 61.1%;
    top: 36.8%;
  }
  .story-shelf-hotspot.moon-mailbox {
    left: 21.6%;
    top: 63.6%;
  }
  .story-shelf-hotspot.jupiter-storm {
    left: 41.4%;
    top: 63.6%;
  }
  .story-shelf-hotspot.neptune-night-light {
    left: 61.1%;
    top: 63.6%;
  }
  .story-pulled-book {
    bottom: 16px;
    width: calc(100% - 24px);
    min-height: 0;
    grid-template-columns: 118px 1fr;
    gap: 12px;
    padding: 12px;
  }
  .story-pulled-copy {
    gap: 6px;
  }
  .story-pulled-copy span {
    width: 38px;
    height: 38px;
    font-size: 22px;
  }
  .story-pulled-copy strong {
    font-size: 26px;
  }
  .story-pulled-copy small {
    font-size: 13px;
  }
  .story-open-cue {
    min-height: 42px;
    font-size: 14px;
    padding: 0 16px;
  }
  .storybook-open-book {
    min-height: min(58svh, 520px);
    grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr);
    padding: 0;
  }
  .storybook-book-gutter {
    display: block;
  }
  .storybook-page-left {
    min-height: 0;
    border-right: 1px solid rgba(95, 61, 22, 0.16);
    border-bottom: 0;
    padding: 7px;
  }
  .storybook-page-right {
    border-left: 1px solid rgba(255, 255, 255, 0.5);
    padding: 9px;
  }
  .storybook-open-book img {
    max-height: min(48svh, 380px);
  }
  .storybook-page-text {
    font-size: clamp(22px, 5.8vw, 34px);
  }
  .story-shelf-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .story-shelf-book {
    min-height: 0;
    grid-template-columns: 112px 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    column-gap: 12px;
    padding: 10px;
  }
  .story-shelf-book img {
    grid-row: 1 / 4;
    max-height: 112px;
    object-fit: contain;
  }
  .story-shelf-book strong {
    font-size: 28px;
  }
  .story-shelf-book small {
    font-size: 13px;
  }
  .story-shelf-book em {
    margin-top: 0;
  }
  .story-shelf-icon {
    right: auto;
    left: 78px;
    top: 18px;
    width: 42px;
    height: 42px;
    font-size: 22px;
  }
  .rocket-pack-level {
    display: block;
    padding: 68px 14px 14px;
    overflow-y: auto;
  }
  .rocket-pack-back {
    left: 14px;
    top: 14px;
    padding: 10px 14px;
  }
  .rocket-builder-stage {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .rocket-build-pad {
    min-height: 300px;
    border-radius: 20px;
  }
  .rocket-build-ship {
    width: 178px;
    height: 300px;
    transform: scale(1.13);
    margin-top: -18px;
  }
  .rocket-nose-img {
    width: 92px;
  }
  .rocket-body-img {
    top: 62px;
    width: 98px;
  }
  .rocket-fins-img {
    top: 172px;
    width: 148px;
  }
  .rocket-window-img {
    top: 92px;
    width: 46px;
  }
  .rocket-engine-img {
    top: 208px;
    width: 70px;
  }
  .rocket-fuel-tank-img {
    top: 146px;
    width: 46px;
    margin-left: -54px;
  }
  .rocket-fuel-pipes-img {
    top: 168px;
    width: 92px;
  }
  .rocket-igniter-img {
    top: 214px;
    width: 34px;
    margin-left: 40px;
  }
  .rocket-booster-img {
    top: 78px;
    width: 176px;
  }
  .rocket-antenna-img {
    top: -34px;
    width: 64px;
  }
  .rocket-badge-img {
    top: 138px;
    width: 42px;
    margin-left: 30px;
  }
  .rocket-nose {
    width: 82px;
    height: 82px;
  }
  .rocket-body {
    top: 78px;
    width: 88px;
    height: 126px;
  }
  .rocket-window {
    top: 25px;
    width: 46px;
    height: 46px;
    border-width: 4px;
  }
  .rocket-fins {
    top: 178px;
    width: 118px;
    height: 54px;
  }
  .rocket-fins span {
    width: 40px;
    height: 54px;
  }
  .rocket-flame {
    top: 242px;
    width: 128px;
    height: auto;
  }
  .rocket-pack-copy {
    gap: 8px;
  }
  .rocket-pack-copy h1 {
    font-size: 42px;
  }
  .rocket-pack-copy p {
    font-size: 13px;
  }
  .pack-next-choice {
    width: 100%;
    min-height: 118px;
    grid-template-columns: 76px 1fr;
    padding: 12px;
  }
  .rocket-part-icon {
    width: 70px;
    height: 70px;
  }
  .pack-next-choice strong {
    font-size: 24px;
  }
  .rocket-pack-done {
    grid-template-columns: 1fr;
  }
  .helmet-lab-preview {
    left: 50%;
    top: 25%;
    width: min(76vw, 38svh, 300px);
  }
  .helmet-lab-info {
    top: auto;
    left: 16px;
    right: 16px;
    bottom: 12px;
    width: auto;
    max-height: 48vh;
    overflow-x: hidden;
  }
  .helmet-lab-view .detail-name {
    font-size: 42px;
    line-height: 0.95;
    margin-bottom: 14px;
  }
  .helmet-lab-view .kid-i-spy {
    margin-bottom: 4px;
  }
  .helmet-lab-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .helmet-rotate-btn {
    width: 52px;
    height: 52px;
  }
  .detail-name {
    font-size: 48px;
  }
  .detail-info {
    width: auto;
    left: 5%;
    right: 5%;
    top: auto;
    bottom: 16px;
    transform: none;
    max-height: 50vh;
  }
  .detail-blurb {
    font-size: 14px;
    margin-bottom: 18px;
    max-width: none;
  }
  .stat-grid {
    margin-bottom: 12px;
  }
  .stat {
    padding: 10px 12px;
  }
  .stat-value {
    font-size: 13px;
  }
  .gravity-play-card {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
  }
  .mars-rover-spotter {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }
  .mars-rover-map {
    min-height: 92px;
  }
  .mars-rover-pin {
    width: 48px;
    height: 48px;
  }
  .gravity-weight-control {
    grid-template-columns: auto 74px auto;
  }
  .gravity-weight-control span {
    grid-column: auto;
  }
  .gravity-jump-meter {
    height: 40px;
  }
  .age-play-card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }
  .detail-nav.prev {
    bottom: auto;
    top: 24px;
    left: auto;
    right: 80px;
  }
  .detail-nav.next {
    bottom: auto;
    top: 24px;
    left: auto;
    right: 28px;
  }
}

@media (max-width: 900px) and (max-height: 700px) {
  .helmet-lab-preview {
    top: 21%;
    width: min(70vw, 32svh, 260px);
  }
  .helmet-lab-info {
    max-height: 56svh;
  }
  .helmet-lab-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }
  .helmet-lab-choice {
    min-height: 50px;
  }
  .helmet-lab-choice span {
    width: 32px;
    height: 32px;
    font-size: 24px;
  }
  .helmet-lab-choice small {
    display: none;
  }
  .helmet-rotate-btn.prev {
    left: 2px;
  }
  .helmet-rotate-btn.next {
    right: 2px;
  }
}
