/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #050508;
  --bg-elevated: #0c0c12;
  --gold: #d4a853;
  --gold-bright: #f0d78c;
  --gold-dim: #8a6b2e;
  --text: #c8c4bc;
  --text-dim: #6a665e;
  --door: #121018;
  --door-edge: #2a2438;
  --light: rgba(255, 220, 140, 0.85);
  --light-soft: rgba(255, 200, 100, 0.25);
  --font-display: "Cinzel", "Noto Serif SC", serif;
  --font-body: "Noto Serif SC", Georgia, serif;
}

html, body {
  height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.hidden { display: none !important; }

/* ===== Scenes ===== */
.scene {
  min-height: 100vh;
  position: relative;
}

.scene--gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 40% at 50% 55%, #1a1520 0%, transparent 70%),
    radial-gradient(circle at 50% 100%, #0f0a18 0%, var(--bg) 55%),
    var(--bg);
  transition: opacity 0.9s ease, filter 0.9s ease;
}

.scene--gate.scene--fade {
  opacity: 0;
  filter: blur(4px);
}

.gate-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,0.75) 100%);
}

.gate-hint {
  position: absolute;
  top: 18%;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.35em;
  color: var(--text-dim);
  animation: pulse-hint 2.5s ease-in-out infinite;
  transition: opacity 0.5s;
}

.gate-hint.fade-out { opacity: 0; }

@keyframes pulse-hint {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ===== Login ===== */
.scene--login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom));
  background: var(--bg);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.65s ease;
}

.scene--login.scene--visible {
  opacity: 1;
}

.login-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.login-light-beam {
  position: absolute;
  left: 50%;
  top: -10%;
  width: min(420px, 90vw);
  height: 75vh;
  transform: translateX(-50%);
  background: linear-gradient(
    180deg,
    rgba(255, 228, 160, 0.22) 0%,
    rgba(212, 168, 83, 0.08) 35%,
    transparent 70%
  );
  filter: blur(28px);
  animation: login-beam 4s ease-in-out infinite;
}

@keyframes login-beam {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) scaleX(0.92); }
  50% { opacity: 1; transform: translateX(-50%) scaleX(1.05); }
}

.login-particles {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(212, 168, 83, 0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 80% 20%, rgba(212, 168, 83, 0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 80%, rgba(212, 168, 83, 0.2) 0%, transparent 100%);
  background-size: 100% 100%;
  opacity: 0.6;
  animation: login-drift 20s linear infinite;
}

@keyframes login-drift {
  from { transform: translateY(0); }
  to { transform: translateY(-12px); }
}

.login-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 55% 45% at 50% 35%, transparent 0%, rgba(5, 5, 8, 0.4) 55%, rgba(5, 5, 8, 0.92) 100%);
}

.login-shell {
  position: relative;
  z-index: 2;
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: login-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.scene--login:not(.scene--visible) .login-shell {
  animation: none;
}

@keyframes login-rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-ornament-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1rem;
}

.login-arch {
  font-size: 0.9rem;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(212, 168, 83, 0.6);
  animation: login-pulse-icon 2.5s ease-in-out infinite;
}

@keyframes login-pulse-icon {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.login-line {
  width: 1px;
  height: 32px;
  margin-top: 0.5rem;
  background: linear-gradient(180deg, var(--gold) 0%, transparent 100%);
  opacity: 0.5;
}

.login-card {
  position: relative;
  width: 100%;
  padding: 2rem 1.75rem 1.75rem;
  background:
    linear-gradient(165deg, rgba(28, 22, 38, 0.97) 0%, rgba(10, 8, 14, 0.99) 55%, rgba(6, 5, 9, 1) 100%);
  border-radius: 2px;
  overflow: hidden;
}

.login-card-glow {
  position: absolute;
  inset: -1px;
  background: linear-gradient(
    135deg,
    rgba(212, 168, 83, 0.45) 0%,
    transparent 40%,
    transparent 60%,
    rgba(212, 168, 83, 0.2) 100%
  );
  opacity: 0.35;
  pointer-events: none;
  animation: login-border-glow 5s ease-in-out infinite;
}

@keyframes login-border-glow {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.5; }
}

