/* 우주 소행성 채굴 타이쿤 — 깊은 남색 우주와 하늘색 레이저 */
:root {
  --bg: #070b1a;
  --panel: #0e1530;
  --panel-2: #152044;
  --line: #2a3a70;
  --ink: #e6ecff;
  --muted: #8f9cc7;
  --sky: #5ad1ff;
  --sky-2: #b7ecff;
  --gold: #ffd166;
  --violet: #b197fc;
  --green: #69f0ae;
  --red: #ff6b81;
  --body: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--body); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--sky-2); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 1fr minmax(360px, 440px); height: 100%; }
.stage { position: relative; overflow: hidden; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; cursor: crosshair; }
.back-btn { position: absolute; top: 10px; left: 10px; z-index: 6; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; border-radius: 8px; background: rgba(7,11,26,.85); border: 1px solid var(--line); }
.back-btn:hover { border-color: var(--sky); }
.mute { position: absolute; top: 10px; right: 10px; z-index: 6; width: 36px; height: 34px; border-radius: 8px; background: rgba(7,11,26,.85); border: 1px solid var(--line); font-size: 16px; }

.hud { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); z-index: 4; display: grid; gap: 6px; justify-items: center; pointer-events: none; width: max-content; max-width: 96%; }
.ore-box { display: flex; align-items: center; gap: 10px; padding: 6px 18px; border-radius: 14px; background: rgba(7,11,26,.86); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.ore-box .ico { font-size: 24px; }
.ore-box b { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ore-box small { color: var(--sky-2); font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { padding: 3px 10px; border-radius: 999px; background: rgba(7,11,26,.85); border: 1px solid var(--line); font-size: 12.5px; pointer-events: auto; }
.chip b { font-variant-numeric: tabular-nums; }
.chip[hidden] { display: none; }

.sector-bar { position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 6px; width: min(520px, calc(100% - 24px)); padding: 6px; border-radius: 12px; background: rgba(7,11,26,.88); border: 1px solid var(--line); }
.sector-bar .nav { width: 34px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-size: 14px; }
.sector-bar .nav:disabled { opacity: .3; }
.sector-mid { flex: 1; min-width: 0; display: grid; gap: 4px; }
.sector-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sector-title b { color: var(--sky-2); }
.sector-title span { color: var(--muted); font-size: 12px; }
.prog { position: relative; height: 16px; border-radius: 8px; background: #0a1028; border: 1px solid var(--line); overflow: hidden; }
.prog i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #2b6cb0, var(--sky)); transition: width .15s; }
.prog.boss i { background: linear-gradient(90deg, #c92a2a, #ff8787); }
.prog.farm i { background: linear-gradient(90deg, #2f9e44, var(--green)); }
.prog span { position: relative; display: block; text-align: center; font-size: 11px; line-height: 14px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.auto { width: 50px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-size: 11px; line-height: 1.15; color: var(--muted); }
.auto[aria-pressed="true"] { background: rgba(90,209,255,.18); border-color: var(--sky); color: var(--sky-2); font-weight: 700; }
.auto.blink { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { border-color: var(--gold); color: var(--gold); } }

.rock-info { position: absolute; left: 50%; top: calc(50% + 60px); transform: translateX(-50%); z-index: 3; width: min(300px, 70%); display: grid; gap: 3px; justify-items: center; pointer-events: none; }
.rock-name { font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px #000; white-space: nowrap; }
.rock-name.boss { color: var(--red); font-size: 15px; }
.rock-name.gold { color: var(--gold); }
.hpbar { position: relative; width: 100%; height: 12px; border-radius: 6px; background: rgba(0,0,0,.6); border: 1px solid var(--line); overflow: hidden; }
.hpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #e03131, #ff8787); }
.hpbar span { position: relative; display: block; text-align: center; font-size: 10px; line-height: 10px; font-weight: 700; text-shadow: 0 1px 2px #000; }

.buffs { position: absolute; top: 50px; left: 10px; z-index: 4; display: grid; gap: 4px; pointer-events: none; }
.buffs span { padding: 3px 9px; border-radius: 8px; background: rgba(255,209,102,.16); border: 1px solid var(--gold); color: var(--gold); font-size: 11.5px; font-weight: 700; }
.tap-hint { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); margin: 0; padding: 6px 14px; border-radius: 999px; background: rgba(7,11,26,.8); border: 1px solid var(--sky); font-size: 13px; pointer-events: none; animation: bob 1.6s ease-in-out infinite; z-index: 4; }
.tap-hint[hidden] { display: none; }
@keyframes bob { 50% { transform: translate(-50%, -6px); } }
.comet { position: absolute; z-index: 7; display: grid; justify-items: center; padding: 6px 10px; border-radius: 16px; border: 2px solid var(--gold); background: radial-gradient(circle, rgba(255,209,102,.35), rgba(7,11,26,.85)); font-size: 32px; line-height: 1; box-shadow: 0 0 24px rgba(255,209,102,.6); animation: wiggle .5s ease-in-out infinite alternate; transform: translate(-50%, -50%); }
.comet span { font-size: 11px; font-weight: 700; color: var(--gold); margin-top: 3px; }
.comet[hidden] { display: none; }
@keyframes wiggle { to { transform: translate(-50%, -50%) rotate(8deg) translateY(-4px); } }

.skills { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 5; display: flex; gap: 6px; }
.skill { position: relative; width: 54px; height: 54px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: 22px; overflow: hidden; display: grid; place-items: center; padding: 0; }
.skill small { position: absolute; bottom: 2px; left: 0; right: 0; font-size: 9.5px; color: var(--muted); }
.skill .cdm { position: absolute; inset: 0; background: rgba(0,0,0,.6); transform-origin: bottom; }
.skill .cdt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--ink); text-shadow: 0 1px 2px #000; }
.skill.ready { border-color: var(--sky); box-shadow: 0 0 10px rgba(90,209,255,.45); }
.skill.on { border-color: var(--gold); box-shadow: 0 0 14px rgba(255,209,102,.7); }
.skill.locked { opacity: .35; }

.log { position: absolute; left: 10px; bottom: 136px; z-index: 4; margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; max-width: min(360px, 70%); pointer-events: none; }
.log li { padding: 4px 9px; border-radius: 8px; background: rgba(7,11,26,.86); border: 1px solid var(--line); font-size: 12px; line-height: 1.4; animation: logIn .25s ease; }
.log li.good { border-color: var(--gold); }
.log li.bad { border-color: #6a3a4a; color: var(--muted); }
.log li.dm { border-color: var(--violet); background: rgba(50,30,90,.85); }
@keyframes logIn { from { opacity: 0; transform: translateX(-10px); } }

/* 패널 */
.panel { display: grid; grid-template-rows: auto 1fr; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: #0b1128; }
.tab { position: relative; display: grid; justify-items: center; gap: 1px; padding: 6px 2px; border-radius: 9px; border: 1px solid transparent; background: none; font-size: 11.5px; color: var(--muted); }
.tab .ti { font-size: 18px; }
.tab[aria-selected="true"] { color: var(--ink); background: var(--panel-2); border-color: var(--line); }
.tab .dot { position: absolute; top: 4px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.tab-body { overflow-y: auto; padding: 10px 12px 24px; min-height: 0; }
.sec-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; flex-wrap: wrap; }
.sec-h h2 { margin: 0; font-size: 17px; color: var(--sky-2); }
.sec-h small { color: var(--muted); font-size: 12px; }
.amt { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.amt button { padding: 4px 10px; border: 0; background: none; font-size: 12px; color: var(--muted); }
.amt button[aria-pressed="true"] { background: var(--sky); color: #06122b; font-weight: 700; }
.note { margin: 0 0 10px; padding: 8px 10px; border-radius: 9px; background: rgba(90,209,255,.07); border: 1px dashed var(--line); color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 4px 10px; padding: 8px 10px; margin-bottom: 6px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
.row .ico { font-size: 25px; text-align: center; }
.row .main { min-width: 0; }
.row b.nm { font-size: 14px; }
.row .lv { margin-left: 6px; font-size: 13px; font-weight: 800; color: var(--gold); }
.row .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.row .sub em { font-style: normal; color: var(--sky-2); }
.row .ms { display: block; height: 4px; margin-top: 5px; border-radius: 2px; background: #0a1028; overflow: hidden; }
.row .ms i { display: block; height: 100%; background: var(--gold); }
.row.locked { opacity: .5; }
.row.done { opacity: .55; }
.buy { min-width: 92px; padding: 7px 8px; border-radius: 9px; border: 1px solid var(--sky); background: rgba(90,209,255,.14); font-size: 12px; font-weight: 700; line-height: 1.25; text-align: center; }
.buy small { display: block; font-weight: 600; color: var(--sky-2); font-size: 11px; }
.buy:disabled { border-color: var(--line); background: none; color: var(--muted); }
.buy:disabled small { color: var(--muted); }
.buy.dm { border-color: var(--violet); background: rgba(177,151,252,.16); }

.warp-box { padding: 12px; border-radius: 12px; border: 1px solid var(--violet); background: linear-gradient(160deg, rgba(80,50,160,.35), rgba(14,21,48,.9)); margin-bottom: 12px; }
.warp-box p { margin: 4px 0; font-size: 13px; line-height: 1.5; }
.warp-box .big { font-size: 22px; font-weight: 800; color: var(--violet); }
.btn { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--sky); background: rgba(90,209,255,.15); font-weight: 700; font-size: 14px; }
.btn.warp { border-color: var(--violet); background: rgba(177,151,252,.25); width: 100%; margin-top: 8px; }
.btn.danger { border-color: var(--red); background: rgba(255,107,129,.12); }
.btn:disabled { opacity: .45; }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.ach { padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); text-align: center; font-size: 11px; color: var(--muted); }
.ach .ai { font-size: 22px; display: block; filter: grayscale(1); opacity: .45; }
.ach b { display: block; font-size: 11.5px; color: var(--ink); margin: 2px 0; }
.ach.got { border-color: var(--gold); background: rgba(255,209,102,.08); }
.ach.got .ai { filter: none; opacity: 1; }

.stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; margin-bottom: 14px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
textarea.save { width: 100%; height: 80px; border-radius: 8px; background: #0a1028; color: var(--ink); border: 1px solid var(--line); font-size: 11px; -webkit-user-select: text; user-select: text; }

.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(2,4,12,.7); }
.modal[hidden] { display: none; }
.modal-card { width: min(420px, 100%); max-height: 90vh; overflow-y: auto; padding: 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-card h2 { margin: 0 0 10px; font-size: 19px; color: var(--sky-2); }
.modal-card p { margin: 6px 0; font-size: 14px; line-height: 1.6; color: var(--ink); }
.modal-card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -80px); z-index: 40; padding: 8px 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--sky); font-size: 13px; transition: transform .25s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); }

.fatal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.fatal[hidden] { display: none; }
.fatal-card { max-width: 420px; padding: 20px; border-radius: 14px; background: var(--panel); border: 1px solid var(--red); text-align: center; }
.fatal-card pre { white-space: pre-wrap; font-size: 11px; color: var(--muted); text-align: left; }
.fatal-card button, .fatal-card a { display: inline-block; margin: 4px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--sky); background: none; color: var(--ink); text-decoration: none; font-size: 14px; }

@media (max-width: 860px), (orientation: portrait) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(360px, 56%) 1fr; height: 100vh; height: 100dvh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .hud { top: 48px; }
  .ore-box { padding: 4px 14px; }
  .ore-box b { font-size: 20px; }
  .sector-bar { bottom: 66px; }
  .skill { width: 48px; height: 48px; font-size: 19px; }
  .log { bottom: 120px; max-width: calc(100% - 20px); }
  .log li { font-size: 11px; padding: 3px 8px; }
  .log li:nth-last-child(n+3) { display: none; }
  .buffs { top: 132px; }
  .buffs span { font-size: 10.5px; padding: 2px 7px; }
  .back-btn { padding: 6px 10px; font-size: 12px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .log { display: none; }
}
