* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b0e13; color: #e9ecef; font-family: system-ui, -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif; overflow: hidden; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#game.playing { cursor: crosshair; }

/* 오버레이 화면 */
#ui { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(5, 8, 12, 0.72); z-index: 10; overflow: auto; padding: 16px; }
#ui.active { display: flex; }
.panel { background: #141a22; border: 1px solid #2b3440; border-radius: 12px; padding: 24px 28px; min-width: min(460px, 94vw); max-width: 94vw; box-shadow: 0 10px 40px #0008; }
.panel.wide { width: min(960px, 96vw); }
h1 { margin: 0 0 4px; font-size: 32px; letter-spacing: -0.5px; }
h1 .ver { font-size: 13px; color: #868e96; font-weight: 600; }
h2 { margin: 0 0 8px; font-size: 26px; }
h2.win { color: #ffd43b; } h2.lose { color: #ff6b6b; }
.sub { color: #adb5bd; margin: 4px 0 14px; font-size: 14px; }
.label { color: #868e96; font-size: 12px; margin: 14px 0 6px; text-transform: none; }
.help { color: #868e96; font-size: 12px; margin-top: 18px; line-height: 1.5; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row.col { flex-direction: column; }
.btn { min-height: 44px; padding: 10px 18px; border-radius: 8px; border: 1px solid #343d4a; background: #1f2731; color: #f1f3f5; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; }
.btn:hover, .btn:focus-visible { background: #2a3442; border-color: #ffd43b; outline: none; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.stage { min-height: 64px; border-radius: 8px; border: 1px solid #343d4a; background: #1a212a; color: #fff; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.stage b { font-size: 16px; } .stage small { color: #868e96; font-size: 11px; }
.stage.cleared small { color: #63e6be; }
.stage.sel, .stage:focus-visible { border-color: #ffd43b; background: #262f3a; outline: none; }
.stage:disabled { opacity: 0.35; cursor: not-allowed; }
table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 15px; }
td { padding: 6px 4px; border-bottom: 1px solid #222a35; }
td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 800; color: #63e6be; border-bottom: none; font-size: 17px; }
.opened { color: #ffd43b; font-weight: 800; font-size: 18px; }
.news { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.new { display: flex; align-items: center; gap: 10px; color: #ffd43b; font-weight: 700; }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.card { background: #1a212a; border: 1px solid #2b3440; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; min-height: 160px; outline: none; }
.card:focus-visible { border-color: #ffd43b; }
.card b { font-size: 14px; } .card small { color: #adb5bd; font-size: 11px; line-height: 1.35; } .card i { color: #ffd43b; font-size: 11px; font-style: normal; }
.card.unknown b { color: #5c6773; }
.opt { display: flex; align-items: center; gap: 10px; margin: 10px 0; min-height: 36px; }
.opt input[type=checkbox] { width: 22px; height: 22px; }
.opt input[type=range] { flex: 1; }
.io { width: 100%; background: #0e1318; color: #e9ecef; border: 1px solid #2b3440; border-radius: 6px; padding: 8px; font: 12px ui-monospace, monospace; resize: vertical; }
.msg { color: #ffd43b; font-size: 13px; min-height: 18px; }

/* 스킬트리 */
#treeroot { position: fixed; inset: 0; display: none; z-index: 20; background: #0b0e13; }
#treeroot.active { display: block; }
.tree { position: absolute; inset: 0; display: flex; flex-direction: column; }
.tree header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #141a22; border-bottom: 1px solid #2b3440; flex-wrap: wrap; }
.tree .title { font-weight: 800; font-size: 18px; }
.tree .shards { color: #63e6be; font-weight: 800; font-size: 18px; margin-left: 12px; }
.tree .grow { flex: 1; }
.treecv { flex: 1; width: 100%; min-height: 0; cursor: grab; touch-action: none; display: block; }
.treecv:active { cursor: grabbing; }
.tip { position: fixed; display: none; width: 260px; background: #141a22f2; border: 1px solid #3b4654; border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.5; pointer-events: none; z-index: 30; }
.tip b { font-size: 15px; } .tip .lv { color: #ffd43b; font-size: 12px; } .tip .d { color: #adb5bd; margin-bottom: 4px; }
.tip .ok { color: #63e6be; } .tip .no { color: #ff8787; }
.legend { position: absolute; left: 10px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: #adb5bd; pointer-events: none; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

/* 튜닝 패널 — 펼쳐져 있으면 게임 영역을 왼쪽으로 줄인다 */
body.has-panel:not(.panel-min) #game, body.has-panel:not(.panel-min) #ui, body.has-panel:not(.panel-min) #treeroot { right: 340px; }
.tuning { position: fixed; top: 0; right: 0; bottom: 0; width: 340px; background: #10151cf0; border-left: 1px solid #2b3440; z-index: 50; overflow-y: auto; font-size: 12px; padding: 8px; }
.tuning.min { width: 120px; bottom: auto; overflow: hidden; }
.tuning.min .tools, .tuning.min .body { display: none; }
.tuning .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tuning button { background: #1f2731; color: #e9ecef; border: 1px solid #343d4a; border-radius: 4px; padding: 4px 8px; margin: 2px; cursor: pointer; font: inherit; }
.tuning button:hover { border-color: #ffd43b; }
.tuning textarea { width: 100%; background: #0b0e13; color: #e9ecef; border: 1px solid #2b3440; font: 11px ui-monospace, monospace; margin-top: 4px; }
.tuning .cheats { margin-top: 4px; border-top: 1px solid #2b3440; padding-top: 4px; }
.tuning details { border-left: 1px solid #2b3440; margin: 2px 0 2px 4px; padding-left: 6px; }
.tuning summary { cursor: pointer; font-weight: 700; color: #ffd43b; padding: 2px 0; }
.tuning .f { display: grid; grid-template-columns: 110px 1fr 70px; gap: 4px; align-items: center; margin: 1px 0; }
.tuning .f label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #ced4da; }
.tuning .f.changed label { color: #ffd43b; }
.tuning .f input[type=number] { width: 70px; background: #0b0e13; color: #e9ecef; border: 1px solid #2b3440; border-radius: 3px; font: 11px ui-monospace, monospace; padding: 2px; }
.tuning .f input[type=range] { width: 100%; }
