@font-face { font-family: 'Orbit QR'; src: url(fonts/orbit-qr.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex KR QR'; src: url(fonts/plex-kr-qr-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex KR QR'; src: url(fonts/plex-kr-qr-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }

/* 테마별 토큰: 장면의 안개·땅 색에서 뽑았다 */
:root, body[data-theme="jungle"] {
  --ink: #151c11;        /* 젖은 이끼 그늘 */
  --paper: #eef0e2;      /* 바랜 콘크리트 */
  --accent: #c6d36f;     /* 지의류 */
  --dim: rgba(238, 240, 226, .62);
  --line: rgba(238, 240, 226, .16);
  --light: #dcd6bf; --dark: #1f2a17;
  --bg-in: #f6f1e4; --bg-out: #d9d0b9; --on-bg: #3a4030;
}
body[data-theme="neon"] {
  --ink: #0d0a19; --paper: #efe9ff; --accent: #ff4fbf;
  --dim: rgba(239, 233, 255, .62); --line: rgba(239, 233, 255, .16);
  --light: #c6f1fb; --dark: #0b0b14;
  --bg-in: #3a2a6e; --bg-out: #120d2a; --on-bg: #d9dcff;
}
body[data-theme="snow"] {
  --ink: #161b25; --paper: #f1f4f8; --accent: #ffb35c;
  --dim: rgba(241, 244, 248, .64); --line: rgba(241, 244, 248, .18);
  --light: #eef3f9; --dark: #1a1f27;
  --bg-in: #f5f8fb; --bg-out: #cdd8e4; --on-bg: #3b4656;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 42%, var(--bg-in), var(--bg-out)) fixed var(--bg-out); color: var(--paper);
  font: 400 15px/1.5 'Plex KR QR', 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
  word-break: keep-all; -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.veil { position: fixed; inset: 0; background: var(--bg-out); pointer-events: none; animation: veil .35s ease-out forwards; }
@keyframes veil { to { opacity: 0; } }

/* 상단: 로고 + 비행 계기 */
.top {
  position: fixed; top: calc(env(safe-area-inset-top) + 12px); left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none;
}
.logo {
  pointer-events: auto; text-decoration: none; color: var(--ink); background: var(--accent);
  font: 400 17px/1 'Black Han Sans', 'Plex KR QR', sans-serif; padding: 6px 8px 5px; border-radius: 2px;
}
.chip {
  pointer-events: auto; cursor: pointer; height: 30px; padding: 0 10px; border-radius: 2px;
  background: var(--ink); color: var(--paper); border: 0; font-size: 12.5px; font-weight: 600;
}
.chip[aria-pressed="false"] { color: var(--dim); }

/* 조준 괄호: 드론이 QR을 잡아낸다 */
.lock {
  position: fixed; left: var(--lx, 0); top: var(--ly, 0); width: var(--lw, 0); height: var(--lh, 0);
  opacity: var(--lo, 0); pointer-events: none;
}
.lock i { position: absolute; width: 22px; height: 22px; border: 0 solid var(--accent); }
.lock i:nth-child(1) { left: 0; top: 0; border-width: 2px 0 0 2px; }
.lock i:nth-child(2) { right: 0; top: 0; border-width: 2px 2px 0 0; }
.lock i:nth-child(3) { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.lock i:nth-child(4) { left: 0; bottom: 0; border-width: 0 0 2px 2px; }
.hint {
  position: fixed; left: var(--free-cx, 50%); bottom: var(--hint-bottom, 200px); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); margin: 0; text-align: center;
  font-size: 13px; color: var(--on-bg); opacity: 0; transition: opacity .4s; pointer-events: none;
}
body[data-state="done"][data-view="iso"] .hint { opacity: .85; }
.site-tag { display: none; }
.exit { display: none; }
body.clean .dock, body.clean .top, body.clean .lock-note, body.clean .hint, body.clean .toast { display: none; }
body.clean .site-tag {
  display: block; position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 18px); margin: 0;
  text-align: center; font-size: 14px; font-weight: 600; color: var(--on-bg); letter-spacing: .01em;
}
body.clean .exit { display: block; position: fixed; top: calc(env(safe-area-inset-top) + 12px); right: 12px; opacity: .35; }
body.clean .exit:hover, body.clean .exit:focus-visible { opacity: 1; }
.lock-note {
  position: fixed; left: var(--qr-cx, 50%); top: calc(env(safe-area-inset-top) + 15px); transform: translateX(-50%); margin: 0; white-space: nowrap;
  font-size: 13px; padding: 4px 9px; background: var(--ink); color: var(--paper); border-radius: 2px;
  opacity: 0; transition: opacity .4s;
}
body[data-state="done"][data-view="top"] .lock-note { opacity: 1; }

/* 하단 도크 */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 16px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--ink); border-top: 1px solid var(--line);
  display: grid; gap: 12px;
  transition: background-color .4s;
}
.compose h1 {
  margin: 0; font: 400 25px/1.15 'Orbit QR', 'Plex KR QR', sans-serif; letter-spacing: -.01em; word-spacing: -.22em;
}
.lede { margin: 4px 0 10px; font-size: 14px; color: var(--dim); }
.field { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--dim); }
.field input {
  min-width: 0; background: transparent; border: 0; padding: 12px 0; font-size: 16px; outline: none;
}
.field input::placeholder { color: var(--dim); }
.field:focus-within { border-bottom-color: var(--accent); }

