:root {
  --ink: #3b281c;
  --ink-soft: #6d4e38;
  --accent: #ff8547;
  --bubble: #ffffff;
  --bubble-border: #3b281c;
  --inside-bg: #2e2e31;       /* 내부 장면 바깥 검회색 */
  --dissolve-ms: 900ms;

  /* 건물.PNG 에서 건물이 그려진 영역 (원본 1920x1080 기준 x 570~1482, y 145~745) */
  --building-ar: 912 / 600;
  --building-w: calc(min(92vw, calc(64vh * 1.52), 920px) * 0.7);

  /* 내부.PNG 에서 방이 그려진 영역 (원본 1920x1080 기준 x 536~1384, y 242~828) */
  --room-ar: 848 / 586;
  --room-w: calc(min(94vw, calc(86vh * 1.447), 1040px) * 0.7);
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  font-family: 'Gaegu', 'Jua', system-ui, sans-serif;
  color: var(--ink);
  background: var(--inside-bg);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- 장면 (외부 / 내부) ---------- */
.page { position: relative; width: 100%; height: 100dvh; touch-action: none; }

.scene {
  position: fixed; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 38px;
  touch-action: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--dissolve-ms) ease,
    visibility 0s linear var(--dissolve-ms);
}
.scene.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity var(--dissolve-ms) ease,
    visibility 0s;
}

/* 외부: 들판 배경 */
.scene-outside {
  background-color: #bfa58d;
  background-image: url('field_1.JPG');
  background-size: 50% auto;
  background-position: center center;
  background-repeat: repeat;
}

/* 내부: 검회색 배경 */
.scene-inside { background: var(--inside-bg); }

/* ---------- 타이틀 ---------- */
.hero {
  position: relative;
  text-align: center;
  z-index: 5;
  pointer-events: none;
  margin-bottom: 6px;
}
/* 제목.PNG 에서 팻말이 그려진 영역만 표시 (원본 1920x1080 기준 x 555~1292, y 208~558) */
.title-sign {
  position: relative;
  display: block;
  margin: 0 auto;
  width: clamp(140px, 20vw, 250px);
  aspect-ratio: 737 / 350;
  overflow: hidden;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .25));
  animation: titleIn .8s cubic-bezier(.2,1.4,.4,1) both;
}
.title-img {
  position: absolute;
  width: 260.516%;            /* 1920 / 737 */
  left: -75.305%;             /* -555 / 737 */
  top: -59.429%;              /* -208 / 350 */
  height: auto;
  filter: url(#sign-tone);    /* 건물 간판과 같은 색으로 (index.html 의 SVG 필터) */
  pointer-events: none;
}
@keyframes titleIn { from { opacity: 0; transform: translateY(-14px) scale(.9); } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 건물 (화면 정중앙) ---------- */
.building {
  position: relative;
  width: var(--building-w);
  aspect-ratio: var(--building-ar);
  filter: drop-shadow(0 10px 14px rgba(40, 30, 20, .3));
  animation: fadeUp .9s .3s both;
  touch-action: manipulation;
}
.building-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;           /* 이미지의 여백을 잘라내 건물만 표시 */
  pointer-events: none;
  z-index: 0;
}
.building-img {
  position: absolute;
  width: 210.526%;            /* 1920 / 912 */
  left: -62.5%;               /* -570 / 912 */
  top: -24.167%;              /* -145 / 600 */
  height: auto;
  pointer-events: none;
}

/* ---------- 문 클릭 영역 ---------- */
.door-hotspot {
  position: absolute;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color .25s ease, box-shadow .25s ease;
  z-index: 5;
}
/* 건물 문 (원본 x 1145~1340, y 290~635) */
.scene-outside .door-hotspot {
  left: 63%; top: 24.2%;
  width: 21.4%; height: 57.5%;
  animation: doorGlow 2.4s ease-in-out 1.2s infinite;
}
.door-hotspot:hover,
.door-hotspot:focus-visible {
  background-color: rgba(255, 220, 120, .18);
  box-shadow: 0 0 0 3px rgba(255, 220, 120, .65), 0 0 22px rgba(255, 210, 110, .55);
  outline: none;
  animation: none;
}
@keyframes doorGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 220, 120, 0); }
  50%      { box-shadow: 0 0 0 3px rgba(255, 220, 120, .45), 0 0 18px rgba(255, 210, 110, .35); }
}

