/* 장면(오늘 화면 위쪽 · 주간 등대 띠 · 퀘스트 카드 그림 · 핵심 칸 아래 장면). 그림은 src/ui/scene/art.js·path-art.js 가 svg 로 그린다.
   규칙(H38, 정책서 11절): 색·크기는 tokens.css 이름만 쓴다. 움직임은 위치(transform)·투명도(opacity)만. 끝없는 배경 움직임은 쉬는 화면(data-rest: 오늘·모험·보물)에서만 켜고
   주기는 3.5초 이상, 번쩍임 없음. 학습·전투 화면의 장면은 끝없이 움직이지 않는다(칸을 넘기는 순간의 부품 생김만, 스크립트가 건다). 그림은 aria-hidden. */

/* ── 오늘 화면 위쪽 장면: 그림 위에 반디(왼쪽)와 말풍선(오른쪽) ── */
.scene-hero { position: relative; height: 236px; margin-top: 6px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); background: linear-gradient(180deg, var(--bg), var(--panel)); }
.scene-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scene-hero__friend { position: absolute; z-index: 2; left: 8px; top: 6px; }
.scene-hero__say { position: absolute; z-index: 3; left: 118px; top: 30px; right: 12px; }
.scene-hero__say .ui-bubble { font-size: var(--fs-body); }

/* 퀘스트 카드 옆 작은 그림 */
.part-pic { flex: none; width: 48px; height: 48px; margin-left: auto; }
.part-pic svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ── 주간 등대 띠: 요일마다 작은 등대, 끝낸 날은 불이 켜지고 오늘은 테두리 ── */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 14px 0 0; padding: 0; list-style: none; text-align: center; font-size: 13px; color: var(--mute); }
.week li { border: 1.5px solid transparent; border-radius: var(--radius); padding: 4px 0 2px; }
.week li svg { display: block; width: 34px; height: 58px; margin: 0 auto 2px; overflow: visible; }
.week li.lit { color: var(--ink); }
.week li.today { border-color: var(--lamp); background: color-mix(in srgb, var(--lamp) 9%, transparent); color: var(--ink); font-weight: 600; }

/* ── 핵심 칸 아래 빈 곳(공사 중인 집 + 이야기 아이). 남는 자리를 채운다 ── */
.scene-fill { position: relative; flex: 1; min-height: 160px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); background: linear-gradient(180deg, var(--bg), var(--panel)); }
.scene-fill[data-scene="key"] { min-height: 220px; }

/* ── 모험 화면(H29·H30): 위 섬 지도 띠 + 아래 마을. 마을 칸은 390×592 기준이라 위치는 % 로 둔다 ── */
.adventure { display: flex; flex-direction: column; gap: 8px; }
.isle-strip { position: relative; height: 112px; flex: none; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: linear-gradient(180deg, var(--sky0), var(--sky1)); }
.isle-strip .strip-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.isle { position: absolute; top: 38px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; min-width: 48px; min-height: var(--touch); padding: 0; border: 0; background: none; color: var(--mute); font-size: var(--fs-small); line-height: 1.2; cursor: pointer; }
.isle.cur { top: 20px; color: var(--lamp); font-weight: 600; cursor: default; }
.isle svg { display: block; overflow: visible; }
.isle:focus-visible, .hs:focus-visible, .sem:focus-visible { outline: var(--focus) solid var(--lamp); outline-offset: 2px; border-radius: 12px; }
.isle-pin-wrap { position: absolute; top: 4px; transform: translateX(-50%); z-index: 3; pointer-events: none; }
.isle-pin-wrap svg { display: block; }

.village-wrap { display: flex; justify-content: center; margin: 0 calc(-1 * var(--gutter)); }
.village { position: relative; width: 100%; max-width: 390px; aspect-ratio: 390 / 592; overflow: hidden; }
.village-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.village .ab { position: absolute; z-index: 3; pointer-events: none; }
.village .ab svg { display: block; overflow: visible; }
.village-friend svg { filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .35)); }
.village-friend { pointer-events: auto !important; z-index: 5 !important; }
.village-chips { position: absolute; z-index: 5; left: 16px; right: 12px; top: 6px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; }
.village-chips > * { pointer-events: auto; }
.isle-chip { background: var(--panel); color: var(--mute); }
.village[data-subject="math"] .isle-chip { color: var(--c-math); }
.village[data-subject="science"] .isle-chip { color: var(--c-science); }
.sem-group { display: flex; gap: 4px; }
.sem { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 52px; min-height: var(--touch); padding: 2px 6px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); font-size: var(--fs-small); line-height: 1.2; cursor: pointer; }
.sem[aria-pressed="true"] { border-color: var(--lamp); color: var(--lamp); font-weight: 600; cursor: default; }

