/* 스타레인: 그림 배경과 같은 깊은 남색 우주 */
:root {
  --bg: #060b1a; --bg-2: #0a1226; --card: #0d1730; --card-2: #111d3a; --line: #1e2b4d; --line-2: #2a3a63;
  --text: #e7ecf7; --muted: #8a97b8; --dim: #5f6b8c;
  --cyan: #45d0ff; --cyan-2: #1b9ed1; --amber: #ffb547; --green: #4ce39a; --red: #ff6b6b; --violet: #a98bff;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg) radial-gradient(1200px 600px at 70% -10%, rgba(69,208,255,.10), transparent 60%) fixed;
  color: var(--text); font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px; line-height: 1.5; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; min-height: 38px; }
input:focus, select:focus { outline: none; border-color: var(--cyan); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.ok { color: var(--green); } .bad { color: var(--red); } .warn { color: var(--amber); }

/* ===== 시작 화면 ===== */
.start { min-height: 100%; display: grid; place-items: end start; padding: 24px; background: #060b1a url("../assets/cover.webp") center / cover no-repeat; position: relative; }
.start::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(6,11,26,.95) 0%, rgba(6,11,26,.7) 45%, rgba(6,11,26,.15) 100%), linear-gradient(0deg, rgba(6,11,26,.9), transparent 40%); }
.start-card { position: relative; width: min(460px, 100%); margin: 0 0 6vh 4vw; }
.start h1 { font-size: clamp(40px, 7vw, 72px); letter-spacing: .08em; margin: 0; font-weight: 800; background: linear-gradient(90deg, #fff, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.start .kr { font-size: 18px; color: var(--cyan); font-weight: 700; letter-spacing: .3em; margin: 4px 0 16px; }
.start p { color: #c3cce4; margin: 0 0 22px; }
.start label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.start input { width: 100%; }
.speeds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.speeds button { padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(13,23,48,.7); font-weight: 700; }
.speeds button small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.speeds button.on { border-color: var(--cyan); background: rgba(69,208,255,.14); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; min-height: 42px; border-radius: 12px; border: 1px solid transparent; background: var(--cyan); color: #04121f; font-weight: 800; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn.ghost { background: var(--card-2); color: var(--text); border-color: var(--line-2); }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(255,107,107,.4); }
.btn.amber { background: var(--amber); color: #2a1700; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 9px; }
.btn.wide { width: 100%; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 20px; padding: 6px; }

/* ===== 게임 틀 ===== */
.game { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: auto 1fr; min-height: 100%; }
.top { grid-column: 1 / -1; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: rgba(6,11,26,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; letter-spacing: .14em; font-size: 14px; }
.brand .logo { color: var(--cyan); font-size: 18px; }
.planet-pick { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); max-width: 230px; }
.planet-pick img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.planet-pick span { text-align: left; line-height: 1.15; min-width: 0; }
.planet-pick b, .planet-pick small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.planet-pick small { color: var(--muted); font-size: 11.5px; }
.resbar { flex: 1; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.res { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); min-width: 128px; }
.res img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.res .v { font-weight: 800; font-size: 14px; line-height: 1.1; }
.res .r { font-size: 11px; color: var(--muted); line-height: 1.2; }
.res .bar { height: 3px; border-radius: 3px; background: var(--line); margin-top: 3px; overflow: hidden; }
.res .bar i { display: block; height: 100%; background: var(--cyan-2); }
.res.full .bar i { background: var(--amber); }
.res.full .v { color: var(--amber); }
.res.power .v.neg { color: var(--red); }

.nav { grid-row: 2; position: sticky; top: 60px; align-self: start; display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; }
.nav button { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; border: 0; background: none; color: var(--muted); font-weight: 700; text-align: left; }
.nav button i { font-style: normal; width: 20px; text-align: center; font-size: 17px; }
.nav button:hover { background: var(--card); color: var(--text); }
.nav button.on { background: linear-gradient(90deg, rgba(69,208,255,.18), rgba(69,208,255,.04)); color: var(--text); box-shadow: inset 3px 0 0 var(--cyan); }
.nav em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11.5px; font-style: normal; font-weight: 800; display: grid; place-items: center; }
.view { padding: 20px 22px 60px; min-width: 0; max-width: 1240px; }

/* ===== 공통 카드 ===== */
.h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.h h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card.locked { opacity: .62; }
.card .art { position: relative; aspect-ratio: 16 / 9; background: #070d20; overflow: hidden; }
.card .art img { width: 100%; height: 100%; object-fit: contain; }
.card .lv { position: absolute; left: 10px; top: 10px; padding: 3px 9px; border-radius: 8px; background: rgba(6,11,26,.82); font-weight: 800; font-size: 13px; border: 1px solid var(--line-2); }
.card .lv.cnt { color: var(--cyan); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h4 { margin: 0; font-size: 16px; }
.card .desc { color: var(--muted); font-size: 13px; margin: 0; }
.effect { font-size: 13px; color: var(--cyan); }
.costs { display: flex; flex-wrap: wrap; gap: 6px; }
.cost { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 3px; border-radius: 8px; background: var(--bg-2); font-size: 12.5px; font-weight: 700; }
.cost img { width: 18px; height: 18px; border-radius: 5px; }
.cost.short { color: var(--red); background: rgba(255,107,107,.08); }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: auto; }
.req { font-size: 12.5px; color: var(--amber); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; font-size: 12px; color: var(--muted); }
.stats b { color: var(--text); font-weight: 700; }
.qty { display: flex; gap: 6px; }
.qty input { width: 90px; flex: 1; }

/* 진행 막대 */
.job { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.job:first-of-type { border-top: 0; }
.job img { width: 52px; height: 40px; object-fit: contain; border-radius: 8px; background: #070d20; flex: none; }
.job .info { flex: 1; min-width: 0; }
.job .info b { display: block; font-size: 14px; }
.prog { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 6px; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan-2), var(--cyan)); }
.cd { font-weight: 800; color: var(--cyan); white-space: nowrap; font-size: 13.5px; }
.empty { color: var(--dim); font-size: 13.5px; padding: 6px 0; }

/* 개요 */
.ov { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
.planet-hero { text-align: center; padding: 22px 16px; background: radial-gradient(circle at 50% 38%, rgba(69,208,255,.12), transparent 60%), var(--card); }
.planet-hero img { width: 200px; height: 200px; margin: 0 auto 10px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 60px rgba(69,208,255,.25); }
.planet-hero h2 { margin: 0; font-size: 22px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; text-align: left; }
.kv div { background: var(--bg-2); border-radius: 10px; padding: 8px 10px; }
.kv small { display: block; color: var(--muted); font-size: 11.5px; }
.kv b { font-size: 15px; }
.mv { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.mv:first-of-type { border-top: 0; }
.mv .tag { padding: 2px 8px; border-radius: 7px; font-size: 12px; font-weight: 800; background: var(--card-2); white-space: nowrap; }
.mv.hostile { background: rgba(255,107,107,.07); border-radius: 10px; padding: 9px 10px; }
.mv.hostile .tag { background: var(--red); color: #fff; }
.mv .grow { flex: 1; min-width: 0; }
.log { font-size: 13px; color: var(--muted); max-height: 220px; overflow: auto; }
.log div { padding: 4px 0; border-top: 1px dashed var(--line); }

/* 함대 보내기 */
.fleet-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
.pickrow { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); }
.pickrow:first-of-type { border-top: 0; }
.pickrow img { width: 44px; height: 34px; object-fit: contain; }
.pickrow .have { color: var(--muted); font-size: 12px; }
.pickrow .qty input { width: 80px; }
.coords { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.missions { display: flex; flex-wrap: wrap; gap: 6px; }
.missions button { padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); font-weight: 700; font-size: 13px; }
.missions button.on { border-color: var(--cyan); background: rgba(69,208,255,.14); color: var(--cyan); }
.missions button:disabled { opacity: .35; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.summary div { background: var(--bg-2); border-radius: 10px; padding: 8px 10px; }
.summary small { display: block; color: var(--muted); font-size: 11.5px; }
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--cyan); }

/* 성계 지도 */
.sys-head { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; border: 1px solid var(--line); }
.sys-head img { width: 100%; height: 150px; object-fit: cover; opacity: .75; }
.sys-head .over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: linear-gradient(90deg, rgba(6,11,26,.85), rgba(6,11,26,.2)); }
.sys-head h2 { margin: 0; font-size: 26px; letter-spacing: .04em; }
.sys-nav { display: flex; gap: 8px; align-items: center; }
.sys-nav select { min-height: 36px; }
.orbit { display: grid; grid-template-columns: 34px 56px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.orbit:first-child { border-top: 0; }
.orbit .no { color: var(--dim); font-weight: 800; text-align: center; }
.orbit img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.orbit .ph { width: 52px; height: 52px; border-radius: 50%; border: 1px dashed var(--line-2); }
.orbit .nm b { display: block; }
.orbit .nm small { color: var(--muted); font-size: 12.5px; }
.orbit.me { background: rgba(69,208,255,.06); }
.orbit .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 800; margin-left: 6px; vertical-align: 1px; }
.badge.raider { background: rgba(255,107,107,.18); color: var(--red); }
.badge.turtle { background: rgba(169,139,255,.18); color: var(--violet); }
.badge.miner { background: rgba(255,181,71,.18); color: var(--amber); }
.badge.trader { background: rgba(76,227,154,.16); color: var(--green); }
.badge.me { background: rgba(69,208,255,.18); color: var(--cyan); }
.debris { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--amber); }
.debris img { width: 18px; height: 18px; border-radius: 4px; }

/* 보고서 */
.rep { border-top: 1px solid var(--line); }
.rep:first-child { border-top: 0; }
.rep > button { width: 100%; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 11px 6px; background: none; border: 0; text-align: left; }
.rep .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); justify-self: center; }
.rep.read .dot { background: transparent; border: 1px solid var(--line-2); }
.rep.read b { font-weight: 600; color: #c5cde3; }
.rep .t { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rep .detail { padding: 4px 6px 16px 42px; font-size: 13.5px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
.tbl th, .tbl td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }

/* 아래에서 올라오는 창 · 알림 */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(2,5,14,.6); display: grid; place-items: center; padding: 16px; }
.sheet > div { width: min(460px, 100%); max-height: 86vh; overflow: auto; background: var(--card); border: 1px solid var(--line-2); border-radius: 18px; padding: 18px; }
.sheet h3 { margin: 0 0 12px; }
.plist button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; border: 1px solid transparent; background: none; text-align: left; }
.plist button:hover, .plist button.on { background: var(--card-2); border-color: var(--line-2); }
.plist img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: #1a2850; border: 1px solid var(--line-2); font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

/* ===== 휴대폰 ===== */
@media (max-width: 860px) {
  .game { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .brand b { display: none; }
  .planet-pick { flex: 1; max-width: none; }
  .resbar { order: 3; flex-basis: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .res { min-width: 0; padding: 3px 6px 3px 3px; gap: 5px; }
  .res img { width: 24px; height: 24px; }
  .res .v { font-size: 12.5px; }
  .res .r { font-size: 10px; }
  .nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; top: auto; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: rgba(6,11,26,.96); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
  .nav button { flex-direction: column; gap: 1px; padding: 6px 2px; font-size: 11px; flex: 1; align-items: center; text-align: center; }
  .nav button i { font-size: 18px; }
  .nav button.on { box-shadow: inset 0 2px 0 var(--cyan); }
  .nav em { right: 50%; top: 4px; transform: translateX(18px); min-width: 16px; height: 16px; font-size: 10px; }
  .view { padding: 14px 12px 90px; }
  .ov, .fleet-grid { grid-template-columns: 1fr; }
  .planet-hero img { width: 150px; height: 150px; }
  .grid { grid-template-columns: 1fr; }
  .orbit { grid-template-columns: 22px 44px 1fr; }
  .orbit img, .orbit .ph { width: 44px; height: 44px; }
  .orbit .acts { grid-column: 2 / -1; justify-content: flex-start; }
  .rep .detail { padding-left: 10px; }
  .start-card { margin: 0 0 4vh 0; }
  .toast { bottom: 84px; }
}

/* 작은 화면 손보기 */
.res .r { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide { display: flex; align-items: center; gap: 14px; background: linear-gradient(90deg, rgba(255,181,71,.14), rgba(255,181,71,.03)); border-color: rgba(255,181,71,.35); }
.guide img { width: 64px; height: 48px; object-fit: contain; flex: none; }
.guide .grow { flex: 1; min-width: 0; }
.guide small { color: var(--amber); font-weight: 800; letter-spacing: .04em; }
.guide b { display: block; font-size: 15px; }
@media (max-width: 860px) {
  .sys-head img { height: 170px; }
  .sys-head .over { flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px; }
  .sys-head h2 { font-size: 22px; }
  .planet-hero img { width: 120px; height: 120px; }
  .guide img { width: 48px; height: 36px; }
}
/* 입력칸이 화면 밖으로 밀려 페이지가 넓어지지 않게 */
.qty input, .coords select, .coords input { min-width: 0; width: 100%; }
.qty { min-width: 0; }
.pickrow > div { min-width: 0; }
@media (max-width: 860px) { .pickrow .qty input { width: 64px; flex: none; } }
