:root {
  --void:           #050506;   
  --void-deep:      #020203;
  --phosphor:       #e6e2d8;  
  --phosphor-dim:   rgba(230, 226, 216, 0.65);
  --gothic-accent:  #d9d5cb;

  --font-serif: 'Cinzel', serif;
  --font-mono: 'Share Tech Mono', monospace;

  --edge: clamp(16px, 3vw, 40px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  background: var(--void-deep);
  color: var(--phosphor);
  font-family: var(--font-serif);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
}

img { display: block; max-width: 100%; }

/* Hidden Audio Elements */
.yt-audio-container {
  position: absolute;
  width: 1px;
  height: 1px;
  top: -9999px;
  left: -9999px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Vignette and Atmospheric Overlays */
.gothic-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  background: radial-gradient(circle at center,
    transparent 40%,
    rgba(0,0,0,0.6) 75%,
    rgba(0,0,0,0.95) 100%);
}

.screen-flicker {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 899;
  background: rgba(255,255,255,0.01);
  animation: flicker 6s infinite;
}

@keyframes flicker {
  0%, 95%, 100% { opacity: 0; }
  96% { opacity: 0.15; }
  97% { opacity: 0.05; }
}

/* Audio Gate */
.audio-gate {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.8s ease;
}

.audio-gate.hidden {
  opacity: 0;
  pointer-events: none;
}

.audio-gate__label {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  letter-spacing: 6px;
  color: var(--phosphor);
  animation: pulse-fade 2s ease-in-out infinite;
}

@keyframes pulse-fade {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.9; }
}

/* State Shell */
.state {
  position: fixed;
  inset: 0;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease;
}

.state--active {
  opacity: 1;
  visibility: visible;
  z-index: 20;
}

/* STATE 1 — MAIN MENU */
.state--menu {
  display: flex;
  position: relative;
  width: 100%;
  height: 100%;
}

.menu-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: contrast(1.05) brightness(0.9);
  transition: background-image 0.5s ease;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.6) 60%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
}

/* Hotspot Container Management */
.scene-hotspots {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  pointer-events: none;
}

.scene-hotspots.active {
  display: block;
  pointer-events: auto;
}

.hotspot {
  position: absolute;
  cursor: pointer;
}

/* Scene 1 (menu.jpg) Hotspots */
.hotspot--wardrobe {
  top: 18%; left: 53%;
  width: 17%; height: 63%;
}

.hotspot--hallway-left {
  top: 0; left: 0;
  width: 20%; height: 100%;
}

/* Scene 2 (menu2.jpg) Hotspots */
.hotspot--hallway-end {
  top: 25%; left: 35%;
  width: 30%; height: 50%;
}

/* Scene 3 (menu3.jpg) Hotspots */
.hotspot--stairs-up {
  top: 25%; left: 50%;
  width: 35%; height: 60%;
}

/* Scene 4 (menu4.jpg) Hotspots */
.hotspot--open-door {
  top: 10%; left: 70%;
  width: 25%; height: 85%;
}

/* Scene 5 (menu5.jpg) Hotspots */
.hotspot--girl {
  top: 55%; left: 37%;
  width: 8%; height: 20%;
}

/* Global Back Hotspot for Return Navigation */
.hotspot--back-left {
  top: 0; left: 0;
  width: 15%; height: 100%;
}

.menu-container {
  position: absolute;
  top: 22%;
  right: 10%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  pointer-events: auto;
}

.menu-title-block {
  margin-bottom: 40px;
}

.menu-title {
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0.18em;
  text-shadow: 0 0 15px rgba(0, 0, 0, 0.8), 2px 2px 8px rgba(0,0,0,0.9);
}

.menu-title__main {
  display: block;
  font-size: clamp(2rem, 5vw, 3.8rem);
  color: var(--phosphor);
}

.menu-title__sub {
  display: block;
  font-size: clamp(3rem, 7.5vw, 5.8rem);
  color: var(--gothic-accent);
  font-weight: 600;
  letter-spacing: 0.12em;
}

.menu-japanese {
  margin-top: 18px;
  font-family: serif;
  font-size: clamp(0.85rem, 1.5vw, 1.1rem);
  letter-spacing: 4px;
  line-height: 1.8;
  color: var(--phosphor-dim);
  text-shadow: 1px 1px 4px #000;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-end;
}

.menu-item {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  letter-spacing: 4px;
  color: var(--phosphor-dim);
  padding: 4px 0;
  transition: all 0.3s ease;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
}

.menu-item:hover,
.menu-item:focus-visible {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255,255,255,0.6), 0 2px 8px rgba(0,0,0,0.9);
  transform: translateX(-4px);
}

/* WARDROBE STATE */
.state--wardrobe { background: #000; }

.wardrobe-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.7) contrast(1.1);
}

/* PANELS */
.state--panel {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--void-deep);
  padding: var(--edge);
}

.panel-content {
  max-width: 600px;
  background: rgba(8, 8, 10, 0.85);
  border: 1px solid rgba(230, 226, 216, 0.2);
  padding: 40px;
  box-shadow: 0 0 40px #000;
}

.panel-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  color: var(--phosphor);
  letter-spacing: 0.1em;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(230, 226, 216, 0.2);
  padding-bottom: 10px;
}

.panel-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--phosphor-dim);
}

.panel-back {
  position: absolute;
  top: var(--edge);
  left: var(--edge);
  z-index: 5;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: 3px;
  color: var(--phosphor-dim);
  transition: all 0.3s ease;
}

