/* 궤도 투입 미션: '종이 위 그림' 틀 (studio/DESIGN.md, 2026-10-18 게임 틀)
   - 위 막대·조작판·판·창은 흰 종이와 잉크(_kit/paper.css 토큰과 부품). 우주 장면은 종이 위의 어두운 그림(#fig.k-dark).
   - 단추를 색으로 칠하지 않는다. 주 단추는 잉크 칠, 보조는 회색 테두리, 고른 상태는 굵은 글자와 칸 아래 3px 막대(.k-on).
   - 반경: 단추·입력 var(--k-r), 판·그림·꼬리표·창 0, 슬라이더 손잡이만 원.
   - 같은 대상은 같은 색: 속도 초록, 중력에 의한 가속도·지구 중심 빨강, 궤적 파랑, 목표(마을·관측 구역·지상국) 분홍.
     -d는 어두운 장면 위(3D·꼬리표), -p는 흰 종이 위(글·읽음값·범례). 흰 바탕 글자 대비는 모두 4.5:1 이상 */
@import "kit/paper.css";

:root {
  --v-d: #4ade80;  --v-p: #237a36;  /* 속도 */
  --a-d: #ff6b4a;  --a-p: #c92a2a;  /* 중력에 의한 가속도, 지구 중심과 그 점선 */
  --tr-d: #7dd3fc; --tr-p: #1864ab; /* 궤적, 같은 시간 간격 점 */
  --tg-d: #f783ac; --tg-p: #c2255c; /* 목표: 마을과 허용 범위 띠, 관측 구역, 지상국 */
  --ok-p: #237a36; --bad-p: #c92a2a;
  --lab-dim: #c3cad8;
  --scene: #04060d; /* 3D 장면 바탕(main.js bgScene과 같다) */
  --hdr: 52px;
  --pw: clamp(min(290px, 42vw), 34%, 520px);
  font-family: var(--k-font);
  color: var(--k-ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--k-paper); }
body { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
/* 줄바꿈: 한국어는 어절, 영어는 낱말, 일본어는 구절·금칙. 틀을 넘는 긴 낱말만 끊는다 */
html { overflow-wrap: break-word; -webkit-hyphens: none; hyphens: none; }
html:lang(ko) { word-break: keep-all; }
html:lang(ja) { word-break: auto-phrase; line-break: strict; }
/* 사파리(auto-phrase 없음): 문구에 넣은 U+200B(구절 경계, i18n.js는 이때만 넣는다)에서만 줄을 바꾼다 */
@supports not (word-break: auto-phrase) { html:lang(ja) { word-break: keep-all; } }
.nw { white-space: nowrap; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; }
sup, sub { font-size: max(12px, 0.72em); line-height: 0; }

/* ── 범례 낱말(.k-w)의 대상 색. 선 모양: 지구 중심은 점선(장면의 지구 중심 점선) ── */
.k-w.w-v { --w: var(--v-p); }
.k-w.w-a { --w: var(--a-p); }
.k-w.w-c { --w: var(--a-p); text-decoration-style: dashed; }
.k-w.w-tr { --w: var(--tr-p); }
.k-w.w-tg { --w: var(--tg-p); }
html:lang(ja) .k-w { white-space: nowrap; } /* 사파리가 범례 낱말 가운데(3つの|村)에서 끊지 않게 */

#app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--pw);
  grid-template-rows: var(--hdr) minmax(0, 1fr) auto;
  grid-template-areas: "top top" "fig panel" "dock panel";
  background: var(--k-paper);
}