.login-card-border {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(212, 168, 83, 0.25);
  border-radius: 2px;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 60px rgba(212, 168, 83, 0.03),
    0 24px 80px rgba(0, 0, 0, 0.65);
}

.login-card-border::before,
.login-card-border::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--gold-dim);
  border-style: solid;
  opacity: 0.6;
}

.login-card-border::before {
  top: 8px;
  left: 8px;
  border-width: 1px 0 0 1px;
}

.login-card-border::after {
  bottom: 8px;
  right: 8px;
  border-width: 0 1px 1px 0;
}

.login-card--shake {
  animation: login-shake 0.45s ease;
}

@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.login-header {
  text-align: center;
  margin-bottom: 1.75rem;
  position: relative;
  z-index: 1;
}

.login-eyebrow {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.45em;
  color: var(--gold-dim);
  opacity: 0.9;
}

.login-title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 5vw, 1.65rem);
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--gold-bright);
  margin-top: 0.65rem;
  text-shadow: 0 0 40px rgba(212, 168, 83, 0.25);
}

.login-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.6rem;
  letter-spacing: 0.12em;
}

.login-fields {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login-field {
  display: block;
}

.login-field-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.login-icon {
  width: 14px;
  height: 14px;
  color: var(--gold-dim);
  opacity: 0.85;
}

.login-field input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.55);
  border: none;
  border-bottom: 1px solid rgba(212, 168, 83, 0.2);
  border-radius: 4px 4px 0 0;
  outline: none;
  transition:
    background 0.25s,
    border-color 0.25s,
    box-shadow 0.25s;
}

.login-field input::placeholder {
  color: rgba(106, 102, 94, 0.7);
  letter-spacing: 0.05em;
}

.login-field input:focus {
  background: rgba(212, 168, 83, 0.06);
  border-bottom-color: var(--gold);
  box-shadow: 0 4px 24px rgba(212, 168, 83, 0.12);
}

.login-error {
  position: relative;
  z-index: 1;
  font-size: 0.8rem;
  color: #f0a8a8;
  text-align: center;
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(180, 60, 60, 0.12);
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.login-error:not(.hidden) {
  animation: login-error-in 0.3s ease;
}

@keyframes login-error-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-submit {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.35em;
  color: #1a1408;
  background: transparent;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s;
}

.login-submit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    #c9a04a 0%,
    var(--gold-bright) 35%,
    var(--gold) 70%,
    #a8843a 100%
  );
  background-size: 200% 100%;
  transition: background-position 0.4s ease;
  z-index: -1;
}

.login-submit:hover::before,
.login-submit:focus-visible::before {
  background-position: 100% 0;
}

.login-submit-text {
  position: relative;
}

.login-submit-arrow {
  position: relative;
  font-size: 1.1rem;
  transition: transform 0.25s ease;
}

.login-submit:hover .login-submit-arrow,
.login-submit:focus-visible .login-submit-arrow {
  transform: translateX(4px);
}

.login-submit:active {
  transform: scale(0.98);
}

.login-footer-note {
  margin-top: 1.25rem;
  font-size: 0.68rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  opacity: 0.45;
  text-align: center;
}

.gate-title {
  position: absolute;
  bottom: max(12%, env(safe-area-inset-bottom));
  font-family: var(--font-display);
  font-size: clamp(0.75rem, 2.5vw, 1rem);
  letter-spacing: 0.5em;
  color: var(--gold-dim);
  opacity: 0.6;
}

/* ===== Door frame ===== */
.door-frame {
  position: relative;
  width: min(280px, 72vw);
  height: min(420px, 58vh);
  perspective: 1200px;
  perspective-origin: 50% 45%;
}

.door-light {
  position: absolute;
  inset: -40% -60%;
  background: radial-gradient(
    ellipse 35% 55% at 50% 50%,
    var(--light) 0%,
    var(--light-soft) 25%,
    transparent 65%
  );
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 1.2s ease 0.35s, transform 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
  pointer-events: none;
  z-index: 0;
  filter: blur(8px);
}

.door-light--on {
  opacity: 1;
  transform: scale(1);
}

.door-gap {
  position: absolute;
  left: 50%;
  top: 0;
  width: 4px;
  height: 100%;
  transform: translateX(-50%);
  overflow: hidden;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s;
}

