/* ============== RESET & BASE ============== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-text: #2C1810;
  --color-cream: #F5DCB4;
  --color-pink: #E58FA1;
  --color-yellow: #FFD66B;
  --font-pixel: 'Press Start 2P', monospace;
  --font-vt: 'VT323', monospace;
  --font-cn: 'ZCOOL KuaiLe', 'PingFang SC', sans-serif;
}

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--font-cn);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse at top, #FFE5B4 0%, #FFB6A3 30%, #C089D4 60%, #6E5C8E 100%);
  background-attachment: fixed;
}

img { image-rendering: pixelated; image-rendering: crisp-edges; }

button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  padding: 0;
}

/* ============== HEADER ============== */
.banner {
  position: relative;
  text-align: center;
  padding: 28px 16px 14px;
  z-index: 4;
}
.title {
  font-family: var(--font-pixel);
  font-size: clamp(13px, 2.4vw, 22px);
  color: #FFF;
  text-shadow:
    2px 2px 0 #8B2C3B,
    4px 4px 0 #2C1810;
  letter-spacing: 2px;
  line-height: 1.4;
}
.subtitle {
  font-family: var(--font-cn);
  font-size: clamp(12px, 1.4vw, 16px);
  color: #FFF7B6;
  margin-top: 10px;
  text-shadow: 1px 1px 0 #5C2C24;
  letter-spacing: 2px;
}
.hint {
  font-family: var(--font-vt);
  color: #FFE9B0;
  font-size: 16px;
  margin-top: 8px;
  letter-spacing: 1px;
  opacity: 0.8;
}

/* ============== TOWN SCENE — long vertical scroll ============== */
.town-scene {
  position: relative;
  width: min(100vw, 600px);
  margin: 0 auto;
  /* match the stitched landscape: 941 wide × 7360 tall */
  aspect-ratio: 941 / 7360;
  background-image: url('images/town_landscape_tall.png');
  background-size: 100% 100%;
  background-position: center top;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid #2C1810;
  box-shadow: 6px 6px 0 rgba(0,0,0,0.4);
  overflow: hidden;
}

/* ============== COUPLE (Yuntao stands at plaza) ============== */
.couple {
  position: absolute;
  left: 38%;
  top: 92.5%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 5;
}
.character {
  width: clamp(40px, 6vw, 56px);
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.4));
  animation: bob 2s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.couple-tag {
  margin-top: 4px;
  background: rgba(44,24,16,0.85);
  color: #FFF7B6;
  font-family: var(--font-vt);
  font-size: 13px;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 1px;
}
.heart-bond {
  position: absolute;
  left: 110%;
  top: 25%;
  font-size: 24px;
  color: #FF4B6E;
  text-shadow: 2px 2px 0 #8B1B33;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* ============== RESIDENTS ============== */
.residents-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  --scene-scale: 1;
}
.resident {
  position: absolute;
  --resident-width: 96px;
  --resident-height: 120px;
  --resident-scale: 1;
  width: calc(var(--resident-width) * var(--scene-scale) * var(--resident-scale));
  min-height: calc(var(--resident-height) * var(--scene-scale) * var(--resident-scale));
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(2px 3px 0 rgba(44,24,16,0.5));
}

.resident-hit {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  z-index: 2;
  transform: translate(-50%, -50%);
  transition: filter 0.18s ease;
}
.resident-hit:hover {
  filter: drop-shadow(3px 5px 0 rgba(44,24,16,0.7)) brightness(1.06);
}
.resident:has(.resident-hit:hover) {
  z-index: 10;
}
.resident:has(.resident-hit:hover) .resident-tag {
  opacity: 1;
  transform: translateY(0);
}

.resident-img-wrap {
  width: 100%;
  height: calc(var(--resident-height) * var(--scene-scale) * var(--resident-scale));
  position: relative;
  overflow: hidden;
  animation: resident-bob 2.4s ease-in-out infinite;
}
.resident-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.resident-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-cn);
  font-size: 11px;
  color: #FFF;
  text-align: center;
  background: linear-gradient(180deg, #8B2C3B, #5C1D26);
  border: 2px solid #FFD66B;
  border-radius: 4px;
  padding: 4px;
  letter-spacing: 1px;
  line-height: 1.2;
}
.resident-placeholder.show { display: flex; }

.resident-tag {
  margin-top: 4px;
  background: rgba(44, 24, 16, 0.92);
  color: #FFF7B6;
  font-family: var(--font-cn);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: 1px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

/* Up balloon house — bigger and floats */
.resident-sky .resident-img-wrap {
  animation: float-sky 5s ease-in-out infinite;
}
.resident-sky {
  --resident-width: 160px;
  --resident-height: 200px;
  animation: none;
}
@keyframes float-sky {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@keyframes resident-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* Mountain residents — slightly bigger so they read on the hillside */
.resident-mountain .resident-img-wrap {
}
.resident-mountain {
  --resident-width: 96px;
  --resident-height: 128px;
}

/* ============== FOOTER ============== */
.footer {
  position: relative;
  text-align: center;
  padding: 20px 16px;
  font-family: var(--font-vt);
  color: #FFF7B6;
  font-size: 16px;
  z-index: 2;
  letter-spacing: 2px;
  background: rgba(44,24,16,0.5);
  margin-top: 12px;
}

/* ============== MODAL ============== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 24, 16, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--color-cream);
  border: 4px solid var(--color-text);
  border-radius: 8px;
  padding: 24px 26px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    8px 8px 0 #2C1810,
    inset 0 0 0 4px var(--color-yellow);
  position: relative;
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 36px;
  height: 36px;
  font-size: 28px;
  font-weight: bold;
  color: var(--color-text);
  line-height: 1;
}
.modal-close:hover {
  color: #8B2C3B;
  transform: scale(1.1);
}

/* ============== DETAIL MODAL ============== */
.modal-detail { text-align: center; }
.detail-img-wrap {
  width: 100%;
  aspect-ratio: 3/4;
  max-width: 220px;
  margin: 0 auto 16px;
  border: 4px solid var(--color-text);
  background: linear-gradient(135deg, #D9BC92, #B8915A);
  position: relative;
  overflow: hidden;
  box-shadow: 4px 4px 0 #2C1810;
}
.detail-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #F5DCB4;
}
.detail-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: var(--font-cn);
  color: #5C2C24;
  font-size: 14px;
  background:
    repeating-linear-gradient(45deg,
      #E8C9A0 0, #E8C9A0 10px,
      #D9BC92 10px, #D9BC92 20px);
}
.detail-placeholder.show { display: flex; }
.detail-name {
  font-family: var(--font-cn);
  font-size: 22px;
  color: #8B2C3B;
  letter-spacing: 2px;
}
.detail-en {
  font-family: var(--font-vt);
  font-size: 17px;
  color: #5C2C24;
  margin: 4px 0 6px;
  letter-spacing: 1px;
}
.detail-activity {
  font-family: var(--font-cn);
  font-size: 14px;
  color: #8B6B4A;
  margin-bottom: 14px;
  letter-spacing: 1px;
}
.detail-memory {
  font-family: var(--font-cn);
  font-size: 16px;
  color: var(--color-text);
  line-height: 1.7;
  background: #FFF7E6;
  padding: 14px 16px;
  border: 2px dashed #8B6B4A;
  border-radius: 4px;
  letter-spacing: 1px;
}

/* ============== RESPONSIVE TWEAKS ============== */
@media (max-width: 600px) {
  .resident-tag { font-size: 11px; }
}