/* ---------- 외부 우편함 ---------- */
.mailbox-obj {
  position: absolute;
  left: 108%;
  top: 89%;
  width: 23.4%;
  aspect-ratio: 4 / 5;
  transform: translate(-50%, -88%);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 440;
  touch-action: manipulation;
}
.mailbox-shadow {
  position: absolute;
  left: 24%;
  bottom: 8%;
  width: 52%;
  height: 10%;
  background: radial-gradient(ellipse, rgba(60, 45, 35, .4), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.mailbox-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  transform-origin: 50% 88%;
  transition: transform .18s ease, filter .2s ease;
}
.mailbox-obj.has-mail .mailbox-img {
  animation: mailBounce 2.2s ease-in-out infinite;
}
@keyframes mailBounce {
  0%, 80%, 100% { transform: scale(1, 1) rotate(0deg); }
  86%           { transform: scale(1.06, .95) rotate(-4deg); }
  92%           { transform: scale(.97, 1.04) rotate(4deg); }
  96%           { transform: scale(1.02, .99) rotate(-2deg); }
}
.mailbox-obj.near-player .mailbox-img,
.mailbox-obj:hover .mailbox-img {
  filter: drop-shadow(0 0 8px rgba(255, 220, 110, .9));
}
.mailbox-prompt {
  top: calc(16% - 10px);
}
.mailbox-obj.near-player .mailbox-prompt,
.mailbox-obj:hover .mailbox-prompt {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}

/* ---------- 내부 방 ---------- */
.room {
  position: relative;
  width: var(--room-w);
  aspect-ratio: var(--room-ar);
  touch-action: manipulation;
}
.room-clip {
  position: absolute; inset: 0;
  overflow: hidden;           /* 이미지의 여백을 잘라내 방만 표시 */
  pointer-events: none;
  z-index: 0;
}
.room-img {
  position: absolute;
  width: 226.415%;            /* 1920 / 848 */
  left: -63.208%;             /* -536 / 848 */
  top: -41.297%;              /* -242 / 586 */
  height: auto;
  pointer-events: none;
  z-index: 0;
}
/* 방 안 오른쪽 아래 출입문 (원본 x 1160~1345, y 776~820) */
.room .door-hotspot.exit {
  left: 73.4%; top: 88%;
  width: 22%; height: 12%;
  z-index: 5;
}

/* ---------- 동물 ---------- */
.animal {
  position: absolute;
  width: calc(24.7% * var(--size, 1));   /* 19% × 1.3, 동물별 배율(--size) 적용 */
  aspect-ratio: 1 / 1;
  /* 발끝(이미지 하단 약 79%, 동물별 --foot)을 좌표 기준점으로 */
  transform: translate(-50%, calc(var(--foot, 79%) * -1));
  pointer-events: none;       /* 투명 여백이 출입문 클릭을 가리지 않도록 */
  z-index: 10;
}

.animal .hit {
  /* 실제 캐릭터 부분만 클릭되도록 */
  position: absolute; left: 22%; top: 18%; width: 56%; height: 64%;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 45%;
  z-index: 3;
}

.animal .shadow {
  position: absolute;
  left: 28%; top: calc(var(--foot, 79%) - 5%); width: 44%; height: 11%;
  background: radial-gradient(ellipse, rgba(60, 45, 35, .38), transparent 70%);
  border-radius: 50%;
  transition: transform .2s;
}

.animal .body {
  position: absolute; inset: 0;
  transform-origin: 50% var(--foot, 79%);
}

.animal .sprite {
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
  transition: transform .14s ease-out;
}
.animal .sprite.flipped { transform: scaleX(-1); }

/* 걷는 중 통통 튀는 모션 */
.animal.walking .body { animation: hop .42s ease-in-out infinite; }
.animal.walking .shadow { animation: shadowPulse .42s ease-in-out infinite; }
@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-6%) rotate(3deg); }
}
@keyframes shadowPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(.8); }
}

