:root { --panel: #101220; --line: rgba(255, 255, 255, 0.12); --text: #e9edf7; --dim: #98a1b8; --accent: #7fd8ff; --gold: #ffd666; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #070814; color: var(--text); font-family: system-ui, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#map { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
img { image-rendering: auto; }
kbd { font-size: 11px; padding: 0 4px; border: 1px solid var(--line); border-radius: 4px; background: rgba(255,255,255,0.08); }

/* ---------- 상단 ---------- */
#top { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.brand { font-size: 12px; letter-spacing: 3px; color: var(--dim); white-space: nowrap; }
.brand b { color: var(--accent); }
#inv { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
#inv span, .cost, .bufs span { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-variant-numeric: tabular-nums; }
#inv img, .cost img, .bufs img, table img, #welcomeList img { width: 18px; height: 18px; }
.cost { margin-right: 6px; font-size: 12px; }
.cost.lack { color: #ff7b7b; }
#power { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; }
.pbar { width: 60px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--gold); }
#power.low b { color: #ff7b7b; }
#power.low .pbar i { background: #ff5c5c; animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.ctl { display: flex; gap: 6px; }
.ctl button { height: 34px; min-width: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); display: inline-flex; align-items: center; gap: 3px; padding: 0 8px; font-size: 14px; }
.ctl button small { font-size: 11px; color: var(--dim); }
.ctl button.on { border-color: var(--gold); background: rgba(255,214,102,0.14); }
#panelToggle { display: none !important; }

