/* 야간 관찰 카메라 — 어두운 숲을 적외선 카메라로 들여다본다.
   학생이 연필로 그린 생물은 반전해 흰 선으로 보이고(.spr), AI 카메라가 생물을 알아본 듯 인식 상자(.detect)를 씌운다.
   색 이름(--paper --k --c --m --y --leaf)은 앞 단원 틀과 같지만 값은 밤 화면의 색 */
:root {
  --paper: #0B100D;
  --paper2: #121A15;
  --paper3: #1A251E;
  --k: #E8EFE4;
  --k2: #B9C5BB;
  --k3: #8B988D;
  --leaf: #C8F031;
  --leaf2: rgba(200, 240, 49, .14);
  --c: #38D3E8;
  --m: #FF6A2B;
  --y: #FFC83D;
  --line: rgba(232, 239, 228, .12);
  --line2: rgba(232, 239, 228, .34);
  --ok: #C8F031;
  --bad: #FF6A2B;
  --font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--k); font-family: var(--font);
  overflow: hidden; -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
button { font: inherit; color: inherit; cursor: pointer; }
#app { height: 100dvh; display: flex; flex-direction: column; position: relative; }
/* 주사선과 가장자리 어둡게(카메라 화면) */
#app::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 30;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%);
}

/* 윗줄: 카메라 상태 표시줄 */
.top {
  flex: 0 0 auto; height: 60px; display: flex; align-items: center; gap: 18px;
  padding: 0 24px; border-bottom: 1px solid var(--line2); background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; background: none; border: 0; padding: 0; }
.brand svg { width: 30px; height: 30px; }
.rec { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .12em; color: var(--k2); }
.rec::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--m); animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }
.bar { display: none; }
.top .gtitle { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.top .gno { font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--leaf); letter-spacing: .08em; }
.top .gname { font-weight: 800; font-size: 22px; letter-spacing: -.02em; white-space: nowrap; }
.top .by { font-size: 15px; color: var(--k2); white-space: nowrap; }
.top .sp { flex: 1; }
.tbtn {
  height: 40px; padding: 0 16px; border: 1px solid var(--line2); background: transparent;
  font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; gap: 8px; position: relative;
}
.tbtn:hover { border-color: var(--leaf); color: var(--leaf); }
.tbtn .dot { width: 8px; height: 8px; background: var(--m); border-radius: 50%; position: absolute; top: -4px; right: -4px; }
kbd {
  font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 1px 6px; border: 1px solid currentColor; opacity: .7;
}

/* 버튼 */
.btn {
  height: 52px; padding: 0 26px; border: 0; background: var(--leaf); color: var(--paper);
  font-weight: 800; font-size: 19px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:hover { box-shadow: 0 0 0 3px var(--leaf2), 0 0 24px rgba(200, 240, 49, .35); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--k); border: 1px solid var(--line2); }
.btn.ghost:hover { border-color: var(--k); box-shadow: none; }
.btn:disabled { opacity: .3; pointer-events: none; }
.btn kbd { opacity: .6; }

/* 뷰파인더 모서리 괄호: 상자에 class="vf"를 붙이면 네 모서리에 ㄱ자가 생긴다(--vf로 색) */
.vf { position: relative; }
.vf::before, .vf::after { content: ""; position: absolute; inset: -1px; pointer-events: none; }
.vf::before {
  background:
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) top left / 18px 2px no-repeat,
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) top left / 2px 18px no-repeat,
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) top right / 18px 2px no-repeat,
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) top right / 2px 18px no-repeat;
}
.vf::after {
  background:
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) bottom left / 18px 2px no-repeat,
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) bottom left / 2px 18px no-repeat,
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) bottom right / 18px 2px no-repeat,
    linear-gradient(var(--vf, var(--k)), var(--vf, var(--k))) bottom right / 2px 18px no-repeat;
}
/* 인식 상자: 생물을 알아본 표시. --dc로 색을 바꾼다(먹이 연두, 위험 주황) */
.detect { position: relative; outline: 1.5px solid var(--dc, var(--leaf)); outline-offset: 4px; }
.detect-l {
  position: absolute; left: -5px; top: -30px; white-space: nowrap; padding: 2px 7px; z-index: 2;
  background: var(--dc, var(--leaf)); color: var(--paper); font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
.mono { font-family: var(--mono); }
.cap { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--k3); text-transform: uppercase; }

