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

:root {
  --bg:   #1f2c52;
  --gold: #f2ac0d;
  --dark: #131d38;
  --fog:  rgba(242,172,13,0.08);
}

html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  font-family: 'Josefin Sans', sans-serif;
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  position: relative;
}

/* ── Grain ── */
body::before {
  content: ''; position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 100; opacity: 0.3;
}

/* ── Radial glow ── */
.glow {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse 55% 45% at 50% 52%, rgba(242,172,13,0.09) 0%, transparent 68%);
  pointer-events: none; z-index: 0;
}

/* ── Drifting steam background ── */
.bg-mist {
  position: fixed; inset: 0; overflow: hidden;
  pointer-events: none; z-index: 1;
}
.mist-strand {
  position: absolute; bottom: 0;
  width: 2px; border-radius: 2px;
  background: linear-gradient(to top, rgba(242,172,13,0.12), transparent);
  animation: mist-rise var(--md,8s) var(--ms,0s) ease-out infinite;
}
@keyframes mist-rise {
  0%   { opacity:0; height:0;  transform:translateX(0) scaleX(1); }
  15%  { opacity:1; }
  85%  { opacity:0.3; }
  100% { opacity:0; height:45vh; transform:translateX(var(--mx,20px)) scaleX(3); }
}

/* ── 404 giant text ── */
.giant-404 {
  position: absolute;
  font-family: 'Playfair Display', serif;
  font-size: clamp(160px, 30vw, 280px);
  font-weight: 700;
  color: transparent;
  -webkit-text-stroke: 1px rgba(242,172,13,0.10);
  letter-spacing: -0.04em;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  z-index: 2;
  animation: ghost-pulse 5s ease-in-out infinite;
}
@keyframes ghost-pulse {
  0%,100% { -webkit-text-stroke-color: rgba(242,172,13,0.10); }
  50%      { -webkit-text-stroke-color: rgba(242,172,13,0.22); }
}

/* ── Scene ── */
.scene {
  position: relative; z-index: 10;
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  padding: 0 24px;
  gap: 0;
  animation: entrance 1.8s cubic-bezier(.22,1,.36,1) forwards;
  opacity: 0; transform: translateY(30px);
}
@keyframes entrance {
  to { opacity:1; transform:translateY(0); }
}

/* ── Spilled cup SVG ── */
.cup-wrap {
  position: relative;
  width: 140px; height: 140px;
  margin-bottom: 8px;
}
.cup-svg {
  width: 100%; height: 100%;
  filter: drop-shadow(0 6px 20px rgba(242,172,13,0.25));
  animation: tilt 3s ease-in-out infinite;
  transform-origin: 80% 75%;
}
@keyframes tilt {
  0%,100% { transform: rotate(-8deg); }
  50%      { transform: rotate(-14deg); }
}

/* Drip drop animation */
.drip {
  position: absolute;
  width: 7px; height: 7px;
  background: var(--gold);
  border-radius: 50% 50% 60% 60%;
  bottom: 14px; left: 30px;
  opacity: 0;
  animation: drip-fall 2.2s 0.6s ease-in infinite;
  box-shadow: 0 0 8px rgba(242,172,13,0.5);
}
.drip2 {
  width: 5px; height: 5px;
  left: 22px; bottom: 10px;
  animation: drip-fall 2.2s 1.3s ease-in infinite;
}
@keyframes drip-fall {
  0%   { opacity: 0; transform: translateY(0) scaleY(1); }
  10%  { opacity: 1; }
  80%  { opacity: 0.8; transform: translateY(28px) scaleY(1.4); }
  100% { opacity: 0; transform: translateY(36px) scaleY(0.5); }
}

/* Puddle */
.puddle {
  position: absolute;
  bottom: 6px; left: 10px;
  width: 60px; height: 8px;
  background: radial-gradient(ellipse, rgba(242,172,13,0.35), transparent 80%);
  border-radius: 50%;
  animation: puddle-grow 2.2s 0.6s ease-out infinite;
}
@keyframes puddle-grow {
  0%  { transform: scaleX(0.4); opacity:0; }
  40% { opacity: 1; }
  100%{ transform: scaleX(1); opacity: 0; }
}

/* ── Error label ── */
.error-label {
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 100;
  font-size: 0.65rem;
  letter-spacing: 0.7em;
  color: rgba(242,172,13,0.45);
  text-transform: uppercase;
  margin-bottom: 10px;
  animation: entrance 1.8s 0.2s cubic-bezier(.22,1,.36,1) both;
}

/* ── Heading ── */
.heading {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  color: var(--gold);
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-shadow: 0 2px 24px rgba(242,172,13,0.2);
  animation: entrance 1.8s 0.35s cubic-bezier(.22,1,.36,1) both;
}
.heading em {
  font-style: italic;
  color: rgba(242,172,13,0.7);
}

/* ── Divider ── */
.divider {
  width: 100px; height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  margin: 18px auto;
  animation: entrance 1.8s 0.5s both;
}

/* ── Subtext ── */
.subtext {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  color: rgba(242,172,13,0.5);
  max-width: 360px;
  line-height: 1.7;
  letter-spacing: 0.03em;
  animation: entrance 1.8s 0.55s cubic-bezier(.22,1,.36,1) both;
}

/* ── Back button ── */
.btn-back {
  display: inline-flex;
  align-items: center; gap: 10px;
  margin-top: 32px;
  padding: 12px 32px;
  border: 1px solid rgba(242,172,13,0.4);
  border-radius: 2px;
  color: var(--gold);
  text-decoration: none;
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 300;
  font-size: 0.72rem;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  position: relative; overflow: hidden;
  transition: color 0.35s, border-color 0.35s, transform 0.3s;
  animation: entrance 1.8s 0.75s cubic-bezier(.22,1,.36,1) both;
}
.btn-back::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(242,172,13,0.08);
  transform: translateX(-101%);
  transition: transform 0.35s cubic-bezier(.22,1,.36,1);
}
.btn-back:hover::before { transform: translateX(0); }
.btn-back:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(242,172,13,0.15);
}
.btn-back svg {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.3s;
}
.btn-back:hover svg { transform: translateX(-4px); }

/* ── Logo watermark ── */
.logo-mark {
  position: fixed; bottom: 24px; left: 47%;
  transform: translateX(-50%);
  opacity: 0.12; z-index: 20;
  pointer-events: none;
  animation: entrance 2.5s 1s both;
}
.logo-mark img { width: 90px; height: auto; }

/* ── Beans ── */
.beans-container { position:fixed; inset:0; pointer-events:none; overflow:hidden; z-index:1; }
.bean {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 35%, rgba(242,172,13,0.4), rgba(19,29,56,0.9));
  opacity: 0;
  animation: float-bean var(--dur,12s) var(--delay,0s) ease-in-out infinite;
}
.bean::after {
  content:''; position:absolute;
  width:1.5px; height:60%; top:20%; left:50%;
  transform:translateX(-50%) rotate(10deg);
  background:rgba(242,172,13,0.25); border-radius:2px;
}
@keyframes float-bean {
  0%  { opacity:0; transform:translateY(0) rotate(0deg); }
  10% { opacity:0.4; }
  90% { opacity:0.2; }
  100%{ opacity:0; transform:translateY(-100vh) rotate(360deg); }
}
