/* g-zoo.css — 탈출하는 동물을 잡아라! (기획 · 동물의 왕국)
   기획서 3쪽(플레이 화면)과 4쪽(인트로·끝 화면)을 그대로 옮겼다.
   왼쪽에 터진 빨간 울타리 / 낱말 팻말을 든 동물 / 오른쪽 끝 올가미를 든 사육사 /
   오른쪽 위 "남은 시간" 과 상자에 든 "포인트".

   크기 규칙 — vh 를 쓰지 않는다.
     게임 중에 "⌨️ 자판" 을 켜면 자판 한 줄이 생기고 게임판(.stage)이 낮아진다.
     vh 는 창 높이라서 판이 낮아져도 그대로여서 그림이 판 밖으로 넘친다.
     그래서 .zoo-room / .zoo-introwrap / .zoo-end 를 크기 컨테이너로 잡고
     모든 세로 치수를 cqh(판 높이의 1%)로 쓴다. 자판을 켜면 판이 낮아진 만큼
     동물·글씨·울타리가 같이 작아져 한 화면에 그대로 들어간다.

   그림 규칙 — 외곽선 #2b241d, 굵기는 그 그림 viewBox 높이의 약 2.4%,
     linejoin/linecap: round, 단색 평면. (동물 viewBox 높이 100 → 2.4)
     사육사·울타리는 viewBox 가 훨씬 커서 화면에 찍히는 굵기가 같아지도록 값을 낮췄다.
   ========================================================= */

.zoo-room {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: inherit;
  container-type: size;
}

/* ---------------------------------------------------------
   하늘과 풀밭 — 지평선은 15%. 이 아래가 전부 땅이다.
   (동물·울타리·사육사는 모두 이 지평선 아래에 발을 붙인다)
   --------------------------------------------------------- */
.zoo-sky {
  position: absolute; left: 0; right: 0; top: 0; height: 15%;
  background: linear-gradient(180deg, #cfe9f7 0%, #eaf6fb 100%);
}
.zoo-ground {
  position: absolute; left: 0; right: 0; top: 15%; bottom: 0;
  background: linear-gradient(180deg, #cfe6a4 0%, #b7d989 40%, #a4cd77 100%);
  border-top: 3px solid #7fae5c;
}
.zoo-ground::after {
  content: ''; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(74deg, rgba(255, 255, 255, .22) 0 3px, rgba(255, 255, 255, 0) 3px 14px);
  opacity: .5;
}
/* 먼 쪽 풀밭은 옅게 — 원근 */
.zoo-ground::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 26%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
}

/* ---------------------------------------------------------
   왼쪽 — 터진 빨간 울타리 (그림 그대로 위·아래 두 토막)
   땅에 붙어 있어야 한다. 위쪽은 지평선을 조금만 넘는다.
   --------------------------------------------------------- */
.zoo-fence {
  position: absolute; left: 0; top: 13%;
  height: 87%; width: auto;
  z-index: 3; pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .22));
}

/* ---------------------------------------------------------
   오른쪽 끝 — 올가미를 든 사육사.
   낱말보다 커서는 안 된다. 발은 땅(지평선 아래)에.
   --------------------------------------------------------- */
.zoo-keeperbox {
  position: absolute; right: 1%; bottom: 2%;
  height: 46%; z-index: 3; pointer-events: none;
  transform-origin: 60% 100%;
}
.zoo-keeper { height: 100%; width: auto; display: block; }
/* 동물을 잡는 순간 — 몸을 앞으로 기울여 올가미를 던진다 */
.zoo-keeperbox.throw { animation: zooThrow .5s ease-out; }
@keyframes zooThrow {
  0% { transform: rotate(0) }
  22% { transform: rotate(6deg) translateY(-1%); }
  55% { transform: rotate(-9deg) translateY(-2%); }
  100% { transform: rotate(0); }
}

/* ---------------------------------------------------------
   동물이 뛰는 판 — 세로로 다섯 줄(레인). 줄 값은 "발이 닿는 자리" 다.
   먼 줄(위)일수록 --sc 가 작아 작게 그려진다 → 원근.
   --------------------------------------------------------- */
.zoo-field { position: absolute; inset: 0; z-index: 4; }

