/* 미니 게임 두 개(하늘 산책 fly.html, 초원 달리기 run.html)가 함께 쓴다.
   배치: 화면 전체가 이세계의 상공 또는 초원(캔버스 한 장). 위에 점수·기운·연속, 가운데에 시작/결과 패널 하나.
   패널과 글자는 게임 본편의 밤 둥지 색(보라 네 단계 + 주황·민트·노랑)을 그대로 쓴다. 한 가지 색 세계로 고정. */
:root {
  --ink: #17142B; --panel: #211C3D; --card: #2A244A; --card-on: #3A3166; --line: #51477A;
  --text: #F5F1FF; --sub: #B9B0D4;
  --lamp: #FFB454; --lamp-deep: #D88932; --lamp-dark: #7A4A14; --lamp-ink: #2B1A08;
  --mint: #6FE0C1; --gold: #FFD86B; --pink: #F06A9B; --shade: rgba(23, 20, 43, 0.86); --veil: rgba(33, 28, 61, 0.94); --title-shadow: #3D2F6B;
  --font-display: 'Do Hyeon', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-body: 'Gowun Dodum', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-pixel: 'Silkscreen', 'Do Hyeon', ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--ink); color: var(--text); font-family: var(--font-body); font-size: 1rem; line-height: 1.5; overflow: hidden; word-break: keep-all; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--mint); }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; }
