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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0a;
  font-family: 'Newsreader', Georgia, serif;
}

.hidden { display: none !important; }

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  color: #c8b99a;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  z-index: 100;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(200, 185, 154, 0.2);
  border-top-color: #c8b99a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.5em;
}

@keyframes spin { to { transform: rotate(360deg); } }

#landing {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
}

#landing-left {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5efe6;
  padding: 60px 40px 20px;
  flex: 1;
}

#landing-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(4rem, 20vw, 10rem);
  font-weight: 600;
  text-align: center;
  line-height: 1;
  letter-spacing: 0.04em;
  color: #b8312e;
  opacity: 0;
  animation: fadeIn 0.8s ease-out 0.1s forwards;
}

#landing-right {
  display: flex;
  flex-direction: column;
  background: #e5d5c0;
  padding: 20px 40px 40px;
  flex: 1;
}

#landing-right-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#landing-subtitle {
  font-family: 'Newsreader', Georgia, serif;
  font-size: clamp(1.15rem, 2.5vw, 1.6rem);
  color: #6b5d4d;
  text-align: center;
  letter-spacing: 0.03em;
  line-height: 1.6;
  margin: 0 0 1.5rem 0;
  max-width: 420px;
  opacity: 0;
  animation: fadeIn 0.8s ease-out 0.3s forwards;
}

#begin-btn {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #b8312e;
  background: transparent;
  border: 1.5px solid rgba(184, 49, 46, 0.4);
  padding: 12px 36px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s, border-color 0.2s;
  opacity: 0;
  animation: fadeIn 0.8s ease-out 0.5s forwards;
}

#begin-btn:hover {
  background: rgba(184, 49, 46, 0.06);
  border-color: rgba(184, 49, 46, 0.55);
}

#landing-footer {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: #b0a898;
  letter-spacing: 0.04em;
  text-align: center;
  opacity: 0;
  animation: fadeIn 0.8s ease-out 0.6s forwards;
}

#landing-footer a {
  color: #8a7d6b;
  text-decoration: none;
  transition: color 0.2s;
}

#landing-footer a:hover {
  color: #6b5d4d;
}

@media (min-width: 768px) {
  #landing {
    flex-direction: row;
  }
  #landing-left {
    flex: 1;
    padding: 40px;
  }
  #landing-right {
    flex: 1;
    padding: 40px;
  }
  #landing-subtitle {
    text-align: left;
  }
  #landing-right-center {
    align-items: flex-start;
  }
  #landing-footer {
    text-align: left;
  }
  #landing-title {
    font-size: clamp(5rem, 10vw, 14rem);
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

#art-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#art-image {
  position: absolute;
  width: 110%;
  height: 110%;
  top: -5%;
  left: -5%;
  object-fit: cover;
  will-change: transform;
}

#art-image.ken-burns {
  animation: kenBurns 12s ease-out forwards;
}

#art-image.ken-burns-pan-h {
  animation: kenBurnsPanH 22s ease-in-out forwards;
}

#art-image.ken-burns-pan-v {
  animation: kenBurnsPanV 22s ease-in-out forwards;
}

@keyframes kenBurns {
  from { transform: scale(1.15); }
  to   { transform: scale(1); }
}

@keyframes kenBurnsPanH {
  from { transform: scale(1.08) translateX(var(--pan-sx, -6%)); }
  to   { transform: scale(1.02) translateX(var(--pan-ex, 6%)); }
}

@keyframes kenBurnsPanV {
  from { transform: scale(1.08) translateY(var(--pan-sy, -6%)); }
  to   { transform: scale(1.02) translateY(var(--pan-ey, 6%)); }
}

#overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0.03) 0%,
    rgba(0,0,0,0.06) 40%,
    rgba(0,0,0,0.25) 70%,
    rgba(0,0,0,0.4) 100%
  );
  pointer-events: none;
}

#art-container.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 5;
  pointer-events: none;
}