.zoo-an {
  position: absolute;
  transform: translate(-50%, -100%);   /* top = 발이 닿는 자리 */
  display: flex; flex-direction: column; align-items: center;
  will-change: left;
  /* 이 글자 크기 하나로 팻말·몸집이 같이 커지고 작아진다 */
  font-size: calc(var(--sc, 1) * 4cqh);
}
.zoo-body {
  display: block;
  width: 3.9em;
  animation: zooHop .5s infinite ease-in-out;
  filter: drop-shadow(0 .12em .1em rgba(60, 80, 40, .28));
}
.zoo-body svg { width: 100%; height: auto; display: block; }
@keyframes zooHop {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-9%) rotate(1.5deg); }
}
/* 외곽선 규칙 — viewBox 높이 100 의 2.4% */
.zoo-draw {
  stroke: #2b241d; stroke-width: 2.4;
  stroke-linejoin: round; stroke-linecap: round;
  overflow: visible;
}

/* ---------------------------------------------------------
   동물이 든 낱말 팻말 — 이 화면에서 가장 큰 글자다.
   (아이가 봐야 하는 건 사육사가 아니라 이 낱말이다)
   --------------------------------------------------------- */
.zoo-sign {
  position: relative;
  margin-bottom: -.12em;
  background: #fffdf5;
  border: .11em solid #2b241d; border-radius: .2em;
  padding: .05em .38em;
  font-weight: 900; color: #2b241d; white-space: nowrap;
  font-size: 1.5em; line-height: 1.3;
  letter-spacing: -.01em;
  box-shadow: 0 .12em .2em -.08em rgba(0, 0, 0, .45);
  z-index: 2;
}
/* 팻말을 받치는 막대 */
.zoo-sign::after {
  content: ''; position: absolute; left: 50%; top: 100%;
  width: .12em; height: .42em; margin-left: -.06em;
  background: #2b241d; border-radius: 0 0 .06em .06em;
}
.zoo-w .hit { color: #0e9c78; }

/* 하이에나 팻말은 색이 다르다 — 함정을 알아볼 수 있게 */
.zoo-an.trap .zoo-sign {
  background: #ffe4de; border-color: #a63d2c; color: #7d2a1c;
}
.zoo-an.trap .zoo-sign::after { background: #a63d2c; }

/* 지금 치고 있는 동물 */
.zoo-an.lock .zoo-sign {
  border-color: #0e9c78;
  box-shadow: 0 0 0 .16em rgba(14, 156, 120, .3), 0 .12em .2em -.08em rgba(0, 0, 0, .45);
}
.zoo-an.lock .zoo-body { animation-duration: .28s; }

/* 잡혔다 — 올가미에 걸려 오른쪽 위로 끌려간다 */
.zoo-an.caught { animation: zooCaught .6s ease-in forwards; }
@keyframes zooCaught {
  0% { transform: translate(-50%, -100%) scale(1) rotate(0); }
  30% { transform: translate(-50%, -108%) scale(1.12) rotate(-8deg); }
  100% { transform: translate(60%, -125%) scale(.3) rotate(22deg); opacity: 0; }
}
/* 함정을 밟았다 */
.zoo-an.bad { animation: zooBad .6s ease-out forwards; }
@keyframes zooBad {
  0% { transform: translate(-50%, -100%) scale(1); }
  25% { transform: translate(-50%, -100%) scale(1.15) rotate(6deg); }
  100% { transform: translate(-50%, -100%) scale(.6) rotate(-10deg); opacity: 0; }
}
/* 달아났다 */
.zoo-an.gone { animation: zooGone .68s ease-in forwards; }
@keyframes zooGone {
  0% { transform: translate(-50%, -100%); }
  100% { transform: translate(140%, -100%); opacity: 0; }
}

/* 사육사가 던지는 올가미 */
.zoo-rope {
  position: absolute;
  width: 6cqh; height: 6cqh;
  margin: 0; transform: translate(-50%, -50%);
  border: .9cqh solid #6b4a2a; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  box-shadow: 0 .4cqh .6cqh -.3cqh rgba(0, 0, 0, .4);
  transition: left .34s cubic-bezier(.3, .8, .4, 1);
  z-index: 6; pointer-events: none;
}
.zoo-rope.fly { animation: zooRope .6s ease-out forwards; }
@keyframes zooRope {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
}

/* ---------------------------------------------------------
   오른쪽 위 HUD — 주인공은 "잡은 동물 N마리".
   0점이 2분 30초 내내 안 변하면 아이는 자기가 아무것도 안 한 줄 안다.
   글씨는 팻말 낱말(1.5 × 4cqh × 0.86~1.14 = 5.2~6.8cqh)의 0.7배를 넘지 않는다
   (가장 큰 숫자가 3cqh × 1.2 = 3.6cqh).
   --------------------------------------------------------- */
.zoo-hud {
  position: absolute; right: 1.5cqh; top: 1.5cqh;
  z-index: 8; display: flex; align-items: center; gap: 1.4cqh;
  font-weight: 900; color: #2b241d;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
.zoo-catch {
  display: inline-flex; align-items: baseline; gap: .25em;
  background: rgba(255, 255, 255, .94);
  border: .12em solid #2b241d; border-radius: .3em;
  padding: .05em .45em;
  font-size: 3cqh; line-height: 1.25;
  box-shadow: 0 .14em .2em -.1em rgba(0, 0, 0, .5);
}
.zoo-catch b { color: #1f6f3f; font-size: 1.2em; }
.zoo-catch.pop { animation: zooPop .42s ease-out; }
@keyframes zooPop {
  0% { transform: scale(1); } 35% { transform: scale(1.18); } 100% { transform: scale(1); }
}
.zoo-time, .zoo-ptbox { font-size: 2.2cqh; }
.zoo-hud .zoo-time b { color: #1f6f3f; }
.zoo-hud.hot .zoo-time b { color: #d1362c; }
.zoo-ptbox {
  background: rgba(255, 255, 255, .9);
  border: .12em solid #2b241d; border-radius: .3em;
  padding: .1em .45em;
}
.zoo-ptbox b { color: #c2410c; }
.zoo-ptbox.down { animation: zooDown .5s ease-out; }
@keyframes zooDown {
  0%, 100% { background: rgba(255, 255, 255, .9); }
  30% { background: #ffd7d7; transform: translateY(.15em); }
}

.zoo-sub {
  position: absolute; left: 1.5cqh; top: 1.5cqh;
  z-index: 8; display: flex; gap: 1cqh; align-items: center;
}
.zoo-diffbadge, .zoo-streak {
  background: rgba(255, 255, 255, .88); border: 2px solid #2b241d;
  border-radius: 999px; padding: .12em .7em;
  font-weight: 800; color: #2b241d;
  font-size: 2cqh;
}
.zoo-streak { background: #fff2c9; }

/* 놓쳤을 때 · 틀렸을 때 화면이 흔들린다 */
.stage.zoo-shake { animation: zooShake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes zooShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* =========================================================
   인트로 — 거북이 등딱지에 제목, 아래 PLAY (기획서 4쪽 왼쪽)
   ========================================================= */
.zoo-introwrap { position: absolute; inset: 0; container-type: size; }
.zoo-introbg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 30% 30%, #dff0fb 0%, #bfe0b4 55%, #8fbe74 100%);
}
.zoo-introbg::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(74deg,
      rgba(255, 255, 255, .2) 0 4px, rgba(255, 255, 255, 0) 4px 14px);
}
.zoo-intro {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 3cqh;
  padding: 2cqh 3cqh;
}
.zoo-introleft {
  flex: none; width: 38%;
  display: flex; flex-direction: column; align-items: center;
}
.zoo-bigturtle { width: 100%; height: auto; display: block; }
.zoo-tt {
  fill: #2b241d; stroke: none;
  font-weight: 900; font-size: 34px;
  text-anchor: middle;
  font-family: inherit;
}
.zoo-play {
  margin-top: 1.4cqh;
  background: linear-gradient(180deg, #fff6d8, #ffdf8c);
  border: .12em solid #2b241d; border-radius: .3em;
  padding: .12em .9em;
  font-size: 5.4cqh; font-weight: 900;
  letter-spacing: .16em; color: #2b241d;
  box-shadow: 0 .14em 0 rgba(0, 0, 0, .22);
  animation: zooPlay 1.4s infinite ease-in-out;
}
@keyframes zooPlay {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.zoo-introgo {
  margin-top: 1cqh; color: #2f4a2a; font-weight: 800;
  font-size: 2.6cqh;
}

.zoo-introright {
  flex: 1; min-width: 0;
  background: rgba(255, 255, 255, .82);
  border: 3px solid #2b241d; border-radius: 16px;
  padding: 2cqh 2.2cqh;
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, .5);
  max-height: 96%; overflow: hidden;
}
.zoo-introby {
  color: #8a4b1e; font-weight: 900; letter-spacing: .4px;
  font-size: 2.4cqh;
}
.zoo-introdesc {
  color: #2b241d; font-weight: 700; line-height: 1.45;
  font-size: 3.1cqh; margin-top: .3cqh;
}
.zoo-introdesc b { color: #b8431f; }
.zoo-introhint {
  color: #4a3b2c; font-weight: 700; line-height: 1.45;
  font-size: 2.3cqh; margin-top: 1cqh;
}

.zoo-chiprow {
  display: flex; flex-wrap: wrap; gap: .8cqh;
  margin: 1.4cqh 0;
}
.zoo-chip {
  flex: 1 1 17%;
  display: flex; flex-direction: column; align-items: center;
  background: #fffdf5; border: 2px solid #2b241d; border-radius: 10px;
  padding: .3cqh .3cqh .5cqh;
}
.zoo-chip.trap { background: #ffe4de; border-color: #a63d2c; }
.zoo-chip i { display: block; width: 7.6cqh; }
.zoo-chip i svg { width: 100%; height: auto; display: block; }
.zoo-chip b { font-size: 2cqh; color: #2b241d; font-weight: 900; }
.zoo-chip u {
  text-decoration: none; font-weight: 900; color: #b8431f;
  font-size: 2cqh;
}
.zoo-chip.trap u { color: #a63d2c; }

.zoo-diffrow {
  display: flex; align-items: center; gap: 1.2cqh;
  margin-top: 1.2cqh;
}
.zoo-diffrow > span {
  font-weight: 900; color: #2b241d; font-size: 2.6cqh;
}
.zoo-dchip {
  display: flex; flex-direction: column; align-items: center;
  background: #fffdf5; border: 3px solid #2b241d; border-radius: 999px;
  padding: .5cqh 1.8cqh;
  font-weight: 900; color: #2b241d; cursor: pointer;
  font-size: 2.8cqh; line-height: 1.15;
  font-family: inherit;
}
.zoo-dchip small { font-weight: 700; color: #6b5a48; font-size: 1.9cqh; }
.zoo-dchip.sel { background: #ffd166; box-shadow: 0 0 0 4px rgba(255, 209, 102, .45); }

/* =========================================================
   끝 화면 (기획서 4쪽 오른쪽)
   "게임 끝!" · 포인트 상자 · 다시하기 · 다음단계 · 난이도 3종
   ========================================================= */
/* 공용 결과판(.overlay, z-index 10)과 게임판 위를 완전히 덮는다.
   여기서 opacity 를 건드리면 뒤가 비쳐 보이므로 나타나는 효과는 안쪽 상자에만 준다. */
.zoo-end {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background-color: #faf6ec;
  background-image: radial-gradient(ellipse 80% 70% at 50% 30%, #fffdf6 0%, #f3ecdb 100%);
  opacity: 1; isolation: isolate;
  container-type: size;
}
@keyframes zooEndIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.zoo-endbox {
  animation: zooEndIn .3s ease-out;
  text-align: center; max-width: 90%;
  display: flex; flex-direction: column; align-items: center;
  gap: 1.6cqh;
}
.zoo-endtitle {
  font-size: 11cqh; font-weight: 900; color: #2b241d;
  letter-spacing: -.02em; line-height: 1;
  text-shadow: 3px 4px 0 rgba(0, 0, 0, .12);
}
.zoo-endcatch {
  font-size: 6cqh; font-weight: 900; color: #1f6f3f;
}
.zoo-endpt {
  background: #fff; border: .1em solid #2b241d; border-radius: .2em;
  padding: .1em .6em;
  font-size: 4.4cqh; font-weight: 900; color: #2b241d;
}
.zoo-endpt b { color: #c2410c; }
.zoo-endsub {
  color: #5c4a38; font-weight: 700; font-size: 2.5cqh;
}
.zoo-endbtns { display: flex; gap: 2.4cqh; }
.zoo-ebtn {
  background: #fff; border: 3px solid #2b241d; border-radius: 8px;
  padding: .3em 1.2em;
  font-size: 3.6cqh; font-weight: 900; color: #2b241d;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .18);
}
.zoo-ebtn:hover { background: #fff3cf; }
.zoo-ebtn.next { background: #ffd166; }
.zoo-enddiff { display: flex; gap: 2cqh; align-items: flex-start; }
.zoo-dchip.big { position: relative; padding-bottom: 1cqh; }
.zoo-dchip em {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  margin-top: 3px; font-style: normal; font-weight: 900; color: #b8431f;
  font-size: 2cqh;
}
.zoo-ghost {
  margin-top: 1.6cqh;
  background: none; border: 2px solid #8a7a68; border-radius: 999px;
  padding: .3em 1.2em; color: #5c4a38; font-weight: 800; cursor: pointer;
  font-size: 2.3cqh; font-family: inherit;
}
.zoo-ghost:hover { background: rgba(0, 0, 0, .06); }

@media (prefers-reduced-motion: reduce) {
  .zoo-body, .zoo-play { animation: none; }
  .stage.zoo-shake, .zoo-keeperbox.throw { animation: none; }
}
