html, body {
  height: 100%;
  margin: 0;
  background: #f7f4ef;
  font-family: system-ui, sans-serif;
}

/* Full viewport background and true centering */
.viewport {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #8cc2ee;
  z-index: 1;
}

@media (max-width: 767px) {
  .viewport {
    min-height: auto;
    padding-bottom: 80px; /* room for footer & scrolling */
  }
}

/*
  Force the scene to be the biggest 5:3 rectangle that fits inside the viewport.
  This guarantees balanced letterboxing on any screen.
*/
.scene-wrapper {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

.scene-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.scene-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
}


.scene-overlay rect {
  fill: transparent;
  cursor: pointer;
  pointer-events: all; /* 🔑 THIS is the fix */
}


@media (hover: hover) {
  .scene-overlay rect:hover {
    stroke: #ffffff;
    stroke-width: 2;
    stroke-dasharray: 6;
  }
}

/* Main Header */
.main-header {
  position: fixed;
  width: 100%;
  z-index: 2;
  text-align: center;
  top: -12px;
}

.main-header h1 {
  margin-top: 5px;
  margin-bottom: 6px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
}

.main-header p {
  margin: 0;
}

@media (min-width: 768px) {
  html, body {
    overflow: hidden;
  }
}

/* Floating footer (does not affect layout) */
.floating-footer {
  position: fixed;
  left: 0;
  bottom: 15px;
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.85;
  z-index: 50;
}

.floating-footer a {
  color: #444;
  text-decoration: none;
  margin: 0 6px;
}

/* Rotate notice stays as you had it (JS controls display) */
#rotate-notice {
  display: none;
  position: fixed;
  inset: 0;
  background: #f7f4ef;
  z-index: 9999;
  text-align: center;
}

.rotate-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 18px;
  color: #333;
}
/* ===== SUBPAGES ===== */

body.subpage {
  background: #f7f4ef;
  overflow-y: auto;
}

.subpage-header {
  text-align: center;
  padding: 20px 12px 10px;
}

.back-link {
  display: block;
  text-align: left;
  margin-bottom: 10px;
  color: #444;
  text-decoration: none;
  font-size: 0.9rem;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 20px;
  max-width: 1100px;
  margin: auto;
}

.book-card {
  background: white;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.book-card img {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.book-card h2 {
  font-size: 1.1rem;
  margin: 10px 0 6px;
}

.book-card p {
  font-size: 0.9rem;
  color: #555;
}

.preview-btn {
  margin-top: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: 20px;
  border: none;
  background: #ffcc66;
  cursor: pointer;
}

.preview-btn:hover {
  background: #ffbb44;
}

.subpage-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.85rem;
  color: #555;
}

/* ===== PARENT GATE MODAL ===== */

.parent-gate {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.parent-gate-box {
  background: white;
  padding: 26px;
  max-width: 360px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.parent-gate-box h2 {
  margin-top: 0;
}

.parent-gate-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.parent-gate-btn {
  display: block;
  padding: 10px;
  border-radius: 20px;
  background: #4466aa;
  color: white;
  text-decoration: none;
}

.parent-gate-btn:hover {
  background: #365b99;
}

.parent-gate-cancel {
  border: none;
  background: none;
  color: #555;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ===== ACTIVITIES PAGE ===== */

.subhead {
  font-size: 0.95rem;
  color: #555;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 20px;
  max-width: 1100px;
  margin: auto;
}

.activity-card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.activity-card h2 {
  margin-top: 0;
}

.activity-card p {
  font-size: 0.9rem;
  color: #555;
}

.activity-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  background: #88cc88;
  color: #244424;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}

.activity-btn:hover {
  background: #77bb77;
}

/* ===== TOYS PAGE ===== */

.toy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 20px;
  max-width: 1100px;
  margin: auto;
}

.toy-card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.toy-image {
  height: 160px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.toy-image.placeholder {
  background: repeating-linear-gradient(
    45deg,
    #ddd,
    #ddd 10px,
    #eee 10px,
    #eee 20px
  );
}

.toy-card h2 {
  margin-top: 0;
}

.toy-card p {
  font-size: 0.9rem;
  color: #555;
}

.toy-btn {
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  background: #ffcc66;
  cursor: pointer;
}

.toy-btn:hover {
  background: #ffbb44;
}

.content-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  line-height: 1.6;
}

.content-page section {
  margin-bottom: 28px;
}

.content-page h2 {
  margin-top: 0;
}

@media (min-width: 768px) {
  .content-page {
    padding: 32px 24px 48px;
  }
}



.main-header .intro {
  font-size: 1rem;
  color: #555;
}

#site {
  position: relative;
}

#room-container {
  position: relative;
  z-index: 1;
}

/* ===== PREVIEW MODAL ===== */
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.preview-modal img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.preview-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 2.5rem;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

.preview-nav.prev { left: 20px; }
.preview-nav.next { right: 20px; }

.preview-counter {
  position: absolute;
  bottom: 16px;
  color: #fff;
  font-size: 0.9rem;
  opacity: 0.85;
}

.preview-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.preview-end {
  text-align: center;
  color: #fff;
  max-width: min(720px, 92vw);
  font-size: 0.95rem;
  line-height: 1.4;
}

.preview-parent-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  background: #ffcc66;
  color: #333;
  text-decoration: none;
  font-weight: 700;
}

.preview-parent-btn:hover {
  background: #ffbb44;
}

.hidden { display: none; }

/* ===== SPEECH BUBBLE ===== */
.speech-bubble {
  position: absolute;
  max-width: 220px;
  padding: 10px 14px;
  background: #f3f3f3;
  border-radius: 16px;
  font-size: 0.9rem;
  color: #333;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);

  /* comic feel */
  border: 2px solid #333;

  z-index: 20;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 20px;
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: #fff transparent transparent;
}

.hidden {
  display: none;
}

/* ===== SCENE SURPRISE IMAGES ===== */
.scene-surprise {
  position: absolute;
  max-width: 180px;
  z-index: 25;
  pointer-events: none; /* purely visual */
}

.scene-surprise img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0);
}

.hidden {
  display: none;
}
