/* Keep the scene in view; move detailed navigation into an accessible phone sheet. */
.mobile-guide-trigger, .mobile-guide-heading, .mobile-shortcuts,
.mobile-stage-toolbar, .touch-controls, .mobile-operation-help { display: none; }
.guide-backdrop[hidden] { display: none; }
.project-info > summary { display: none; }
.project-info { flex-shrink: 0; }
.loading { z-index: 20; }
button, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid #bc975b; outline-offset: 3px; }
.stage.is-immersive { position: fixed; inset: 0; z-index: 40; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
.stage.is-immersive .stage-caption { display: none; }
.stage.is-immersive .room-nav { position: absolute; left: 23px; bottom: 20px; display: flex; gap: 6px; max-width: 63%; flex-wrap: wrap; z-index: 2; }
.stage.is-immersive .neighbor-tour { bottom: 72px; }
.is-touch-ui .touch-controls { display: contents; }
.touch-joystick, .touch-actions { position: absolute; z-index: 5; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); user-select: none; -webkit-user-select: none; touch-action: none; }
.touch-joystick { left: max(16px, env(safe-area-inset-left, 0px)); width: 112px; height: 112px; border: 1px solid #dfc89585; border-radius: 50%; background: radial-gradient(circle, #b18a4b18 0 42%, #251e16a8 43% 100%); box-shadow: inset 0 0 0 6px #d4b88609, 0 4px 22px #0002; }
.touch-joystick.is-active { border-color: #f5d794; background-color: #b4945a28; }
.joystick-knob { position: absolute; width: 44px; height: 44px; left: calc(50% - 22px); top: calc(50% - 22px); border: 1px solid #f1d49dba; border-radius: 50%; background: linear-gradient(145deg, #d8bd89db, #967344d9); box-shadow: 0 3px 12px #120c0570; pointer-events: none; }
.joystick-direction { position: absolute; color: #f2dfbfa8; line-height: 1; font-size: 20px; pointer-events: none; }
.joystick-direction.north { top: 7px; left: calc(50% - 6px); }
.joystick-direction.south { bottom: 10px; left: calc(50% - 6px); }
.joystick-direction.west { left: 9px; top: calc(50% - 12px); }
.joystick-direction.east { right: 9px; top: calc(50% - 12px); }
.joystick-label { position: absolute; left: 0; right: 0; bottom: -21px; text-align: center; color: #fff3dc; font-size: 11px; text-shadow: 0 1px 4px #000; pointer-events: none; }
.touch-actions { right: max(16px, env(safe-area-inset-right, 0px)); width: 110px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.touch-actions button { min-width: 0; min-height: 48px; padding: 6px 3px; border: 1px solid #d8bc8273; border-radius: 13px; color: #f4dfb6; background: #30261ae6; font-size: 21px; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-actions small { display: block; font-size: 10px; line-height: 1.4; }
.touch-actions #touch-door { grid-column: span 2; min-height: 44px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.touch-actions button:disabled { opacity: .55; }
.touch-actions button.is-held, .touch-actions #touch-door:not(:disabled) { color: #221a0e; border-color: #efd9ad; background: #d5b67c; }
.touch-tip { position: absolute; bottom: calc(226px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); padding: 8px 12px; border: 1px solid #e9c68d42; border-radius: 20px; color: #f3e3c5; background: #292016b8; font-size: 11px; white-space: nowrap; pointer-events: none; transition: opacity .5s; }
.touch-tip.is-dismissed { opacity: 0; }
.is-touch-ui .stage-hint { display: none; }
.is-touch-ui .look-reticle { opacity: .65; width: 9px; height: 9px; }
.is-touch-ui .look-reticle::before { height: 9px; width: 1px; }
.is-touch-ui .look-reticle::after { width: 9px; height: 1px; }
.is-touch-ui .door-hint { bottom: calc(226px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; font-size: 12px; z-index: 4; }

@media (max-width: 900px), (pointer: coarse) and (hover: none), (any-pointer: coarse) and (max-width: 1280px) {
  :root { --phone-header: calc(56px + env(safe-area-inset-top, 0px)); }
  html, body { height: 100%; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
  .topbar { height: var(--phone-header); padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px)); }
  .brand { gap: 9px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .brand-copy strong { font-size: 14px; }
  .brand-copy > span, .live-pill, .top-index { display: none; }
  .mobile-guide-trigger { display: block; min-height: 44px; padding: 0 15px; border: 1px solid #d7c5a4; border-radius: 11px; background: #f4eddf; color: #665132; font-size: 13px; }
  .layout { display: block; height: calc(100% - var(--phone-header)); min-height: 0; padding: 0 6px 6px; }
  .stage { height: 100%; min-height: 0; border-radius: 16px; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 60; display: flex; width: 100%; max-height: 88vh; max-height: 88dvh; min-height: 0; margin: 0; padding: 20px max(20px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); border: 1px solid #cabb9e; border-bottom: 0; border-radius: 24px 24px 0 0; background: #fbf8ef; box-shadow: 0 -12px 60px #160e0840; overflow: auto; overscroll-behavior: contain; visibility: hidden; transform: translateY(105%); transition: transform .24s ease, visibility .24s; }
  body.guide-is-open .sidebar { visibility: visible; transform: translateY(0); }
  .guide-backdrop { display: block; position: fixed; z-index: 55; inset: 0; width: 100%; border: 0; background: #100d09a6; backdrop-filter: blur(3px); touch-action: none; }
  .mobile-guide-heading { position: sticky; top: -20px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; margin-bottom: 18px; padding: 10px 0; background: #fbf8ef; }
  .mobile-guide-heading span { font-family: "Songti SC", "SimSun", serif; font-size: 21px; color: #483922; letter-spacing: .08em; }
  .mobile-guide-heading small { display: block; margin-top: 6px; font-size: 11px; color: #8b7c64; }
  #guide-close { flex-shrink: 0; width: 44px; height: 44px; border: 1px solid #e0d5be; border-radius: 50%; color: #6e5e43; background: #f2ecdf; font-size: 28px; }
  .mobile-shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 23px; }
  .mobile-shortcuts button { min-height: 68px; padding: 13px; border: 1px solid #e4d5ba; border-radius: 12px; background: #fffdf7; color: #4d3b22; text-align: left; font-size: 14px; }
  .mobile-shortcuts small { display: block; margin-top: 5px; color: #938063; font-size: 10px; }
  .mobile-shortcuts .active { border-color: #b39660; background: #eee3cb; }
  .project-info { order: 10; margin: 15px 0; }
  .project-info > summary { display: list-item; min-height: 44px; padding: 12px 0; color: #75634b; cursor: pointer; font-size: 13px; }
  .project-info h1 { margin-top: 10px; }
  .project-info .intro { font-size: 12px; margin-bottom: 16px; }
  .project-info .spec { gap: 12px; padding: 10px; }
  .project-info .spec strong { max-width: 62%; text-align: right; line-height: 1.6; }
  .sidebar .section-label { flex-shrink: 0; margin-top: 8px; font-size: 11px; }
  .sidebar .view-grid { flex-shrink: 0; gap: 8px; }
  .sidebar .view-button { min-height: 62px; }
  .sidebar .view-button span { font-size: 12px; }
  .sidebar .secondary-button { flex-shrink: 0; min-height: 46px; margin-top: 5px; }
  .sidebar-foot { order: 11; padding-top: 12px; margin-top: 0; }
  .mobile-operation-help { display: block; }
  .desktop-operation-help { display: none; }
  .stage-tag { top: 12px; left: max(12px, env(safe-area-inset-left, 0px)); max-width: calc(100% - 102px); min-height: 40px; padding: 9px 12px; font-size: 11px; z-index: 3; }
  .tag-number, .tag-divider { display: none; }
  #scene-mode-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stage-caption, .stage-hint { display: none; }
  .fullscreen-button { top: 12px; right: max(12px, env(safe-area-inset-right, 0px)); min-width: 68px; min-height: 44px; padding: 9px; border-radius: 13px; font-size: 12px; z-index: 4; }
  .walk-button { top: 64px; right: max(12px, env(safe-area-inset-right, 0px)); min-height: 44px; padding: 9px 13px; border-radius: 13px; font-size: 12px; z-index: 4; }
  .mobile-stage-toolbar { position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); top: 64px; display: flex; gap: 6px; z-index: 4; }
  .mobile-stage-toolbar button { min-height: 44px; padding: 9px 11px; border: 1px solid #d9bd7f73; border-radius: 13px; background: #30251bd9; color: #f1dcb3; font-size: 12px; }
  .stage .neighbor-tour, .stage:fullscreen .neighbor-tour, .stage.is-immersive .neighbor-tour { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.25fr); gap: 6px; padding: 6px; border-radius: 14px; z-index: 6; }
  .neighbor-tour > span, .neighbor-tour > button { display: none; }
  .neighbor-tour select { width: 100%; max-width: none; min-width: 0; height: 44px; padding: 0 7px; font-size: 16px; border-radius: 9px; }
  .stage:fullscreen .room-nav, .stage.is-immersive .room-nav { display: none; }
  .stage.is-immersive .stage-tag, .stage:fullscreen .stage-tag { top: calc(12px + env(safe-area-inset-top, 0px)); }
  .stage.is-immersive .fullscreen-button, .stage:fullscreen .fullscreen-button { top: calc(12px + env(safe-area-inset-top, 0px)); }
  .stage.is-immersive .mobile-stage-toolbar, .stage.is-immersive .walk-button, .stage:fullscreen .mobile-stage-toolbar, .stage:fullscreen .walk-button { top: calc(64px + env(safe-area-inset-top, 0px)); }
  .stage:fullscreen .door-hint, .stage.is-immersive .door-hint { bottom: calc(226px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 370px) {
  .mobile-stage-toolbar { gap: 4px; }
  .mobile-stage-toolbar button { padding: 8px; }
  .walk-button { padding: 8px 10px; }
  .touch-joystick { width: 100px; height: 100px; }
  .touch-actions { width: 100px; }
  .neighbor-tour select { font-size: 16px; padding-left: 4px; }
}

@media (max-height: 500px) and (max-width: 900px), (max-height: 500px) and (pointer: coarse) and (hover: none), (max-height: 500px) and (any-pointer: coarse) and (max-width: 1280px) {
  :root { --phone-header: calc(44px + env(safe-area-inset-top, 0px)); }
  .stage-tag, .fullscreen-button { top: 8px; }
  .mobile-stage-toolbar, .walk-button { top: 58px; }
  .is-touch-ui .touch-joystick { width: 96px; height: 96px; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
  .is-touch-ui .touch-actions { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: 104px; }
  .stage .neighbor-tour, .stage:fullscreen .neighbor-tour, .stage.is-immersive .neighbor-tour { left: 50%; right: auto; width: min(420px, calc(100% - 280px)); transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .touch-tip, .is-touch-ui .door-hint, .stage.is-immersive .door-hint, .stage:fullscreen .door-hint { bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { max-height: 96dvh; }
}