.door-gap--open { opacity: 1; }

.door-gap-glow {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--gold-bright) 30%,
    #fff8e0 50%,
    var(--gold-bright) 70%,
    transparent 100%
  );
  box-shadow: 0 0 40px 20px var(--light-soft);
  animation: gap-flicker 3s ease-in-out infinite;
}

@keyframes gap-flicker {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

/* ===== Doors (open backward) ===== */
.door {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 2;
  transform-style: preserve-3d;
  transition: transform 1.35s cubic-bezier(0.4, 0, 0.15, 1);
}

.door--left {
  left: 0;
  transform-origin: left center;
}

.door--right {
  right: 0;
  transform-origin: right center;
}

.door--left.door--open {
  transform: rotateY(-108deg);
}

.door--right.door--open {
  transform: rotateY(108deg);
}

.door-panel {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(135deg, #1e1a28 0%, var(--door) 40%, #0a0810 100%);
  border: 2px solid var(--door-edge);
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.8),
    inset 4px 0 12px rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
}

.door--left .door-panel {
  border-right: 1px solid #000;
  border-radius: 4px 0 0 4px;
}

.door--right .door-panel {
  border-left: 1px solid #000;
  border-radius: 0 4px 4px 0;
}

.door-ornament {
  font-size: 1.2rem;
  color: var(--gold-dim);
  opacity: 0.5;
  text-shadow: 0 0 12px var(--gold);
}

.door-knob {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: radial-gradient(circle at 30% 30%, var(--gold-bright), var(--gold-dim));
  cursor: pointer;
  box-shadow: 0 0 16px rgba(212, 168, 83, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.door-knob:hover {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 0 24px rgba(240, 215, 140, 0.6);
}

.door-knob:disabled {
  cursor: default;
  opacity: 0.5;
}

/* ===== Maze scene ===== */
.scene--maze {
  padding: max(1rem, env(safe-area-inset-top)) clamp(0.75rem, 4vw, 2.5rem) max(1.5rem, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #15121c 0%, transparent 50%),
    var(--bg);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.scene--maze.scene--visible {
  opacity: 1;
  transform: translateY(0);
}

.maze-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.maze-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  letter-spacing: 0.2em;
  color: var(--gold);
  font-weight: 600;
}

.maze-sub {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.maze-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.maze-room-list {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.maze-room-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem;
  min-height: 44px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: rgba(12, 10, 18, 0.92);
  border: 1px solid var(--door-edge);
  border-radius: 999px;
  cursor: pointer;
}

.maze-room-chip:active {
  border-color: var(--gold);
  background: rgba(212, 168, 83, 0.12);
}

.btn-back {
  position: absolute;
  left: clamp(0.75rem, 4vw, 2.5rem);
  top: max(1rem, env(safe-area-inset-top));
  min-height: 44px;
  min-width: 44px;
  background: transparent;
  border: 1px solid var(--door-edge);
  color: var(--text-dim);
  padding: 0.4rem 0.8rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.2s, border-color 0.2s;
}

.btn-back:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
}

.maze-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 520;
  min-height: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--door-edge);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.maze-svg {
  width: 100%;
  height: 100%;
  color: var(--gold-dim);
  opacity: 0.35;
}

.room-nodes {
  position: absolute;
  inset: 0;
}

.room-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.7rem;
  min-width: 48px;
  min-height: 48px;
  background: rgba(12, 10, 18, 0.92);
  border: 1px solid var(--door-edge);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  min-width: 72px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: room-appear 0.6s ease backwards;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}

.room-node:hover {
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(212, 168, 83, 0.25);
  transform: translate(-50%, -50%) scale(1.06);
}

.room-node-icon { font-size: 1.4rem; }

.room-node-name {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--gold-dim);
  white-space: nowrap;
}

@keyframes room-appear {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
}

.maze-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.maze-footer code {
  color: var(--gold-dim);
  font-size: 0.85em;
}

/* ===== Room dialog ===== */
.room-dialog {
  border: none;
  padding: 0;
  margin: auto;
  max-width: min(720px, 100%);
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: transparent;
  color: var(--text);
}

.room-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
}

