:root {
  --sky-top: #03060b;
  --sky-mid: #0a1420;
  --sky-low: #12202e;
  --sea-1: #0b1a27;
  --sea-2: #08131d;
  --sea-3: #050c13;
  --light: #ffdc8f;
  --light-soft: rgba(255, 220, 143, 0.55);
  --text: #e8edf2;
  --muted: #8796a6;
  --stone: #c9cfd6;
  --font-display: "Cinzel", "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--sky-top);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Sky & storm ---------- */

.sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(40, 60, 80, 0.35), transparent 70%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-low) 100%);
  z-index: 0;
}

.clouds {
  position: fixed;
  inset: -10% -20% auto -20%;
  height: 55%;
  z-index: 1;
  pointer-events: none;
}

.cloud {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 42, 56, 0.9), rgba(30, 42, 56, 0));
  filter: blur(8px);
  animation: drift linear infinite;
}

.cloud:nth-child(1) { width: 70vw; height: 22vh; top: 4%;  left: -10%; animation-duration: 90s; }
.cloud:nth-child(2) { width: 55vw; height: 18vh; top: 18%; left: 40%;  animation-duration: 120s; animation-delay: -40s; }
.cloud:nth-child(3) { width: 80vw; height: 26vh; top: -6%; left: 20%;  animation-duration: 150s; animation-delay: -70s; }
.cloud:nth-child(4) { width: 45vw; height: 15vh; top: 28%; left: -5%;  animation-duration: 100s; animation-delay: -20s; opacity: 0.7; }

@keyframes drift {
  from { transform: translateX(-15vw); }
  to   { transform: translateX(15vw); }
}

#rain, #bolt {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#bolt { z-index: 2; }
#rain { z-index: 6; }

.flash {
  position: fixed;
  inset: 0;
  background: rgba(200, 220, 255, 0.0);
  pointer-events: none;
  z-index: 7;
  transition: background 60ms linear;
}

.flash.on { background: rgba(200, 220, 255, 0.28); }

/* ---------- Lighthouse ---------- */

.lighthouse {
  position: fixed;
  left: 50%;
  bottom: 9vh;
  height: min(60vh, 540px);
  aspect-ratio: 1 / 2;
  transform: translateX(-50%);
  z-index: 3;
}

.lighthouse svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* Lamp sits at (100, 67) in a 200x400 viewBox */
.lamp-anchor {
  position: absolute;
  left: 50%;
  top: 16.75%;
  width: 0;
  height: 0;
  perspective: 900px;
}

.beam {
  position: absolute;
  left: 0;
  top: -70px;
  width: 130vw;
  height: 140px;
  transform-origin: 0 50%;
  /* Soft cone drawn inside an image so no hard box edges show while it rotates */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 200' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g'%3E%3Cstop offset='0' stop-color='%23ffe2a0' stop-opacity='.75'/%3E%3Cstop offset='.45' stop-color='%23ffe2a0' stop-opacity='.18'/%3E%3Cstop offset='.85' stop-color='%23ffe2a0' stop-opacity='0'/%3E%3C/linearGradient%3E%3Cfilter id='b' x='-5%25' y='-20%25' width='110%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='5'/%3E%3C/filter%3E%3C/defs%3E%3Cpolygon points='0,96 1000,30 1000,170 0,104' fill='url(%23g)' filter='url(%23b)'/%3E%3C/svg%3E") no-repeat;
  background-size: 100% 100%;
  animation: sweep 9s linear infinite;
  pointer-events: none;
}

.beam.back {
  animation-delay: -4.5s;
  opacity: 0.6;
}

@keyframes sweep {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(360deg); }
}

.glow {
  position: absolute;
  left: 0;
  top: 0;
  width: 220px;
  height: 220px;
  margin: -110px 0 0 -110px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 230, 170, 0.95), rgba(255, 210, 120, 0.35) 35%, rgba(255, 210, 120, 0) 100%);
  mix-blend-mode: screen;
  animation: pulse 4.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.75); opacity: 0.75; }
  50%      { transform: scale(1.15); opacity: 1; }
}

.lamp-hit {
  position: absolute;
  left: -24px;
  top: -24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: default;
  background: transparent;
  border: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.lamp-hit:focus { outline: none; }
.lamp-hit:focus-visible { outline: 1px dashed rgba(255, 220, 143, 0.4); outline-offset: 4px; }

/* ---------- Sea ---------- */

.sea {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22vh;
  z-index: 4;
  pointer-events: none;
}

.wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background-repeat: repeat-x;
  animation: roll linear infinite;
}

.wave.w1 {
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 100' preserveAspectRatio='none'%3E%3Cpath d='M0 40 Q100 10 200 40 T400 40 T600 40 T800 40 V100 H0Z' fill='%230b1a27'/%3E%3C/svg%3E");
  background-size: 800px 100%;
  animation-duration: 22s;
}

