* { box-sizing: border-box }
html, body { width: 100%; height: 100%; }
body { padding: 0; margin: 0; overflow: hidden; background: #231F20; }
#unity-container { position: absolute; overflow: hidden; }
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
#unity-container.unity-mobile { left: 50%; top: 50%; transform: translate(-50%, -50%); }
#unity-canvas { display: block; background: #231F20; touch-action: none; }
.unity-mobile #unity-canvas { display: block; }
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-dark.png') no-repeat center }
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }
#unity-footer { position: relative }
.unity-mobile #unity-footer { display: none }
#unity-build-title { float: left; margin-left: 10px; line-height: 38px; font-family: arial; font-size: 18px }
#unity-fullscreen-button { float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }

/* The scene keeps Unity's original 960x600 (8:5) framing. On touch devices
   the canvas is sized by index.html to the largest centered 8:5 rectangle that
   fits the viewport, while these controls stay in screen space. */
/* iOS ignores user-scalable=no, so the letterbox bars must not pinch-zoom or
   open the long-press callout either. */
body.touch-layout { touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
#touch-ui { display: none; position: fixed; inset: 0; z-index: 20; pointer-events: none; touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
body.touch-layout #touch-ui { display: block; }
#touch-joystick { position: absolute; left: max(5vw, calc(env(safe-area-inset-left) + 12px)); bottom: max(6vh, calc(env(safe-area-inset-bottom) + 12px)); width: clamp(112px, 22vw, 168px); height: clamp(112px, 22vw, 168px); border: 2px solid rgba(255,255,255,.55); border-radius: 50%; background: rgba(25,20,18,.30); box-shadow: 0 2px 12px rgba(0,0,0,.28); pointer-events: auto; touch-action: none; }
#touch-joystick::after { content: ""; position: absolute; inset: 18%; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; }
#touch-stick { position: absolute; left: 50%; top: 50%; width: 38%; height: 38%; border-radius: 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,.66); box-shadow: 0 1px 7px rgba(0,0,0,.35); pointer-events: none; }
#touch-exit { position: absolute; z-index: 2; right: max(4vw, calc(env(safe-area-inset-right) + 12px)); top: max(4vh, calc(env(safe-area-inset-top) + 8px));min-width: 112px; height: 40px; padding: 0 14px; border: 1px solid rgba(255,255,255,.65); border-radius: 8px; background: rgba(25,20,18,.62); color: #fff; font: 16px sans-serif; box-shadow: 0 2px 10px rgba(0,0,0,.28); pointer-events: auto; touch-action: manipulation; }
/* Unity reports the current space through YulanPage.jslib; the hall itself
   has nothing to return to. */
body.in-museum #touch-exit { display: none; }
#touch-look { position: absolute; right: 0; top: 0; width: 58%; height: 100%; pointer-events: auto; touch-action: none; }
#rotate-hint { display: none; position: absolute; left: 50%; top: max(12vh, calc(env(safe-area-inset-top) + 64px)); transform: translateX(-50%); width: max-content; max-width: 86vw; padding: 10px 16px; border-radius: 8px; background: rgba(25,20,18,.72); color: #fff; font: 15px/1.5 sans-serif; text-align: center; }
@media (orientation: portrait) {
  body.touch-layout #rotate-hint { display: block; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #touch-joystick { bottom: max(4vh, calc(env(safe-area-inset-bottom) + 8px)); }
}
/* Run toggle, right of the joystick and level with its centre. */
#touch-run { position: absolute; z-index: 2; left: calc(max(5vw, calc(env(safe-area-inset-left) + 12px)) + clamp(112px, 22vw, 168px) + 14px); bottom: calc(max(6vh, calc(env(safe-area-inset-bottom) + 12px)) + clamp(112px, 22vw, 168px) / 2 - 22px); min-width: 64px; height: 44px; padding: 0 14px; border: 1px solid rgba(255,255,255,.65); border-radius: 22px; background: rgba(25,20,18,.62); color: #fff; font: 16px sans-serif; box-shadow: 0 2px 10px rgba(0,0,0,.28); pointer-events: auto; touch-action: manipulation; }
#touch-run.active { background: #ffd25a; border-color: #ffd25a; color: #2a1d10; font-weight: 600; }
@media (orientation: landscape) and (max-height: 520px) {
  #touch-run { bottom: calc(max(4vh, calc(env(safe-area-inset-bottom) + 8px)) + clamp(112px, 22vw, 168px) / 2 - 22px); }
}

/* Desktop HUD over the 8:5 canvas box (also in page fullscreen). Unity sets
   body.in-museum / body.aim-target / body.aim-portal through YulanPage.jslib;
   index.html sets body.pointer-locked and body.unity-ready. */
#hud { display: none; position: absolute; left: 0; top: 0; z-index: 10; width: 100%; aspect-ratio: 8 / 5; pointer-events: none; font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif; color: #fff; }
body.unity-ready:not(.touch-layout) #hud { display: block; }
body.unity-ready.touch-layout.aim-target #hud { display: block; }
body.touch-layout #hud #hud-exit-group { display: none; }
#touch-portal-tip { display: none; position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 4px 10px; border-radius: 6px; background: rgba(25,20,18,.78); color: white; font: 14px/1.5 sans-serif; pointer-events: none; }
body.touch-layout.unity-ready.in-museum:not(.aim-target) #touch-portal-tip { display: block; }
/* Pointer Lock hides the cursor, so mark the click point. */
#hud-crosshair { display: none; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; }
body.pointer-locked #hud-crosshair { display: block; }
#hud-crosshair svg { display: block; width: 100%; height: 100%; overflow: visible; fill: none; stroke: #fff; stroke-width: 2; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.95)); transition: transform .12s ease-out; }
#hud-crosshair .dot { fill: #fff; stroke: none; }
body.aim-target #hud-crosshair svg { transform: scale(1.3); stroke: #ffd25a; }
body.aim-target #hud-crosshair .dot { fill: #ffd25a; }
/* Label at the aimed object: under the crosshair, or next to the free cursor. */
#hud-aim-label { display: none; position: absolute; left: 50%; top: calc(50% + 24px); transform: translateX(-50%); padding: 3px 10px; border-radius: 999px; background: #ffd25a; color: #2a1d10; font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 6px rgba(0,0,0,.45); }
body:not(.pointer-locked) #hud-aim-label { transform: none; }
body.touch-layout.aim-target #hud-aim-label { top: calc(50% + 12px); transform: translateX(-50%); }
body.touch-layout.aim-target #hud-crosshair { display: block; width: 18px; height: 18px; margin: -9px 0 0 -9px; }
body.aim-target #hud-aim-label { display: block; }
#hud-aim-label .portal, body.aim-portal #hud-aim-label .click { display: none; }
body.aim-portal #hud-aim-label .portal { display: inline; }
/* Unity writes an inline cursor style on the canvas. */
body.aim-target:not(.pointer-locked) #unity-canvas { cursor: pointer !important; }
#hud-exit { display: none; position: absolute; top: 12px; right: 12px; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 14px; border: 1px solid rgba(255,255,255,.7); border-radius: 8px; background: rgba(25,20,18,.72); color: #fff; font: 15px "PingFang TC", "Microsoft JhengHei", sans-serif; box-shadow: 0 2px 10px rgba(0,0,0,.35); cursor: pointer; pointer-events: auto; }
#hud-exit:hover { background: rgba(70,45,25,.85); border-color: #ffd25a; }
#hud-exit kbd { padding: 1px 6px; border: 1px solid rgba(255,255,255,.6); border-radius: 4px; font: 12px/1.4 Consolas, monospace; }
body:not(.in-museum) #hud-exit { display: flex; }
/* Return button with its Esc hint underneath (pages from 20261029 on). */
#hud-exit-group { display: none; position: absolute; top: 12px; right: 12px; flex-direction: column; align-items: flex-end; gap: 4px; }
body:not(.in-museum) #hud-exit-group { display: flex; }
#hud-exit-group #hud-exit { position: static; padding: 0 16px; }
#hud-exit-tip { padding: 2px 8px; border-radius: 4px; background: rgba(25,20,18,.6); font-size: 12px; line-height: 1.5; }