.room-dialog-inner {
  background: linear-gradient(160deg, #141018 0%, #0a090e 100%);
  border: 1px solid var(--door-edge);
  border-radius: 12px;
  padding: 1.25rem;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  max-height: min(85vh, 100dvh);
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 0 60px rgba(212, 168, 83, 0.08);
  position: relative;
}

.room-dialog--gallery .room-dialog-inner {
  max-height: 100dvh;
  height: 100dvh;
  border-radius: 0;
  border: none;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.room-dialog--gallery .room-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.room-dialog--gallery .room-close {
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 200;
}

.gallery-hint {
  position: absolute;
  bottom: max(0.65rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  white-space: nowrap;
  z-index: 150;
  pointer-events: none;
  padding: 0.35rem 0.75rem;
  background: rgba(0,0,0,0.5);
  border-radius: 999px;
}

.room-close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
}

.room-close:hover { background: rgba(212, 168, 83, 0.2); }

.room-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding-right: 2rem;
}

.room-icon { font-size: 2.5rem; }

.room-header h2 {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 1.35rem;
  letter-spacing: 0.1em;
}

.room-header p {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ===== 相册房：飘动 + 点击居中 ===== */
.gallery-topbar {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top));
  left: max(0.75rem, env(safe-area-inset-left));
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 0.95rem;
  pointer-events: none;
  text-shadow: 0 2px 8px #000;
}

.gallery-arena {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 60vh;
  overflow: hidden;
  perspective: 1100px;
  perspective-origin: 50% 45%;
  transform-style: preserve-3d;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, rgba(30, 24, 40, 0.9) 0%, #050508 100%);
}

.gallery-arena-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(212, 168, 83, 0.06) 0%, transparent 55%);
  pointer-events: none;
  animation: arena-pulse 6s ease-in-out infinite;
  z-index: 0;
}

.gallery-arena-stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  z-index: 1;
  /* 避免子元素 3D 与父级层叠上下文冲突导致互相穿刺 */
  transform: translateZ(0);
}

@keyframes arena-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* 2.5D：平面始终朝向镜头，仅用平移/景深/平面旋转，重叠时不穿刺 */
@keyframes photo-space-3d {
  0%, 100% {
    transform: translate(-50%, -50%)
      translate3d(var(--x0, 0), var(--y0, 0), var(--z0, 0))
      rotateZ(var(--rz0, 0deg))
      scale(var(--sc0, 1));
  }
  25% {
    transform: translate(-50%, -50%)
      translate3d(var(--x1, 10vw), var(--y1, -8vh), var(--z1, 40px))
      rotateZ(var(--rz1, 10deg))
      scale(var(--sc1, 1));
  }
  50% {
    transform: translate(-50%, -50%)
      translate3d(var(--x2, -12vw), var(--y2, 12vh), var(--z2, 80px))
      rotateZ(var(--rz2, -8deg))
      scale(var(--sc2, 1));
  }
  75% {
    transform: translate(-50%, -50%)
      translate3d(var(--x3, 8vw), var(--y3, 6vh), var(--z3, 20px))
      rotateZ(var(--rz3, 12deg))
      scale(var(--sc3, 1));
  }
}

.float-photo {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 1;
  transform-origin: center center;
  transition:
    width 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    filter 0.4s ease;
  will-change: transform, z-index;
}

.float-photo-card {
  display: block;
  width: 100%;
}

.float-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid rgba(212, 168, 83, 0.35);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.7),
    0 4px 12px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(212, 168, 83, 0.1);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.float-photo-cap {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--gold-dim);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.float-photo--focused .float-photo-cap,
.float-photo:hover .float-photo-cap {
  opacity: 1;
}

@media (hover: hover) {
  .float-photo:hover .float-photo-card {
    filter: brightness(1.08);
  }
  .float-photo:hover img {
    border-color: var(--gold);
    box-shadow:
      0 20px 50px rgba(0, 0, 0, 0.75),
      0 0 32px rgba(212, 168, 83, 0.2);
  }
}

.float-photo--dim {
  opacity: 0.55;
  filter: blur(1px);
  pointer-events: none;
}

