:root {
  --bg: #040405;
  --fg: #f5f5f7;
  --muted: #8e8e93;
  --orange: #ff6a1a;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', 'Segoe UI', Roboto, Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.75, 0.2, 1);
  --hold-bottom: max(8vh, calc(env(safe-area-inset-bottom) + 72px));
  color-scheme: dark;
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  touch-action: none;
  overscroll-behavior: none;
  cursor: default;
}

#scene,
#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#confetti {
  pointer-events: none;
  z-index: 5;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.7) 100%);
}

.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, #fff 0%, #ffe2c8 22%, rgba(255, 120, 40, 0.45) 50%, rgba(255, 90, 20, 0) 80%);
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange);
}

/* ---------- Ladeanzeige ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: radial-gradient(ellipse 60% 45% at 50% 50%, #121214 0%, var(--bg) 70%);
  transition: opacity 0.9s var(--ease), visibility 0s linear 0.9s;
}

body.ready .loader {
  opacity: 0;
  visibility: hidden;
}

.loader-gift {
  position: relative;
  width: 64px;
  height: 64px;
  transform: scale(1.25);
  margin-bottom: 8px;
  filter: drop-shadow(0 0 22px rgba(255, 106, 26, 0.35));
}

.loader-box,
.loader-lid {
  position: absolute;
  left: 50%;
  border-radius: 5px;
  background:
    linear-gradient(90deg, transparent 42%, var(--orange) 42%, var(--orange) 58%, transparent 58%),
    linear-gradient(180deg, #4a4a50, #26262a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.loader-box {
  bottom: 0;
  width: 50px;
  height: 36px;
  margin-left: -25px;
}

.loader-lid {
  bottom: 38px;
  width: 58px;
  height: 13px;
  margin-left: -29px;
  animation: lid-hop 1.6s var(--ease) infinite;
}

/* Schleife auf dem Deckel */
.loader-lid::before,
.loader-lid::after {
  content: '';
  position: absolute;
  bottom: 11px;
  left: 50%;
  width: 14px;
  height: 10px;
  border: 3px solid var(--orange);
  border-radius: 50% 50% 0 50%;
}

.loader-lid::before {
  margin-left: -15px;
  transform: rotate(-12deg);
}

.loader-lid::after {
  margin-left: 1px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(12deg);
}

@keyframes lid-hop {
  0%,
  55%,
  100% {
    transform: translateY(0) rotate(0);
  }
  20% {
    transform: translateY(-9px) rotate(-5deg);
  }
  35% {
    transform: translateY(-2px) rotate(3deg);
  }
}

.loader-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.loader-track {
  width: 160px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.loader-bar {
  width: 100%;
  height: 100%;
  background: var(--orange);
  box-shadow: 0 0 10px var(--orange);
  transform: scaleX(0.04);
  transform-origin: left center;
  transition: transform 0.35s var(--ease);
}

.load-indeterminate .loader-bar {
  width: 40%;
  transform: none !important;
  animation: indeterminate 1.3s ease-in-out infinite;
}

@keyframes indeterminate {
  from {
    margin-left: -40%;
  }
  to {
    margin-left: 100%;
  }
}

/* ---------- Intro ---------- */

.intro {
  position: fixed;
  top: max(7vh, calc(env(safe-area-inset-top) + 28px));
  left: 0;
  right: 0;
  padding: 0 24px;
  text-align: center;
  z-index: 3;
  pointer-events: none;
}

.intro-title {
  margin-top: 10px;
  font-size: clamp(34px, 5.4vw, 64px);
  font-weight: 700;
  text-wrap: balance;
  letter-spacing: -0.025em;
  line-height: 1.08;
  background: linear-gradient(180deg, #fff 35%, #9a9aa0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hold {
  position: fixed;
  left: 50%;
  bottom: var(--hold-bottom);
  width: 84px;
  height: 84px;
  margin-left: -42px;
  z-index: 3;
  pointer-events: none;
}

.hold-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.hold-ring circle {
  fill: none;
  stroke-width: 3;
}

.hold-ring .track {
  stroke: rgba(255, 255, 255, 0.14);
}

.hold-ring .progress {
  stroke: var(--orange);
  stroke-linecap: round;
  stroke-dasharray: 289.03;
  stroke-dashoffset: 289.03;
  filter: drop-shadow(0 0 6px rgba(255, 106, 26, 0.9));
}

.hold-dot {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.35);
  animation: breathe 2.4s ease-in-out infinite;
  transition: transform 0.25s var(--ease), background 0.25s;
}

.hold-dot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  animation: ping 2.4s var(--ease) infinite;
}

body.holding .hold-dot {
  animation: none;
  transform: scale(0.78);
  background: var(--orange);
}

body.holding .hold-dot::after {
  animation: none;
  opacity: 0;
}

.hold-label {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--hold-bottom) - 34px);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  z-index: 3;
  pointer-events: none;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.88);
  }
}

@keyframes ping {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  70%,
  100% {
    transform: scale(2.3);
    opacity: 0;
  }
}