/* 대기 중 숨쉬기 */
.animal.idle .body { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50%      { transform: scale(1.02, .97); }
}

/* 말하는 중: 클릭 반응 */
.animal.talking .body { animation: boing .45s cubic-bezier(.3,1.8,.5,1); }
@keyframes boing {
  0%   { transform: scale(1, 1); }
  30%  { transform: scale(1.12, .86); }
  60%  { transform: scale(.94, 1.08); }
  100% { transform: scale(1, 1); }
}

/* ---------- 플레이어(Man) 및 상호작용 힌트 ---------- */
.player-tag {
  position: absolute;
  left: 50%;
  top: calc(var(--head, 21%) - 10px);
  transform: translate(-50%, -100%);
  padding: 2px 9px 3px;
  background: rgba(59, 40, 28, .82);
  color: #fffbe6;
  font-family: 'Jua', sans-serif;
  font-size: clamp(0.66rem, 1.25vw, 0.82rem);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .22);
}

/* 동물 머리 위 Space 대화 힌트 */
.talk-prompt {
  position: absolute;
  left: 50%;
  top: calc(var(--head, 25%) - 10px);
  transform: translate(-50%, -90%) scale(.88);
  padding: 2px 9px 3px;
  background: #fffbe6;
  color: #5c4328;
  border: 2px solid #f08a3c;
  font-family: 'Jua', sans-serif;
  font-size: clamp(0.66rem, 1.25vw, 0.82rem);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease, transform .2s cubic-bezier(.2,1.5,.4,1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .22);
  z-index: 20;
}
.animal.near-player .talk-prompt {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}
.animal.near-player .sprite {
  filter: drop-shadow(0 0 6px rgba(255, 220, 110, .85));
}

/* 문 위 E키 출입 힌트 */
.door-prompt {
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translate(-50%, -90%) scale(.9);
  padding: 3px 10px 4px;
  background: #fffbe6;
  color: #5c4328;
  border: 2px solid #f5a623;
  font-family: 'Jua', sans-serif;
  font-size: clamp(0.68rem, 1.3vw, 0.84rem);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease, transform .22s cubic-bezier(.2,1.5,.4,1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
}
.door-hotspot.near-player .door-prompt,
.door-hotspot:hover .door-prompt {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}
.door-hotspot.near-player {
  background-color: rgba(255, 220, 120, .22);
  box-shadow: 0 0 0 3px rgba(255, 220, 120, .75), 0 0 22px rgba(255, 210, 110, .6);
  animation: none;
}

/* 마우스 클릭 이동 목표 물결 표시 */
.click-ripple {
  position: absolute;
  width: 26px;
  height: 14px;
  transform: translate(-50%, -50%);
  border: 2.5px solid rgba(255, 240, 175, .95);
  border-radius: 50%;
  pointer-events: none;
  z-index: 6;
  animation: rippleOut .5s ease-out forwards;
}
@keyframes rippleOut {
  0%   { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.7); opacity: 0; }
}

