* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050302;
  font-family: Georgia, "Times New Roman", serif;
  color: #fff3d0;
}

#aegir-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(circle at 70% 45%, rgba(255, 190, 90, 0.08), transparent 28%),
    linear-gradient(90deg, rgba(0,0,0,0.72), rgba(0,0,0,0.25), rgba(0,0,0,0.58));
}

.hero {
  position: absolute;
  left: clamp(24px, 7vw, 110px);
  top: 50%;
  transform: translateY(-50%);
  max-width: 520px;
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: #d7a84f;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 6.8rem);
  line-height: 0.9;
  text-shadow: 0 0 28px rgba(255, 170, 70, 0.25);
}

.subtitle {
  max-width: 430px;
  margin: 22px 0 32px;
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.5;
  color: #f2dba6;
}

.start-btn {
  border: 1px solid rgba(255, 210, 120, 0.75);
  background: rgba(42, 20, 8, 0.72);
  color: #fff0c2;
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 26px rgba(255, 152, 50, 0.18);
}

.start-btn:hover {
  background: rgba(90, 42, 12, 0.8);
}

.corner-controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.corner-controls button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.42);
  color: #fff3d0;
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

@media (max-width: 700px) {
  .hero {
    left: 22px;
    right: 22px;
    top: auto;
    bottom: 92px;
    transform: none;
  }

  .overlay {
    background:
      linear-gradient(0deg, rgba(0,0,0,0.82), rgba(0,0,0,0.22), rgba(0,0,0,0.48));
  }
}

.hero {
  transition:
    opacity 1.8s ease,
    transform 1.8s ease;
}

.overlay.flying .hero {
  opacity: 0;
  transform: translateY(-50%) translateX(-40px);
}

#preloader{
  position:fixed;
  inset:0;
  z-index:9999;

  display:flex;
  align-items:center;
  justify-content:center;

  background:#050302;
  transition:opacity 1.2s ease;
}

#preloader.hidden{
  opacity:0;
  pointer-events:none;
}

.preloader-box{
  text-align:center;
  width:min(500px,80vw);
}

.preloader-box h1{
  color:#f0e4c8;
  font-size:3rem;
  margin-bottom:30px;
}

.loader-bar{
  width:100%;
  height:10px;

  background:rgba(255,255,255,.08);

  border-radius:999px;
  overflow:hidden;
}

#loaderFill{
  width:0%;
  height:100%;

  background:#d5a04a;

  transition:width .25s ease;
}

#loaderText{
  margin-top:20px;
  color:#d8c7a2;
  font-size:1rem;
}

/* Intro-Fix: Start-Overlay darf den Kameraflug auf Mobile nicht blockieren */
.overlay.flying {
  pointer-events: none;
  background: transparent;
  transition: background 1.2s ease;
}

.overlay.flying .hero {
  pointer-events: none;
}

.overlay.intro-finished .hero {
  display: none;
}


/* Startbildschirm-Ruhemodus:
   Nach 10 Sekunden verschwindet das Overlay, bei Maus/Finger/Tastatur kommt es zurück. */
.overlay {
  opacity: 1;
  transition:
    opacity 1.2s ease,
    background 1.2s ease;
}

.overlay.idle-hidden {
  opacity: 0;
  pointer-events: none;
  background: transparent;
}

.overlay.idle-hidden .hero,
.overlay.idle-hidden .corner-controls {
  pointer-events: none;
}

/* Kapitel 2: Der Steg zwischen den Welten */
.chapter-fade {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}

.chapter-fade.visible { opacity: 1; }

.chapter-title {
  text-align: center;
  color: #fff1c8;
  transform: translateY(12px);
  transition: transform 1.2s ease;
}

.chapter-fade.visible .chapter-title { transform: translateY(0); }

.chapter-title span {
  display: block;
  margin-bottom: 14px;
  color: #d6a943;
  letter-spacing: .28em;
  text-transform: uppercase;
  font-size: clamp(.75rem, 2vw, .95rem);
}

.chapter-title strong {
  display: block;
  font-size: clamp(2rem, 7vw, 5rem);
  line-height: .95;
  font-weight: 700;
}