/* ── 위 막대: 종이 위 글줄. 상자 없이 ── */
#top { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 4px 10px 2px 6px; min-width: 0; }
.icon {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: var(--k-r);
  background: transparent; color: var(--k-ink); display: grid; place-items: center; padding: 0;
}
#ttl { flex: 1; min-width: 0; padding-left: 10px; font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mbar { flex: 1; min-width: 0; padding: 0 8px; font-size: 15px; line-height: 1.34; }
#mbar .mb { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
#lvTag { font-weight: 800; }
#lvGoal .gs { display: none; }
#lvTag .tag { font-weight: 650; color: var(--k-sub); }
#starsNow { flex: none; padding: 0 6px; font-size: 18px; color: var(--k-ink); white-space: nowrap; }
#app[data-mode="title"] #btnMenu, #app[data-mode="title"] #mbar, #app[data-mode="title"] #starsNow { display: none; }
#app:not([data-mode="title"]) #ttl { display: none; }

/* ── 우주 그림: 카드 없이 종이 위에 ── */
#fig { grid-area: fig; position: relative; min-width: 0; min-height: 0; overflow: hidden; margin: 4px 8px 0 16px; background: var(--scene); }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* 장면 꼬리표: 반경 0, 바탕은 장면과 같은 불투명 색, 글자색은 대상 색 */
.wlabel {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-size: 12px; font-weight: 700; line-height: 1.25; padding: 1px 5px; border-radius: 0; background: var(--scene); color: var(--lab-dim);
}
.wlabel.tg { color: var(--tg-d); }
.wlabel.tg.hit { color: #ffffff; }
.alabel { position: absolute; display: none; transform: translate(-50%, -50%); font-weight: 800; font-size: 15px; font-style: italic; padding: 0 3px; background: var(--scene); line-height: 1.2; }
.alabel.v { color: var(--v-d); }
.alabel.a { color: var(--a-d); }
/* 명중·성공 글자: 종이 꼬리표가 잠깐 떠올랐다 사라진다(한 번만, 맥박 없음) */
#pop { position: absolute; transform: translate(-50%, -50%); font-size: 20px; font-weight: 800; color: var(--k-ink); background: var(--k-paper); padding: 2px 8px; opacity: 0; visibility: hidden; white-space: nowrap; }
#pop.go { animation: pop 1.4s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; visibility: visible; transform: translate(-50%, -30%); } 15% { opacity: 1; transform: translate(-50%, -60%); } 70% { opacity: 1; } 99% { visibility: visible; } 100% { opacity: 0; visibility: hidden; transform: translate(-50%, -110%); } }
#figFoot { position: absolute; left: 10px; bottom: 6px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
#warpTag, #scalebar { font-size: 12.5px; font-weight: 650; color: var(--lab-dim); font-variant-numeric: tabular-nums; background: var(--scene); padding: 0 3px; width: max-content; }
#warpTag b { color: #ffffff; }
#scalebar { display: flex; align-items: center; gap: 6px; }
#scalebar i { display: block; height: 6px; border: 2px solid var(--lab-dim); border-top: none; }
/* 발사 결과 알림(휴대폰처럼 판이 좁을 때만 보인다. 넓으면 판의 #shotLine에 남는다) */
#toast {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 3; opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 16px); padding: 7px 12px; background: var(--k-ink); color: var(--k-paper);
  font-size: 14px; font-weight: 650; line-height: 1.4; text-align: center; visibility: hidden; transition: opacity 0.2s, visibility 0s 0.2s;
}
#toast.show { opacity: 1; visibility: visible; transition: opacity 0.2s; }
#toast .k-w { --w: var(--k-paper); }

