/* 04 레벨업! 먹이사슬 — 야간 관찰 카메라로 들여다보는 육지·바다 */
.g4 { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 12px 18px 16px; gap: 10px; }

/* 바다/육지 고르기 */
.g4-pick { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.g4-ask { margin: 0; font-size: clamp(26px, 4vh, 38px); font-weight: 900; letter-spacing: -.035em; }
.g4-doors { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: min(1500px, 100%); height: min(68vh, 700px); }
.g4-door { --vf: var(--k3); display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 8px; padding: 14px 14px 16px; text-align: left;
  background: var(--paper2); border: 1px solid var(--line2); transition: border-color .15s, background .15s; }
.g4-door:hover, .g4-door:focus-visible { --vf: var(--leaf); border-color: var(--leaf); background: var(--paper3); outline: none; }
.g4-door-art { position: relative; overflow: hidden; border: 1px solid var(--line); background: var(--paper); min-height: 0; }
.g4-door-hero { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); height: 34%; width: auto; }
.g4-door-art.sea .g4-door-hero { height: 30%; }
.g4-door-t { display: flex; align-items: center; gap: 12px; }
.g4-door-t b { font-size: clamp(34px, 5.4vh, 52px); font-weight: 900; letter-spacing: -.04em; line-height: 1; }
.g4-door:focus-visible .g4-door-t b, .g4-door:hover .g4-door-t b { color: var(--leaf); }
.g4-door-s { font-size: 18px; color: var(--k2); font-weight: 600; }

/* 위 HUD */
.g4-hud { flex: 0 0 auto; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 22px; }
.g4-l { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--k3); text-transform: uppercase; }
.g4-me { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.g4-face { width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--c); background: var(--paper2); padding: 4px; }
.g4-face svg { width: 100%; }
.g4-who { display: flex; flex-direction: column; gap: 2px; }
.g4-name { font-size: 28px; font-weight: 900; letter-spacing: -.035em; line-height: 1.1; color: var(--c); white-space: nowrap; }
.g4-gauge { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.g4-gtop { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.g4-cnt { font-family: var(--mono); font-size: 32px; font-weight: 800; line-height: 1; color: var(--leaf); }
.g4-cnt small { font-size: .6em; color: var(--k2); }
.g4-need { font-size: 18px; font-weight: 700; color: var(--k2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g4-bar { height: 16px; border: 1px solid var(--line2); background: var(--paper2); position: relative; }
.g4-bar i { position: absolute; left: 2px; top: 2px; bottom: 2px; width: 0; max-width: calc(100% - 4px); background: var(--leaf); transition: width .25s; }
.g4-bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--paper) calc(10% - 1px) 10%); pointer-events: none; }
.g4-chain { display: flex; list-style: none; margin: 0; padding: 0; gap: 4px; }
.g4-chain li { width: 60px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; border: 1px solid transparent; opacity: .78; position: relative; }
.g4-chain li + li::before { content: "›"; position: absolute; left: -7px; top: 12px; color: var(--k3); font-size: 16px; }
.g4-ci { height: 34px; width: 46px; display: flex; align-items: center; justify-content: center; }
.g4-ci svg { width: 100%; }
.g4-cn { font-size: 13px; font-weight: 700; white-space: nowrap; color: var(--k2); }
.g4-chain li.done { opacity: 1; }
.g4-chain li.done .g4-cn { color: var(--leaf); }
.g4-chain li.now { opacity: 1; border-color: var(--c); background: var(--paper2); }
.g4-chain li.now .g4-cn { color: var(--c); }
.g4-lives { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.g4-lives .hearts svg path[fill="var(--m)"] { stroke: var(--m); }

/* 관찰 화면(밭) */
.g4-field { --vf: var(--k2); flex: 1; min-height: 0; position: relative; overflow: hidden; border: 1px solid var(--line2); touch-action: none; cursor: crosshair;
  background: radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--leaf) 7%, transparent), transparent 70%), var(--paper); }
.g4-field.sea { background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--c) 9%, transparent), transparent 72%), var(--paper); }
.g4 .g4-vf { position: absolute; inset: 10px; pointer-events: none; z-index: 3; }
.g4-door, .g4-evo-box { position: relative; }
.g4-bg { position: absolute; inset: 0; pointer-events: none; }
.g4-bg .spr, .g4-door-art > .spr:not(.g4-door-hero) { position: absolute; opacity: .26; width: auto; max-width: none; }
.g4-bg-tree { left: 4%; bottom: 0; height: 94%; }
.g4-bg-cl { bottom: 4%; height: 5%; }
.g4-bg-cl.a { left: 30%; } .g4-bg-cl.b { left: 58%; } .g4-bg-cl.c { left: 86%; }
.g4-ground { position: absolute; left: 0; right: 0; bottom: 4%; border-top: 1px dashed var(--line2); }
.g4-water { position: absolute; left: 0; right: 0; top: 7%; height: 10px; opacity: .5;
  background: radial-gradient(circle at 10px -4px, transparent 9px, var(--c) 10px, transparent 11px) 0 0 / 20px 10px repeat-x; }
.g4-bg-coral { left: 1%; bottom: 0; height: 52%; }
.g4-bg-oct { right: 9%; top: 18%; height: 24%; }
.g4-bg-jel { left: 44%; top: 26%; height: 12%; }
.g4-bg-weed { right: 1%; bottom: 0; height: 18%; }
.g4-rec { position: absolute; right: 22px; top: 18px; z-index: 3; font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .12em; color: var(--k2); display: flex; align-items: center; gap: 8px; pointer-events: none; }
.g4-rec i { width: 9px; height: 9px; border-radius: 50%; background: var(--m); animation: blink 1.2s steps(2) infinite; }