.helmet-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(var(--helmet-x, 0px), var(--helmet-y, 0px), 0) scale(1.045);
  transform-origin: center center;
  will-change: transform, opacity;
  transition: opacity 1.8s ease;
  mix-blend-mode: normal;
  filter: none;
}

.helmet-overlay.visible { opacity: 1; }
.helmet-overlay.helmet-missing { display: none; }

.chapter-hint {
  position: fixed;
  left: 50%;
  bottom: clamp(24px, 8vh, 72px);
  z-index: 60;
  transform: translateX(-50%) translateY(10px);
  max-width: min(620px, calc(100vw - 34px));
  padding: 12px 18px;
  border: 1px solid rgba(255, 211, 118, .28);
  border-radius: 999px;
  background: rgba(0, 5, 12, .48);
  backdrop-filter: blur(8px);
  color: #fff0c8;
  text-align: center;
  font-size: clamp(.85rem, 2vw, 1rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.4s ease, transform 1.4s ease;
}

.chapter-hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Nach dem Kameraflug: nur noch der Eintrittsbutton vor dem Portal */
.overlay.ready-to-enter {
  opacity: 1;
  pointer-events: none;
  background: transparent;
}

.overlay.ready-to-enter .hero {
  left: 50%;
  top: auto;
  bottom: clamp(28px, 8vh, 78px);
  right: auto;
  transform: translateX(-50%);
  width: auto;
  max-width: none;
  opacity: 1;
  pointer-events: auto;
}

.overlay.ready-to-enter .eyebrow,
.overlay.ready-to-enter h1,
.overlay.ready-to-enter .subtitle {
  display: none;
}

.overlay.ready-to-enter .start-btn {
  min-width: 160px;
  background: rgba(16, 8, 3, .74);
  box-shadow: 0 0 32px rgba(255, 200, 95, .24);
}

.overlay.ready-to-enter .corner-controls {
  pointer-events: auto;
}

/* Kapitel 2 Fix: altes Portal-Overlay wirklich abschalten */
.overlay.chapter-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Kapitel 2: Der zusätzliche Eintreten-Button wurde entfernt.
   Der Spieler ist bereits durch das Portal eingetreten. */

/* Kapitel 2: Audio- und Vollbild-Buttons bleiben erreichbar. */
.corner-controls.chapter-controls {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: auto;
  z-index: 70;
  display: flex;
  gap: 10px;
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.corner-controls.chapter-controls button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 5, 12, .48);
  border: 1px solid rgba(255, 255, 255, .28);
  backdrop-filter: blur(8px);
}

@media (max-width: 760px), (pointer: coarse) {
  .corner-controls.chapter-controls {
    top: auto;
    right: 16px;
    bottom: 16px;
  }
}

/* Wiederverwendbarer Dimensions-/Portalübergang */
.dimension-transition {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at center, rgba(255, 232, 162, .24) 0%, rgba(58, 78, 132, .16) 22%, rgba(0, 2, 8, .94) 68%, #000 100%);
  transition: opacity .7s ease;
}

.dimension-transition.is-active { opacity: 1; }
.dimension-transition.is-fading { opacity: 0; transition-duration: 1.05s; }
.dimension-transition.is-flashing { background-color: rgba(255, 244, 205, .16); }

.dimension-transition__tunnel,
.dimension-transition__vortex,
.dimension-transition__ring,
.dimension-transition__stars,
.dimension-transition__runes {
  position: absolute;
  inset: 0;
}

.dimension-transition__tunnel {
  transform-origin: center;
  animation: dimension-tunnel 4.75s cubic-bezier(.12,.76,.12,1) forwards;
}

.dimension-transition__vortex {
  width: 190vmax;
  height: 190vmax;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg,
      rgba(255, 224, 150, 0),
      rgba(255, 224, 150, .38),
      rgba(90, 156, 255, .24),
      rgba(0, 0, 0, 0),
      rgba(255, 226, 170, .22),
      rgba(0, 0, 0, 0));
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.42) rotate(0deg);
  filter: blur(12px);
  animation: dimension-vortex 4.8s cubic-bezier(.13,.78,.12,1) forwards;
}

