:root { font-family: system-ui, "Noto Sans TC", sans-serif; color: #f7f0e1; background: #151b1f; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
#app { height: 100dvh; min-height: 280px; position: relative; overflow: hidden; }
#viewport { position: absolute; inset: 0; touch-action: none; }
#viewport canvas { display: block; width: 100%; height: 100%; }
#poster { position: absolute; z-index: 20; inset: 0; display: grid; place-items: end start; background: #27343a; }
#poster img { position: absolute; width: 100%; height: 100%; object-fit: cover; object-position: center; }
#poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, #0b131bd9 0%, #0b131b92 40%, #0000 80%), linear-gradient(0deg, #111a24bb, #0000 45%); }
.poster-content { position: relative; z-index: 1; max-width: 680px; padding: clamp(20px, 5vw, 66px); }
.poster-content h1 { font-size: 2.6rem; margin: 0 0 10px; letter-spacing: 0; }
.poster-content p { max-width: 34em; line-height: 1.7; }
#enter { font-size: 1.05rem; min-height: 46px; padding: 8px 18px; background: #8b563d; border-color: #dfb184; }
#open-atlas { min-height: 46px; margin-left: 8px; padding: 8px 16px; background: #1c3838; }
#loading-status { min-height: 1.5em; font-size: .9rem; color: #e8dec8; }
.atlas { position: absolute; z-index: 35; inset: 0; overflow: auto; background: #101a1c; color: #f7f0e1; }
.atlas-inner { max-width: 980px; margin: 0 auto; padding: 0 24px 48px; }
.atlas-header { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 14px; background: #101a1c; border-bottom: 1px solid #64807b; }
.atlas-header h2 { margin: 0; font-size: 1.6rem; }
.atlas-search { display: block; margin: 22px 0 8px; font-size: .95rem; }
.atlas-search input { display: block; width: min(100%, 480px); min-height: 44px; margin-top: 6px; padding: 8px 10px; border: 1px solid #a99c75; border-radius: 4px; color: #fff; background: #263334; font: inherit; }
.atlas-search input:focus-visible, .atlas-entry summary:focus-visible { outline: 3px solid #f0ce83; outline-offset: 2px; }
#atlas-status { min-height: 1.4em; color: #c9d6d0; font-size: .85rem; }
.atlas-group { margin: 28px 0 0; }
.atlas-group h3 { margin: 0 0 4px; padding-bottom: 8px; border-bottom: 2px solid #8ca7a0; color: #e9d6b3; font-size: 1.1rem; }
.atlas-entry { border-bottom: 1px solid #425656; padding: 2px 0 10px; }
.atlas-entry summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.atlas-entry p { max-width: 62em; margin: 2px 0 8px; line-height: 1.65; }
.atlas-entry small { display: block; margin-bottom: 10px; color: #c3d2cd; }
.atlas-entry nav { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 12px; }
.atlas-entry a { color: #f2d393; text-underline-offset: 3px; }
.atlas-entry button { margin-bottom: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.toolbar { position: absolute; z-index: 10; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); width: min(540px, calc(100% - 24px)); display: grid; gap: 8px; padding: 10px 12px; border: 1px solid #a08f72; border-radius: 8px; background: #172126ed; box-shadow: 0 4px 18px #0006; }
.toolbar-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.toolbar-actions, .camera-controls { display: flex; gap: 6px; flex-shrink: 0; }
.toolbar h1 { margin: 0; font-size: 1.15rem; white-space: nowrap; }
.toolbar h1 small { display: block; font-size: 0.7rem; font-weight: 400; color: #ddd0b7; }
.toolbar label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.place-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; }
.place-bar select { width: 100%; min-width: 0; }
.scene-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; max-height: calc(100dvh - 190px); overflow: auto; padding: 12px 0 2px; border-top: 1px solid #637674; overscroll-behavior: contain; }
.scene-controls .view-control { grid-column: 1 / -1; }
.scene-controls select { flex: 1; min-width: 0; }
.camera-controls button { width: 44px; padding: 0; font-size: 1.2rem; }
button, select { min-height: 36px; border: 1px solid #af9871; border-radius: 5px; background: #2a3838; color: #fff6e7; font: inherit; padding: 5px 9px; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, select:focus-visible { outline: 3px solid #f0ce83; outline-offset: 2px; }
#info { position: absolute; z-index: 11; right: 16px; bottom: 60px; max-width: min(360px, calc(100vw - 32px)); max-height: 42vh; overflow: auto; padding: 16px; background: #172126f2; border: 1px solid #ac9166; border-radius: 8px; line-height: 1.6; }
#info h2 { margin: 0; font-size: 1.15rem; }
#info h2:focus { outline: 2px solid #f0ce83; outline-offset: 3px; }
#info p { margin: 8px 0; }
#info small { display: block; color: #c9bea8; margin-bottom: 12px; }
#info nav { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; }
#info a, #error a { color: #ffe0a4; text-underline-offset: 3px; }
#info a:focus-visible, #error a:focus-visible { outline: 3px solid #f0ce83; outline-offset: 2px; }
.caption { position: absolute; z-index: 10; left: max(12px, env(safe-area-inset-left)); bottom: max(8px, env(safe-area-inset-bottom)); max-width: min(620px, calc(100% - 24px)); max-height: 25dvh; overflow: auto; margin: 0; padding: 5px 8px; font-size: 0.75rem; line-height: 1.5; background: #182122ed; border-radius: 4px; }
.caption summary { cursor: pointer; min-height: 28px; display: list-item; }
.caption p { margin: 6px 0; }
#error { position: absolute; z-index: 30; inset: auto 15px 70px; background: #332522; border: 1px solid #d2a17d; padding: 18px; border-radius: 7px; }
#error a { color: #ffe0a4; }
@media (max-width: 700px) {
  .poster-content { padding: 20px 16px 65px; }
  .poster-content h1 { font-size: 2rem; }
  #open-atlas { margin: 8px 0 0; }
  .atlas-inner { padding: 0 16px 32px; }
  .atlas-header { padding: 12px 0; }
  .atlas-header h2 { font-size: 1.25rem; }
  .toolbar { top: max(6px, env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left)); width: calc(100% - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)); gap: 6px; padding: 6px; }
  .toolbar h1 { font-size: 1rem; }
  .toolbar h1 small { font-size: .65rem; }
  .toolbar-actions { gap: 4px; }
  .toolbar label { font-size: 0.85rem; }
  button, select { min-height: 44px; padding: 4px 7px; font-size: 0.85rem; }
  .toolbar-actions button { min-width: 44px; }
  .camera-controls { grid-column: 1 / -1; }
  .camera-controls button { flex: 0 0 44px; }
  .scene-controls { gap: 8px; max-height: calc(100dvh - 175px); }
  #info { left: 8px; right: 8px; bottom: max(58px, env(safe-area-inset-bottom)); max-width: none; max-height: calc(100dvh - 190px); }
  .caption { left: max(6px, env(safe-area-inset-left)); bottom: max(5px, env(safe-area-inset-bottom)); font-size: 0.73rem; }
}
@media (max-height: 480px) and (min-width: 701px) {
  .toolbar { width: min(450px, calc(100% - 24px)); padding: 6px 8px; gap: 6px; }
  .scene-controls { max-height: calc(100dvh - 150px); }
  #info { top: 12px; bottom: auto; max-height: calc(100dvh - 70px); max-width: min(310px, calc(100% - 480px)); }
}
@media (max-width: 350px) {
  #info { max-height: calc(100dvh - 220px); }
  .toolbar-heading { flex-wrap: wrap; }
  .toolbar h1 { display: flex; align-items: baseline; gap: 8px; }
  .toolbar-actions { width: 100%; justify-content: space-between; }
  .toolbar-actions button { flex: 1; }
}
