/* 미리내 — CRT 단말. 모바일 세로가 기준이고 900px부터 3단. */
@property --fg { syntax: '<color>'; inherits: true; initial-value: #a9f5c2; }
@property --dim { syntax: '<color>'; inherits: true; initial-value: #63a880; }
@property --faint { syntax: '<color>'; inherits: true; initial-value: #24503a; }
@property --bg { syntax: '<color>'; inherits: true; initial-value: #020705; }
@property --hot { syntax: '<color>'; inherits: true; initial-value: #ffc27a; }

:root {
  --font: 'Nanum Gothic Coding', 'D2Coding', 'Apple SD Gothic Neo', 'Malgun Gothic', ui-monospace, monospace;
  --sys: 'NeoDunggeunmo', 'Nanum Gothic Coding', 'D2Coding', ui-monospace, monospace;
  --dockh: clamp(300px, 48dvh, 420px);
  --glow: 0.32;
}
body[data-power='ok'] { --fg: #a9f5c2; --dim: #63a880; --faint: #24503a; --bg: #020705; --hot: #ffc27a; }
body[data-power='low'] { --fg: #ffd596; --dim: #b58c52; --faint: #5e4520; --bg: #070500; --hot: #ff9a7c; }
body[data-power='crit'] { --fg: #ffa799; --dim: #b86a5f; --faint: #642d27; --bg: #080202; --hot: #fff1e2; }
body[data-fx='1'] { --glow: 0.16; }
body[data-fx='0'] { --glow: 0; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: #000; overscroll-behavior: none; }
body {
  position: fixed; inset: 0; overflow: hidden;
  font-family: var(--font); font-size: 16px; line-height: 1.7; color: var(--fg); background: var(--bg);
  transition: --fg 1.6s, --dim 1.6s, --faint 1.6s, --bg 1.6s, --hot 1.6s;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  text-shadow: 0 0 0.55em color-mix(in srgb, var(--fg) calc(var(--glow) * 100%), transparent);
  word-break: keep-all; overflow-wrap: anywhere;
}
button, input { font: inherit; color: inherit; text-shadow: inherit; }
button { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: left; border-radius: 0; }
h1, h2, h3, p, pre { margin: 0; font-weight: 400; }
[hidden] { display: none !important; }

#stars { position: fixed; inset: 0; width: 100%; height: 100%; opacity: 0.55; pointer-events: none; }
body[data-fx='0'] #stars { display: none; }

/* ---------- 틀 (모바일) ---------- */
#app {
  position: absolute; left: 0; right: 0; top: 0; height: var(--vvh, 100dvh);
  display: flex; flex-direction: column; max-width: 600px; margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
#status { flex: none; padding: 8px 12px 6px; border-bottom: 1px solid var(--faint); transition: opacity 1.2s; }
body.boot #status { opacity: 0.0; }
body.boot.booted #status { opacity: 1; }
.res { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 2px 6px; }
.r { display: flex; align-items: baseline; gap: 5px; height: 24px; min-width: 0; white-space: nowrap; visibility: hidden; opacity: 0; transition: opacity 1.4s; font-variant-numeric: tabular-nums; }
.r.on { visibility: visible; opacity: 1; }
.r .k { font-size: 12px; color: var(--dim); flex: none; }
.r .v { font-size: 15px; }
.r .d { font-size: 11px; color: var(--dim); flex: none; letter-spacing: -0.02em; }
.r.neg .d { color: var(--hot); }
.r.flash .v { animation: flash 0.6s; }
.strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 20px; margin-top: 3px; font-size: 12px; color: var(--dim); font-family: var(--sys); }
#podmini { display: inline-flex; gap: 3px; }
#podmini i { width: 9px; height: 11px; border: 1px solid var(--dim); display: block; opacity: 0.9; }
#podmini i.sleep { background: linear-gradient(to top, var(--dim) var(--h, 50%), transparent 0); }
#podmini i.awake { background: var(--fg); border-color: var(--fg); }
#podmini i.dead { border-style: dotted; opacity: 0.35; }
#podmini i.empty { border-style: dashed; opacity: 0.5; }
#podmini i.warn { border-color: var(--hot); animation: blink 1s steps(2) infinite; }
#pstate { min-width: 3em; text-align: right; }

#feedwrap { flex: 1 1 0; min-height: 0; position: relative; }
#feed {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 14px 18px 26px; scrollbar-width: none;
  mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 100%);
}
#feed::-webkit-scrollbar { display: none; }
#feed .spacer { height: 40%; }
.ln { margin: 0 0 0.55em; min-height: 1.7em; white-space: pre-wrap; }
.ln.n { color: color-mix(in srgb, var(--fg) 90%, var(--bg)); }
.ln.s { font-family: var(--sys); color: var(--dim); letter-spacing: 0.02em; margin-bottom: 0.3em; }
.ln.w { color: var(--hot); }
.ln.c { color: var(--dim); margin: 0.9em 0 0.7em; }
.ln.c::before { content: '> '; }
.ln.h { font-family: var(--sys); color: var(--fg); text-align: center; margin: 1.8em 0 1.3em; display: flex; align-items: center; gap: 12px; letter-spacing: 0.08em; }
.ln.h::before, .ln.h::after { content: ''; flex: 1; height: 1px; background: var(--faint); }
.ln.g { font-family: var(--sys); color: var(--fg); letter-spacing: 0.06em; margin-top: 1em; }
.ln.d { padding-left: 12px; border-left: 2px solid var(--faint); margin-bottom: 0.45em; }
.ln.d .who { display: block; font-size: 12.5px; line-height: 1.5; color: var(--dim); letter-spacing: 0.04em; margin-top: 0.5em; }
.ln.d.cont .who { display: none; }
.ln.d.rec { border-left-style: dotted; color: color-mix(in srgb, var(--fg) 82%, var(--bg)); }
.ln.old { opacity: 0.62; }
.ln.typing .t::after, .ln.typing.plain::after { content: ''; display: inline-block; width: 0.5em; height: 1em; margin-left: 2px; vertical-align: -0.12em; background: var(--fg); animation: blink 0.9s steps(2) infinite; }
#tobottom { position: absolute; right: 12px; bottom: 10px; min-height: 36px; padding: 4px 12px; border: 1px solid var(--dim); background: var(--bg); font-size: 13px; font-family: var(--sys); }

#dock { flex: none; height: var(--dockh); display: flex; flex-direction: column; border-top: 1px solid var(--faint); background: color-mix(in srgb, var(--bg) 86%, transparent); }
#panes { flex: 1 1 0; min-height: 0; position: relative; }
.pane { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 16px; display: none; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
.pane.on { display: block; }
#tabs { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--faint); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { height: 50px; text-align: center; font-family: var(--sys); font-size: 15px; color: var(--dim); position: relative; visibility: hidden; opacity: 0; transition: opacity 1.2s, color 0.2s; }
#tabs button.show { visibility: visible; opacity: 1; }
#tabs button.on { color: var(--fg); }
#tabs button.on::before { content: ''; position: absolute; left: 22%; right: 22%; top: -1px; height: 2px; background: var(--fg); }
#tabs button.mark::after { content: ''; position: absolute; top: 12px; right: calc(50% - 26px); width: 6px; height: 6px; background: var(--hot); animation: blink 1.2s steps(2) infinite; }
body.inscene #tabs button { color: var(--faint); pointer-events: none; }
body.inscene #tabs button.on::before { background: var(--faint); }

/* ---------- 버튼 ---------- */
.grp { margin-top: 12px; opacity: 0; visibility: hidden; transition: opacity 1.2s; }
.grp.show { opacity: 1; visibility: visible; }
.grp h3 { font-family: var(--sys); font-size: 13px; color: var(--dim); letter-spacing: 0.08em; margin: 0 2px 6px; display: flex; justify-content: space-between; }
/* 운용 탭: 손 단추, 구분 단추(시설 / 드론), 할 일 자리, 시설 */
#opsseg { display: none; margin: 6px 0; }
#opsseg.show { display: flex; }
#opsseg button { position: relative; }
#opsseg small { margin-left: 8px; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
#opsseg button.mark::after { content: ''; position: absolute; top: 8px; right: 10px; width: 6px; height: 6px; background: var(--hot); animation: blink 1.2s steps(2) infinite; }
#l-task, #l-build { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#l-task { margin-bottom: 6px; position: relative; }
#l-task.one { grid-template-columns: 1fr; margin-top: 8px; }
#l-task.slot { min-height: 56px; }
#l-task:not(.slot):empty { margin-bottom: 0; }
#l-task.slot:empty { border: 1px dotted var(--faint); }
#l-task.slot:empty::before { content: '할 일 없음'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--faint); font-family: var(--sys); letter-spacing: 0.06em; }
body.boot #l-task.slot:empty { border-color: transparent; }
body.boot #l-task.slot:empty::before { content: ''; }
#l-task .row, #l-build .row { grid-template-columns: 1fr; align-content: center; min-height: 56px; padding: 6px 10px; }
#l-task .row { border-color: var(--fg); }
#l-task .row[data-state='no'], #l-task .row[data-state='lock'] { border-color: var(--dim); }
#l-task .row .lab, #l-build .row .lab { font-size: 15px; }
#l-task .row .lab, #l-build .row .lab { white-space: nowrap; overflow: hidden; text-overflow: clip; letter-spacing: -0.02em; }
#l-task .row .cost, #l-build .row .cost { grid-column: 1; grid-row: auto; text-align: left; white-space: nowrap; max-width: none; font-size: 12px; }
#l-build .row .cost .cnt { font-style: normal; color: var(--dim); float: right; margin-left: 6px; }
#l-task .row .sub, #l-build .row .sub { display: none; }
.opsnote { font-size: 13px; color: var(--dim); margin: 6px 2px 0; }
.opsnote:empty { display: none; }
#g-sys .list { min-height: 56px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.row, .big, .choice {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px;
  width: 100%; min-height: 50px; padding: 7px 12px; border: 1px solid var(--dim); background: color-mix(in srgb, var(--fg) 4%, transparent);
  overflow: hidden; transition: border-color 0.25s, opacity 0.25s, background 0.15s;
}
.row.in, .choice.in { animation: fadein 0.9s both; }
.row:active, .big:active, .choice:active { background: color-mix(in srgb, var(--fg) 16%, transparent); }
.row .fill, .big .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, var(--fg) 14%, transparent); pointer-events: none; }
.row .lab, .big .lab { position: relative; font-size: 15.5px; line-height: 1.35; }
.row .sub { position: relative; grid-column: 1; font-size: 12.5px; line-height: 1.35; color: var(--dim); }
.row .sub:empty { display: none; }
.row .cost { position: relative; grid-column: 2; grid-row: 1 / span 2; font-size: 12.5px; line-height: 1.4; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; white-space: pre-line; }
.row .cost b { font-weight: 400; color: var(--hot); }
.row[data-state='no'], .row[data-state='lock'], .big[data-state='no'] { border-color: var(--faint); }
.row[data-state='no'] .lab, .row[data-state='lock'] .lab, .big[data-state='no'] .lab { color: var(--dim); }
.row[data-state='lock'] .cost { max-width: 11.5em; white-space: normal; }
.row[data-state='busy'] { border-style: dashed; }
.row[data-state='done'] { border-color: var(--faint); border-style: dotted; }
.row[data-state='done'] .lab { color: var(--dim); }
.row.nope { animation: nope 0.3s; }
.clicks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.big { min-height: 48px; grid-template-columns: 1fr; text-align: center; visibility: hidden; opacity: 0; transition: opacity 1.2s, border-color 0.25s; }
.big.show { visibility: visible; opacity: 1; }
.big[data-slot='draw'] { grid-column: 1 / span 2; }
.big[data-state='cd'] .lab { color: var(--dim); }
.big .lab small { display: block; font-size: 11.5px; line-height: 1.2; color: var(--dim); }
/* 자동 순환이 돌아오면 손 단추는 한 줄로 줄어든다 */
.clicks.compact { grid-template-columns: 1fr 1fr 1fr; }
.clicks.compact .big { min-height: 46px; padding: 4px 6px; border-color: var(--faint); }
.clicks.compact .big[data-slot='draw'] { grid-column: auto; }
.clicks.compact .big .lab { font-size: 14.5px; line-height: 1.25; }

.job { display: grid; grid-template-columns: 1fr 52px 2.6em 52px; align-items: center; min-height: 46px; border-bottom: 1px dotted var(--faint); }
#l-job { gap: 0; }
.job .lab { font-size: 15px; padding-left: 4px; }
.job .lab small { display: block; font-size: 12px; color: var(--dim); line-height: 1.3; }
.job .n { text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.job button { height: 44px; text-align: center; border: 1px solid var(--dim); font-size: 18px; line-height: 1; }
.job button[aria-disabled='true'] { border-color: var(--faint); color: var(--faint); }

/* ---------- 선내 지도 ---------- */
.map { font-family: 'Nanum Gothic Coding', ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 16px; white-space: pre; color: var(--faint); display: flex; flex-direction: column; align-items: center; margin: 2px 0 10px; user-select: none; }
.map .ml { display: block; height: 16px; }
.map .cell { display: inline-block; width: 8ch; text-align: center; overflow: hidden; vertical-align: top; height: 16px; cursor: pointer; }
.map .bd { vertical-align: top; }
.map .cell.known { color: var(--dim); }
.map .cell.lit { color: var(--fg); background: color-mix(in srgb, var(--fg) 10%, transparent); }
.map .cell.away { color: var(--hot); }
.map .cell.sel { background: color-mix(in srgb, var(--fg) 22%, transparent); color: var(--fg); }
.map .cell.me { color: var(--fg); }
.map .cell.just { animation: lit 1.6s; }
.map .bd.lit { color: var(--dim); }

/* ---------- 동면실 ---------- */
.pods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pod { display: block; border: 1px solid var(--dim); padding: 6px 8px 7px; min-height: 76px; position: relative; overflow: hidden; }
.pod .no { font-family: var(--sys); font-size: 12px; color: var(--dim); display: flex; justify-content: space-between; }
.pod .nm { font-size: 15px; line-height: 1.4; display: block; }
.pod .st { font-size: 12px; color: var(--dim); display: block; line-height: 1.4; }
.pod .bar { display: block; height: 4px; margin-top: 5px; border: 1px solid var(--faint); }
.pod .bar i { display: block; height: 100%; background: var(--dim); width: 0; transition: width 0.6s; }
.pod.sel { background: color-mix(in srgb, var(--fg) 10%, transparent); border-color: var(--fg); }
.pod.dead { border-style: dotted; border-color: var(--faint); color: var(--dim); }
.pod.empty { border-style: dashed; border-color: var(--faint); color: var(--dim); }
.pod.awake .bar { visibility: hidden; }
.pod.warn { border-color: var(--hot); }
.pod.warn .bar i { background: var(--hot); }
.pod.talk .no::after { content: ''; width: 6px; height: 6px; background: var(--hot); animation: blink 1.2s steps(2) infinite; align-self: center; }
.poddetail { margin-top: 10px; min-height: 150px; }
.poddetail .info { font-size: 13.5px; line-height: 1.55; color: var(--dim); margin: 0 2px 8px; min-height: 3.1em; }
.poddetail .info b { color: var(--fg); font-weight: 400; }
.pods.mini .pod { min-height: 60px; pointer-events: none; }

/* ---------- 기억·설정 ---------- */
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.seg button { flex: 1; min-height: 44px; text-align: center; border: 1px solid var(--faint); color: var(--dim); font-size: 14.5px; padding: 0 6px; }
.seg button.on { border-color: var(--fg); color: var(--fg); background: color-mix(in srgb, var(--fg) 8%, transparent); }
.setrow { display: grid; grid-template-columns: 5.2em 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.setrow > span { font-size: 14px; color: var(--dim); }
.setrow .seg { margin: 0; }
.setnote { font-size: 13px; color: var(--hot); min-height: 1.7em; margin: 4px 2px; }

/* ---------- 장면 ---------- */
#skip { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: var(--faint); font-family: var(--sys); font-size: 14px; letter-spacing: 0.06em; z-index: 3; }
body.typing .pane[data-pane='scene'] #skip { display: flex; }
body.typing .pane[data-pane='scene'] #l-choice, body.typing .pane[data-pane='scene'] #inputform { visibility: hidden; }
.pane[data-pane='scene'] { display: none; flex-direction: column; justify-content: flex-end; }
.pane[data-pane='scene'].on { display: flex; }
.pane[data-pane='scene'] .list { flex: none; }
.pane[data-pane='scene'].guard .choice, .pane[data-pane='scene'].guard #inputform { pointer-events: none; }
.choice { min-height: 52px; grid-template-columns: 1fr; font-size: 15.5px; line-height: 1.4; }
.choice[aria-disabled='true'] { border-color: var(--faint); color: var(--dim); }
.choice small { display: block; font-size: 12px; color: var(--hot); }
#inputform { margin-bottom: 10px; }
#inputlabel { display: block; font-family: var(--sys); font-size: 13.5px; color: var(--dim); margin: 0 2px 6px; }
.inrow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; border: 1px solid var(--fg); padding: 0 0 0 12px; background: color-mix(in srgb, var(--fg) 5%, transparent); }
.inrow .caret { color: var(--dim); }
#inputbox { min-width: 0; height: 52px; background: none; border: 0; outline: 0; font-size: 17px; caret-color: var(--fg); user-select: text; -webkit-user-select: text; border-radius: 0; }
#inputbox::placeholder { color: var(--faint); text-shadow: none; }
#inputgo { height: 52px; padding: 0 16px; border-left: 1px solid var(--dim); text-align: center; font-family: var(--sys); }
#hints { font-size: 13.5px; color: var(--hot); margin: 6px 2px 0; min-height: 1.6em; line-height: 1.55; }
#hints p + p { margin-top: 2px; }
#inputform.miss .inrow { animation: nope 0.3s; }

/* ---------- 덮개: 타이틀, 기록 읽기, 엔딩 ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 20px) 22px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; }
.overlay.fade { animation: fadein 1.4s both; }
.tbox, .ebox { width: 100%; max-width: 420px; text-align: center; }
.tart { font-family: 'Nanum Gothic Coding', ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 14px; color: var(--faint); margin-bottom: 26px; white-space: pre; overflow: hidden; }
#title h1 { font-family: var(--sys); font-size: 64px; line-height: 1.1; letter-spacing: 0.12em; margin-left: 0.12em; }
.tsub { font-family: var(--sys); font-size: 15px; color: var(--dim); letter-spacing: 0.1em; margin: 10px 0 38px; }
.tbtns { display: flex; flex-direction: column; gap: 8px; }
.tbtns button { min-height: 52px; border: 1px solid var(--dim); text-align: center; font-size: 16px; padding: 6px 12px; }
.tbtns button:active { background: color-mix(in srgb, var(--fg) 16%, transparent); }
.tbtns button.dimb { border-color: var(--faint); color: var(--dim); }
.tbtns button small { display: block; font-size: 12px; color: var(--dim); }
.tlist { margin-top: 14px; text-align: left; border: 1px solid var(--faint); padding: 10px 14px; font-size: 14.5px; }
.tlist p { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.tlist p.no { color: var(--faint); }
.tlist p span:first-child { font-family: var(--sys); color: var(--dim); }
.tfoot { margin-top: 22px; }
.tfoot button { min-height: 44px; padding: 0 14px; color: var(--dim); font-size: 13.5px; font-family: var(--sys); }
.rbox { width: 100%; max-width: 560px; max-height: 100%; display: flex; flex-direction: column; text-align: left; }
#readertext { overflow-y: auto; padding: 6px 4px 18px; }
#readerclose { flex: none; min-height: 52px; border: 1px solid var(--dim); text-align: center; }
#ending { background: #000; }
#endart { min-height: 190px; display: flex; align-items: center; justify-content: center; margin-bottom: 26px; }
#endart pre { font-family: 'Nanum Gothic Coding', ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 15px; white-space: pre; color: var(--dim); text-align: left; }
#endart canvas { width: 100%; max-width: 380px; height: 120px; }
#endno { font-family: var(--sys); font-size: 13px; color: var(--dim); letter-spacing: 0.14em; }
#endname { font-family: var(--sys); font-size: 34px; letter-spacing: 0.1em; margin: 8px 0 12px; }
#endstat { font-size: 13.5px; color: var(--dim); line-height: 1.7; margin-bottom: 28px; white-space: pre-line; }
#ending .ebox > * { animation: fadein 2.4s both; }
#ending .ebox > :nth-child(2) { animation-delay: 1.2s; }
#ending .ebox > :nth-child(3) { animation-delay: 1.6s; }
#ending .ebox > :nth-child(4) { animation-delay: 2.4s; }
#ending .ebox > :nth-child(5) { animation-delay: 4s; }
.endline { font-family: var(--sys); font-size: 16px; color: var(--fg); letter-spacing: 0.06em; line-height: 1.9; }
.cursor::after { content: ''; display: inline-block; width: 0.55em; height: 1em; background: currentColor; vertical-align: -0.12em; margin-left: 3px; animation: blink 1s steps(2) infinite; }
.tilt { transform: rotate(-6deg); }
.orbit { position: relative; width: 150px; height: 150px; }
.orbit .pl { position: absolute; inset: 35px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #6b5a4c, #2a2320 70%); box-shadow: 0 0 22px rgba(120, 90, 70, 0.25); }
.orbit .ring { position: absolute; inset: 8px; border: 1px dotted var(--faint); border-radius: 50%; animation: spin 9.4s linear infinite; }
.orbit .ring::after { content: ''; position: absolute; top: -3px; left: 50%; width: 5px; height: 5px; background: var(--fg); box-shadow: 0 0 8px var(--fg); }

/* ---------- CRT ---------- */
#crt { position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.2) 2px 3px),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%);
  animation: flicker 7s steps(1) infinite; }
body[data-fx='1'] #crt { background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.1) 2px 3px), radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.4) 100%); animation: none; }
body[data-fx='0'] #crt { display: none; }
body.shake #app { animation: shake 0.45s; }
body.glitch #feedwrap, body.glitch #status { animation: glitch 0.5s steps(2); }
body.alarm #status { animation: alarm 0.9s 2; }
body.cut #app { animation: cut 0.35s forwards; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes flash { 0% { color: var(--hot); } 100% { color: inherit; } }
@keyframes nope { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes lit { 0% { background: color-mix(in srgb, var(--fg) 60%, transparent); } 100% { background: color-mix(in srgb, var(--fg) 10%, transparent); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flicker { 0%, 100% { opacity: 1; } 3% { opacity: 0.86; } 4% { opacity: 1; } 47% { opacity: 0.93; } 48% { opacity: 1; } 81% { opacity: 0.9; } 82% { opacity: 1; } }
@keyframes shake { 10% { transform: translate(-4px, 2px); } 30% { transform: translate(5px, -3px); } 50% { transform: translate(-3px, -2px); } 70% { transform: translate(3px, 3px); } 90% { transform: translate(-1px, 1px); } }
@keyframes glitch { 0% { transform: translateX(-6px) skewX(-4deg); filter: hue-rotate(40deg); opacity: 0.7; } 25% { transform: translateX(5px); clip-path: inset(12% 0 38% 0); } 50% { transform: translateX(-3px) skewX(3deg); clip-path: inset(55% 0 8% 0); } 75% { transform: translateX(2px); opacity: 0.85; } 100% { transform: none; filter: none; clip-path: none; opacity: 1; } }
@keyframes alarm { 50% { background: color-mix(in srgb, var(--hot) 22%, transparent); } }
@keyframes cut { 0% { transform: scaleY(1); filter: brightness(1); } 60% { transform: scaleY(0.006); filter: brightness(3); } 100% { transform: scaleY(0); filter: brightness(0); } }

/* ---------- 키보드가 올라왔을 때 ---------- */
body.kb #status { display: none; }
body.kb #tabs { display: none; }
body.kb #dock { height: auto; }
body.kb #panes { flex: none; }
body.kb .pane[data-pane='scene'].on { position: static; max-height: 58vh; }
body.kb #skip { position: static; min-height: 70px; }

/* ---------- 디버그 (주소에 ?debug=1이 있을 때만 만들어진다) ---------- */
#dbg { position: fixed; z-index: 60; right: 0; top: 36%; display: flex; flex-wrap: wrap; gap: 4px; max-width: 250px; justify-content: flex-end; font: 11px/1 ui-monospace, monospace; text-shadow: none; }
#dbg:not(.open) button:not(.tog) { display: none; }
#dbg .tog { opacity: 0.5; padding: 3px 5px; }
#dbg button { background: #111; color: #9ad; border: 1px solid #357; padding: 6px 7px; }
#dbg button.on { background: #246; color: #fff; }

/* ---------- 데스크톱: 3단 ---------- */
@media (min-width: 900px) {
  :root { --dockh: auto; }
  #app {
    max-width: 1340px; height: 100vh; padding: 30px 34px 26px;
    display: grid; gap: 0 26px;
    grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.95fr) minmax(310px, 0.72fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: 'feed dock status' 'feed dock side';
  }
  #feedwrap { grid-area: feed; border: 1px solid var(--faint); }
  #feed { padding: 22px 28px 30px; font-size: 16.5px; }
  #dock { grid-area: dock; height: auto; border: 1px solid var(--faint); }
  #status { grid-area: status; border: 1px solid var(--faint); padding: 12px 16px; }
  .res { grid-template-columns: repeat(2, 1fr); }
  #side { grid-area: side; display: block; border: 1px solid var(--faint); border-top: 0; padding: 14px 12px; overflow-y: auto; min-height: 0; }
  .pane[data-pane='ship'] > #map { display: none; }
  .pane { padding: 14px 16px 18px; }
  #tabs button { cursor: pointer; }
  .row:hover, .big:hover, .choice:hover, .tbtns button:hover { border-color: var(--fg); }
  #title h1 { font-size: 80px; }
  .pods.mini { margin-top: 14px; }
}
@media (max-width: 899px) { #side { display: none; } }
@media (max-width: 359px) { body { font-size: 15px; } .map { font-size: 12px; } .row .lab, .big .lab { font-size: 14.5px; } }
@media (max-height: 640px) and (max-width: 899px) { :root { --dockh: clamp(260px, 50dvh, 340px); } }

@media (prefers-reduced-motion: reduce) {
  #crt { animation: none; }
  body.shake #app, body.glitch #feedwrap, body.glitch #status { animation: none; }
  .orbit .ring { animation: none; }
}