/* 상단 조작 안내 바 */
.controls-bar {
  position: fixed;
  left: 50%;
  top: max(10px, env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
  padding: 5px 12px;
  background: rgba(46, 46, 49, .78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fffbe6;
  font-family: 'Jua', sans-serif;
  font-size: clamp(0.7rem, 1.3vw, 0.84rem);
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .22);
  pointer-events: none;
}
.controls-bar kbd {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 3px;
  background: #fffbe6;
  color: #3b281c;
  border-radius: 5px;
  font-family: inherit;
  font-size: .88em;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.controls-bar .mobile-only { display: none; }

/* ---------- 모바일 가상 컨트롤러 (반투명 조이스틱 + 단일 상호작용 버튼) ---------- */
.mobile-controls {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.joystick-zone {
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  border: 1.5px solid rgba(255, 251, 230, .32);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 251, 230, .38);
  border: 1.5px solid rgba(240, 138, 60, .55);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  transition: transform .08s ease-out, background-color .15s ease;
}
.joystick-zone.active .joystick-knob {
  transition: none;
  background: rgba(255, 229, 163, .62);
}

.mobile-actions {
  display: flex;
  align-items: center;
  pointer-events: auto;
}

.mobile-btn {
  border: 1.5px solid rgba(255, 251, 230, .42);
  border-radius: 999px;
  padding: 13px 22px;
  font-family: 'Jua', sans-serif;
  font-size: 0.95rem;
  color: rgba(255, 251, 230, .92);
  background: rgba(46, 46, 49, .32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .16);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.mobile-btn:active {
  transform: scale(.92);
  background: rgba(240, 138, 60, .48);
}
.mobile-btn.highlight {
  background: rgba(240, 138, 60, .42);
  border-color: rgba(255, 220, 120, .85);
  box-shadow: 0 0 0 2px rgba(255, 220, 120, .55), 0 0 14px rgba(255, 210, 110, .45);
}

/* ---------- 대화창 (동물의숲 스타일, 화면 하단) ---------- */
.dialog {
  --cream: #fffbe6;
  position: absolute;
  left: 50%;
  bottom: max(36px, env(safe-area-inset-bottom));
  z-index: 1000;
  width: min(92vw, 760px);
  min-height: calc(2 * 1.55em + 2.6em);   /* 두 줄 기준 높이 고정 */
  padding: 1.25em 2.6em 1.45em;
  font-family: 'Jua', sans-serif;
  font-size: clamp(1rem, 2.7vw, 1.45rem);
  line-height: 1.55;
  color: #7a6040;
  cursor: pointer;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 14px) scale(.96);
  transition: opacity .2s ease, transform .35s cubic-bezier(.2,1.5,.4,1);
}
.dialog.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

/* 몽글몽글한 베개 모양 배경 */
.dialog-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .28));
  z-index: -1;
}
.dialog-bg path { fill: var(--cream); }

/* 이름표: 왼쪽 위에 살짝 기울어져 걸친 알약 모양 */
.dialog-name {
  position: absolute;
  top: -.75em;
  left: 5%;
  padding: .12em 1em .16em;
  background: var(--tag, #f08a3c);
  color: #fffdf3;
  font-size: .72em;
  white-space: nowrap;
  border-radius: 999px;
  transform: rotate(-4deg);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .18);
}

.dialog-text {
  text-align: left;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* 타자기 효과: 글자 하나씩 나타남 */
.dialog .ch { opacity: 0; }
.dialog .ch.on { opacity: 1; }

/* 대사가 다 나오면 하단 중앙에 통통 튀는 ▼ */
.dialog-next {
  position: absolute;
  left: 50%;
  bottom: .35em;
  width: .9em; height: .62em;
  margin-left: -.45em;
  background: #f5a623;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 2px;
  opacity: 0;
}
.dialog.done .dialog-next {
  opacity: 1;
  animation: nextBounce .75s ease-in-out infinite;
}
@keyframes nextBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}

/* ---------- 우편함 리스트 & 편지 이미지 모달 ---------- */
.mail-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(25, 22, 20, .62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility 0s linear .22s;
}
.mail-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .22s ease, visibility 0s;
}

.mail-modal {
  width: min(92vw, 420px);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  background: #fffbe6;
  border: 3px solid #3b281c;
  border-radius: 22px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .35);
  overflow: hidden;
  animation: modalPop .25s cubic-bezier(.2, 1.4, .4, 1);
}
.mail-modal[hidden],
.letter-modal[hidden] {
  display: none !important;
}