#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; cursor: crosshair; }
.read { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* 위 줄: 점수 / 남은 시간과 지금 나는 곳 / 연속 */
.hud { position: fixed; inset: 0 0 auto 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; padding-top: calc(env(safe-area-inset-top, 0px) + 12px); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); pointer-events: none; font-family: var(--font-display); line-height: 1; text-shadow: 2px 2px 0 var(--shade), -1px -1px 0 var(--shade); font-variant-numeric: tabular-nums; }
.hud small { display: block; font-family: var(--font-pixel); font-size: 0.6875rem; letter-spacing: 0.16em; color: var(--mint); margin-bottom: 4px; }
.hud-score b { display: inline-block; font-weight: 400; font-size: 2rem; transform-origin: left center; }
.hud-score canvas { display: block; width: 72px; height: 72px; margin: 4px 0 0 -8px; image-rendering: pixelated; image-rendering: crisp-edges; }
.hud-time { min-width: 108px; text-align: center; }
.hud-time b { font-weight: 400; font-size: 1.5rem; }
/* 남은 시간(한 판 3분): 30초 남으면 노랑, 10초 남으면 분홍 */
.hud-time .clock { display: block; font-size: 2rem; margin-bottom: 8px; }
.hud-time .clock.soon { color: var(--gold); }
.hud-time .clock.low { color: var(--pink); }
.hud-time .bar { display: block; height: 6px; margin-top: 6px; background: var(--shade); box-shadow: 0 0 0 2px var(--line); }
.hud-time .bar i { display: block; height: 100%; width: 100%; background: var(--lamp); transform-origin: left center; }
.hud-time .place { display: block; margin-top: 9px; font-size: 1rem; white-space: nowrap; }
.hearts { display: block; font-size: 1.625rem; letter-spacing: 0.08em; }
.hearts i { font-style: normal; color: var(--pink); }
.hearts i.off { color: var(--line); text-shadow: none; }
.hud b.hearts.lost { animation: lost 0.5s steps(4); }
.hud-time .mission { display: block; margin-top: 7px; font-size: 0.875rem; color: var(--gold); white-space: nowrap; }
.hud-time .aura { display: block; margin-top: 10px; }
.hud-time .aura em { display: block; font-style: normal; font-size: 0.9375rem; color: var(--gold); white-space: nowrap; }
.hud-time .aura .bar i { background: var(--mint); }
.hud-combo { text-align: right; }
.hud-combo b { display: inline-block; font-weight: 400; font-size: 2rem; color: var(--gold); transform-origin: right center; }
.hud-view { display: block; white-space: nowrap; margin: 10px 0 0 auto; pointer-events: auto; border: 0; cursor: pointer; padding: 8px 10px 6px; font-family: var(--font-display); font-size: 0.875rem; line-height: 1; color: var(--text); text-shadow: none; background: var(--shade); box-shadow: 0 0 0 2px var(--line); }
.hud b.pop { animation: pop 0.22s ease-out; }
.hud-combo b.lost { animation: lost 0.5s steps(4); }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes lost { 0%, 50% { color: var(--pink); transform: translateX(-4px); } 25%, 75% { color: var(--pink); transform: translateX(4px); } }
.tip { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); margin: 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); text-align: center; pointer-events: none; font-family: var(--font-display); font-size: 1.125rem; text-shadow: 2px 2px 0 var(--shade), -1px -1px 0 var(--shade); transition: opacity 0.6s; }
.tip b { font-weight: 400; color: var(--gold); }
.tip.gone { opacity: 0; }
/* 아래쪽 방향 패드(손가락으로 하는 기기): 왼손 엄지 자리. 민 쪽으로 간다 */
.nav { position: fixed; left: max(14px, env(safe-area-inset-left, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); touch-action: none; }
.nav-pad { position: relative; width: 132px; height: 132px; border-radius: 50%; background: rgba(23, 20, 43, 0.5); box-shadow: 0 0 0 3px var(--line), inset 0 0 0 2px rgba(245, 241, 255, 0.14); touch-action: none; }
.nav-pad::before, .nav-pad::after { content: ''; position: absolute; left: 50%; top: 50%; background: rgba(245, 241, 255, 0.16); pointer-events: none; }
.nav-pad::before { width: 2px; height: 76%; transform: translate(-50%, -50%); }
.nav-pad::after { width: 76%; height: 2px; transform: translate(-50%, -50%); }
.nav-pad i { position: absolute; z-index: 1; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 0 3px var(--lamp-deep), 0 4px 0 3px var(--lamp-dark); pointer-events: none; }
/* 패드가 떠 있을 때: 좁은 화면에서는 안내 글을 패드 위로 올리고, 넓은 화면에서는 패드와 뛰기 버튼 사이에 둔다 */
.has-nav .tip { bottom: calc(env(safe-area-inset-bottom, 0px) + 166px); }
.has-nav .jump { bottom: calc(env(safe-area-inset-bottom, 0px) + 40px); }
@media (min-width: 600px) { .has-nav .tip { bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); padding-left: 170px; padding-right: 170px; } }
/* 뛰기 버튼(초원 달리기)·돌진 버튼(하늘 산책): 오른손 엄지 자리. 돌진은 쉬는 동안 흐려진다 */
.jump { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 88px); width: 84px; height: 84px; margin: 3px; padding: 0; border: 0; cursor: pointer; font-family: var(--font-display); font-size: 1.375rem; line-height: 1; color: var(--lamp-ink); background: var(--lamp); opacity: 0.94; touch-action: manipulation; box-shadow: 0 -3px 0 0 var(--lamp-deep), 0 3px 0 0 var(--lamp-dark), -3px 0 0 0 var(--lamp-deep), 3px 0 0 0 var(--lamp-deep); }
.jump:active { transform: translateY(2px); }
.jump.wait { opacity: 0.42; }