.wave.w2 {
  height: 75%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 100' preserveAspectRatio='none'%3E%3Cpath d='M0 45 Q75 15 150 45 T300 45 T450 45 T600 45 V100 H0Z' fill='%2308131d'/%3E%3C/svg%3E");
  background-size: 600px 100%;
  animation-duration: 14s;
  animation-direction: reverse;
}

.wave.w3 {
  height: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 100' preserveAspectRatio='none'%3E%3Cpath d='M0 50 Q50 20 100 50 T200 50 T300 50 T400 50 V100 H0Z' fill='%23050c13'/%3E%3C/svg%3E");
  background-size: 400px 100%;
  animation-duration: 9s;
}

@keyframes roll {
  from { background-position-x: 0; }
  to   { background-position-x: 800px; }
}

.wave.w2 { animation-name: roll2; }
.wave.w3 { animation-name: roll3; }
@keyframes roll2 { from { background-position-x: 0; } to { background-position-x: 600px; } }
@keyframes roll3 { from { background-position-x: 0; } to { background-position-x: 400px; } }

/* ---------- Copy ---------- */

.copy {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: clamp(28px, 7vh, 72px) 16px 0;
  text-align: center;
  z-index: 8;
  pointer-events: none;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

.title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 5.4vw, 4rem);
  letter-spacing: 0.08em;
  line-height: 1.1;
  margin: 0;
  color: var(--text);
  text-shadow: 0 0 28px rgba(255, 220, 143, 0.18);
}

.title span {
  display: block;
  font-size: 0.42em;
  letter-spacing: 0.5em;
  margin-top: 10px;
  color: var(--light);
  opacity: 0.85;
}

.tagline {
  margin: 22px auto 0;
  max-width: 34ch;
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  line-height: 1.6;
  color: #b7c3cf;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 220, 143, 0.22);
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--light);
  background: rgba(5, 10, 16, 0.45);
  backdrop-filter: blur(4px);
}

.status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--light);
  box-shadow: 0 0 10px var(--light);
  animation: blink 2.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 1; }
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14px;
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(135, 150, 166, 0.55);
  z-index: 8;
  padding: 0 16px;
}

.sound-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 220, 143, 0.22);
  background: rgba(5, 10, 16, 0.45);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: color 0.2s, border-color 0.2s;
}

.sound-toggle svg { width: 18px; height: 18px; }
.sound-toggle[aria-pressed="true"] { color: var(--light); }
.sound-toggle:hover,
.sound-toggle:focus-visible { color: var(--text); border-color: rgba(255, 220, 143, 0.55); outline: none; }

/* ---------- Unlock sequence ---------- */

body.unlocking .beam { animation-duration: 1.2s; }
body.unlocking .glow { animation: none; transform: scale(3); opacity: 1; transition: transform 1s ease-out; }
body.unlocking .whiteout { opacity: 1; }

.whiteout {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, #fff6dc, #ffdc8f 30%, #0a1420 100%);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 1.1s ease-in 0.3s;
}

/* ---------- Keeper's page ---------- */

body.keeper { overflow: auto; }

.keeper-wrap {
  position: relative;
  z-index: 8;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(40px, 10vh, 96px) 16px 64px;
  text-align: center;
  animation: fadein 1.2s ease-out both;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.keeper-wrap .title { font-size: clamp(1.6rem, 4.4vw, 2.8rem); }

.links {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 44px;
}

.link-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 22px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(180deg, rgba(18, 32, 46, 0.72), rgba(8, 16, 24, 0.72));
  border: 1px solid rgba(255, 220, 143, 0.14);
  text-align: left;
  backdrop-filter: blur(6px);
  transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}

.link-card:hover,
.link-card:focus-visible {
  border-color: rgba(255, 220, 143, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 10px 40px -12px rgba(255, 220, 143, 0.25);
  outline: none;
}

.link-card .icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 220, 143, 0.1);
  color: var(--light);
}

.link-card .icon svg { width: 24px; height: 24px; }

.link-card h2 {
  margin: 2px 0 6px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.link-card p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

.link-card .host {
  display: block;
  margin-top: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: rgba(255, 220, 143, 0.6);
  word-break: break-all;
}

.leave {
  margin-top: 48px;
  background: none;
  border: 1px solid rgba(135, 150, 166, 0.3);
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.leave:hover, .leave:focus-visible { color: var(--text); border-color: rgba(255, 220, 143, 0.5); outline: none; }

/* ---------- Responsive & motion ---------- */

@media (max-width: 600px) {
  .lighthouse { height: min(48vh, 420px); bottom: 8vh; }
  .eyebrow { letter-spacing: 0.3em; }
  .title span { letter-spacing: 0.32em; }
}

@media (max-height: 560px) {
  .tagline, .status { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .wave, .status .dot, .glow { animation: none; }
  .beam { animation-duration: 30s; }
}