/* 학생 그림: 연필 선을 반전해 밝은 선으로 */
.spr { display: block; max-width: 100%; max-height: 100%; object-fit: contain; filter: invert(1) brightness(1.15); mix-blend-mode: screen; user-select: none; -webkit-user-drag: none; }
.spr.raw { filter: none; mix-blend-mode: normal; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border: 1px solid var(--line2); background: var(--paper2); font-weight: 800; font-size: 15px; }

/* 홈 */
.home { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; padding: 22px 28px 26px; gap: 18px; position: relative;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 56px 56px; background-position: -1px -1px; }
.hero { position: relative; display: flex; align-items: center; min-height: 0; overflow: hidden; }
.hero h1 { position: relative; z-index: 2; margin: 0; font-size: clamp(60px, 11vh, 128px); line-height: .92; font-weight: 900; letter-spacing: -.055em; }
.hero h1 span { display: block; }
.hero h1 em { font-style: normal; color: var(--leaf); }
.hero .sub { position: relative; z-index: 2; margin-left: 36px; font-size: clamp(17px, 2.2vh, 22px); line-height: 1.55; color: var(--k2); max-width: 520px; font-weight: 600; }
.hero .sub .cap { display: block; margin-bottom: 10px; color: var(--leaf); }
.hero .art { position: absolute; right: 0; top: 0; bottom: 0; width: 50%; z-index: 1; display: flex; align-items: center; justify-content: center; }
.chain { width: 100%; height: 100%; }
.chain .node { animation: pop .6s cubic-bezier(.2, 1.2, .4, 1) both; transform-box: fill-box; transform-origin: center; }
.chain .arrow { stroke: var(--k2); stroke-width: 1.6; fill: none; stroke-dasharray: 4 6; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -20; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.scan { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--leaf), transparent); opacity: .45; animation: scan 4s linear infinite; pointer-events: none; }
@keyframes scan { from { top: 0; } to { top: 100%; } }
.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.card {
  position: relative; text-align: left; border: 1px solid var(--line2); background: var(--paper2); padding: 14px 14px 12px;
  display: grid; grid-template-rows: auto 1fr auto; gap: 8px; height: clamp(196px, 31vh, 300px); overflow: hidden;
  transition: border-color .18s, background .18s;
}
.card:hover, .card:focus-visible { border-color: var(--leaf); background: var(--paper3); outline: none; }
.card .no { display: flex; justify-content: space-between; font-family: var(--mono); font-weight: 700; font-size: 13px; color: var(--k2); letter-spacing: .08em; }
.card .thumb { min-height: 0; display: flex; align-items: center; justify-content: center; background: #050806; border: 1px solid var(--line); position: relative; overflow: hidden; }
.card .thumb .spr { max-height: 92%; max-width: 92%; }
.card:hover .thumb .spr, .card:focus-visible .thumb .spr { filter: invert(1) brightness(1.3) drop-shadow(0 0 6px rgba(200, 240, 49, .55)); }
.card .t { font-weight: 800; font-size: clamp(18px, 2.5vh, 23px); letter-spacing: -.03em; line-height: 1.2; }
.card .b { font-size: 15px; color: var(--k2); margin-top: 2px; }

/* 게임 공통 */
.game { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.stage { flex: 1; min-height: 0; position: relative; }
.hud { display: flex; flex-direction: column; gap: 2px; }
.hud .l { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--k3); letter-spacing: .12em; }
.hud .v { font-family: var(--mono); font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.hud .v small { font-size: .5em; font-weight: 700; color: var(--k2); margin-left: 2px; }
.hearts { display: flex; gap: 6px; }
.hearts svg { width: 30px; height: 30px; }
.hearts svg path { stroke: var(--k2); }
.panel { border: 1px solid var(--line2); background: var(--paper2); position: relative; }
.ask { font-size: clamp(24px, 3.6vh, 34px); font-weight: 900; letter-spacing: -.035em; }
.ask b { color: var(--leaf); }
.shake { animation: shake .32s; }
@keyframes shake { 20% { transform: translateX(-7px) } 40% { transform: translateX(6px) } 60% { transform: translateX(-4px) } 80% { transform: translateX(3px) } }
.flash-ok { animation: fok .5s; } @keyframes fok { from { box-shadow: inset 0 0 0 200px rgba(200, 240, 49, .25); } }
.flash-bad { animation: fbad .5s; } @keyframes fbad { from { box-shadow: inset 0 0 0 200px rgba(255, 106, 43, .3); } }

/* 결과 막 */
.overlay {
  position: absolute; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center;
  background: rgba(5, 8, 6, .78); backdrop-filter: blur(4px);
}
.overlay.on { display: flex; }
.overlay .box { position: relative; background: var(--paper2); border: 1px solid var(--line2); padding: 44px 52px 34px; min-width: 460px; max-width: 680px; text-align: center; }
.overlay .box::before, .overlay .box::after { content: ""; position: absolute; inset: -7px; pointer-events: none; }
.overlay .box::before { background: linear-gradient(var(--leaf), var(--leaf)) top left / 26px 2px no-repeat, linear-gradient(var(--leaf), var(--leaf)) top left / 2px 26px no-repeat,
    linear-gradient(var(--leaf), var(--leaf)) top right / 26px 2px no-repeat, linear-gradient(var(--leaf), var(--leaf)) top right / 2px 26px no-repeat; }
.overlay .box::after { background: linear-gradient(var(--leaf), var(--leaf)) bottom left / 26px 2px no-repeat, linear-gradient(var(--leaf), var(--leaf)) bottom left / 2px 26px no-repeat,
    linear-gradient(var(--leaf), var(--leaf)) bottom right / 26px 2px no-repeat, linear-gradient(var(--leaf), var(--leaf)) bottom right / 2px 26px no-repeat; }
.overlay h2 { margin: 0 0 6px; font-size: 60px; font-weight: 900; letter-spacing: -.05em; line-height: 1; }
.overlay .msg { font-size: 21px; color: var(--k2); margin: 12px 0 24px; line-height: 1.5; font-weight: 600; }
.overlay .acts { display: flex; gap: 12px; justify-content: center; }
.overlay .chip { position: absolute; top: 14px; left: 18px; display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--k3); }
.overlay .chip i { display: none; }
.overlay .chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--m); animation: blink 1.2s steps(2) infinite; }
.overlay .chip::after { content: "REC"; }

