html, body {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  height: 100%;
}

body {
  background: #2f211f url('/postcards/images/postcardbg.jpg') center/cover no-repeat fixed;
  text-align: center;
  min-height: 100vh;
  overflow-y: auto;
  padding: 0 3rem;
}

/* --- EXIT BUTTON (HOVER SWAP) --- */
.exit {
  position: absolute;
  top: 20px;
  left: 0;
  width: 190px;
  height: auto;
  z-index: 2000;
  /* pointer-events: none;  <-- REMOVED so hover works */
}

#original-image,
#hover-image {
  position: absolute;
  top: 20px;
  left: 0;
  width: 190px;
  height: auto;
  z-index: 2000;
}

#hover-image { opacity: 0; }
a:hover #original-image { opacity: 0; }
a:hover #hover-image   { opacity: 1; }

/* --- POSTCARDS CONTAINER --- */
.postcards {
  position: relative;  /* FIXED: was absolute, causing layout issues */
  width: 100%;
  height: 100vh;
}

/* --- DRAGGABLE CARDS --- */
.postcards a {
  position: absolute;
  display: block;
  cursor: grab;
  user-select: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.2s ease;
  left: calc(10% + 80% * var(--randX));
}

.postcards a.dragging {
  cursor: grabbing;
  z-index: 9999;
  transition: none;
  pointer-events: none;
}

.postcards a {
  transform: rotate(calc(-10deg + 20deg * var(--rand)));
}

.postcards img {
  width: 150px;
  height: auto;
  display: block;
  border-radius: 6px;
  pointer-events: none;
}

.postcards img.landscape {
  width: 500px;
  height: auto;
  aspect-ratio: 3 / 2;
}

.postcards img.portrait {
  width: auto;
  height: 500px;
  aspect-ratio: 2 / 3;
}

.card {
  position: absolute;
  opacity: 0;       
  transition: opacity 0.4s ease;
}

/* --- AUDIO --- */
audio {
  width: 100%;
  height: 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #fff;
  border-radius: 0;
  padding: 0;
  filter: invert(1) hue-rotate(180deg);
}

audio::-webkit-media-controls-progress-bar { background-color: #444 !important; height: 5px; border-radius: 5px; }
audio::-webkit-media-controls-progress-bar::-webkit-progress-value { background-color: #fff !important; height: 100%; }
audio::-webkit-media-controls-current-time-display,
audio::-webkit-media-controls-time-remaining-display,
audio::-webkit-media-controls-timeline { color: #fff !important; }
audio::-webkit-media-controls-play-button { background-color: #fff; border-radius: 30% !important; width: 20px; height: 20px; }
audio::-webkit-media-controls-volume-slider { border-radius: 0 !important; }
audio::-webkit-media-controls-mute-button,
audio::-webkit-media-controls-volume-slider { filter: invert(1); }

/* --- FOOTER --- */
footer {
  font-family: "Roboto Condensed", sans-serif;
  position: absolute;
  bottom: 0;
  right: 10px;
  font-size: 10px;
  color: #fff;
  z-index: 10;
  text-shadow: 1px 1px 3px black, 0 0 5px black;
}

footer a {
  color: #74cfff;
  text-decoration: none;
}

footer a:hover { color: red; }

/* --- MOBILE PORTRAIT --- */
@media (max-width: 480px) {

  .exit {
    width: 40px;
    top: 15px;
  }

  .postcards img.landscape { width: 240px; height: auto; }
  .postcards img.portrait  { width: auto; height: 240px; }

  footer { font-size: 7px; padding-right: 10px; }
}

/* --- MOBILE LANDSCAPE --- */
@media (orientation: landscape) and (max-width: 1024px) {

  .exit {
    width: 100px;
    top: 15px;
  }

  .postcards img.landscape { width: 350px; max-width: 70%; height: auto; }
  .postcards img.portrait  { height: 400px; max-height: 75vh; width: auto; }
}