.panel-back:hover { color: #fff; transform: translateX(-4px); }

/* STATE 2 — DIALOGUE */
.state--dialogue { background: #000; }

.dialogue-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.4) contrast(1.1);
}

.character-frame {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100vw;
  height: 100vh;
  max-width: none;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.1s ease-out;
}

.character-frame__img {
  width: auto;
  height: 140%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 0 25px rgba(0,0,0,0.95)) brightness(0.85);
}

.character-frame.is-talking {
  animation: char-bob 0.12s ease-in-out infinite alternate;
}

@keyframes char-bob {
  0%   { transform: translateX(-50%) translateY(0); }
  100% { transform: translateX(-50%) translateY(-10px); }
}

.dialogue-box {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  z-index: 10;
  padding: 0 var(--edge) clamp(20px, 4vh, 40px);
}

.dialogue-box__frame {
  max-width: 900px;
  margin: 0 auto;
  min-height: 120px;
  background: rgba(5, 5, 6, 0.88);
  border: 1px solid rgba(230, 226, 216, 0.25);
  padding: 24px 30px;
  box-shadow: 0 0 30px rgba(0,0,0,0.9);
  position: relative;
}

.dialogue-box__text {
  font-family: var(--font-serif);
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  line-height: 1.6;
  color: var(--phosphor);
  letter-spacing: 1px;
  display: inline;
}

.dialogue-box__cursor {
  color: var(--phosphor-dim);
  font-size: 0.9rem;
  margin-left: 8px;
  animation: cursor-blink 0.8s infinite;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

.dialogue-choices {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.dialogue-choices.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.choice-btn {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  letter-spacing: 2px;
  padding: 8px 24px;
  background: rgba(5, 5, 6, 0.9);
  border: 1px solid rgba(230, 226, 216, 0.2);
  color: var(--phosphor-dim);
  transition: all 0.3s ease;
}

.choice-btn:hover,
.choice-btn:focus-visible {
  color: #fff;
  border-color: rgba(230, 226, 216, 0.6);
  background: rgba(20, 20, 25, 0.9);
}

.panel-back--dialogue { top: var(--edge); left: var(--edge); z-index: 20; }

/* TRANSITION SHUTTER */
.elevator {
  position: fixed;
  inset: 0;
  z-index: 800;
  pointer-events: none;
  display: none;
}

.elevator.active { display: block; }

.elevator__door {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  background: #000;
}

.elevator__door--left  { left: 0; transform: translateX(-100%); }
.elevator__door--right { right: 0; transform: translateX(100%); }

.elevator.elevator--closing .elevator__door--left,
.elevator.elevator--closing .elevator__door--right {
  transition: transform 0.65s cubic-bezier(0.7,0,0.2,1);
}
.elevator.elevator--closing .elevator__door--left  { transform: translateX(0); }
.elevator.elevator--closing .elevator__door--right { transform: translateX(0); }

.elevator.elevator--opening .elevator__door--left,
.elevator.elevator--opening .elevator__door--right {
  transition: transform 0.75s cubic-bezier(0.6,0,0.2,1) 0.1s;
}
.elevator.elevator--opening .elevator__door--left  { transform: translateX(-100%); }
.elevator.elevator--opening .elevator__door--right { transform: translateX(100%); }

/* STATE 3 — GALLERY */
.state--gallery { background: var(--void-deep); overflow: hidden; }

.gallery-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.35) contrast(1.1);
}

.gallery-header {
  position: absolute;
  top: var(--edge);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
}

.gallery-title {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 2.8vw, 2.2rem);
  letter-spacing: 0.15em;
  color: var(--phosphor);
}

.gallery-hint {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--phosphor-dim);
}

.gallery-wall {
  position: absolute;
  inset: 0;
}

.painting {
  position: absolute;
  width: clamp(180px, 16vw, 220px);
  cursor: pointer;
  transition: transform 0.3s ease, filter 0.3s ease;
  filter: brightness(0.85) contrast(1.1);
}

.painting:hover,
.painting:focus-visible {
  filter: brightness(1.05) contrast(1.15);
  transform: scale(1.1) !important;
  z-index: 100 !important;
}

.painting__frame-art {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.painting__screen {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  overflow: hidden;
  background: #000;
  z-index: 1;
}

.painting__screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.painting__overlay-frame {
  position: absolute;
  inset: -10px;
  width: calc(100% + 20px);
  height: calc(100% + 20px);
  object-fit: fill;
  pointer-events: none;
  z-index: 2;
}

.painting__caption {
  margin-top: 6px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: var(--phosphor-dim);
}

/* VIDEO MODAL */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.video-modal.active { opacity: 1; pointer-events: auto; }

.video-modal__frame {
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16/9;
  background: #000;
  border: 1px solid rgba(230, 226, 216, 0.2);
}

.video-modal__iframe { width: 100%; height: 100%; border: none; display: block; }

.video-modal__close {
  position: absolute;
  top: 20px; right: 20px;
  width: 40px; height: 40px;
  border: 1px solid rgba(230, 226, 216, 0.3);
  background: rgba(5,5,5,0.8);
  color: var(--phosphor);
  font-size: 18px;
  line-height: 38px;
}

@media (max-width: 768px) {
  .menu-container {
    right: 50%;
    transform: translateX(50%);
    text-align: center;
    align-items: center;
    width: 90%;
  }
  .menu-list { align-items: center; }

  .gallery-wall { 
    position: static; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 32px; 
    padding: 100px 20px 60px; 
    overflow-y: auto;
    height: 100%;
  }
  .painting { 
    position: static !important; 
    width: min(220px, 80vw) !important; 
    transform: none !important; 
  }
}