:root {
  color-scheme: dark;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #0f0c15;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  color: #f3ede2;
  background:
    radial-gradient(
      circle at 20% 20%,
      rgba(86, 77, 118, 0.35),
      transparent 55%
    ),
    radial-gradient(
    circle at 80% 0%,
    rgba(210, 176, 114, 0.2),
    transparent 45%
  ),
    #0f0c15;
  overflow: hidden;
}

@keyframes candle-drift {
  0%, 100% {
    opacity: 0.14;
    transform: translate3d(-42%, -8%, 0) rotate(8deg);
  }
  45% {
    opacity: 0.24;
    transform: translate3d(28%, 6%, 0) rotate(8deg);
  }
  70% {
    opacity: 0.11;
    transform: translate3d(8%, -10%, 0) rotate(8deg);
  }
}

@keyframes letter-pulse {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45);
  }
  28% {
    opacity: 0.58;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.35);
  }
}

@keyframes eye-shimmer {
  0%, 100% {
    opacity: 0.42;
    transform: translate(-50%, -50%) scale(0.92) rotate(0deg);
  }
  44% {
    opacity: 0.78;
    transform: translate(-50%, -50%) scale(1.06) rotate(18deg);
  }
  70% {
    opacity: 0.26;
  }
}

@keyframes tag-arrive {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px) rotate(-0.8deg);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) rotate(-0.8deg);
  }
}

body:focus-within {
  scroll-behavior: smooth;
}

/* ═════════════════════════════════════════════════════════
   🌑 ATMOSPHERIC OVERLAYS - Spooky depth layers
   ════════════════════════════════════════════════════════ */

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAADUlEQVR4AWP4z/D/PwAHggJ/lEBe7QAAAABJRU5ErkJggg==");
  background-size: 200px 200px;
  opacity: 0.16;
  mix-blend-mode: soft-light;
}

body::after {
  background: radial-gradient(
    circle at center,
    transparent 45%,
    rgba(7, 5, 10, 0.78) 95%
  );
}

/* Additional spooky atmosphere layers */
.spooky-vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 30%,
    rgba(0, 0, 0, 0.4) 70%,
    rgba(15, 12, 21, 0.85) 100%
  );
  pointer-events: none;
  z-index: 10;
  mix-blend-mode: multiply;
}

.spooky-noise {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.04;
  pointer-events: none;
  z-index: 11;
  mix-blend-mode: overlay;
}

@keyframes flicker {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
  75% {
    opacity: 0.92;
  }
  25% {
    opacity: 0.78;
  }
}

@keyframes random-flicker {
  0% {
    opacity: 1;
  }
  5% {
    opacity: 0.88;
  }
  10% {
    opacity: 1;
  }
  15% {
    opacity: 0.92;
  }
  20% {
    opacity: 1;
  }
  60% {
    opacity: 0.8;
  }
  80% {
    opacity: 1;
  }
  85% {
    opacity: 0.9;
  }
  100% {
    opacity: 1;
  }
}

.flicker-candle {
  animation: random-flicker 3.5s infinite;
  animation-timing-function: ease-in-out;
}

/* ═════════════════════════════════════════════════════════
   📽️ OLD MOVIE EFFECTS - Vintage film aesthetics
   ════════════════════════════════════════════════════════ */

.film-grain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23grain)'/%3E%3C/svg%3E");
  opacity: 0.12;
  pointer-events: none;
  z-index: 12;
  mix-blend-mode: overlay;
  animation: grain-flow 8s steps(10) infinite;
}

@keyframes grain-flow {
  0%, 100% {
    transform: translate(0, 0);
  }
  10% {
    transform: translate(-5%, -10%);
  }
  20% {
    transform: translate(-15%, 5%);
  }
  30% {
    transform: translate(7%, -25%);
  }
  40% {
    transform: translate(-5%, 25%);
  }
  50% {
    transform: translate(15%, 5%);
  }
  60% {
    transform: translate(5%, 15%);
  }
  70% {
    transform: translate(-10%, -15%);
  }
  80% {
    transform: translate(20%, 0%);
  }
  90% {
    transform: translate(-20%, 10%);
  }
}

.chromatic-aberration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 13;
  mix-blend-mode: screen;
  opacity: 0.25;
}

.chromatic-aberration::before,
.chromatic-aberration::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(255, 0, 0, 0.08) 100%
  );
}

.chromatic-aberration::after {
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 100, 255, 0.08) 100%
  );
}