.intro-sub {
  margin-top: 12px;
  font-size: clamp(15px, 1.6vw, 20px);
  font-weight: 500;
  color: var(--muted);
}

/* Intro einblenden, sobald die Szene läuft, und beim Öffnen ausblenden */
.intro,
.hold,
.hold-label {
  opacity: 0;
  transition: opacity 1.2s var(--ease), transform 1.2s var(--ease);
}

.intro {
  transform: translateY(-12px);
}

body.ready .intro,
body.ready .hold,
body.ready .hold-label {
  opacity: 1;
  transform: none;
}

body.ready .hold {
  transition-delay: 0.4s;
}

body.opened .intro,
body.opened .hold,
body.opened .hold-label {
  opacity: 0;
  transition-duration: 0.3s;
  transition-delay: 0s;
}

/* ---------- Reveal ---------- */

.reveal {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  top: 50%;
  right: 6vw;
  width: min(42vw, 520px);
  transform: translateY(-50%);
  text-align: left;
}

body.portrait .reveal {
  top: auto;
  right: 0;
  left: 0;
  bottom: 0;
  width: auto;
  transform: none;
  padding: 0 24px calc(env(safe-area-inset-bottom) + 34px);
  text-align: center;
}

.reveal > * {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}

.reveal > .headline {
  opacity: 1;
  transform: none;
}

body.revealed .reveal > * {
  opacity: 1;
  transform: none;
}

body.revealed .reveal > .product {
  transition-delay: 0.9s;
}

body.revealed .reveal > .message {
  transition-delay: 1.15s;
}

body.revealed .reveal > .signature {
  transition-delay: 1.4s;
}

body.revealed .reveal > .actions {
  transition-delay: 1.9s;
}

.headline {
  margin-top: 10px;
  font-size: clamp(36px, 4.8vw, 68px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.04;
  text-wrap: balance;
  color: var(--fg);
}

.headline .word {
  display: inline-block;
  white-space: nowrap;
}

.headline .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.4em) scale(0.96);
  filter: blur(12px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), filter 0.9s var(--ease);
  transition-delay: calc(0.15s + var(--i) * 0.035s);
}

body.revealed .headline .char {
  opacity: 1;
  transform: none;
  filter: blur(0);
}

.product {
  margin-top: 14px;
  font-size: 17px;
  color: var(--muted);
  letter-spacing: -0.01em;
}

.product-name {
  color: var(--fg);
  font-weight: 600;
}

.product-name,
.product-finish {
  display: inline-block;
  white-space: nowrap;
}

.product-finish::before {
  content: '·';
  margin: 0 0.45em 0 0.2em;
}

.message[hidden] {
  display: none;
}

.message {
  margin-top: 18px;
  font-size: clamp(15px, 1.35vw, 19px);
  line-height: 1.5;
  color: #c7c7cc;
  max-width: 34em;
}

body.portrait .product-finish {
  display: block;
  margin-top: 2px;
  font-size: 15px;
}

body.portrait .product-finish::before {
  content: none;
}

body.portrait .message {
  margin-left: auto;
  margin-right: auto;
}

.signature {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--orange);
}

.actions {
  margin-top: 26px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

body.portrait .actions {
  justify-content: center;
  margin-top: 18px;
}

.replay {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font: 500 14px var(--font);
  color: var(--fg);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: background 0.2s;
}

.replay:hover {
  background: rgba(255, 255, 255, 0.16);
}

.replay svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sehr kleine Displays */
@media (max-height: 700px) {
  body.portrait .message {
    font-size: 14px;
    line-height: 1.42;
  }
  body.portrait .headline {
    font-size: 34px;
  }
}

/* ---------- Namensnennung 3D-Modell ---------- */

.credit {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 4;
  text-align: center;
  font-size: 9px;
  line-height: 1.3;
  color: rgba(142, 142, 147, 0.45);
  opacity: 0;
  transition: opacity 1s var(--ease) 3s;
  pointer-events: none;
}

.credit a {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}

body.revealed .credit {
  opacity: 1;
}

body.model-fallback .credit {
  display: none;
}

/* ---------- Ton-Schalter ---------- */

.mute {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 7;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 1s var(--ease), color 0.2s;
}

body.ready .mute {
  opacity: 1;
}

.mute:hover {
  color: var(--fg);
}

.mute svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mute .icon-off,
.mute.is-muted .icon-on {
  display: none;
}

.mute.is-muted .icon-off {
  display: block;
}

/* ---------- Fallback ohne WebGL ---------- */

body.no-webgl .reveal {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: min(90vw, 560px);
  transform: translate(-50%, -50%);
  text-align: center;
}

body.no-webgl .hold,
body.no-webgl .hold-label,
body.no-webgl .intro,
body.no-webgl .mute {
  display: none;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--fg);
}

@media (prefers-reduced-motion: reduce) {
  .loader-lid,
  .hold-dot,
  .hold-dot::after {
    animation: none;
  }
}
