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

:root {
  --frame-shadow:
    0 0 0 6px #1c1108,
    0 25px 60px rgba(0, 0, 0, 0.7),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05060a;
  font-family: "Georgia", "Times New Roman", serif;
}

#scene-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#sky {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 15%, #1b2340 0%, #0c0f1f 45%, #05060a 80%);
}

#moon {
  position: absolute;
  top: 8%;
  right: 12%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fdf6e3, #e7dcb8 70%);
  box-shadow: 0 0 60px 20px rgba(253, 246, 227, 0.25), 0 0 140px 60px rgba(253, 246, 227, 0.08);
}

.hills {
  position: absolute;
  left: 0;
  width: 100%;
  height: 32vh;
}

.hills-back {
  bottom: 6vh;
  opacity: 0.9;
}
.hills-back polygon {
  fill: #10131f;
}

.hills-front {
  bottom: 0;
}
.hills-front polygon {
  fill: #05060a;
}

.fog-layer {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 18vh;
  background: linear-gradient(to top, rgba(200, 210, 230, 0.18), rgba(200, 210, 230, 0));
  filter: blur(6px);
  pointer-events: none;
}
.fog-1 {
  bottom: 20vh;
  animation: fogDrift 60s ease-in-out infinite;
}
.fog-2 {
  bottom: 8vh;
  height: 22vh;
  opacity: 0.8;
  animation: fogDrift 90s ease-in-out infinite reverse;
}
.fog-3 {
  bottom: -2vh;
  height: 20vh;
  opacity: 0.9;
  animation: fogDrift 45s ease-in-out infinite;
}

@keyframes fogDrift {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(6%); }
  100% { transform: translateX(0); }
}

#creatures {
  position: absolute;
  inset: 0;
}

.creature {
  position: absolute;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.6));
}

.creature-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 6s infinite;
  animation-delay: calc(var(--blink-delay) * -1s);
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(0.08); }
}

.sclera {
  fill: #eee6d8;
}

.pupil {
  fill: #060606;
  transition: transform 0.12s ease-out;
}

#picker {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 2, 5, 0.92);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

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

.picker-inner {
  text-align: center;
  color: #eee6d8;
  padding: 2rem;
  max-width: 640px;
}

.picker-inner h1 {
  font-size: 1.9rem;
  margin-bottom: 1.75rem;
  color: #ff9d3d;
  text-shadow: 0 0 20px rgba(255, 157, 61, 0.5);
}

.picker-cards {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.picker-card {
  font-family: inherit;
  width: 260px;
  text-align: left;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(238, 230, 216, 0.25);
  background: rgba(238, 230, 216, 0.05);
  color: #eee6d8;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.picker-card:hover {
  background: rgba(255, 157, 61, 0.1);
  border-color: rgba(255, 157, 61, 0.5);
  transform: translateY(-2px);
}

.picker-card h2 {
  font-size: 1.15rem;
  color: #ff9d3d;
  margin-bottom: 0.5rem;
}

.picker-card p {
  font-size: 0.85rem;
  line-height: 1.45;
  opacity: 0.8;
}

#gate {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 2, 5, 0.85);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

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

.gate-inner {
  max-width: 480px;
  text-align: center;
  color: #eee6d8;
  padding: 2rem;
}

.gate-inner h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: #ff9d3d;
  text-shadow: 0 0 20px rgba(255, 157, 61, 0.5);
}

.gate-inner p {
  font-size: 0.95rem;
  line-height: 1.5;
  opacity: 0.85;
  margin-bottom: 1.5rem;
}

#enter-btn {
  font-family: inherit;
  font-size: 1.1rem;
  padding: 0.75rem 1.75rem;
  border-radius: 999px;
  border: 1px solid #ff9d3d;
  background: rgba(255, 157, 61, 0.12);
  color: #ff9d3d;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

#enter-btn:hover {
  background: rgba(255, 157, 61, 0.25);
  transform: scale(1.03);
}