.violet-wash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(120, 81, 169, 0.08),
    rgba(88, 58, 128, 0.05) 50%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 14;
  mix-blend-mode: overlay;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-shell {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.eyebrow {
  font-size: clamp(0.62rem, 1.2vw, 0.82rem);
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: rgba(180, 165, 145, 0.7);
  font-weight: 600;
}

.board-scene {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.board-wrap {
  position: relative;
  flex: 0 0 auto;
  width: min(100vw, calc(100vh * 1.5));
  height: min(100vh, calc(100vw / 1.5));
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate3d(var(--camera-x, 0px), var(--camera-y, 0px), 0);
  will-change: transform;
}

.board-grid {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 32px;
  overflow: hidden;
  box-shadow:
    inset 0 1px 24px rgba(0, 0, 0, 0.35),
    0 32px 64px rgba(0, 0, 0, 0.45);
  isolation: isolate;
}

.board-grid > img {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.board-grid::before {
  content: "";
  position: absolute;
  top: -18%;
  left: -28%;
  z-index: 1;
  width: 70%;
  height: 140%;
  background: linear-gradient(
    96deg,
    transparent 0%,
    rgba(255, 213, 142, 0.04) 32%,
    rgba(255, 238, 188, 0.16) 48%,
    rgba(118, 86, 57, 0.05) 62%,
    transparent 100%
  );
  mix-blend-mode: screen;
  pointer-events: none;
  animation: candle-drift 11s ease-in-out infinite;
}

.board-grid::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  border: 1px solid rgba(247, 232, 206, 0.18);
  pointer-events: none;
}

.board-keys {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.board-key {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: clamp(0.95rem, 2.8vw, 1.6rem);
  font-weight: 600;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: rgba(240, 232, 220, 0);
  transition: transform 260ms ease, text-shadow 260ms ease, opacity 260ms ease;
  pointer-events: none;
  background: none;
  border: none;
  padding: clamp(0.35rem, 0.8vw, 0.65rem);
  opacity: 0;
}

.board-key::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(42px, 5.4vw, 92px);
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(
    circle,
    rgba(255, 242, 196, 0.42) 0%,
    rgba(255, 228, 149, 0.14) 34%,
    transparent 68%
  );
  filter: blur(1px);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.board-key span {
  pointer-events: none;
}

/* Toggle glow on/off by commenting/uncommenting these blocks */

.board-key.flash {
  /* GLOW DISABLED - Uncomment below to enable */
  /*
  color: rgba(253, 228, 186, 0.86);
  opacity: 1;
  */
  opacity: 0;
}

.board-key.active {
  z-index: 2;
  opacity: 1;
}

.board-key.active::before {
  animation: letter-pulse 540ms ease-out both;
}

.board-key.goodbye {
  letter-spacing: 0.5em;
}

.planchette {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: clamp(125px, 16vw, 210px);
  aspect-ratio: 3 / 2;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.55)) drop-shadow(
    0 0 16px rgba(214, 186, 132, 0.08)
  );
  transition: opacity 320ms ease;
  transform-origin: 50% 37%;
  will-change: opacity, transform;
}

.planchette::before,
.planchette::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.planchette::before {
  left: 50%;
  top: 37%;
  z-index: 3;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(
    circle at 38% 32%,
    rgba(255, 249, 218, 0.85) 0 8%,
    rgba(255, 236, 170, 0.32) 16%,
    rgba(144, 112, 80, 0.08) 42%,
    transparent 68%
  );
  mix-blend-mode: screen;
  filter: blur(0.4px);
  animation: eye-shimmer 3.8s ease-in-out infinite;
}

.planchette::after {
  inset: 0;
  z-index: 0;
  background: url("/planchette.png") center / contain no-repeat;
  opacity: 0.14;
  filter: blur(1.4px);
  mix-blend-mode: screen;
  transform: translate(8px, 5px) rotate(-2deg);
}

.planchette img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
}

.reading-actions {
  position: absolute;
  bottom: clamp(1.2rem, 4vw, 2.6rem);
  left: 50%;
  z-index: 20;
  animation: tag-arrive 520ms ease-out both;
}

.ambient-player {
  display: none;
}

.oracle-action {
  min-height: 44px;
  padding: 0.38rem 0.95rem;
  background: linear-gradient(
    130deg,
    rgba(32, 25, 31, 0.86),
    rgba(105, 76, 56, 0.5)
  );
  border: 1.5px solid rgba(255, 231, 181, 0.76);
  border-radius: 4px;
  color: rgba(255, 240, 215, 0.96);
  font-size: clamp(0.62rem, 1.1vw, 0.75rem);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 160ms ease;
  box-shadow:
    0 2px 0 rgba(255, 240, 204, 0.16) inset,
    0 8px 18px rgba(0, 0, 0, 0.34);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-0.8deg);
  backdrop-filter: blur(10px);
}

.oracle-action:hover {
  background: rgba(28, 24, 32, 0.9);
  transform: translateY(-1px) rotate(0.4deg);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  color: rgba(220, 205, 185, 1);
}

.oracle-action:focus-visible {
  outline: 3px solid rgba(255, 240, 210, 0.95);
  outline-offset: 4px;
}

.oracle-action:active {
  transform: translateY(0);
}

@media (max-width: 720px) {
  .board-wrap {
    width: min(170dvh, 250vw);
    height: min(113.333dvh, 166.667vw);
  }

  .board-grid {
    border-radius: 22px;
  }

  .board-key {
    letter-spacing: 0.32em;
  }

  .reading-actions {
    bottom: max(0.85rem, env(safe-area-inset-bottom));
  }
}

.not-found-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  z-index: 2;
}

.not-found-card {
  width: min(460px, 100%);
  padding: 1.5rem;
  border: 2px solid rgba(88, 78, 98, 0.45);
  border-radius: 16px;
  background: rgba(28, 24, 32, 0.88);
  color: rgba(243, 230, 200, 0.95);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.45);
}

.not-found-card h1 {
  margin: 0.4rem 0;
  font-size: clamp(3rem, 18vw, 6rem);
  line-height: 0.95;
}

.not-found-card p:not(.eyebrow) {
  margin: 0 0 1.25rem;
  color: rgba(200, 185, 165, 0.84);
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .board-wrap {
    transform: none !important;
  }
}