#art-container.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 2px solid rgba(200, 185, 154, 0.2);
  border-top-color: #c8b99a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 6;
  pointer-events: none;
}

#poem-display {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4rem 2rem 6rem;
  color: #ece4d9;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  pointer-events: none;
  max-width: 900px;
  margin: 0 auto;
}

#poem-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  color: #e8dcc8;
}

#poem-author {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  font-style: italic;
  color: #c8b99a;
  margin-bottom: 1.5rem;
  letter-spacing: 0.04em;
}

#poem-body {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.75;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(200,185,154,0.3) transparent;
  pointer-events: auto;
}

#poem-body::-webkit-scrollbar {
  width: 4px;
}
#poem-body::-webkit-scrollbar-thumb {
  background: rgba(200,185,154,0.3);
  border-radius: 2px;
}

#poem-body .poem-line {
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

#poem-body .poem-line:nth-child(1) { animation-delay: 0.05s; }
#poem-body .poem-line:nth-child(2) { animation-delay: 0.1s; }
#poem-body .poem-line:nth-child(3) { animation-delay: 0.15s; }
#poem-body .poem-line:nth-child(4) { animation-delay: 0.2s; }
#poem-body .poem-line:nth-child(5) { animation-delay: 0.25s; }
#poem-body .poem-line:nth-child(6) { animation-delay: 0.3s; }
#poem-body .poem-line:nth-child(7) { animation-delay: 0.35s; }
#poem-body .poem-line:nth-child(8) { animation-delay: 0.4s; }
#poem-body .poem-line:nth-child(9) { animation-delay: 0.45s; }
#poem-body .poem-line:nth-child(10) { animation-delay: 0.5s; }
#poem-body .poem-line:nth-child(n+11) { animation-delay: 0.55s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#poem-source {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: #9a8f7a;
  letter-spacing: 0.04em;
}

#art-info {
  position: fixed;
  bottom: 4.5rem;
  right: 1.5rem;
  text-align: right;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 10;
}

#art-info-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  font-weight: 600;
}

#art-info-artist {
  font-size: 0.75rem;
  font-style: italic;
  color: rgba(200, 185, 154, 0.8);
}

#art-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ece4d9;
  padding: 0.45rem 1rem;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s, border-color 0.2s;
  z-index: 10;
}

#art-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

#art-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
}

#art-modal img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.6);
}

#art-modal-close {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 210;
  line-height: 1;
  transition: color 0.2s;
  border: none;
  background: none;
  font-family: inherit;
}

#art-modal-close:hover {
  color: #fff;
}

#art-modal-info {
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  padding: 1rem 1.5rem 2rem;
  pointer-events: none;
}

#art-modal-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  letter-spacing: 0.06em;
  font-weight: 600;
}

#art-modal-artist {
  font-size: 0.85rem;
  font-style: italic;
  color: rgba(200, 185, 154, 0.8);
  margin-top: 0.15rem;
}

#music-btn {
  position: fixed;
  top: 1.5rem;
  right: calc(1.5rem + 56px);
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  color: #ece4d9;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  z-index: 20;
}

#music-btn svg {
  display: block;
}

#music-btn .icon-pause {
  display: none;
}

#music-btn.playing .icon-play {
  display: none;
}

#music-btn.playing .icon-pause {
  display: block;
}

#music-btn.playing {
  border-color: rgba(100, 200, 100, 0.35);
}

#music-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

#next-btn {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  color: #ece4d9;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  z-index: 20;
}

#next-btn svg {
  display: block;
}

#next-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

#hint {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: rgba(200, 185, 154, 0.4);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.5s;
}

@media (max-width: 600px) {
  #poem-display {
    padding: 3rem 1.25rem 5rem;
  }
  #poem-title {
    font-size: 1.2rem;
  }
  #poem-body {
    font-size: 1rem;
    max-height: 45vh;
  }
  #art-info {
    display: none;
  }
}