/* ── 조작판: 그림 아래 종이 위 ── */
#dock { grid-area: dock; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; padding: 8px 8px 10px 16px; min-width: 0; }
.ctl { grid-column: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.ctl .val { display: flex; flex-direction: column; min-width: 104px; line-height: 1.15; }
.ctl .lbl { font-size: 13px; font-weight: 650; color: var(--k-sub); white-space: nowrap; }
.ctl output { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
#rowSpeed output { color: var(--v-p); }
#speed { --q: var(--v-p); }
.ctl .k-range { flex: 1 1 auto; min-width: 70px; }
.step {
  flex: none; min-width: 48px; white-space: nowrap; height: 40px; padding: 0 6px; border: 1.5px solid var(--k-ctl); border-radius: var(--k-r);
  background: var(--k-paper); color: var(--k-ink); font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; touch-action: manipulation;
}
.step:active { background: var(--k-wash); }
.acts { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
#dock .acts .k-btn { min-width: 0; }
#btnLaunch { min-width: 92px; font-size: 16px; }
/* 미션을 마친 뒤 단추가 셋(결과, 다음 미션, 발사)이면 조작 줄 칸을 380px 아래로 줄이지 않고, 모자라는 언어(en·ja)는 단추 줄이 두 줄로 접힌다 */
@media (min-aspect-ratio: 111/100) and (min-width: 760px) {
  #dock.fin { grid-template-columns: minmax(380px, 1fr) minmax(0, auto); }
}
#dock.fin #btnClear { display: none; } /* 미션을 마친 뒤에는 '결과 보기'·'다음 미션' 자리를 위해 궤적 지우기를 접는다(지난 궤적은 발사 횟수가 늘면 저절로 바뀐다) */
#btnAuto .sm, #btnResult .sm { display: none; }
#btnFF.k-on { box-shadow: inset 0 -3px 0 var(--k-ink); }
/* 조작판이 좁으면(작은 데스크톱 틀 830×466 등) 단추 줄을 조작 줄 아래로 */
#dock { container: dock / inline-size; }
@container dock (min-width: 400px) and (max-width: 640px) {
  .ctl { grid-column: 1 / -1; }
  .acts { grid-column: 1 / -1; grid-row: auto; }
  #dock.two .acts { display: flex; }
}
/* 미션 5(고도 줄이 있는 두 줄 조작판): 단추를 두 단으로 */
#dock.two .acts { display: grid; grid-template-columns: repeat(2, auto); justify-content: end; }
#dock.two .acts .k-btn { width: 100%; }
@media (hover: hover) {
  .icon:hover, .step:hover { background: var(--k-wash); }
  .opt:not(:disabled):hover, .lvrow:hover { background: var(--k-wash); }
}
#app[data-mode="title"] #dock { visibility: hidden; }

/* ── 오른쪽 판: 읽음값, 발사 결과, 내 예측, 범례 ── */
#panel { grid-area: panel; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; padding: 8px 16px 12px 8px; }
#read { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; }
.rd { display: flex; flex-direction: column; min-width: 0; }
.rd > span { font-size: 13px; font-weight: 650; color: var(--k-sub); white-space: nowrap; }
.rd b { font-size: 22px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd.v b { color: var(--v-p); }
.rd.a b { color: var(--a-p); }
#shotLine { margin: 0; padding-top: 10px; border-top: 1px solid var(--k-rule); font-size: 15px; line-height: 1.5; min-height: 1.5em; }
#shotLine:empty { display: none; }
#shotLine .ok { color: var(--ok-p); font-weight: 750; }
#predLine { margin: 0; font-size: 14px; line-height: 1.45; color: var(--k-sub); }
#predLine b { color: var(--k-ink); }
#legend { list-style: none; margin: auto 0 0; padding: 0; font-size: 13px; line-height: 1.5; color: var(--k-ink-2); }
#legend li { display: flex; align-items: center; gap: 8px; }
#legend .sw { flex: none; display: block; width: 22px; height: 4px; }
#legend .sw.v { background: var(--v-p); }
#legend .sw.a { background: var(--a-p); }
#legend .sw.c { height: 0; border-top: 2px dashed var(--a-p); }
#legend .sw.d { width: 8px; height: 8px; margin: 0 7px; border-radius: 50%; background: var(--tr-p); }
#legend .small { color: var(--k-sub); font-size: 12.5px; }

/* ── 창 두 가지(studio/DESIGN.md '창') ──
   옆 창(#side: 처음 화면, 미션 소개와 예측, 결과): 막 없이 판 자리에. 데스크톱은 오른쪽 판, 세로 휴대폰은 아래 판을 덮는다.
   가운데 창(#modal: 미션 목록, 마무리): 뒤를 --k-dim으로 어둡게만 가린다 */
.card { display: flex; flex-direction: column; background: var(--k-paper); color: var(--k-ink); border-radius: 0; }
.card h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; line-height: 1.3; }
.card h2:focus { outline: none; }
.card p { margin: 6px 0; font-size: 15px; line-height: 1.55; }
.card .note { font-size: 13.5px; color: var(--k-sub); }
/* 질문은 창에서 가장 큰 글자. 라벨·상자 없이 */
.card p.q { margin: 12px 0 4px; font-size: 20px; font-weight: 750; line-height: 1.4; }
.card .cb { flex: 0 1 auto; min-height: 0; overflow: auto; }
#side { grid-column: 2; grid-row: 2 / 4; z-index: 2; min-width: 0; min-height: 0; padding: 8px 16px 12px 8px; }
#side .k-start { flex: 1; min-height: 0; height: 100%; padding: 6px 2px 4px 6px; }
#side .k-start .k-q { margin: 0; }
#side .k-start h1.k-q { font-weight: 800; }
#side .k-start p.k-q { font-weight: 700; }
#side .k-start .k-note { margin-top: auto; }
#side .k-start .k-link { white-space: nowrap; }
.k-stage .k-t .tag, .lvrow .t .tag { color: var(--k-sub); font-weight: 600; }
.acts2 { flex: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 12px; }
.acts2 .k-primary, .acts2 .k-link + .k-btn { margin-left: auto; } /* 주 단추(와 진행 지우기 뒤 닫기)는 오른쪽 끝 */
.acts2 .k-btn { height: 44px; padding: 0 16px; }
/* 예측 보기: 고른 것은 굵은 글자와 칸 아래 3px 막대(kit .k-on) */
.opts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.opt {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; text-align: left;
  border: 1.5px solid var(--k-ctl); border-radius: var(--k-r); background: var(--k-paper); color: var(--k-ink); font-size: 15px; font-weight: 600; line-height: 1.3;
}
.opt .n { color: var(--k-sub); font-variant-numeric: tabular-nums; }
.opt.k-on { border-color: var(--k-ink); }
.numin { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.numin output { flex: 1 1 120px; font-size: 24px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; color: var(--v-p); white-space: nowrap; }
.numin .step { flex: 1 1 48px; }
details { margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--k-ink-2); }
details summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; font-weight: 650; color: var(--k-ink); text-decoration: underline; text-underline-offset: 3px; }
/* 미션 소개를 두 쪽으로 나눔(판이 낮을 때): 소개 → 예측 */
.brief.paged.pg2 .bA, .brief.paged:not(.pg2) .bB { display: none; }
.brief.paged:not(.pg2) .acts2 .bGo { display: none; }
/* 결과: 별 세 줄(기준과 함께), 맞힘 초록 ✓, 틀림 빨강 ✗ */
.res { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 6px; }
.res li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 6px; align-items: start; font-size: 15px; line-height: 1.4; }
.res .s { font-size: 20px; line-height: 1.1; color: var(--k-ink); }
.res small { display: block; font-size: 13.5px; color: var(--k-sub); }
.res .ok { color: var(--ok-p); font-weight: 750; }
.res .bad { color: var(--bad-p); font-weight: 750; }
.card .bigstars { margin: 2px 0 4px; font-size: 30px; color: var(--k-ink); }
.insight { padding-top: 8px; border-top: 1px solid var(--k-rule); }

#modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: var(--k-dim); padding: 12px; }
#modal .card { width: min(540px, 100%); max-height: calc(100vh - 24px); padding: 20px 22px 18px; }
/* 미션 목록 */
.levels { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.lvrow {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 6px; width: 100%; min-height: 44px;
  padding: 6px 4px; border: 0; border-top: 1px solid var(--k-rule); background: none; text-align: left; font-size: 15px; color: var(--k-ink);
}
.levels li:last-child .lvrow { border-bottom: 1px solid var(--k-rule); }
.lvrow .n { color: var(--k-sub); font-variant-numeric: tabular-nums; }
.lvrow .t { font-weight: 650; line-height: 1.3; }
.lvrow .st { font-size: 15px; white-space: nowrap; }
.lvrow[aria-current="true"] { box-shadow: inset 0 -3px 0 var(--k-ink); }
.sub { margin: 0 0 6px; font-size: 14px; color: var(--k-sub); font-variant-numeric: tabular-nums; }
.endstars { display: flex; flex-wrap: wrap; gap: 2px 16px; margin: 4px 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.endstars span { white-space: nowrap; }
.endstars .n { font-size: 13px; color: var(--k-sub); margin-right: 4px }

/* ── 낮은 가로 화면(사이트 데스크톱 틀 830×466 등) ── */
@media (max-height: 560px) and (min-aspect-ratio: 11/10) {
  :root { --hdr: 46px; }
  #mbar { font-size: 14px; }
  #panel { gap: 8px; padding-top: 4px; }
  .rd b { font-size: 19px; }
  #shotLine { font-size: 14px; padding-top: 8px; }
  #legend .small { display: none; }
  .card p.q { font-size: 18px; margin-top: 8px; }
  .card p { font-size: 14.5px; line-height: 1.5; }
  .opts { gap: 6px; }
  .opt { min-height: 40px; font-size: 14.5px; }
  .acts2 { margin-top: 8px; }
  .acts2 .k-btn { height: 40px; }
  /* 결과 창: 별은 기준 세 줄의 ★☆로, 기준 아래 작은 글은 같은 줄에. 옆 창은 조금 넓게 */
  .card .bigstars { display: none; }
  .res small { display: inline; margin-left: 6px; }
  #app.side-open { grid-template-columns: minmax(0, 1fr) clamp(300px, 40%, 520px); }
}
@media (max-height: 460px) and (min-aspect-ratio: 11/10) {
  #legend { display: none; }
  #predLine { display: none; }
  .opts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
/* 아주 낮은 가로 화면(750×280, 320×200): 조작판을 한 줄로, 슬라이더 대신 ± 단추 */
@media (max-height: 360px) and (min-aspect-ratio: 11/10) {
  :root { --hdr: 40px; --pw: clamp(120px, 34%, 300px); }
  #app { grid-template-areas: "top top" "fig panel" "dock dock"; }
  #fig { margin: 2px 6px 0 10px; }
  #top { padding: 2px 6px 0 4px; }
  #mbar { font-size: 13px; line-height: 1.3; }
  #starsNow { font-size: 15px; }
  #dock { padding: 4px 10px 6px; gap: 4px 8px; }
  .ctl .k-range { display: none; }
  .ctl { gap: 4px; }
  .ctl .val { min-width: 76px; }
  .ctl .lbl { display: none; }
  .ctl output { font-size: 17px; }
  .step { min-width: 44px; }
  #panel { padding: 2px 10px 4px 4px; gap: 4px; }
  #read { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .rd { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 6px; }
  .rd b { font-size: 15px; }
  .rd > span { font-size: 12px; }
  #shotLine { display: none; }
  #toast { font-size: 13px; padding: 4px 8px; }
  #app.side-open { grid-template-columns: minmax(0, 1fr) clamp(200px, 56%, 440px); }
  #app.side-open #dock { display: none; }
  #side { grid-row: 2 / 4; padding: 2px 8px 4px 4px; }
  .card p.q { font-size: 16px; line-height: 1.35; margin-top: 4px; }
  .card h2 { font-size: 15px; margin-bottom: 2px; }
  .card p { font-size: 13.5px; margin: 3px 0; line-height: 1.4; }
  .opt { min-height: 36px; padding: 3px 8px; font-size: 13.5px; }
  .acts2 { margin-top: 6px; gap: 6px; }
  .acts2 .k-btn { height: 36px; padding: 0 10px; }
  .res { gap: 2px; margin: 4px 0; }
  .res li { font-size: 13.5px; line-height: 1.35; }
  .res small { display: inline; margin-left: 6px; font-size: 12.5px; }
  .card .bigstars { display: none; } /* 별은 기준 세 줄의 ★☆로 보인다 */
  .insight { padding-top: 4px; }
  #modal .card { padding: 12px 14px; width: min(620px, 100%); }
  .lvrow { min-height: 36px; padding: 2px 4px; font-size: 14px; }
  /* 미션 목록: 두 단, 제목과 별 합계를 한 줄에 */
  .levels { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 14px; }
  .levels li:nth-last-child(2) .lvrow { border-bottom: 1px solid var(--k-rule); }
  #card h2 { display: inline; margin-right: 10px; }
  #card .sub { display: inline; }
}
@media (max-height: 240px) and (min-aspect-ratio: 11/10) {
  :root { --hdr: 38px; }
  #mbar { font-size: 12.5px; line-height: 1.25; }
  #lvTag .tl, #lvGoal .gl { display: none; }
  #lvGoal .gs { display: inline; }
  #starsNow { display: none; }
  :root { --pw: 128px; }
  #dock { padding: 2px 6px 4px; gap: 4px; }
  .step { min-width: 36px; padding: 0 1px; font-size: 12px; }
  .ctl .val { min-width: 66px; }
  .ctl output { font-size: 13.5px; }
  /* 읽음값: 이름 위, 값 아래(판 안 스크롤 허용 틀) */
  #panel { overflow: auto; padding-right: 6px; }
  .rd { flex-direction: column; align-items: flex-start; gap: 0; }
  .rd > span { line-height: 1.1; }
  .rd b { font-size: 14px; line-height: 1.15; }
  #btnClear { display: none; }
  #btnLaunch { min-width: 60px; padding: 0 6px; }
  #dock .acts { flex-direction: column; flex-wrap: nowrap; gap: 4px; align-items: stretch; }
  #dock.two .acts { display: flex; }
  #dock .acts .k-btn { padding: 0 6px; }
  #btnAuto .lg, #btnResult .lg { display: none; }
  #btnAuto .sm, #btnResult .sm { display: inline; }
  #side { overflow: auto; }
  #side .cb { flex: none; overflow: visible; }
  #btnNext { display: none; } /* 아주 작은 틀은 조작판이 한 줄이라 다음 미션은 결과 창과 ☰ 미션 목록에서 */
  #figFoot { display: none; }
}

/* ── 세로 화면: 위 막대, 그림, 읽음값, 조작판. 옆 창은 아래(읽음값·조작판 자리)를 덮는다 ── */
@media (max-aspect-ratio: 11/10) {
  :root { --hdr: 52px; }
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--hdr) minmax(0, 1fr) auto auto;
    grid-template-areas: "top" "fig" "panel" "dock";
  }
  #top { padding: 4px 4px 2px 2px; }
  #fig { margin: 2px 10px 0; }
  #panel { padding: 6px 10px 0; gap: 4px; }
  #read { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 8px; }
  .rd > span { font-size: 12px; }
  .rd b { font-size: 15px; }
  /* 아주 좁으면 두 줄 두 칸, 이름과 값을 한 줄에 */
  @media (max-width: 420px) {
    #read { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
    .rd { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 6px; }
    .rd b { font-size: 15px; }
  }
  #shotLine, #predLine, #legend { display: none !important; }
  #dock { grid-template-columns: minmax(0, 1fr); padding: 6px 10px 10px; gap: 6px; }
  .ctl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .ctl .val { grid-column: 1 / span 2; grid-row: 1; min-width: 0; }
  .ctl .k-range { grid-column: 3 / span 2; grid-row: 1; width: 100%; min-width: 0; }
  .step { grid-row: 2; min-width: 0; }
  .ctl output { font-size: 18px; }
  .acts { grid-column: 1; grid-row: auto; flex-wrap: nowrap; }
  .acts .k-btn { flex: 1 1 auto; padding: 0 8px; }
  #btnLaunch { flex: 1.6 1 auto; }
  /* 옆 창이 뜨면 그림을 줄이고(--figS, main.js fitSide) 그 아래를 창이 쓴다 */
  #app.side-open { grid-template-rows: var(--hdr) var(--figS, 30vh) minmax(0, 1fr); }
  #app.side-open #panel, #app.side-open #dock { display: none; }
  #app.side-open #figFoot { display: none; } /* 줄어든 그림 안에서 '배속' 이름표가 화살표 이름표(a)와 겹치지 않게 */
  #side { grid-column: 1; grid-row: 3; padding: 8px 10px 10px; }
  #side .k-start { padding: 4px 2px 2px; }
  #modal { padding: 10px; }
  #modal .card { padding: 16px 14px 14px; }
}
/* 좁은 세로 화면: 위 막대는 '미션 1 짧은 목표'(별은 미션 목록에) */
@media (max-aspect-ratio: 11/10) and (max-width: 520px) {
  #lvTag .tl, #lvGoal .gl, #starsNow { display: none; }
  #lvGoal .gs { display: inline; }
}
/* 세로 휴대폰(341×470~390×604): 조작판 한 줄(슬라이더 대신 ± 단추, 길게 누르면 빨라진다) */
@media (max-aspect-ratio: 11/10) and (max-height: 560px) {
  :root { --hdr: 48px; }
  #mbar { font-size: 13.5px; line-height: 1.3; }
  #starsNow { font-size: 15px; padding: 0 2px; }
  .ctl { display: flex; gap: 5px; }
  .ctl .k-range { display: none; }
  .ctl .lbl { display: none; }
  .ctl .val { flex: none; min-width: 84px; }
  .ctl output { font-size: 17px; }
  .step { flex: 1 1 0; min-width: 32px; padding: 0 1px; font-size: 13px; }
  #dock.two .acts { display: flex; }
  .acts .k-btn { padding: 0 6px; }
  #btnLaunch { min-width: 72px; }
  #dock.two #btnClear { display: none; } /* 미션 5: 원궤도 속력 맞추기·발사(·다음)만. 지난 궤적은 다섯 번째 발사부터 저절로 바뀐다 */
  .card p.q { font-size: 18px; }
  .card p { font-size: 14.5px; line-height: 1.5; }
  .opt { min-height: 40px; font-size: 14.5px; }
  .card .bigstars { display: none; } /* 별은 기준 세 줄의 ★☆로 보인다 */
  .res small { display: inline; margin-left: 6px; }
  .acts2 { gap: 6px; }
  .acts2 .k-btn { padding: 0 8px; font-size: 14px; }
  #modal .card p.q { font-size: 17px; margin-top: 8px; }
  .res { gap: 3px; margin: 6px 0; }
  .res li { font-size: 14.5px; line-height: 1.35; }
  .acts2 { margin-top: 8px; }
  .acts2 .k-btn { height: 40px; padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  #pop.go { animation: none; opacity: 0; }
  #toast { transition: none; }
}

/* 썸네일(window.game.thumb): 장면만 화면 가득 */
#app.thumb { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "fig"; }
#app.thumb > :not(#fig), #app.thumb #labels, #app.thumb #figFoot, #app.thumb #toast { display: none !important; }
#app.thumb #fig { margin: 0; }
/* 처음 화면: 모드가 하나뿐이라 넓어도 한 단 */
#side .k-start .k-modes { grid-template-columns: minmax(0, 1fr); }
.brief .bPrev, .brief .bNext { display: none; }
.brief.paged:not(.pg2) .bNext, .brief.paged.pg2 .bPrev { display: inline-flex; }
.brief.paged.pg2 .bMenu { display: none; }
.card h2 .tag { font-size: 14px; font-weight: 650; color: var(--k-sub); }
#side h1:focus, #side h2:focus, #card h2:focus, .card .q:focus { outline: none; }