/* 숨는 곳 */
.g4-zone { position: absolute; transform: translate(-50%, -50%); border: 1.5px dashed color-mix(in srgb, var(--leaf) 55%, transparent); pointer-events: none;
  background: repeating-linear-gradient(100deg, transparent 0 9px, color-mix(in srgb, var(--leaf) 16%, transparent) 9px 11px), var(--leaf2);
  display: flex; align-items: flex-end; justify-content: space-around; padding: 0 4% 6%; }
.g4-zone .spr { width: 30%; height: auto; opacity: .75; }
.g4-field.sea .g4-zone .spr { width: 46%; opacity: .9; }
.g4-zl { position: absolute; left: -1px; bottom: -24px; font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--leaf); white-space: nowrap; }

/* 생물 */
.g4-ents { position: absolute; inset: 0; pointer-events: none; }
.g4-ents > .g4-ent { position: absolute; left: 0; top: 0; will-change: transform; outline-offset: 2px; }
.g4-pic { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.g4-pic .spr { max-width: 100%; max-height: 100%; }
.g4-pic svg { width: 100%; }
.g4-ents > .food { --dc: var(--leaf); outline-color: color-mix(in srgb, var(--leaf) 70%, transparent); }
.g4-ents > .foe { --dc: var(--m); z-index: 2; }
.g4-ents > .foe.chase { outline-width: 3px; }
.g4-ents > .me { --vf: var(--c); --dc: var(--c); z-index: 10; }
.g4-ents > .me .detect-l { font-size: clamp(14px, 1.9vh, 20px); top: auto; bottom: calc(100% + 6px); }
.g4-ents > .me .g4-pic .spr:not(.raw) { filter: invert(1) brightness(1.3) drop-shadow(0 0 5px color-mix(in srgb, var(--c) 70%, transparent)); }
.g4-ents > .me.hid { --vf: var(--leaf); --dc: var(--leaf); opacity: .55; }
.g4-ents > .me.inv { animation: g4-blink .25s steps(2) infinite; }
@keyframes g4-blink { 50% { opacity: .25; } }
.g4-tagl { font-size: clamp(13px, 1.55vh, 17px); }
/* 먹이 이름표는 상자 아래, 나머지는 위 → 이름표끼리 덜 겹친다 */
.g4-ents > .food .detect-l { top: calc(100% + 6px); }
.g4-ents > .foe .detect-l { top: auto; bottom: calc(100% + 6px); }
.g4-ents > .gone { opacity: 0; outline-color: transparent; transition: opacity .3s, outline-color .1s; }
.g4-ents > .gone .g4-pic { transform: scale(.3) !important; transition: transform .3s; }
.g4-ents > .gone .detect-l { display: none; }
.g4-plus { position: absolute; transform: translate(-50%, -50%); font-family: var(--mono); font-size: 26px; font-weight: 800; color: var(--leaf); pointer-events: none; animation: g4-up .7s ease-out forwards; }
@keyframes g4-up { to { transform: translate(-50%, -150%); opacity: 0; } }

/* 안내 말, 진화 */
/* 안내는 밭 맨 위 띠(46px)에 한 줄로. 생물은 이 띠 아래에서만 움직여 가리지 않는다 */
.g4-say { position: absolute; left: 1px; right: 1px; top: 1px; height: 46px; z-index: 4; padding: 0 22px; display: flex; align-items: center; justify-content: center; gap: 14px;
  background: color-mix(in srgb, var(--paper2) 88%, transparent); border-bottom: 1px solid var(--line2);
  font-size: 22px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; opacity: 0; transition: opacity .25s; pointer-events: none; }
.g4-say.on { opacity: 1; }
.g4-say b { color: var(--leaf); }
.g4-say b.bad { color: var(--m); }
.g4-say small { font-size: 18px; font-weight: 600; color: var(--k2); }
.g4-evo { position: absolute; inset: 0; z-index: 5; display: none; align-items: center; justify-content: center; background: color-mix(in srgb, var(--paper) 72%, transparent); }
.g4-evo.on { display: flex; }
.g4-evo-box { --vf: var(--leaf); padding: 22px 40px 24px; background: var(--paper2); border: 1px solid var(--line2); text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.g4-evo-row { display: flex; align-items: center; gap: 28px; }
.g4-evo-a { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 150px; }
.g4-evo-a .spr, .g4-evo-a svg { height: 120px; width: auto; max-width: 150px; }
.g4-evo-a svg { width: 110px; height: auto; }
.g4-evo-a span { font-size: 20px; font-weight: 800; }
.g4-evo-a + .g4-evo-arr + .g4-evo-a span { color: var(--leaf); }
.g4-evo-arr { font-style: normal; font-size: 40px; color: var(--leaf); }
.g4-evo-box > b { font-size: 34px; font-weight: 900; letter-spacing: -.04em; color: var(--leaf); }

@media (max-height: 700px) {
  .g4 { padding: 8px 14px 12px; gap: 8px; }
  .g4-face { width: 50px; height: 50px; }
  .g4-name { font-size: 26px; }
  .g4-cnt { font-size: 28px; }
  .g4-ci { height: 28px; }
}
/* 오른쪽 끝에 있는 생물은 이름표를 오른쪽에 맞춰 밭 밖으로 안 나가게 */
.g4-ents > .g4-ent.lr .detect-l { left: auto; right: -5px; }