/* 집 누르는 칸(최소 96px 폭 · 44px 높이): 이름표는 14px 이상, 불빛 칸은 이름표 아래 */
.hs { position: absolute; z-index: 4; transform: translateX(-50%); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 0; background: none; border: 0; cursor: pointer; min-height: var(--touch); color: var(--ink); }
.hl { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin-top: auto; padding: 1px 7px; border-radius: 12px; background: color-mix(in srgb, var(--sky0) 74%, transparent); font-size: var(--fs-small); line-height: 1.3; color: var(--ink); text-align: center; max-width: 100px; text-wrap: balance; }
/* 줄이 4개 이상(집 7채~)이면 이름표는 한 줄(3줄까지는 두 줄)(넘치면 …). 전체 이름은 화면 읽기(aria-label)와 길게 눌렀을 때(title)로 */
.village[data-lines="1"] .hl { -webkit-line-clamp: 1; text-wrap: nowrap; text-overflow: ellipsis; display: block; white-space: nowrap; }
.hs.dim .hl { color: var(--mute); }
.hs[aria-disabled="true"] { cursor: default; }
.pips { display: flex; gap: 3px; margin-top: 3px; padding: 2px 5px; border-radius: 999px; background: color-mix(in srgb, var(--sky0) 74%, transparent); }
.pips i { display: block; width: 10px; height: 7px; border-radius: 2px; border: 1.5px solid var(--line-strong); box-sizing: border-box; }
.pips i.on { background: var(--lamp); border-color: var(--lamp); box-shadow: 0 0 5px var(--lamp-glow); }
.pips i.dm { background: color-mix(in srgb, var(--lamp) 50%, transparent); border-color: color-mix(in srgb, var(--lamp) 75%, transparent); }

/* 눌렀지만 못 들어가는 집에 한 줄 안내 */
.village-note { position: absolute; z-index: 6; left: 100px; right: 12px; bottom: 14px; margin: 0; }
.village-note[hidden] { display: none; }
.village-note .line { display: block; }