#status-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translate(-50%, 20px);
  z-index: 30;
  background: rgba(20, 20, 25, 0.9);
  color: #eee6d8;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 90%;
  text-align: center;
}

#status-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

#debug-btn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 25;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  border: 1px solid rgba(238, 230, 216, 0.25);
  background: rgba(20, 20, 25, 0.6);
  color: rgba(238, 230, 216, 0.55);
  cursor: pointer;
  transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  opacity: 0.5;
}

#debug-btn:hover {
  opacity: 1;
  color: #eee6d8;
  border-color: rgba(238, 230, 216, 0.6);
}

/* --- Portrait scene --- */

.portrait-wall {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(60, 20, 30, 0.4), transparent 60%),
    repeating-linear-gradient(
      45deg,
      #2a1420,
      #2a1420 18px,
      #301823 18px,
      #301823 36px
    );
}

.portrait-wall::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 22vh 4vh rgba(0, 0, 0, 0.85);
}

.candle-glow {
  position: absolute;
  top: 50%;
  width: 18vh;
  height: 18vh;
  border-radius: 50%;
  transform: translateY(-50%);
  background: radial-gradient(circle, rgba(255, 170, 80, 0.35), transparent 70%);
  filter: blur(4px);
  animation: flicker 3.2s ease-in-out infinite;
}

.candle-left {
  left: 8%;
}

.candle-right {
  right: 8%;
  animation-delay: -1.6s;
}

@keyframes flicker {
  0%, 100% { opacity: 0.7; transform: translateY(-50%) scale(1); }
  45%      { opacity: 0.95; transform: translateY(-50%) scale(1.06); }
  60%      { opacity: 0.6; transform: translateY(-50%) scale(0.96); }
}

.portrait-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(60vh, 80vw);
  aspect-ratio: 1;
  padding: 1.4rem;
  border-radius: 6px;
  background: linear-gradient(155deg, #cfa15a, #7a5222 45%, #cfa15a 55%, #4a3216);
  box-shadow: var(--frame-shadow);
}

.cat-svg {
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(ellipse at 50% 35%, #2c1f28, #150d13 75%);
  border-radius: 2px;
}

.cat-head,
.cat-ear {
  fill: #4a3a40;
}

.cat-ear-inner {
  fill: #a9707c;
  opacity: 0.85;
}

.cat-fur path {
  fill: none;
  stroke: rgba(238, 230, 216, 0.18);
  stroke-width: 0.8;
  stroke-linecap: round;
}

.cat-whiskers path {
  fill: none;
  stroke: rgba(238, 230, 216, 0.55);
  stroke-width: 0.5;
  stroke-linecap: round;
}

.cat-nose {
  fill: #d98a9a;
}

.cat-mouth {
  fill: none;
  stroke: rgba(20, 12, 15, 0.7);
  stroke-width: 1;
  stroke-linecap: round;
}

/* --- Pennywise painting scene --- */

.painting-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(56vh, 72vw);
  aspect-ratio: 3 / 4;
  padding: 1.1rem;
  border-radius: 6px;
  background: linear-gradient(155deg, #cfa15a, #7a5222 45%, #cfa15a 55%, #4a3216);
  box-shadow: var(--frame-shadow);
}

.painting-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  overflow: hidden;
}

.painting-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.painted-eyes-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.painted-iris {
  transition: transform 0.15s ease-out;
}

/* --- Watchful Cat scene --- */

.cat-painting-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(72vh, 80vw);
  aspect-ratio: 1;
  padding: 1.3rem;
  border-radius: 6px;
  background: linear-gradient(120deg, #5a3411, #f1c260 20%, #8e581e 45%, #edc66e 76%, #684015);
  box-shadow: var(--frame-shadow);
}

.cat-painting-frame .painting-inner {
  border: 6px solid #3e250f;
  box-shadow: inset 0 0 0 2px #d9a64d;
}

.cat-pupil {
  transition: transform 0.12s linear;
}
