/* ============================================================
   一窗两面 · mobile (<768)
   - 下界改成横向 snap 轮播，居中人物自动同步 hoveredId
   - 上界只开居中一扇窗
   - 详览在 scroll.css 里改成竖卷，一屏内纵向阅读
   ============================================================ */

@media (max-width: 767px) {
  :root {
    --win-w: 36vw;
    --win-h: 54vw;
  }

  .intro__arch {
    width: 90vw;
    height: 68vh;
    bottom: 2vh;
  }

  .intro__pillar {
    width: 13%;
  }

  .intro__couplet {
    top: 19%;
    bottom: 10%;
    font-size: 11px;
    letter-spacing: 0.22em;
    padding: 1.2vh 0.5vw;
  }

  .intro__couplet--right {
    right: 5.2%;
  }

  .intro__couplet--left {
    left: 5.2%;
  }

  .intro__prologue {
    display: none;
  }

  .intro__plaque {
    top: 2%;
    min-width: 32vw;
    padding: 0.9vh 3vw 1.1vh;
  }

  .intro__plaque strong {
    font-size: 18px;
  }

  .intro__knob {
    top: 54%;
    width: 78px;
    height: 78px;
  }

  .intro__hint {
    top: calc(54% + 62px);
    font-size: 9px;
    letter-spacing: 0.2em;
  }

  .intro__footer {
    font-size: 7px;
    letter-spacing: 0.24em;
  }

  .controls {
    top: 1.8vh;
    right: 3vw;
    gap: 0.9vh;
  }

  .ctl {
    font-size: 9px;
    gap: 4px;
    letter-spacing: 0.12em;
  }

  .ctl__key {
    display: none;
  }

  .realm__moon {
    top: 3vh;
    width: 12vh;
    height: 12vh;
  }

  .realm__haze--a,
  .realm__haze--b {
    filter: blur(16px);
  }

  /* only the centered upper window on mobile */
  .upper-frames {
    display: block;
  }

  .uframe {
    left: 50%;
    top: 11vh;
    width: 38vw;
    height: 24vh;
    opacity: 0;
    border-color: rgba(198, 161, 91, 0.14);
    transform: translateX(-50%);
    z-index: 1;
  }

  .uframe.is-hovered {
    top: 10vh;
    width: 64vw;
    height: 28vh;
    opacity: 1;
    z-index: 3;
  }

  .uframe__ghost {
    opacity: 0;
  }

  .uframe.is-hovered .uframe__ghost {
    top: 2vh;
    height: 22vh;
    opacity: 0.12;
  }

  .uframe__name {
    font-size: 8px;
  }

  .uframe__text {
    top: 2.4vh;
    right: 5vw;
    left: 5vw;
    bottom: 4.8vh;
    font-size: 11px;
    line-height: 1.5;
  }

  .uframe__seal {
    width: 1.3vh;
    height: 3.6vh;
    bottom: -1.2vh;
  }

  .upper-shared {
    left: 50%;
    top: 10vh;
    width: 88vw;
    height: 29vh;
  }

  .upper-shared__text {
    top: 2.6vh;
    right: 4vw;
    left: 4vw;
    bottom: 4.6vh;
    gap: 0.9em;
    font-size: 10.5px;
  }

  .upper-shared__seal {
    width: 1.3vh;
    height: 3.6vh;
  }

  .upper-shared__seal--left {
    left: 12%;
  }

  .upper-shared__seal--right {
    right: 12%;
  }

  .fog-curtain {
    height: 48vh;
    filter: blur(7px);
  }

  .fog-curtain--left {
    width: calc(var(--hover-x) + 5vw);
    transform: translateX(calc(var(--open) * -9vw));
  }

  .fog-curtain--right {
    left: calc(var(--hover-x) - 5vw);
    transform: translateX(calc(var(--open) * 9vw));
  }

  .realm-whisper {
    top: 40vh;
    font-size: 8px;
  }

  /* mirror: smaller so the carousel starts below it */
  .mirror {
    top: 36vh;
    height: 30vh;
  }

  .mirror__flip {
    width: 180vw;
    height: 40vh;
  }

  .mirror__water,
  .mirror__rim,
  .mirror__back-plate {
    width: 180vw;
    height: 40vh;
  }

  .mirror__rim--inner {
    width: 176vw;
    height: 38vh;
  }

  .mirror__glint {
    width: 54vw;
    height: 5vh;
  }

  .mirror__chains {
    display: none;
  }

  .mirror__epilogue {
    width: 88vw;
    font-size: 14px;
    line-height: 1.9;
    letter-spacing: 0.1em;
  }

  .realm--lower {
    background:
      radial-gradient(60vw 18vh at 50% 0%, rgba(255, 255, 255, 0.4) 0%, transparent 68%),
      linear-gradient(180deg, #efe1ca 0%, #f6ecd9 26%, #f2e6d0 62%, #e8d0c4 100%);
  }

  .garden__moon-gate {
    left: 4%;
    bottom: 34vh;
    width: 14vh;
    height: 14vh;
    border-width: 0.9vh;
    opacity: 0.6;
  }

  .garden__willow {
    right: 0;
    bottom: 33vh;
    opacity: 0.16;
  }

  .bamboo {
    bottom: 27vh;
    opacity: 0.2;
  }

  .garden__lantern {
    display: none;
  }

  /* horizontal snap carousel */
  .windows {
    position: absolute;
    top: calc(36vh - 0.926667 * var(--win-h));
    left: 0;
    right: 0;
    height: var(--win-h);
    display: flex;
    align-items: flex-start;
    gap: 7vw;
    padding: 0 32vw;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 32vw;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    z-index: 10;
    pointer-events: auto;
  }

  .windows::-webkit-scrollbar {
    display: none;
  }

  .window {
    position: relative;
    left: auto;
    top: auto;
    flex: 0 0 var(--win-w);
    width: var(--win-w);
    height: var(--win-h);
    transform: none;
    transform-origin: 50% 92.667%;
    scroll-snap-align: center;
    opacity: 0.5;
    transition:
      opacity 360ms ease,
      transform 360ms var(--ease);
  }

  .window.is-hovered {
    transform: scale(1.035);
    opacity: 1;
  }

  .window.is-dimmed {
    opacity: 0.36;
  }

  .window.is-linked {
    opacity: 0.62;
  }

  .window__glow {
    inset: -12% -10% -6%;
    filter: blur(1.4vh);
  }

  .window__echo {
    display: none;
  }

  .window__sheen {
    display: none;
  }

  .window-labels {
    display: none;
  }

  .stone-rail {
    top: 36vh;
    height: 14vh;
  }

  .stone-rail::after {
    background:
      repeating-linear-gradient(90deg, transparent 0 18vw, rgba(88, 72, 54, 0.12) 18vw calc(18vw + 1px), transparent calc(18vw + 1px) 36vw),
      radial-gradient(ellipse at 50% 10%, rgba(255, 255, 255, 0.12), transparent 58%);
  }

  .garden__grass {
    width: 34vw;
    opacity: 0.2;
  }

  .garden__ridge {
    bottom: 40vh;
    height: 20vh;
  }

  .garden__ridge--b {
    bottom: 37vh;
  }

  .gauge {
    width: 92vw;
    bottom: 1.6vh;
  }

  .gauge__readout {
    gap: 2.2vw;
    margin-bottom: 0.8vh;
  }

  .gauge__label {
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  .gauge__chapter {
    font-size: 8px;
    letter-spacing: 0.05em;
  }

  .gauge__track {
    height: 2.2vh;
  }

  .gauge__mark {
    font-size: 8px;
    letter-spacing: 0.08em;
    padding-top: 0.9vh;
  }

  .gauge__mark small {
    display: none;
  }

  .hint {
    bottom: 6.4vh;
    font-size: 10px;
    letter-spacing: 0.14em;
    white-space: normal;
    width: 84vw;
    text-align: center;
    padding: 0.6vh 0;
  }

  .toast {
    top: 6.6vh;
    max-width: 88vw;
    font-size: 10px;
    letter-spacing: 0.08em;
    padding: 0.8vh 3vw;
  }

  .thread {
    width: 1px;
    opacity: 0.8;
  }

  .thread__knot {
    width: 4px;
    height: 4px;
  }

  .relation-label {
    font-size: 8px;
  }

  .hidden-window {
    top: calc(54vh + var(--y-offset, 0px));
    width: 26vw;
    height: 39vw;
  }

  .hidden-star {
    top: calc(54vh + var(--y-offset, 0px));
  }

  .hidden-verdict {
    width: 92vw;
    bottom: 10vh;
    padding: 1.2vh 4vw;
  }

  .hidden-verdict__text {
    max-height: 20vh;
    font-size: 11px;
  }

  .debug-note {
    left: 2vw;
    top: 7vh;
    font-size: 9px;
    white-space: pre-wrap;
    max-width: 90vw;
  }

  .debug-line span {
    font-size: 9px;
  }
}

@media (max-width: 767px) and (max-height: 700px) {
  .intro__arch {
    height: 64vh;
  }

  .intro__couplet {
    font-size: 10px;
    letter-spacing: 0.16em;
  }

  .intro__knob {
    top: 56%;
  }

  .uframe.is-hovered {
    height: 26vh;
  }

  .mirror {
    top: 37vh;
  }

  .mirror__flip,
  .mirror__water,
  .mirror__rim,
  .mirror__back-plate {
    height: 36vh;
  }

  .mirror__rim--inner {
    height: 34vh;
  }

  .windows {
    top: calc(36vh - 0.926667 * var(--win-h));
  }
}


@media (max-width: 767px) {
  .garden__far,
  .garden__mid,
  .garden__front,
  .windows,
  .window-labels {
    transform: none !important;
  }
}