@keyframes modalPop {
  from { transform: scale(.9) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.mail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #e65540;
  color: #fffbe6;
  border-bottom: 3px solid #3b281c;
}
.mail-title {
  font-family: 'Jua', sans-serif;
  font-size: 1.25rem;
  font-weight: 400;
}

.mail-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #3b281c;
  background: #fffbe6;
  color: #3b281c;
  font-family: 'Jua', sans-serif;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, background-color .15s ease;
}
.mail-close-btn:hover,
.mail-close-btn:active {
  background: #ffe0a3;
  transform: scale(.94);
}

.mail-list {
  list-style: none;
  padding: 14px;
  margin: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 15px;
  background: #ffffff;
  border: 2.5px solid #3b281c;
  border-radius: 16px;
  font-family: 'Jua', sans-serif;
  color: #3b281c;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(59, 40, 28, .16);
  transition: transform .12s ease, background-color .15s ease;
}
.mail-item:hover,
.mail-item:active {
  background: #fff3c4;
  transform: translateY(-2px);
}
.mail-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.mail-item-icon {
  font-size: 1.45rem;
  flex-shrink: 0;
}
.mail-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mail-item-title {
  font-size: 1.02rem;
  color: #3b281c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-item-sender {
  font-size: 0.82rem;
  color: #7a6040;
}
.mail-badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #e65540;
  color: #fffbe6;
}
.mail-item.is-read .mail-badge {
  background: #d8d2c5;
  color: #6d5a48;
}

/* 편지 이미지 뷰어 */
.letter-modal {
  width: min(92vw, 440px);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  animation: modalPop .25s cubic-bezier(.2, 1.4, .4, 1);
}
.letter-top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.letter-back-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 2px solid #3b281c;
  background: #fffbe6;
  color: #3b281c;
  font-family: 'Jua', sans-serif;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
}
.letter-back-btn:hover,
.letter-back-btn:active {
  background: #ffe0a3;
}
.letter-img-wrap {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
}
.letter-img {
  width: 100%;
  max-height: 78dvh;
  height: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .45));
}

@media (max-width: 820px), (pointer: coarse) {
  :root {
    --building-w: min(80vw, calc(50dvh * 1.52));
    --room-w: min(94vw, calc(56dvh * 1.447));
  }

  .scene-outside .building {
    margin-right: 10vw;
  }

  .scene {
    padding-top: 36px;
    padding-bottom: 96px;
    gap: 6px;
  }

  .title-sign {
    width: clamp(120px, 34vw, 190px);
  }

  .controls-bar {
    width: max-content;
    max-width: 94vw;
    padding: 4px 10px;
    font-size: 0.72rem;
    gap: 4px 8px;
  }
  .controls-bar .pc-only { display: none; }
  .controls-bar .mobile-only { display: inline; }

  .mobile-controls {
    display: flex;
  }

  .animal .hit {
    left: 14%;
    top: 12%;
    width: 72%;
    height: 74%;
  }

  .room .door-hotspot.exit {
    left: 71%;
    top: 84%;
    width: 26%;
    height: 16%;
  }

  .dialog {
    width: 92vw;
    padding: 1em 1.4em 1.2em;
    font-size: clamp(0.92rem, 3.6vw, 1.15rem);
    bottom: calc(132px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 520px) {
  :root {
    --building-w: min(62vw, calc(68dvh * 1.52));
    --room-w: min(64vw, calc(66dvh * 1.447));
  }

  .scene {
    padding-top: 32px;
    padding-bottom: 10px;
    gap: 4px;
  }

  .title-sign {
    width: clamp(95px, 15vw, 140px);
  }

  .joystick-zone {
    width: 90px;
    height: 90px;
  }
  .joystick-base {
    width: 78px;
    height: 78px;
  }
  .joystick-knob {
    width: 34px;
    height: 34px;
  }
  .mobile-btn {
    padding: 9px 14px;
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .animal.walking .body, .animal.idle .body, .animal.walking .shadow { animation: none; }
}