.btn {
  height: 44px; padding: 0 14px; border-radius: 2px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--paper); font-weight: 600; font-size: 14.5px;
  white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn.ghost { border-color: transparent; color: var(--dim); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.field .btn { margin-bottom: 6px; }
.link { background: none; border: 0; padding: 6px 0; color: var(--dim); cursor: pointer; font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.themes button {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 6px; text-align: left;
  background: transparent; border: 1px solid var(--line); border-radius: 2px; cursor: pointer;
  font-size: 12.5px; line-height: 1.25; color: var(--dim);
}
.themes button[aria-checked="true"] { border-color: var(--accent); color: var(--paper); }
.th { flex: none; width: 40px; height: 30px; object-fit: contain; }

.playing { display: none; align-items: center; justify-content: space-between; gap: 12px; }
#status { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 14px; }
.actions { display: none; grid-template-columns: 1fr 44px 44px 44px; gap: 8px; }
.btn.icon { padding: 0; display: grid; place-items: center; }
.btn.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sheet {
  position: absolute; right: 16px; bottom: calc(100% + 8px); display: grid; min-width: 230px;
  background: var(--ink); border: 1px solid var(--line); border-radius: 2px; padding: 4px 0;
}
.sheet[hidden] { display: none; }
.sheet button { background: none; border: 0; color: var(--paper); text-align: left; padding: 12px 16px; font-size: 14.5px; cursor: pointer; }
.sheet button:hover, .sheet button:focus-visible { background: var(--line); }

body[data-state="play"] .compose, body[data-state="play"] .themes, body[data-state="done"] .compose { display: none; }
body[data-state="play"] .playing { display: flex; }
body[data-state="done"] .actions { display: grid; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--dockH, 200px) + 14px); transform: translate(-50%, 8px);
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 2px;
  background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 녹화: 9:16 화면으로 고정 */
.rec-badge { display: none; }
body.rec .dock, body.rec .top, body.rec .lock { visibility: hidden; }
body.rec #stage { inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(100vw, 56.25dvh); height: min(100dvh, 177.78vw); }
body.rec .rec-badge {
  display: block; position: fixed; top: calc(env(safe-area-inset-top) + 14px); left: 50%; transform: translateX(-50%);
  padding: 6px 10px 6px 24px; border-radius: 2px; background: var(--ink); color: var(--paper); font-size: 13px;
}
body.rec .rec-badge::before { content: ''; position: absolute; left: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: #ff3b3b; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

body.noui .dock, body.noui .top, body.noui .lock, body.noui .toast, body.noui .veil { display: none !important; }

.fallback, .err { position: fixed; inset: auto 16px 40% 16px; text-align: center; font-size: 15px; }

/* 데스크톱: 도크를 왼쪽 아래 패널로 */
@media (min-width: 900px) {
  .top { left: 24px; right: 24px; top: 20px; }
  .dock { left: 24px; right: auto; bottom: 24px; width: 460px; padding: 20px; border: 1px solid var(--line); }
  .compose h1 { font-size: 30px; }
  .toast { left: 214px; bottom: calc(var(--dockH, 200px) + 40px); }
}

@media (prefers-reduced-motion: reduce) {
  .veil { animation-duration: .01s; }
}

/* ---------------------------------------------------------------- 설명서 (첫 화면 아래)
   장면은 그대로 고정. 문서만 스크롤되게 풀고, 설명서는 첫 화면 바로 아래에서 시작해 도크 색 그대로 장면 위로 올라온다. */
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: visible; }
body.rec, body.noui { overflow: hidden; }
/* 광고 자리(/vendor/ads): 녹화·녹화 모드·UI 숨김에서는 숨긴다 */
body.rec .ad-slot, body.clean .ad-slot, body.noui .ad-slot { display: none !important; }
.guide {
  position: relative; z-index: 30; margin-top: 100vh; margin-top: 100svh;
  background: var(--ink); color: var(--paper); border-top: 1px solid var(--line);
  font: 400 15.5px/1.7 'Pretendard Variable', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  content-visibility: auto; contain-intrinsic-size: auto 1700px;
}
.guide-in { max-width: 1080px; margin: 0 auto; padding: 44px 16px calc(56px + env(safe-area-inset-bottom)); }
.guide h2 { margin: 0; font: 400 24px/1.25 'Black Han Sans', 'Pretendard Variable', sans-serif; letter-spacing: -.01em; }
.guide h3 { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--accent); }
.guide-lede { margin: 12px 0 0; max-width: 36em; color: var(--dim); }
.guide section, .guide-more { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); }
.guide-steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; counter-reset: s; }
.guide-steps li { counter-increment: s; position: relative; padding-left: 40px; color: var(--dim); }
.guide-steps li::before {
  content: counter(s); position: absolute; left: 0; top: 2px; width: 26px; height: 26px; display: grid; place-items: center;
  border: 1px solid var(--accent); border-radius: 2px; color: var(--accent); font: 400 15px/1 'Black Han Sans', sans-serif;
}
.guide b { display: block; color: var(--paper); font-weight: 700; }
.guide dl { margin: 0; display: grid; gap: 22px; }
.guide dt { font-weight: 700; }
.guide dd { margin: 4px 0 0; color: var(--dim); max-width: 38em; }
.guide-more ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.guide-more a { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 2px; color: var(--dim); text-decoration: none; }
.guide-more a:hover, .guide-more a:focus-visible { border-color: var(--accent); }
@media (min-width: 900px) {
  .guide-in { padding: 64px 24px 72px; }
  .guide h2 { font-size: 30px; }
  .guide-steps ol { grid-template-columns: repeat(3, 1fr); gap: 28px; }
  .guide dl { grid-template-columns: 1fr 1fr; gap: 26px 48px; }
  .guide-more ul { grid-template-columns: 1fr 1fr; gap: 12px; }
}