.dimension-transition__ring {
  width: 72vmin;
  height: 72vmin;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  border: 1px solid rgba(255, 220, 140, .24);
  box-shadow: 0 0 42px rgba(255, 198, 95, .13), inset 0 0 42px rgba(100, 165, 255, .10);
  transform: translate(-50%, -50%) scale(2.4);
  opacity: 0;
  animation: dimension-ring 4.4s ease forwards;
}

.dimension-transition__ring--two { animation-delay: .36s; border-color: rgba(130, 178, 255, .22); }
.dimension-transition__ring--three { animation-delay: .72s; border-color: rgba(255, 245, 205, .16); }

.dimension-transition__stars {
  transform: scale(1.22);
  animation: dimension-stars 4.4s cubic-bezier(.12,.82,.18,1) forwards;
}

.dimension-transition__stars i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(2.5px * var(--s));
  height: calc(2.5px * var(--s));
  border-radius: 999px;
  background: rgba(255, 240, 205, .95);
  box-shadow: 0 0 18px rgba(255, 218, 130, .62);
  transform:
    rotate(var(--a))
    translateX(var(--d))
    scale(var(--s));
  opacity: 0;
  animation: dimension-star-pull 3.7s cubic-bezier(.1,.82,.16,1) forwards;
  animation-delay: calc(var(--i) * 16ms);
}

.dimension-transition__runes b {
  position: absolute;
  left: 50%;
  top: 50%;
  color: rgba(255, 230, 160, .7);
  font-family: Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 4.8rem);
  font-weight: 700;
  text-shadow: 0 0 24px rgba(255, 214, 130, .36);
  transform: rotate(var(--a)) translateX(var(--d)) rotate(calc(var(--a) * -1)) scale(.8);
  opacity: 0;
  animation: dimension-rune-pull 4s ease forwards;
  animation-delay: calc(.45s + var(--i) * 180ms);
}

.dimension-transition__title {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff0c8;
  text-shadow: 0 0 32px rgba(255, 200, 100, .28);
  opacity: 0;
  transform: translateY(10px) scale(.98);
  animation: dimension-title 4.1s ease forwards;
  max-width: min(92vw, 980px);
  padding: 0 20px;
}

.dimension-transition__title span {
  display: block;
  margin-bottom: 14px;
  color: #d6a943;
  letter-spacing: .28em;
  text-transform: uppercase;
  font-size: clamp(.74rem, 1.9vw, .95rem);
}

.dimension-transition__title strong {
  display: block;
  font-size: clamp(2rem, 7vw, 5rem);
  line-height: .95;
}

.dimension-transition--castle {
  background:
    radial-gradient(circle at center, rgba(255, 184, 88, .22) 0%, rgba(45, 14, 8, .34) 30%, rgba(0, 0, 0, .97) 68%, #000 100%);
}

@keyframes dimension-tunnel {
  0% { transform: scale(1.06) rotate(0deg); filter: blur(0px); }
  55% { transform: scale(.82) rotate(18deg); filter: blur(1px); }
  100% { transform: scale(.35) rotate(48deg); filter: blur(3px); }
}

@keyframes dimension-vortex {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.55) rotate(0deg); }
  18% { opacity: .58; }
  78% { opacity: .95; }
  100% { opacity: .15; transform: translate(-50%, -50%) scale(.10) rotate(760deg); }
}

@keyframes dimension-ring {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.9); }
  20% { opacity: .55; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
}

@keyframes dimension-stars {
  0% { transform: scale(1.28) rotate(0deg); opacity: .28; }
  100% { transform: scale(.22) rotate(120deg); opacity: .95; }
}

@keyframes dimension-star-pull {
  0% { opacity: 0; }
  18% { opacity: .9; }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(1vw) scale(.18); }
}

@keyframes dimension-rune-pull {
  0% { opacity: 0; filter: blur(8px); }
  24% { opacity: .65; filter: blur(0px); }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(2vmin) rotate(calc(var(--a) * -1)) scale(.18); filter: blur(10px); }
}

@keyframes dimension-title {
  0% { opacity: 0; transform: translateY(14px) scale(.96); }
  20% { opacity: 1; transform: translateY(0) scale(1); }
  76% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px) scale(1.025); }
}