/* ── 끝내기 화면(H36, ui.closing): 오늘 퀘스트를 다 했어요 + 내일 귀신 한 줄 + 쉬러 가는 친구. 주 단추 '내일 봐요'는 오른쪽 아래, '더 하고 싶어요'는 작은 단추로 왼쪽 아래(숨기지 않음) ── */
.screen.closing { display: flex; flex-direction: column; gap: 12px; min-height: 100dvh; padding-bottom: 0; text-align: center; }
.closing-dots { display: flex; justify-content: center; gap: 16px; margin: 20px 0 8px; padding: 0; list-style: none; }
.closing-dots li { width: 20px; height: 20px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 10px var(--lamp-glow); }
.closing-title { margin: 8px 0 0; font-family: var(--f-head); font-size: var(--fs-title); line-height: 1.3; }
.closing-ghost { margin: 0; color: var(--mute); }
.scene-closing { height: 236px; margin-top: 8px; }
.closing-bar { position: sticky; bottom: 0; margin: auto calc(-1 * var(--gutter)) 0; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + var(--sab)); background: linear-gradient(180deg, rgba(10, 17, 40, 0), rgba(10, 17, 40, 0.96) 28%); }
.closing-bar__main .ui-btn { min-width: 150px; }
.closing-bar [data-role="more"] { min-height: var(--touch); }
/* 하루 미션 상자(2026-11-06): 닫힌 상자 단추(56px) 또는 연 뒤 얻은 것 이름 한 줄. 문장 없이 단추·이름만 둔다(2문장 화면) */
.closing-chest { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.closing-chest .ui-btn { min-width: 200px; min-height: 56px; }
.closing-chest .ui-btn .ui-icon { width: 28px; height: 28px; color: var(--lamp); }
.closing-chest .ui-btn .bt-chest__img { width: 36px; height: 36px; margin-block: -4px; }
.closing-chest .bt-chest { width: min(100%, 320px); min-height: 56px; text-align: left; }

/* ── 오늘 화면 위쪽 장면: 등대 가는 길(H38). 칸 비율 358:236 고정, 모든 것은 칸의 % 위치 ── */
.scene-hero.scene-path { height: auto; }
.path-stage { position: relative; width: 100%; aspect-ratio: 358 / 236; overflow: hidden; }
.path-stage svg { display: block; }
.path-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.path-lh, .path-lamp, .path-kid, .path-blk { position: absolute; }
.path-lh svg, .path-lamp svg, .path-kid svg, .path-blk svg { width: 100%; height: auto; overflow: visible; }
.path-lh { z-index: 1; }
.path-lamp { z-index: 1; transform-origin: 50% 100%; }
.path-kid { z-index: 2; }
.path-kid.is-follow { z-index: 4; }
.path-blk { z-index: 3; transform-origin: 50% 70%; }
.path-blk.is-gone { visibility: hidden; }
.path-bandi { position: absolute; z-index: 5; width: 56px; height: 56px; }
.path-hits { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.path-hit { position: absolute; transform: translate(-50%, -50%); padding: 0; margin: 0; border: 0; border-radius: 12px; background: transparent; cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent; }
.path-hit:focus-visible { outline: var(--focus) solid var(--lamp); outline-offset: 1px; }
.path-pt { position: absolute; z-index: 5; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--lamp); pointer-events: none; }
.path-spark { position: absolute; z-index: 5; width: 20px; height: 20px; pointer-events: none; }
.path-spark svg { width: 100%; height: 100%; }
.scene-path .scene-hero__say { left: 10px; right: 10px; top: 8px; z-index: 7; pointer-events: none; }
.scene-path .scene-hero__say .ui-bubble { display: inline-block; max-width: 100%; margin: 0; }
/* 방해꾼·아이의 포즈: 하나만 보인다 */
.path-blk .po { display: none; }
.path-blk[data-pose="block"] .po-block, .path-blk[data-pose="play"] .po-play, .path-blk[data-pose="flee"] .po-flee { display: inline; }
.path-kid .kk-c { display: none; }
.path-kid.is-cheer .kk-s { display: none; }
.path-kid.is-cheer .kk-c { display: inline; }
.path-kid .lk-on { opacity: 0; }
.path-kid.is-follow .lk-on { opacity: 1; }
/* 가로등: 꺼진 그림은 또렷하게(32판: 새 꺼짐 그림이 이미 어둡다, 불투명도 1), 켜지면 위에 켜진 모습이 겹친다 */
.path-lamp .lp-off { opacity: 1; }
.path-lamp .lp-on { opacity: 0; transform-box: fill-box; transform-origin: 50% 55%; }
.path-lamp.is-lit .lp-on { opacity: 1; }
.path-lh .lh-on { opacity: 0; transform-box: fill-box; transform-origin: 50% 70%; }
.path-lh.is-lit .lh-on { opacity: 1; }
.path-lh .lh-beam { opacity: 0; transform-box: fill-box; }
.path-lh .lh-bl { transform-origin: 100% 50%; }
.path-lh .lh-br { transform-origin: 0 50%; }
.path-lh.is-lit .lh-beam { opacity: .13; }
.path-lh .lh-rays { transform-box: fill-box; transform-origin: 50% 50%; }
.path-bg .tw, .path-bg .wv { transform-box: fill-box; }

/* 가로등 밝기 3단계(H54): 1 은은하게(작은 불씨) · 2 밝게(빛무리) · 3 반짝(더 큰 무리와 별 셋). 모양은 path-art.js 가 그리고, 여기서는 켜진 층의 번짐만 다듬는다 */
.path-lamp .lp-sp, .result-lamp .lp-sp { transform-box: fill-box; }
.result-lamp { display: inline-block; width: 44px; }
.result-lamp svg { display: block; width: 100%; height: auto; overflow: visible; }

/* ── 쉬는 화면(data-rest)에서만 끝없이 도는 약한 배경 움직임: 위치·투명도만, 주기 3.5초 이상, 번쩍임 없음 ── */
@media (prefers-reduced-motion: no-preference) {
  [data-rest]:not([data-reduce]) .tw { animation: sc-tw 5.2s ease-in-out infinite; }
  [data-rest]:not([data-reduce]) .tw1 { animation-duration: 6.4s; animation-delay: -1.7s; }
  [data-rest]:not([data-reduce]) .tw2 { animation-duration: 4.3s; animation-delay: -3s; }
  [data-rest]:not([data-reduce]) .tw3 { animation-duration: 7.1s; animation-delay: -4.4s; }
  [data-rest]:not([data-reduce]) .path-blk:not(.is-gone) .blk-in { animation: sc-bob 3.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
  [data-rest]:not([data-reduce]) .path-lamp.is-lit .lp-on { animation: sc-breathe 4s ease-in-out infinite; }
  [data-rest]:not([data-reduce]) .path-lamp.is-lit .lp-sp { animation: sc-tw 4.6s ease-in-out infinite; }
  [data-rest]:not([data-reduce]) .path-lh.is-lit .lh-bl { animation: sc-sway 7s ease-in-out infinite; }
  [data-rest]:not([data-reduce]) .path-lh.is-lit .lh-br { animation: sc-sway 7s ease-in-out -3.5s infinite; }
  [data-rest]:not([data-reduce]) .wv { animation: sc-wave 5s linear infinite; }
  [data-rest]:not([data-reduce]) .wv1 { animation-duration: 7s; animation-direction: reverse; }
}
@keyframes sc-tw { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes sc-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes sc-breathe { 0%, 100% { opacity: .78; } 50% { opacity: 1; } }
@keyframes sc-sway { 0%, 100% { transform: scaleX(1); opacity: .13; } 50% { transform: scaleX(.45); opacity: .06; } }
@keyframes sc-wave { from { transform: translateX(0); } to { transform: translateX(8.5px); } }
/* 움직임 줄이기(앱 설정 data-reduce): 장면 안의 끝없는 움직임·사건 움직임이 없다(상태만 보인다) */
[data-reduce].scene-path *, [data-reduce] .village * { animation: none !important; }

/* ── 원리 카드 집 짓기(H38): 부품이 하나씩 생긴다. 움직임은 스크립트가 건다(칸을 넘기는 순간뿐) ── */
.scene-fill svg [data-hp] { transform-box: fill-box; }
.house-spark { position: absolute; z-index: 2; width: 20px; height: 20px; pointer-events: none; }
.house-spark svg { display: block; width: 100%; height: 100%; }
.scene-fill[data-scene="story"], .scene-fill[data-scene="caution"] { flex: none; min-height: 0; height: 172px; }

/* ── 모험 마을 쉬는 화면 움직임(data-rest): 별 반짝임 · 남은 귀신 둥실 · 켜진 집 불빛 숨쉬기 · 옅은 안개 흐름 ── */
@media (prefers-reduced-motion: no-preference) {
  .village[data-rest]:not([data-reduce]) .ghost-on svg { animation: sc-bob 3.6s ease-in-out infinite; }
  .village[data-rest]:not([data-reduce]) .ghost-on:nth-of-type(2n) svg { animation-delay: -1.8s; }
  .village[data-rest]:not([data-reduce]) .hglow { animation: sc-breathe 4s ease-in-out infinite; }
  .village[data-rest]:not([data-reduce]) .vmist { animation: sc-drift 7s ease-in-out infinite alternate; }
}
@keyframes sc-drift { from { transform: translateX(0); } to { transform: translateX(5px); } }
.village-art .hwrap, .village-art .hprev { transform-box: fill-box; }
.village-art .hglow { transform-box: fill-box; }

/* ── 빈 곳 채우기(H40, config ui.fill): 칸이 하는 일을 보여 주는 그림. 나타날 때 한 번(--fill-ms, 설정 fillAppearMaxMs 이하), 읽고 푸는 동안은 멈춘다 ── */
.fill-scene { position: relative; min-width: 0; }
.fill-scene--flex { flex: 1 1 0; min-height: 0; max-height: min(40dvh, 460px); container-type: size; }
.fill-scene--fixed { flex: none; }
.fill-box { position: absolute; inset: 0; overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--line); background: linear-gradient(180deg, var(--bg), var(--panel)); }
.fill-box > svg { display: block; width: 100%; height: 100%; }
@container (max-height: 63px) { .fill-box { display: none; } } /* 자리가 너무 좁으면 접는다(화면을 늘리지 않는다) */
.fill-scene--fixed[data-scene="hubStrip"] { aspect-ratio: 358 / 150; flex: 1 0 auto; max-height: 300px; } /* 남는 자리가 있으면 위쪽 하늘이 더 보이게 늘어난다 */
.fill-scene[data-scene="closingKids"], .fill-scene[data-scene="treasure"], .fill-scene[data-scene="guardianGate"] { flex: 1 1 0; min-height: 140px; max-height: none; }
/* 24판(H12·H40): 첫 시작 아이 화면 넷과 '핵심만 먼저 봐요' 요약의 남는 자리. 큰 화면에서도 비지 않게 높이를 넓게 허용한다 */
.fill-scene[data-scene^="welcome"], .fill-scene[data-scene="summaryBuild"], .fill-scene[data-scene="lostWay"] { flex: 1 1 0; min-height: 150px; max-height: min(66dvh, 820px); margin-bottom: var(--sp-2); }
@media (prefers-reduced-motion: no-preference) {
  .fill-in:not([data-reduce]) { animation: fill-in var(--fill-ms, 450ms) ease-out both; }
}
@keyframes fill-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 단원 첫 화면 단계 카드: 그림 + 이름·한 줄 */
.hub-stage { display: flex; align-items: center; gap: var(--sp-3); }
.hub-stage__pic { flex: none; width: 52px; height: 52px; }
.hub-stage__pic svg { display: block; width: 52px; height: 52px; overflow: visible; }
.hub-stage__txt { min-width: 0; }
.hub-stage__txt .ui-card__title { margin: 0 0 2px; font-size: 17px; }
.hub-stage-card.is-locked { border-style: dashed; border-color: var(--line-strong); background: transparent; cursor: default; }
.hub-stage-card.is-locked .hub-stage__txt { color: var(--mute); }
/* 흐름 잇기 1차(#6): 끝낸 단계 체크, 다음에 할 단계 테두리 */
.hub-stage__done { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 6px; vertical-align: -3px; border-radius: 50%; background: var(--lamp); color: var(--lamp-ink); }
.hub-stage__done svg { width: 15px; height: 15px; fill: none; stroke: currentColor; }
.hub-stage-card[data-next="true"] { border-color: var(--lamp); }
/* 보물·보호자 잠금 입구(준비 중 화면)의 빈 곳 */
.screen.has-fill { display: flex; flex-direction: column; gap: var(--sp-3); }
.screen.has-fill .placeholder { min-height: 0; padding: var(--sp-5) 0 var(--sp-2); }
.screen.has-fill .fill-scene { min-height: 200px; }
/* 연습 화면: 문제 아래 한 줄(남는 자리만), 연습 결과(괴물 놀라 도망) */
.fill-scene[data-scene="practiceEnd"] { flex: 1 1 0; min-height: 170px; max-height: none; }
.learn-body:has(.fill-scene[data-scene="practiceEnd"]) .learn-center { flex: none; padding-block: var(--sp-3); }
.screen.has-fill { min-height: 100dvh; }

/* ── 캐릭터 팩 그림(src/ui/scene/char-pic.js, 2026-11-05) ──
   정사각 칸에 contain. 모든 포즈가 같은 캔버스·같은 바닥 기준점(--char-ay, 목록 canvas.anchor.y)이라 포즈가 바뀌어도 발이 그대로다.
   --char-foot: 이 칸에서 발이 놓일 높이(칸 높이의 비율). 기준점이 그 높이에 오도록 그림 전체를 옮긴다(자르지 않고, 칸 밖으로 조금 나가도 보이게 둔다). */
.char-pic { position: relative; display: block; aspect-ratio: 1; --char-ay: .8984375; --char-foot: var(--char-ay); pointer-events: none; user-select: none; }
.char-pic__pic, .char-pic__img { display: block; width: 100%; height: 100%; }
.char-pic__img { object-fit: contain; transform: translateY(calc((var(--char-foot) - var(--char-ay)) * 100%)); -webkit-user-drag: none; }
.char-pic.is-fallback > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.char-pic__lock { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.char-pic[data-pose="locked"] .char-pic__img { opacity: .5; }
/* SVG 장면 위에 얹는 층: fit = svg 칸이 viewBox 비율 그대로 · cover = xMidYMax slice(빈 곳 채우기 상자, 상자 크기는 컨테이너 단위로 읽는다) */
.char-host { position: relative; }
.char-layer { position: absolute; pointer-events: none; }
.char-layer--fit { inset: 0; }
.char-layer--cover { left: 50%; bottom: 0; width: max(100cqw, calc(100cqh * var(--vb-w) / var(--vb-h))); aspect-ratio: var(--vb-w) / var(--vb-h); transform: translateX(-50%); }
.char-layer .char-pic { position: absolute; }
.fill-box { container-type: size; }
/* 자리마다 */
.path-blk .char-pic, .part-pic .char-pic { width: 100%; }
.part-pic .char-pic { height: 100%; }
