/* 마왕성 키우기 — 보랏빛 밤과 뼈빛 상아색 */
:root {
  --bg: #17111f;
  --panel: #211830;
  --panel-2: #2b2040;
  --line: #4a3a66;
  --bone: #efe6d2;
  --muted: #a99bbf;
  --violet: #b07aff;
  --violet-2: #d8b8ff;
  --gold: #f0c35a;
  --green: #7dffb2;
  --red: #ff7a7a;
  --display: "Gowun Batang", "AppleMyungjo", "Batang", serif;
  --body: "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(--bone); font-family: var(--body); -webkit-user-select: none; user-select: none; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--violet-2); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 1fr minmax(380px, 460px); 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: pointer; }
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.back-btn { position: absolute; top: 12px; left: 12px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--bone); text-decoration: none; border-radius: 8px; background: rgba(23,17,31,.85); border: 1px solid var(--line); }
.back-btn:hover { border-color: var(--violet); }

.res-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 4; display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.res.bones { display: flex; align-items: center; gap: 10px; padding: 8px 18px; border-radius: 14px; background: rgba(23,17,31,.88); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.res.bones .ico { font-size: 26px; }
.res.bones b { display: block; font: 700 26px var(--display); font-variant-numeric: tabular-nums; line-height: 1.1; }
.res.bones small { color: var(--violet-2); font-size: 12px; }
.res-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.res.sm { padding: 4px 10px; border-radius: 999px; background: rgba(23,17,31,.85); border: 1px solid var(--line); font-size: 13px; pointer-events: auto; }
.res.sm b { font-variant-numeric: tabular-nums; }
.buffs { position: absolute; top: 120px; left: 12px; z-index: 4; display: grid; gap: 4px; pointer-events: none; }
.buffs span { padding: 4px 10px; border-radius: 8px; background: rgba(240,195,90,.18); border: 1px solid var(--gold); color: var(--gold); font-size: 12px; font-weight: 700; }
.tap-hint { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); margin: 0; padding: 6px 14px; border-radius: 999px; background: rgba(23,17,31,.8); border: 1px solid var(--violet); font-size: 13px; pointer-events: none; animation: bob 1.6s ease-in-out infinite; }
.tap-hint[hidden] { display: none; }
@keyframes bob { 50% { transform: translate(-50%, -6px); } }
.hero { position: absolute; z-index: 6; display: grid; justify-items: center; padding: 6px 10px; border-radius: 14px; border: 2px solid var(--gold); background: radial-gradient(circle, rgba(240,195,90,.35), rgba(23,17,31,.85)); font-size: 34px; line-height: 1; box-shadow: 0 0 24px rgba(240,195,90,.6); animation: wiggle .5s ease-in-out infinite alternate; }
.hero span { font: 700 11px var(--body); color: var(--gold); margin-top: 3px; }
.hero[hidden] { display: none; }
@keyframes wiggle { to { transform: rotate(6deg) translateY(-4px); } }
.log { position: absolute; left: 12px; bottom: 12px; z-index: 4; margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; max-width: min(420px, 70%); pointer-events: none; }
.log li { padding: 5px 10px; border-radius: 8px; background: rgba(23,17,31,.86); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.4; animation: logIn .25s ease; }
.log li.good { border-color: var(--gold); }
.log li.bad { border-color: #6a4a5a; color: var(--muted); }
.log li.relic { border-color: var(--violet-2); background: rgba(80,40,120,.85); }
@keyframes logIn { from { opacity: 0; transform: translateX(-10px); } }
.ftxt { position: absolute; left: 0; top: 0; font: 800 15px var(--body); color: var(--violet-2); text-shadow: 0 1px 3px #000; white-space: nowrap; }
.ftxt.crit { color: var(--gold); font-size: 22px; }

/* 패널 */
.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: #1b1428; }
.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(--bone); background: var(--panel-2); border-color: var(--line); }
.tab[hidden] { display: none; }
.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; }
.sec-h h2 { margin: 0; font: 700 18px var(--display); color: var(--violet-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(--violet); color: #1b1028; font-weight: 700; }
.amt button:disabled { opacity: .35; }
.note { margin: 0 0 10px; padding: 8px 10px; border-radius: 9px; background: rgba(176,122,255,.08); 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: 9px 10px; margin-bottom: 6px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
.row .ico { font-size: 26px; text-align: center; }
.row .main { min-width: 0; }
.row b.nm { font-size: 14.5px; }
.row .cnt { margin-left: 6px; font: 700 13px var(--display); color: var(--gold); }
.row .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.row .bar { height: 4px; margin-top: 5px; border-radius: 2px; background: rgba(255,255,255,.08); overflow: hidden; }
.row .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--violet-2)); }
.row.locked { opacity: .55; }
.row.teaser .nm { color: var(--muted); }
.buy { min-width: 96px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--violet); background: linear-gradient(180deg, #4a2f7a, #33205a); text-align: right; font-size: 12px; line-height: 1.25; }
.buy b { display: block; font-size: 13.5px; }
.buy:disabled { opacity: .4; border-color: var(--line); background: #2a2238; }
.buy.gold { border-color: var(--gold); background: linear-gradient(180deg, #6a4f1a, #4a3510); }
.buy.soul { border-color: #8ad8ff; background: linear-gradient(180deg, #24496a, #18324a); }
.buy.stone { border-color: #ff9ad8; background: linear-gradient(180deg, #6a245a, #4a1840); }

.region { margin-bottom: 12px; border-radius: 12px; border: 1px solid var(--line); overflow: hidden; }
.region > header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 9px 12px; background: linear-gradient(90deg, color-mix(in srgb, var(--rc) 22%, var(--panel-2)), var(--panel-2)); border-bottom: 1px solid var(--line); }
.region h3 { margin: 0; font: 700 15px var(--display); color: var(--rc); }
.region header small { color: var(--muted); font-size: 11.5px; }
.tgt { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.05); }
.tgt:last-child { border-bottom: 0; }
.tgt .nm { font-size: 13.5px; font-weight: 600; }
.tgt .meta { font-size: 11.5px; color: var(--muted); }
.tgt .meta .ch { font-weight: 700; }
.tgt.boss .nm { color: var(--gold); }
.tgt.locked { opacity: .45; }
.go { min-width: 64px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--red); background: linear-gradient(180deg, #6a2a3a, #4a1a28); font-size: 12.5px; font-weight: 700; }
.go:disabled { opacity: .35; border-color: var(--line); background: #2a2238; }
.active-raids { display: grid; gap: 6px; margin-bottom: 12px; }
.ar { padding: 8px 10px; border-radius: 10px; background: #2a1830; border: 1px solid #6a3a5a; font-size: 12.5px; }
.ar .top { display: flex; justify-content: space-between; gap: 8px; }
.ar .bar { height: 6px; margin-top: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.ar .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); }
.ar button { border: 0; background: none; color: var(--muted); font-size: 11px; padding: 0 0 0 6px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.toggle input { width: 18px; height: 18px; accent-color: var(--violet); }

.card { padding: 12px; margin-bottom: 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.card h3 { margin: 0 0 4px; font: 700 17px var(--display); }
.card p { margin: 4px 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.card .lv { color: var(--gold); font: 700 15px var(--display); }
.card .act { display: flex; justify-content: flex-end; margin-top: 8px; }
.unlocks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.unlocks span { padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); }
.unlocks span.on { border-color: var(--green); color: var(--green); }

.relics { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.relic { display: grid; gap: 3px; justify-items: center; text-align: center; padding: 10px 6px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
.relic .ri { font-size: 30px; }
.relic b { font-size: 12.5px; }
.relic small { font-size: 11px; color: var(--muted); line-height: 1.35; }
.relic.r2 { border-color: #5aa3ff; } .relic.r3 { border-color: var(--violet); } .relic.r4 { border-color: var(--gold); box-shadow: inset 0 0 14px rgba(240,195,90,.15); }
.relic.unknown { opacity: .45; }
.relic .forge { width: 100%; padding: 4px; border-radius: 7px; border: 1px solid var(--gold); background: #3a2a10; font-size: 11px; }
.relic .forge:disabled { opacity: .35; border-color: var(--line); background: none; }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 5px; }
.ach { aspect-ratio: 1; display: grid; place-items: center; border-radius: 9px; background: #1b1428; border: 1px solid var(--line); font-size: 18px; filter: grayscale(1); opacity: .35; }
.ach.on { filter: none; opacity: 1; border-color: var(--gold); background: rgba(240,195,90,.1); }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 600; font-size: 13px; }
.btn:hover:not(:disabled) { border-color: var(--violet); }
.btn.primary { border-color: var(--violet); background: linear-gradient(180deg, #6a3ab0, #4a2588); color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
textarea { width: 100%; min-height: 90px; padding: 8px; border-radius: 9px; border: 1px solid var(--line); background: #140f1c; color: var(--bone); font: 12px ui-monospace, Menlo, monospace; -webkit-user-select: text; user-select: text; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8,5,14,.7); }
.modal[hidden] { display: none; }
.sheet { width: min(480px, 100%); max-height: 90vh; overflow: auto; padding: 22px; border-radius: 16px; background: var(--panel); border: 1px solid var(--violet); box-shadow: 0 0 40px rgba(176,122,255,.25), 0 20px 50px rgba(0,0,0,.5); text-align: center; }
.sheet h2 { margin: 0 0 8px; font: 700 24px var(--display); color: var(--violet-2); }
.sheet p { color: var(--muted); line-height: 1.6; font-size: 14px; }
.sheet .big { font: 700 22px var(--display); color: var(--bone); }
.sheet .btns { justify-content: center; margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 60; padding: 9px 16px; border-radius: 999px; background: rgba(23,17,31,.95); border: 1px solid var(--violet); font-size: 13px; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.loading { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--bg); }
.loading[hidden] { display: none; }
.load-card { width: min(340px, 86vw); text-align: center; }
.load-card h1 { font: 700 30px var(--display); color: var(--violet-2); margin: 0 0 14px; }
.load-track { height: 8px; border-radius: 4px; background: #0f0b16; overflow: hidden; border: 1px solid var(--line); }
.load-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--violet-2)); transition: width .2s; }
.load-card p { color: var(--muted); font-size: 13px; }
.load-err { max-width: 520px; padding: 0 16px; text-align: center; line-height: 1.6; }

@media (max-width: 860px) {
  body { overflow: hidden; }
  .app { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .res-bar { top: 50px; }
  .res.bones b { font-size: 21px; }
  .buffs { top: auto; bottom: 46px; }
  .tap-hint { bottom: 8px; }
  .log { display: none; }
  .tabs { grid-template-columns: repeat(5, 1fr); }
}