/* 시작·결과 패널 */
.wrap { position: fixed; inset: 0; display: grid; place-items: center; overflow-y: auto; padding-block: calc(env(safe-area-inset-top, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 16px); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.panel { width: min(100%, 430px); display: flex; flex-direction: column; gap: 12px; padding: 20px 18px 16px; text-align: center; background: var(--veil); box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line); }
.eyebrow { margin: 0; font-family: var(--font-pixel); font-size: 0.6875rem; letter-spacing: 0.2em; color: var(--mint); }
h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(2.125rem, 10vw, 2.75rem); line-height: 1.05; text-shadow: 3px 3px 0 var(--title-shadow); text-wrap: balance; }
.lede { margin: 0; color: var(--sub); text-wrap: balance; }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; padding: 3px; }
.pick { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 6px 4px 8px; border: 0; cursor: pointer; background: var(--card); font-family: var(--font-display); line-height: 1.2; box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line); }
.pick canvas { width: 96px; height: 96px; image-rendering: pixelated; image-rendering: crisp-edges; }
.pick .nm { font-size: 1.0625rem; }
.pick .code { font-family: var(--font-pixel); font-size: 0.625rem; letter-spacing: 0.04em; color: var(--sub); margin-top: 2px; }
.pick[aria-pressed="true"] { background: var(--card-on); box-shadow: 0 -3px 0 0 var(--lamp), 0 3px 0 0 var(--lamp), -3px 0 0 0 var(--lamp), 3px 0 0 0 var(--lamp); }
.pick[aria-pressed="true"] .nm { color: var(--lamp); }
/* 고를 아이가 여섯일 때(초원 달리기): 세 칸씩 두 줄 */
.picks.six { grid-template-columns: repeat(3, 1fr); gap: 9px; }
.picks.six .pick canvas { width: 72px; height: 72px; }
.picks.six .pick .nm { font-size: 0.9375rem; }
.picks.six .pick .code { font-size: 0.5625rem; letter-spacing: 0; }
.btn { align-self: center; border: 0; cursor: pointer; font-family: var(--font-display); font-size: 1.375rem; line-height: 1; padding: 14px 28px 12px; margin: 3px; background: var(--lamp); color: var(--lamp-ink); box-shadow: 0 -3px 0 0 var(--lamp-deep), 0 3px 0 0 var(--lamp-dark), -3px 0 0 0 var(--lamp-deep), 3px 0 0 0 var(--lamp-deep); }
.btn:active { transform: translateY(2px); }
.btn.quiet { background: var(--card); color: var(--text); box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line); }
/* 그만두기 전에 묻는 창: 다른 것들 위에 뜨고, 뒤는 살짝 어둡게 */
.ask { z-index: 5; background: rgba(23, 20, 43, 0.6); }
.ask .panel { width: min(100%, 340px); gap: 14px; padding: 22px 18px 18px; }
.ask-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.625rem; line-height: 1.15; text-wrap: balance; }
.ask .row { gap: 6px 14px; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px; }
.ghost { border: 0; cursor: pointer; background: none; padding: 6px 6px; font-family: var(--font-display); font-size: 0.9375rem; color: var(--sub); text-decoration: underline; text-underline-offset: 3px; }
.ghost[aria-pressed="true"] { color: var(--mint); }
.how { margin: 0; font-size: 0.875rem; color: var(--sub); }
.how b { font-weight: 400; color: var(--text); }
.note { margin: 0; min-height: 1.3em; font-size: 0.8125rem; color: var(--sub); text-wrap: pretty; }
.final { margin: 0; font-family: var(--font-display); font-size: clamp(3rem, 16vw, 4.25rem); line-height: 1; color: var(--gold); text-shadow: 3px 3px 0 var(--title-shadow); font-variant-numeric: tabular-nums; }
.final small { font-size: 0.4em; color: var(--text); }
.facts { margin: 0; color: var(--sub); }
.facts b { font-weight: 400; color: var(--text); }
@media (max-height: 780px) { .pick canvas, .picks.six .pick canvas { width: 60px; height: 60px; } .panel { gap: 8px; padding-block: 12px 10px; } }
/* 가로로 누운 휴대폰: 패널을 두 칸으로(왼쪽 설명, 오른쪽 아이 고르기) */
@media (max-height: 560px) and (orientation: landscape) {
  #menu .panel { width: min(100%, 720px); display: grid; grid-template-columns: 1fr 1.05fr; align-items: center; gap: 8px 20px; padding: 14px 18px; }
  #menu .picks { grid-column: 2; grid-row: 1 / span 5; }
  #menu .panel .span { grid-column: 1 / -1; }
  .pick canvas { width: 72px; height: 72px; }
  .picks.six .pick canvas { width: 56px; height: 56px; }
  .jump { bottom: calc(env(safe-area-inset-bottom, 0px) + 56px); }
  h1 { font-size: 2.125rem; }
  .note { display: none; }
}
@media (prefers-reduced-motion: reduce) { .hud b { animation: none !important; } .tip { transition: none; } }