/* ---------- 오른쪽 패널 ---------- */
#side { position: fixed; top: 64px; right: 10px; width: 290px; max-height: calc(100vh - 190px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 9px 0; background: none; border: none; font-size: 13px; color: var(--dim); }
.tabs button.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
#side section { overflow: auto; padding: 10px 12px; font-size: 13px; }
#goals ul { list-style: none; margin: 0; padding: 0; }
#goals li { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
#goals li.done { opacity: 0.5; }
#goals li.now { color: #fff; font-weight: 600; }
#goals li small { display: block; font-weight: 400; color: var(--dim); margin-top: 3px; }
.prog { margin: 0 0 6px; color: var(--dim); font-size: 12px; }
.rnode { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 10px; }
.rnode small { display: block; color: var(--dim); font-size: 11.5px; margin: 2px 0 4px; }
.rnode.done { opacity: 0.55; }
.rnode.locked { opacity: 0.5; }
.rnode.ready { border-color: var(--gold); }
.rnode button { flex: none; padding: 6px 12px; border-radius: 8px; border: none; background: var(--gold); color: #2a2000; font-weight: 700; }
.rnode .req { max-width: 80px; text-align: right; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--dim); font-weight: 500; padding: 4px 2px; }
td { padding: 4px 2px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
td img { vertical-align: middle; }
.mach { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 8px; font-size: 12px; }
.small { font-size: 12px; color: var(--dim); margin: 6px 0; }
.st-working { color: #5fe08a; } .st-starved { color: #ffd24d; } .st-blocked { color: #ff6b6b; } .st-nopower { color: #c77dff; } .st-norecipe { color: #cfd3dc; } .st-noore { color: #8a8f99; }

/* ---------- 건물 정보 ---------- */
#inspect { position: fixed; left: 10px; top: 64px; width: 250px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; }
#inspect header { display: flex; justify-content: space-between; align-items: center; }
#inspect header button { background: none; border: none; color: var(--dim); }
#inspect .st { margin: 6px 0; font-weight: 600; }
.util { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ubar { flex: 1; height: 6px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
.ubar i { display: block; height: 100%; background: #5fe08a; }
.recipes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 8px 0; }
.recipes button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,0.05); font-size: 14px; }
.recipes button small { font-size: 9.5px; color: var(--dim); }
.recipes button img { width: 20px; height: 20px; }
.recipes button.on { border-color: var(--gold); background: rgba(255,214,102,0.14); }
.recipes button:disabled { opacity: 0.4; }
.bufs { display: flex; gap: 8px; flex-wrap: wrap; }
.acts { display: flex; gap: 6px; margin-top: 8px; }
.acts button { flex: 1; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); }

/* ---------- 하단 ---------- */
#bottom { position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: calc(100vw - 20px); }
#hint { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: 12.5px; text-align: center; }
#hint small { color: var(--dim); }
#toolbar { display: flex; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; max-width: 100%; overflow-x: auto; }
#tools { display: flex; gap: 6px; }
#toolbar button { flex: none; width: 58px; height: 54px; border-radius: 12px; border: 1px solid transparent; background: rgba(255,255,255,0.05); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 19px; line-height: 1; }
#toolbar button small { font-size: 10.5px; color: var(--dim); white-space: nowrap; }
#toolbar button.on { border-color: var(--accent); background: rgba(127,216,255,0.14); }
#toolbar button.locked { opacity: 0.35; }

#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 5; }
.toast { background: rgba(16,18,32,0.94); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: 13px; animation: pop 0.3s ease-out; transition: opacity 0.4s; max-width: calc(100vw - 40px); text-align: center; }
.toast.gold { border-color: var(--gold); color: #fff3c9; }
.toast.out { opacity: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }

.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(5,6,15,0.6); z-index: 10; padding: 16px; }
.modal.open { display: flex; }
.card { width: min(380px, 100%); background: #141629; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card h2 { margin: 4px 0 12px; font-size: 18px; }
.card p { color: var(--dim); font-size: 14px; line-height: 1.6; }
.eyebrow { margin: 0; font-size: 12px; }
#welcomeList { list-style: none; margin: 0 0 14px; padding: 0; max-height: 45vh; overflow: auto; }
#welcomeList li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
#welcomeList b { margin-left: auto; color: #5fe08a; font-variant-numeric: tabular-nums; }
.card button { width: 100%; padding: 10px; border-radius: 10px; border: none; background: var(--accent); color: #062433; font-weight: 700; font-size: 15px; }

/* ---------- 2단계: 행성 · 밤낮 · 청사진 ---------- */
#planets { display: flex; gap: 4px; }
#planets[hidden], #sky[hidden] { display: none; }
#planets button { height: 34px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,0.05); display: inline-flex; align-items: center; gap: 4px; font-size: 15px; }
#planets button small { font-size: 11px; color: var(--dim); }
#planets button.on { border-color: var(--accent); background: rgba(127,216,255,0.16); }
#planets button.on small { color: var(--text); }
#sky { font-size: 12.5px; white-space: nowrap; }
#sky small { color: var(--dim); margin-left: 2px; }
.cfg { display: grid; gap: 6px; margin: 8px 0; }
.cfg label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.cfg select { flex: 1; max-width: 150px; background: #1c1f36; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px; font: inherit; font-size: 12px; }
h4 { margin: 12px 0 4px; font-size: 13px; }
.routes td { font-size: 12px; }
.bpbar { display: flex; gap: 6px; margin: 4px 0 8px; }
.bpbar button { flex: 1; padding: 7px 4px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); font-size: 12px; }
.bpbar button:disabled { opacity: 0.4; }
.bplist { list-style: none; margin: 0 0 8px; padding: 0; }
.bplist li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.bplist li small { display: block; color: var(--dim); font-size: 11px; }
.bplist li span { display: flex; gap: 4px; flex: none; }
.bplist li button { padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); font-size: 12px; }
.bplist li.empty { color: var(--dim); font-size: 12px; display: block; }
#bpCode { width: 100%; resize: vertical; background: #0e1022; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font: 11px ui-monospace, monospace; -webkit-user-select: text; user-select: text; }
#bpMsg.err { color: #ff7b7b; } #bpMsg.ok { color: #5fe08a; }
#welcomeList li.ph { font-weight: 700; color: var(--accent); border-bottom: none; padding-top: 10px; }
#welcomeList li.ph small { color: var(--dim); font-weight: 400; }
#welcomeList b.neg { color: #ff9d7b; }
.st-nopair, .st-nofilter { color: #ff6b6b; } .st-noroute { color: #cfd3dc; } .st-nofuel { color: #ff9d4d; } .st-loading { color: #ffd24d; } .st-flying { color: #7fd8ff; }
.st-charging, .st-full { color: #5fe08a; } .st-discharging { color: #ffd24d; } .st-empty { color: #ff6b6b; }

/* ---------- 모바일 ---------- */
@media (max-width: 760px) {
  #top { flex-wrap: wrap; gap: 4px 8px; top: 6px; left: 6px; right: 6px; }
  .brand { display: none; }
  #inv { order: 3; flex-basis: 100%; gap: 6px; }
  #sky { order: 4; flex-basis: 100%; }
  #planets button small { display: none; }
  #inv span { font-size: 12px; }
  #panelToggle { display: inline-flex !important; }
  .pbar { width: 40px; }
  #side { display: none; top: auto; bottom: 150px; left: 6px; right: 6px; width: auto; max-height: 50vh; }
  body.panel-open #side { display: flex; }
  #inspect { top: auto; bottom: 150px; left: 6px; right: 6px; width: auto; }
  #toolbar button { width: 50px; height: 48px; font-size: 17px; }
  #hint { font-size: 11.5px; padding: 5px 8px; }
  #toasts { top: 122px; }
  .toast { font-size: 12px; padding: 6px 10px; max-width: 300px; }
  .toast:nth-last-child(n+3) { display: none; } /* 모바일은 최근 2개만 */
}