.float-photo--focused {
  width: min(88vw, 520px) !important;
  max-width: 92vw !important;
  z-index: 100 !important;
  transform: translate(-50%, -50%) translate3d(0, 0, 120px) rotateZ(0deg) scale(1) !important;
  transition:
    width 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.float-photo--focused .float-photo-card {
  transform: none !important;
}

.float-photo--focused img {
  border-color: var(--gold-bright);
  box-shadow:
    0 0 80px rgba(212, 168, 83, 0.4),
    0 28px 60px rgba(0, 0, 0, 0.85);
}

/* Documents */
.doc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.doc-card {
  padding: 1rem;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border-left: 3px solid var(--gold-dim);
}

.doc-ext {
  font-size: 0.7rem;
  color: var(--gold);
  text-transform: uppercase;
}

.doc-card h3 {
  margin: 0.35rem 0;
  font-size: 1rem;
}

.doc-card p {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Music */
.music-list { display: flex; flex-direction: column; gap: 1rem; }

.music-card {
  padding: 0.75rem;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
}

.music-card div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.music-card span { color: var(--text-dim); }

.music-card audio { width: 100%; height: 36px; }

/* Video */
.video-wrap h3 { margin-bottom: 0.75rem; color: var(--gold-dim); }

.video-wrap video {
  width: 100%;
  border-radius: 8px;
  background: #000;
}

/* Lists */
.book-list, .link-list, .dl-list {
  list-style: none;
}

.book-list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--door-edge);
  font-size: 0.9rem;
}

.book-list em {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: normal;
  margin-top: 0.2rem;
}

.link-list a {
  color: var(--gold);
  text-decoration: none;
  display: block;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--door-edge);
}

.link-list a:hover { text-decoration: underline; }

.notes { display: flex; flex-direction: column; gap: 0.75rem; }

.note-card {
  padding: 1rem;
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
}

.note-card time {
  font-size: 0.75rem;
  color: var(--gold-dim);
}

.note-card p {
  margin-top: 0.5rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

.dl-card {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.dl-icon { font-size: 1.25rem; }

.dl-card small {
  display: block;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.empty-room {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
}

.empty-room code { color: var(--gold-dim); }

/* ===== Responsive / H5 ===== */
@media (max-width: 768px) {
  .maze-header {
    padding-top: 2.75rem;
    margin-bottom: 1rem;
  }

  .maze-header h1 {
    font-size: 1.15rem;
    letter-spacing: 0.12em;
  }

  .maze-sub {
    font-size: 0.8rem;
    padding: 0 0.5rem;
  }

  .maze-layout {
    gap: 0.75rem;
  }

  .maze-wrap {
    aspect-ratio: 4/3;
    min-height: 200px;
  }

  .maze-room-list {
    display: flex;
  }

  .room-node {
    padding: 0.4rem 0.5rem;
    min-width: 44px;
  }

  .room-node-name {
    font-size: 0.6rem;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .room-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
  }

  .room-dialog-inner {
    border-radius: 0;
    max-height: 100dvh;
    height: 100dvh;
    width: 100%;
  }

  .room-dialog:not(.room-dialog--gallery) .room-dialog-inner {
    padding: 1rem;
    padding-top: max(3rem, calc(env(safe-area-inset-top) + 2rem));
  }

  .room-close {
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
  }

  .gallery-hint {
    font-size: 0.65rem;
    max-width: 92vw;
    white-space: normal;
    text-align: center;
  }

  .float-photo--focused {
    width: min(92vw, 400px) !important;
  }

  .doc-card,
  .music-card,
  .note-card {
    padding: 0.85rem;
  }

  .music-card audio,
  .video-wrap video {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .door-frame {
    width: min(240px, 85vw);
    height: min(360px, 52vh);
  }

  .gate-hint {
    top: max(14%, env(safe-area-inset-top));
    font-size: 0.75rem;
  }

  .login-card {
    padding: 1.65rem 1.25rem 1.5rem;
  }

  .login-title {
    letter-spacing: 0.18em;
  }

  .login-submit {
    letter-spacing: 0.22em;
  }
}

@media (max-width: 380px) {
  .room-node-icon {
    font-size: 1.1rem;
  }

  .maze-room-chip {
    font-size: 0.72rem;
    padding: 0.5rem 0.65rem;
  }
}
