@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

:root {
  --black: #070509;
  --dark: #100812;
  --burgundy: #4a102b;
  --wine: #761b3c;
  --purple: #29132f;
  --gold: #c7a66b;
  --white: #f3eaf0;
  --muted: #b8a6b5;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--black);
  color: var(--white);
  font-family: 'Cormorant Garamond', serif;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.screen {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 30%, #301124 0%, transparent 48%),
    radial-gradient(ellipse at 10% 90%, #201027 0%, transparent 45%),
    linear-gradient(145deg, #080609, #160914 55%, #080609);
}

.hidden {
  display: none !important;
}

/* PASSWORD SCREEN */

.password-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  isolation: isolate;
  background:
    linear-gradient(to top, #030204 0%, transparent 65%),
    radial-gradient(ellipse at 50% 55%, #85355245, transparent 58%),
    linear-gradient(180deg, #08060b, #24101f 65%, #050306);
}

.moon {
  position: absolute;
  z-index: -2;
  width: 170px;
  height: 170px;
  top: 7%;
  right: 13%;
  border-radius: 50%;
  background: radial-gradient(circle, #d5c0ce, #796078 35%, transparent 72%);
  opacity: 0.3;
  filter: blur(2px);
}

.castle-backdrop {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  opacity: 0.9;
}

.back-castle {
  position: absolute;
  width: 52%;
  height: 33%;
  left: 24%;
  bottom: 0;
  background: linear-gradient(90deg, #09060b, #241425, #08060b);
  border: 1px solid #392536;
  border-bottom: none;
  box-shadow: 0 0 45px #7b244555;
}

.back-tower {
  position: absolute;
  bottom: 0;
  width: 15%;
  height: 43%;
  background: linear-gradient(90deg, #08060b, #241626, #09060b);
  border: 1px solid #392536;
}

.left-tower {
  left: 19%;
}

.right-tower {
  right: 19%;
}

.back-tower::before {
  content: "";
  position: absolute;
  top: -21%;
  left: -16%;
  width: 132%;
  height: 23%;
  background: #1c1020;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.back-window {
  position: absolute;
  width: 12px;
  height: 25px;
  background: #a35c71;
  border-radius: 50% 50% 0 0;
  box-shadow: 0 0 18px #c24760;
}

.window-one {
  left: 24%;
  top: 20%;
}

.window-two {
  right: 24%;
  top: 40%;
}

.back-door {
  position: absolute;
  bottom: 0;
  left: 41%;
  width: 18%;
  height: 48%;
  border: 1px solid #674256;
  border-bottom: none;
  border-radius: 50% 50% 0 0;
  background: #050407;
}

.foreground-ground {
  position: absolute;
  bottom: 0;
  height: 12%;
  width: 100%;
  background: linear-gradient(transparent, #030204);
}

.intro-card {
  position: relative;
  z-index: 2;
  width: min(440px, 100%);
  text-align: center;
  padding: 42px 28px;
  border: 1px solid #8c5367;
  background: linear-gradient(145deg, #1c0c1ced, #09060bee);
  box-shadow: 0 0 65px #842b5140, inset 0 0 40px #772b461c;
  animation: entranceGlow 4s ease-in-out infinite alternate;
}

@keyframes entranceGlow {
  from {
    box-shadow: 0 0 35px #842b5130, inset 0 0 25px #772b4610;
  }
  to {
    box-shadow: 0 0 75px #a23e6845, inset 0 0 40px #772b4625;
  }
}

.eyebrow {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.intro-card h1 {
  margin: 20px 0 12px;
  font-family: 'Cinzel', serif;
  font-size: clamp(30px, 7vw, 48px);
  font-weight: 500;
  letter-spacing: 5px;
  color: #f6e8ef;
  text-shadow: 0 0 8px #a54b70, 0 0 30px #6f2149;
}

.ornament {
  color: #c7a66b;
  font-size: 14px;
  letter-spacing: 4px;
  margin: 18px 0;
}

.subtitle {
  color: var(--muted);
  font-style: italic;
  font-size: 19px;
  line-height: 1.5;
  margin-bottom: 30px;
}

input[type="password"] {
  display: block;
  width: 100%;
  padding: 15px;
  margin-bottom: 16px;
  color: white;
  background: #0a070c;
  border: 1px solid #82506a;
  outline: none;
  text-align: center;
}

input:focus,
textarea:focus {
  border-color: var(--gold);
}

button {
  color: var(--white);
  background: linear-gradient(135deg, #681a3b, #35132f);
  border: 1px solid #9a536c;
  padding: 13px 20px;
  letter-spacing: 2px;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  transition: 0.25s ease;
}

button:hover {
  background: linear-gradient(135deg, #8a2449, #49204b);
  box-shadow: 0 0 20px #87375b55;
}

.intro-card button {
  width: 100%;
  padding: 16px;
  letter-spacing: 3px;
}

#passwordMessage {
  min-height: 18px;
  color: #d58b9c;
  font-style: italic;
}

/* TOP NAVIGATION */

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid #572b42;
  background: #09060be8;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 2px;
}

.small-button {
  padding: 9px 12px;
  font-size: 9px;
  letter-spacing: 1px;
}

/* FORT */

.fort-content {
  width: min(900px, 100%);
  padding: 30px 18px;
  margin: auto;
  text-align: center;
}

.fort-content h1,
.library-heading h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(27px, 5vw, 43px);
  font-weight: 500;
  margin: 10px 0;
  text-shadow: 0 0 25px #8b274c;
}

.description,
.library-heading p {
  color: var(--muted);
  font-size: 18px;
  font-style: italic;
  line-height: 1.5;
}

.fort-scene {
  height: min(430px, 58vh);
  min-height: 300px;
  max-width: 720px;
  margin: 25px auto;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 65%, #55213f 0%, transparent 35%),
    linear-gradient(#09070f 0%, #211023 58%, #080609 100%);
  border: 1px solid #4f2a42;
  box-shadow: inset 0 -60px 90px #030205, 0 0 35px #3b1234;
}

.scene-moon {
  position: absolute;
  top: 8%;
  left: 42%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #bba1b9, #5e3a5b 55%, transparent 75%);
  opacity: 0.4;
}

.scene-castle {
  position: absolute;
  width: 70%;
  height: 70%;
  left: 15%;
  bottom: 0;
  filter: drop-shadow(0 0 22px #8b234955);
}

.scene-main {
  position: absolute;
  width: 48%;
  height: 57%;
  left: 26%;
  bottom: 12%;
  background: linear-gradient(90deg, #100c15, #30202e, #100b13);
  border: 2px solid #3d2b3b;
  border-bottom: none;
}

.scene-door {
  position: absolute;
  width: 25%;
  height: 40%;
  bottom: 0;
  left: 37%;
  border: 2px solid #664057;
  border-bottom: none;
  border-radius: 50% 50% 0 0;
  background: #07050a;
  box-shadow: 0 0 22px #6f173c55;
}

.scene-upper-window,
.scene-window {
  position: absolute;
  width: 14px;
  height: 24px;
  left: 45%;
  top: 20%;
  border: 1px solid #a46b79;
  border-radius: 50% 50% 0 0;
  background: #c17b74;
  box-shadow: 0 0 18px #c24760;
}

.scene-tower {
  position: absolute;
  bottom: 12%;
  width: 24%;
  height: 76%;
  background: linear-gradient(90deg, #100a14, #382536, #110b13);
  border: 2px solid #3c293b;
}

.tower-left {
  left: 5%;
}

.tower-right {
  right: 5%;
}

.scene-roof {
  position: absolute;
  top: -25%;
  left: -15%;
  width: 130%;
  height: 27%;
  background: #201222;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  border-bottom: 2px solid #6b3c52;
}

.scene-fog {
  position: absolute;
  height: 30px;
  width: 150%;
  left: -20%;
  bottom: 15%;
  background: #b3a0b0;
  opacity: 0.08;
  filter: blur(18px);
  border-radius: 50%;
  animation: fogMove 12s ease-in-out infinite alternate;
}

.fog-two {
  bottom: 35%;
  animation-delay: -5s;
}

@keyframes fogMove {
  from { transform: translateX(-8%); }
  to { transform: translateX(8%); }
}

.hidden-object {
  position: absolute;
  z-index: 4;
  padding: 0;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  color: #f2d7a0;
  border: 1px solid #9e7b65;
  background: #170d1dc9;
  box-shadow: 0 0 15px #c57c9c66;
  animation: objectPulse 2s infinite alternate;
}

.hidden-object.found {
  opacity: 0.2;
  pointer-events: none;
  animation: none;
}

.object-one { top: 27%; left: 18%; }
.object-two { top: 48%; right: 18%; }
.object-three { bottom: 24%; left: 35%; }
.object-four { top: 18%; right: 30%; }
.object-five { bottom: 15%; right: 33%; }

@keyframes objectPulse {
  from { box-shadow: 0 0 6px #a0447a44; }
  to { box-shadow: 0 0 20px #dba4b866; }
}

.scene-ground {
  position: absolute;
  height: 15%;
  bottom: 0;
  width: 100%;
  background: linear-gradient(transparent, #050407);
  pointer-events: none;
}

.mission-panel {
  max-width: 520px;
  margin: auto;
  padding: 20px;
  background: #100812;
  border: 1px solid #4d2b43;
}

#missionText,
#objectCount {
  color: var(--muted);
  font-style: italic;
  font-size: 17px;
}

.progress-track {
  height: 5px;
  width: 100%;
  background: #2a1a2a;
  margin: 15px 0;
}

#missionProgress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6f2345, #d1a2b2);
  transition: width 0.4s ease;
}

/* LIBRARY */

.library-heading {
  text-align: center;
  padding: 25px 15px 15px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 13px;
  width: min(950px, 94%);
  margin: 20px auto 45px;
}

.chamber {
  min-height: 100px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 10px 4px;
  border: 1px solid #684155;
  background: linear-gradient(150deg, #35172fdd, #100912f5 70%);
  box-shadow: inset 0 0 22px #8e34551a, 0 5px 18px #0008;
  color: #f0dfe8;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 1px;
  overflow: hidden;
}

.chamber::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #b17a8c, transparent);
}

.chamber .chamber-icon {
  font-size: 24px;
  color: #c9a0b4;
}

.chamber.locked {
  filter: grayscale(0.7);
  opacity: 0.65;
  background: linear-gradient(150deg, #17121b, #09070a);
}

.chamber.available {
  box-shadow: 0 0 20px #7b2e5540;
}

.chamber.opened {
  border-color: #c49b72;
}

/* OWNER PANEL */

.owner-panel {
  width: min(650px, 92%);
  margin: 0 auto 40px;
  padding: 22px;
  background: #150b17;
  border: 1px solid #754052;
  text-align: center;
}

.owner-panel p {
  color: var(--muted);
  line-height: 1.5;
}

/* LETTERS */

.letter-layout {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 14px;
}

.letter-card {
  width: min(720px, 100%);
  padding: clamp(20px, 5vw, 42px);
  background: linear-gradient(145deg, #1a0d1b, #0b080e 75%);
  border: 1px solid #714055;
  box-shadow: 0 0 45px #5b183b22;
}

.letter-card > .eyebrow {
  text-align: center;
}

.letter-display {
  color: #f4eaf1;
  white-space: pre-wrap;
  font-size: clamp(18px, 3vw, 22px);
  line-height: 1.65;
  font-style: italic;
  margin: 25px 0 35px;
  overflow-wrap: anywhere;
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 16px;
  color: white;
  background: #09060c;
  border: 1px solid #654057;
  font-family: 'Cormorant Garamond', serif;
  font-size: 19px;
  line-height: 1.5;
  outline: none;
}

.edit-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.secondary-button {
  background: #16101a;
  border-color: #654057;
}

.voice-section {
  padding-top: 20px;
  border-top: 1px solid #4c2b41;
}

.voice-section .eyebrow {
  letter-spacing: 3px;
}

audio {
  display: block;
  width: 100%;
  margin: 15px 0;
}

#voiceStatus,
.day-message {
  color: var(--muted);
  font-size: 16px;
  font-style: italic;
  line-height: 1.4;
}

#voiceUpload {
  display: none;
}

.upload-label {
  display: inline-block;
  padding: 12px;
  margin: 8px 0;
  color: white;
  border: 1px solid #8b526c;
  background: #341329;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
}

#removeVoice {
  display: block;
  margin-top: 8px;
}

.return-button {
  width: 100%;
  margin-top: 28px;
}

/* MOBILE */

@media (max-width: 600px) {
  .topbar {
    padding: 12px 9px;
    gap: 5px;
    font-size: 8px;
    letter-spacing: 1px;
  }

  .small-button {
    padding: 8px 7px;
    font-size: 8px;
  }

  .library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
  }

  .chamber {
    min-height: 84px;
    font-size: 10px;
  }

  .chamber .chamber-icon {
    font-size: 21px;
  }

  .fort-scene {
    height: 360px;
  }

  .intro-card {
    padding: 32px 20px;
  }

  .back-castle {
    width: 65%;
    left: 17.5%;
  }

  .left-tower {
    left: 8%;
  }

  .right-tower {
    right: 8%;
  }
}

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