/* 시작 막 */
.intro .rules { text-align: left; font-size: 19px; line-height: 1.6; margin: 10px 0 24px; padding: 0; list-style: none; font-weight: 600; color: var(--k); }
.intro .rules li { padding-left: 24px; position: relative; }
.intro .rules li + li { margin-top: 4px; }
.intro .rules li::before { content: ""; position: absolute; left: 0; top: 9px; width: 10px; height: 10px; border: 2px solid var(--leaf); }

/* 편지: 어두운 화면 위의 밝은 종이 한 장(읽기 편하게) */
.modal { position: absolute; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, .7); }
.modal.on { display: flex; }
.letter {
  position: relative; width: min(860px, 92vw); max-height: 88dvh; overflow: auto; background: #F2F4EE; color: #111813;
  padding: 40px 52px 34px; font-size: 19px; line-height: 1.75;
}
.letter .to { font-weight: 800; font-size: 22px; margin: 0 0 10px; }
.letter p { margin: 0 0 12px; }
.letter .mine, .letter .hint { border-top: 1.5px solid #111813; padding-top: 12px; margin: 18px 0; }
.letter .mine ul { margin: 0; padding-left: 22px; }
.letter .hint .h { padding-left: 16px; border-left: 4px solid #6E9A12; }
.letter .from { text-align: right; font-weight: 700; margin-top: 18px; }
.letter .x { position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; border: 1.5px solid #111813; background: none; color: #111813; font-size: 22px; line-height: 1; }
.letter .bar { display: flex; position: absolute; top: 0; left: 0; right: 0; height: 6px; margin: 0; background: #111813; }
.letter .bar i { display: none; }

/* 크롬북 가로 화면 조정 */
@media (max-height: 700px) {
  .top { height: 54px; }
  .hud .v { font-size: 28px; }
  .btn { height: 46px; font-size: 17px; }
}
