/* Fixed 16:9 relief wall and single photo control. */
:root {
  --color-surround: #07080b;
  --color-accent: #e5d8b8;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap-target: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --duration-fast: 160ms;
  --ease-standard: cubic-bezier(.22, 1, .36, 1);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  background: var(--color-surround);
}
body { font: 1rem/1.5 var(--font-sans); color: #f3f1ec; }
p { margin: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.viewport-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--color-surround);
}
.stage-16x9 {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 100dvh;
  overflow: hidden;
  background: #10110f;
  box-shadow: 0 24px 80px #000b;
  touch-action: none;
  user-select: none;
  outline: none;
}
.stage-16x9:focus-visible { outline: 2px solid #9babbb; outline-offset: -3px; }
@media (pointer: fine) { body[data-light="on"] .stage-16x9 { cursor: none; } }
body[data-light="off"] .stage-16x9 { background: #101518; }
.relief-canvas, .air-beam-canvas, .hand-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.relief-canvas { z-index: 0; }
.air-beam-canvas { z-index: 2; }
.hand-canvas { z-index: 4; }
body[data-blackout='true'] { --color-surround: #000; }
body[data-blackout='true'] .stage-16x9 { background: #000; box-shadow: none; outline: none; }
body[data-blackout='true'] :is(.hand-canvas, .air-beam-canvas, .light-hint, .hud-top,
  .hand-model-notice, .wall-art-notice, .bgm-notice) { visibility: hidden; }
body[data-blackout='true'] .hud-icon-btn { pointer-events: none; }
.hand-model-notice, .wall-art-notice, .bgm-notice {
  position: absolute;
  z-index: 8;
  left: clamp(8px, 2%, 24px);
  top: clamp(12px, 4%, 28px);
  max-width: 44%;
  color: #e0e2db;
  text-shadow: 0 1px 3px #0a0c0e;
  font: 500 clamp(.65rem, 1.2vw, .82rem)/1.35 var(--font-sans);
  pointer-events: none;
}
.wall-art-notice { top: auto; bottom: 10%; }
.bgm-notice { top: auto; bottom: 18%; }
[data-wall-source='photo'] .wall-art-notice { display: none; }
.webgl-fallback {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 2.5rem;
  background: #17181c;
  color: #f4f4f1;
  text-align: center;
}
.light-hint {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: clamp(.45rem, 3.2%, 1.6rem);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(86%, 32rem);
  color: #e0e0d9;
  text-shadow: 0 1px 2px #111619, 0 0 6px #111619;
  font: 400 clamp(.64rem, 1.15vw, .75rem)/1.4 var(--font-sans);
  text-align: center;
  letter-spacing: .025em;
  pointer-events: none;
  transition: opacity 400ms ease;
}
.light-hint.is-dismissed { opacity: 0; }
.hud-top {
  position: absolute;
  top: max(clamp(6px, 1.8%, 20px), var(--safe-top));
  right: max(clamp(6px, 1.8%, 20px), var(--safe-right));
  z-index: 12;
  display: grid;
  justify-items: end;
  gap: .55rem;
  max-width: min(18rem, calc(100% - 26px));
  pointer-events: none;
}
.hud-icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap-target);
  height: var(--tap-target);
  padding: 0;
  color: #d3d1c7;
  background: #171b1bd6;
  border: 1px solid #cbd4cc48;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  transition: transform var(--duration-fast) var(--ease-standard),
    background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}
.hud-icon-btn:is(:hover, :focus-visible) {
  color: #fff6e3;
  background: #28302f;
  border-color: #a99d84;
}
.hud-icon-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.hud-icon-btn:active { transform: scale(.94); }
.photo-layers {
  width: min(37rem, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  overflow: auto;
  overscroll-behavior: contain;
  color: #f1ece0;
  background: #171a1b;
  border: 1px solid #68655b;
  border-radius: 12px;
  padding: clamp(15px, 4vw, 30px);
  box-shadow: 0 28px 110px #000a;
}
.photo-layers::backdrop { background: #06080ad1; }
.photo-layer-header { margin-bottom: 22px; }
.photo-layer-header > p:first-child {
  color: #d0bb91;
  font: 600 .68rem/1.4 var(--font-sans);
  letter-spacing: .19em;
}
.photo-layer-header h1 {
  font: 400 clamp(1.65rem, 5vw, 2.25rem)/1.24 "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  letter-spacing: .025em;
  margin: .3rem 0 .55rem;
}
#photo-layer-intro { max-width: 42ch; color: #cfccc3; font-size: .9rem; line-height: 1.5; }
.photo-layer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 2.4vw, 16px); }
.photo-layer-slot { min-width: 0; }
.photo-layer-meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: .7rem; margin-bottom: .45rem; }
.photo-layer-meta h2 { margin: 0; font: 600 .875rem/1.45 var(--font-sans); }
.photo-layer-meta span { color: #b9b9b0; font-size: .72rem; }
[data-photo-role='upper'] .photo-layer-meta span { color: #ddc99d; }
.photo-pick, .photo-action {
  font: inherit;
  cursor: pointer;
  color: #eeeae1;
  border: 1px solid #6a6c66;
  background: #232729;
  min-height: var(--tap-target);
}
.photo-pick { width: 100%; display: block; border-radius: 8px; padding: 0; overflow: hidden; text-align: left; }
[data-photo-role='upper'] .photo-pick { border-color: #907e59; }
.photo-preview { display: grid; place-items: center; position: relative; aspect-ratio: 16 / 9; background: #101213; }
.photo-preview canvas { position: absolute; width: 100%; height: 100%; inset: 0; }
.photo-placeholder { color: #e1cda7; font: 300 1.65rem/1 var(--font-sans); border: 1px solid #7f7056; border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; }
[data-photo-role='lower'] .photo-placeholder { color: #c7cacf; border-color: #687079; }
[data-filled='true'] .photo-placeholder { visibility: hidden; }
.photo-filename { display: block; padding: .65rem .7rem; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-pick[aria-busy='true'] .photo-filename { color: #dfcda7; }
.photo-pick:not(:disabled):hover, .photo-action:not(:disabled):hover { background: #303535; }
.photo-layers button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.photo-layer-status { min-height: 2.95em; margin: 13px 0 8px; color: #c8c5bd; font-size: .77rem; overflow-wrap: anywhere; }
.photo-layer-status[data-kind='error'] { color: #ffcab4; }
.photo-layer-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem; }
.photo-action { border-radius: 6px; padding: .55rem .8rem; font-size: .83rem; }
.photo-swap { margin-right: auto; }
.photo-apply { background: #deca9f; border-color: #e2cca4; color: #211b12; font-weight: 650; }
.photo-apply:not(:disabled):hover { background: #efdfbd; }
.photo-action:disabled { opacity: .46; cursor: default; }
@media (max-width: 397px) {
  .photo-swap { flex: 1 0 100%; margin-right: 0; }
  .photo-action:not(.photo-swap) { flex: 1; }
  .photo-layer-header { margin-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

.light-tools{position:fixed;right:20px;top:88px;z-index:30;color:#eee8d8;font:14px/1.5 system-ui,sans-serif}.light-tools summary{list-style:none;display:flex;align-items:center;justify-content:center;width:44px;height:44px;margin-left:auto;border:1px solid #ffffff38;border-radius:50%;background:#171c1bd9;cursor:pointer;font-size:26px;user-select:none}.light-tools summary::-webkit-details-marker{display:none}.light-tools-panel{width:230px;padding:18px;margin-top:10px;background:#171c1bf2;border:1px solid #ffffff28;border-radius:14px;box-shadow:0 12px 36px #0005}.light-tools h2{font-size:15px;margin:0 0 16px}.light-tools label{display:flex;justify-content:space-between;gap:12px;margin-top:16px}.light-tools output{color:#baa984;font-variant-numeric:tabular-nums}.light-tools input{display:block;width:100%;margin:12px 0 4px;accent-color:#c8b27b;cursor:pointer}.light-tools summary:focus-visible,.light-tools input:focus-visible{outline:2px solid #c8b27b;outline-offset:4px}@media(max-width:600px){.light-tools{right:14px;top:78px}.light-tools-panel{width:210px}}

/* Both controls share one responsive layout; no independent viewport offsets. */
.hud-top{display:flex;flex-direction:column;align-items:flex-end;gap:12px;overflow:visible}.hud-top .light-tools{position:relative;top:auto;right:auto;z-index:30;pointer-events:auto}.hud-top .light-tools summary{width:var(--tap-target);height:var(--tap-target);margin:0}.hud-top .light-tools-panel{position:absolute;right:calc(100% + 12px);top:0;margin:0;max-width:calc(100vw - 100px)}@media(max-width:600px){.hud-top .light-tools{top:auto;right:auto}.hud-top .light-tools-panel{top:calc(100% + 10px);right:0;max-width:calc(100vw - 28px)}}

/* Darkness stays immersive until the next click restores the light. */
body[data-light='off'],body[data-light='off'] *{cursor:none!important}body[data-light='off'] .hand-canvas,body[data-light='off'] .air-beam-canvas{visibility:hidden!important}
