/* 병력 커스텀 — 스타일 (기획안 §6 화면 설계) */
/* 화면 테마 (F-25): 기본 = 어둡게. 밝게 = [data-theme="light"] 또는 "시스템"+기기 밝은 모드 */
:root {
  --bg: #121826;
  --bg2: #0f1420;
  --panel: #1b2335;
  --panel2: #243049;
  --line: #34415d;
  --text: #eef2f8;
  --muted: #9aa7bd;
  --gold: #f7c948;
  --gold-dark: #b07c0c;
  --accent-text: #f7c948;
  --red: #ff6363;
  --green: #44d18c;
  --blue: #9fc6ff;
  --topbar-bg: linear-gradient(#1f2a40, #182033);
  --capbar-bg: rgba(18, 24, 38, .95);
  --track: #0b101b;
  --issues-bg: #3a1d24;
  --issues-line: #7a2e3b;
  --issues-text: #ffc9c9;
  --warn-bg: #3b3018;
  --warn-line: #6b5520;
  --warn-text: #ffd27a;
  --capbar-h: 58px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef1f6;
  --bg2: #f7f9fc;
  --panel: #ffffff;
  --panel2: #edf1f7;
  --line: #cfd7e3;
  --text: #18202e;
  --muted: #5b6678;
  --accent-text: #8f6200;
  --red: #d63a3a;
  --green: #1d9a58;
  --blue: #2560c4;
  --topbar-bg: linear-gradient(#ffffff, #f3f6fa);
  --capbar-bg: rgba(238, 241, 246, .95);
  --track: #dde3ec;
  --issues-bg: #fff1f1;
  --issues-line: #f0b9b9;
  --issues-text: #9b1c1c;
  --warn-bg: #fff7df;
  --warn-line: #ecd08a;
  --warn-text: #7a5600;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f6;
    --bg2: #f7f9fc;
    --panel: #ffffff;
    --panel2: #edf1f7;
    --line: #cfd7e3;
    --text: #18202e;
    --muted: #5b6678;
    --accent-text: #8f6200;
    --red: #d63a3a;
    --green: #1d9a58;
    --blue: #2560c4;
    --topbar-bg: linear-gradient(#ffffff, #f3f6fa);
    --capbar-bg: rgba(238, 241, 246, .95);
    --track: #dde3ec;
    --issues-bg: #fff1f1;
    --issues-line: #f0b9b9;
    --issues-text: #9b1c1c;
    --warn-bg: #fff7df;
    --warn-line: #ecd08a;
    --warn-text: #7a5600;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.45 system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img { display: block; }
/* 길게 누르기(상세 보기)와 겹치는 iOS 이미지 메뉴·글자 선택 끄기 */
.tile, .slot-img, .gear, .hero-face, .check, .th-tile { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: linear-gradient(#ffd75e, #e9a920); color: #2b1d00; border-color: var(--gold-dark); }
.btn.game { background: linear-gradient(#61e292, #23a157); color: #04210e; border-color: #1b7d43; }
.btn.danger { background: linear-gradient(#ff8080, #d64444); color: #2a0303; border-color: #a52a2a; }
.btn.icon { width: 38px; padding: 0; font-size: 20px; }
.icon-btn {
  width: 36px; height: 36px; flex: none; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); cursor: pointer; font-size: 15px;
}
.link-btn {
  margin-left: auto; background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: underline;
}

/* ── 상단 바 ── */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
}
.th-btn {
  display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px 0 6px;
  border-radius: 12px; background: var(--panel2); border: 1px solid var(--line);
  cursor: pointer; font-weight: 900; font-size: 15px;
}
.th-btn img { width: 28px; height: 28px; object-fit: contain; }
.preset-box { display: flex; gap: 6px; align-items: center; flex: 1 1 300px; min-width: 0; }
#preset-select {
  flex: 1; min-width: 0; height: 38px; border-radius: 10px; padding: 0 10px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 700;
}
.preset-btns { display: flex; gap: 4px; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── 용량 막대 (F-04) ── */
.capbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px;
  padding: 8px 16px; background: var(--capbar-bg);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.cap {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 10px 6px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px;
}
.cap img { width: 16px; height: 16px; object-fit: contain; }
.cap-l { color: var(--muted); font-weight: 600; }
.cap b { font-variant-numeric: tabular-nums; }
.cap em { font-style: normal; color: var(--muted); font-size: 12px; }
.cap-bar { position: absolute; left: 8px; right: 8px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--track); overflow: hidden; }
.cap-bar > i { display: block; height: 100%; background: var(--gold); }
.cap.full .cap-bar > i { background: var(--green); }
.cap.over { border-color: var(--red); }
.cap.over b { color: var(--red); }
.cap.over .cap-bar > i { background: var(--red); }
.cap.main { padding-right: 12px; }
.cap.main b { font-size: 15px; }
.cap-sep { width: 1px; background: var(--line); margin: 2px 4px; }

/* 화면에는 안 보이고 화면 읽기 프로그램·검색 엔진만 읽는 제목 (D-23) */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── 검증 경고 (R-14) ── */
.issues {
  max-width: 1400px; margin: 10px auto 0; padding: 10px 14px;
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  border-radius: 12px; background: var(--issues-bg); border: 1px solid var(--issues-line);
}
.issues[hidden] { display: none; }
.issues ul { margin: 4px 0 0; padding-left: 18px; color: var(--issues-text); font-size: 13px; }

/* ── 배치 ── */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 16px;
  max-width: 1400px; margin: 0 auto; padding: 16px; align-items: start;
}
.compose { min-width: 0; }
.palette {
  position: sticky; top: calc(var(--capbar-h) + 12px);
  max-height: calc(100vh - var(--capbar-h) - 24px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}

/* ── 구성 패널 ── */
.sec {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px 14px; margin-bottom: 12px;
}
.sec h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.sec h3 small { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.sec h3 small.over { color: var(--red); }
.sec.bad { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.cc-title { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 18px 4px 10px; color: var(--accent-text); }
.cc-title img { width: 22px; height: 22px; object-fit: contain; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.note.info { color: var(--blue); }
.note.warn {
  color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-line);
  padding: 8px 10px; border-radius: 10px; margin: 8px 0;
}
.memo textarea { min-height: 70px; }

/* 병력 총합 (F-33) */
.summary h3 small { font-weight: 600; }
.sum-table { width: 100%; max-width: 520px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sum-table th, .sum-table td { padding: 6px 8px; text-align: right; white-space: nowrap; }
.sum-table th:first-child { text-align: left; padding-left: 0; color: var(--muted); font-weight: 600; white-space: normal; }
.sum-table thead th { font-size: 12px; color: var(--muted); font-weight: 700; padding-top: 0; }
.sum-table td { font-weight: 700; }
.sum-table tbody tr + tr { border-top: 1px solid var(--line); }
.sum-table tfoot tr { border-top: 2px solid var(--line); }
.sum-table tfoot th:first-child, .sum-table tfoot td { color: var(--accent-text); font-weight: 800; }
.sum-notes { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.sum-notes li + li { margin-top: 2px; }

/* 구성 칸 (D-9: 42px, [−][아이콘][+] 한 줄) */
.slot-list { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.slot { display: flex; flex-direction: column; align-items: center; }
.slot-row { display: flex; align-items: stretch; gap: 2px; }
.slot-img {
  position: relative; width: 42px; height: 42px; border-radius: 8px; overflow: hidden;
  border: 1.5px solid rgba(0, 0, 0, .4); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.slot-img img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.slot-num {
  position: absolute; right: 1px; bottom: 1px; min-width: 18px; height: 15px; padding: 0 3px;
  border-radius: 5px; border: 0; background: rgba(10, 14, 24, .88); color: #fff;
  font-weight: 900; font-size: 11px; line-height: 15px; cursor: pointer;
}
.sbtn {
  width: 22px; border-radius: 7px; border: 1px solid var(--line); padding: 0;
  background: var(--panel2); cursor: pointer; font-weight: 900; font-size: 14px; line-height: 1;
}
.sbtn:hover { filter: brightness(1.2); }
.slot-name {
  margin-top: 2px; max-width: 90px; font-size: 10.5px; color: var(--muted); text-align: center;
  line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot.bad .slot-img { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.empty-hint {
  width: 100%; padding: 14px; border: 1px dashed var(--line); border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer;
}

/* 영웅 (F-08, D-14: 영웅 한 명 = 가로 한 줄, 영웅들은 위아래로) */
.hero-list { display: flex; flex-direction: column; gap: 6px; }
.hero-row {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 620px;
  padding: 6px 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
}
.hero-row.bad { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.hero-row.empty {
  justify-content: flex-start; min-height: 52px; gap: 8px; padding-left: 14px;
  border: 2px dashed var(--line); background: transparent; color: var(--muted); cursor: pointer; font-weight: 800; font-size: 13px;
}
.hero-row.empty b { font-size: 20px; line-height: 1; }
.hero-face {
  width: 40px; height: 52px; flex: none; padding: 0; border-radius: 8px; overflow: hidden;
  border: 1.5px solid rgba(0, 0, 0, .4); cursor: pointer;
}
.hero-face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; pointer-events: none; }
.hero-gearrow { display: flex; align-items: center; gap: 4px; flex: none; }
.gear-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 2px; }
.gear {
  width: 36px; height: 36px; flex: none; padding: 0; border-radius: 8px; overflow: hidden;
  border: 1.5px solid rgba(0, 0, 0, .4); cursor: pointer;
}
.gear img { width: 100%; height: 100%; object-fit: contain; padding: 2px; pointer-events: none; }
.gear.g-pet img { object-fit: cover; padding: 0; }
.gear.empty { background: transparent; border: 1.5px dashed var(--line); color: var(--muted); font-size: 10px; font-weight: 800; }
.gear.locked { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; cursor: default; opacity: .6; }
.gear.locked small { font-size: 9px; }
.gear.bad { box-shadow: 0 0 0 2px var(--red); border-color: var(--red); }
.mode-btn {
  flex: none; min-width: 46px; height: 26px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 11px; font-weight: 800; cursor: pointer;
}
.mode-btn.air { background: #2d5f9a; border-color: #4b85c9; color: #fff; }
.hero-info { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.hero-info b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-info small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 팔레트 ── */
.pal-head {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  padding: 12px 12px 0; border-bottom: 1px solid var(--line);
}
.seg { display: inline-flex; justify-self: start; background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 16px; border-radius: 8px; cursor: pointer; font-weight: 800; color: var(--muted); }
.seg button.on { background: linear-gradient(#ffd75e, #e9a920); color: #2b1d00; }
.sheet-close { display: none; }
.tabs { grid-column: 1 / -1; display: flex; gap: 2px; }
.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted); padding: 10px 0;
  font-weight: 800; cursor: pointer; border-bottom: 3px solid transparent;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.pal-body { overflow-y: auto; padding: 4px 12px 16px; overscroll-behavior: contain; }
.pal-body h4 { margin: 12px 0 8px; font-size: 13px; color: var(--muted); }
.pal-body h4 small { color: var(--accent-text); margin-left: 4px; }

/* 팔레트 아이콘 (D-9: 40px, 아이콘만) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, 40px); gap: 6px; }
.tile {
  position: relative; width: 40px; height: 40px; padding: 0; overflow: hidden; cursor: pointer;
  border-radius: 8px; border: 1.5px solid rgba(0, 0, 0, .45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 1px 0 rgba(0, 0, 0, .35);
  transition: transform .08s;
}
.tile:hover { filter: brightness(1.12); }
.tile:active { transform: scale(.93); }
.tile img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.tile > span, .pick-img > span { position: absolute; font-weight: 900; pointer-events: none; color: #fff; }  /* 아이콘 위 배지는 테마와 상관없이 흰 글씨 */
.tile .hs {
  right: 1px; bottom: 1px; min-width: 13px; height: 12px; padding: 0 2px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 20, .85); font-size: 9px;
}
.tile .have, .pick-img .have {
  left: 1px; top: 1px; min-width: 13px; height: 13px; padding: 0 3px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; background: var(--gold); color: #2b1d00; font-size: 9.5px;
}
.tile .lock, .pick-img .lock {
  inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  color: #ffd27a; font-size: 10px; line-height: 1.05; text-shadow: 0 1px 2px #000, 0 0 4px #000;
}
.tile.locked img, .pick.locked img { filter: grayscale(1) brightness(.5); }
.tile.dim, .pick.dim { opacity: .6; }
.tile.dim img, .pick.dim img { filter: grayscale(.6); }
.hero-tile img { object-position: 50% 15%; }
.pal-status {
  padding: 7px 12px; border-top: 1px solid var(--line); background: var(--bg2);
  color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 선택 창 항목 (D-9: 48px + 아래 이름) */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px 6px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.pick:hover { background: var(--panel2); }
.pick-img {
  position: relative; width: 48px; height: 48px; border-radius: 9px; overflow: hidden;
  border: 1.5px solid rgba(0, 0, 0, .45); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.pick-img img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.pick-img .rar { right: 1px; top: 1px; padding: 0 3px; border-radius: 4px; font-size: 8.5px; background: #6a2fa0; }
.pick.cur .pick-img { box-shadow: 0 0 0 2px var(--gold); }
.pick-nm { font-size: 10.5px; line-height: 1.2; text-align: center; color: var(--text); max-width: 68px; }
.pick.locked .pick-nm { color: var(--muted); }
.g-hero.pick-img img { object-position: 50% 15%; }

/* 보유 장비 설정 (F-28) */
.pick.unowned img { filter: grayscale(1) brightness(.5); }
.pick.unowned .pick-nm { color: var(--muted); text-decoration: line-through; }
.pick-img .own-mark {
  left: 1px; top: 1px; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; font-size: 9.5px; background: var(--green); color: #fff;
}
.pick-img .own-mark.def { background: rgba(8, 12, 20, .8); }
.own-bulk { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.own-hero { display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; font-size: 14px; }
.own-hero img { width: 24px; height: 32px; object-fit: cover; object-position: 50% 15%; border-radius: 5px; }

/* 메뉴의 화면 테마 고르기 (F-25) */
.menu-theme { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; font-weight: 700; }

/* 종류별 카드 색 */
.g-elixir { background: linear-gradient(160deg, #c66be0, #7a3a9e); }
.g-dark { background: linear-gradient(160deg, #5d4f7d, #2a2240); }
.g-super { background: linear-gradient(160deg, #ffaa4d, #b25414); }
.g-spell-elixir { background: radial-gradient(circle at 50% 40%, #5d72d8, #2b377c); }
.g-spell-dark { background: radial-gradient(circle at 50% 40%, #61508a, #281f3e); }
.g-siege { background: linear-gradient(160deg, #c49a5a, #6c4d21); }
.g-hero { background: linear-gradient(160deg, #ffd76a, #a8730e); }
.g-pet { background: linear-gradient(160deg, #6fd6a8, #27735a); }
.g-eq-common { background: linear-gradient(160deg, #7193bb, #33506f); }
.g-eq-epic { background: linear-gradient(160deg, #b97ce8, #57288a); }
.g-spell-elixir > img, .g-spell-dark > img, .g-eq-common > img, .g-eq-epic > img { object-fit: contain; padding: 7%; }

.shake { animation: shake .35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ── 선택 창 ── */
.modal-wrap {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(4, 7, 14, .68);
}
.modal {
  width: min(440px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
}
.modal.wide { width: min(700px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.msg { margin: 0 0 10px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.field input, textarea, .qr input {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.th-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; }
.th-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-weight: 900; font-size: 13px;
}
.th-tile img { width: 40px; height: 40px; object-fit: contain; }
.th-tile.on { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }

.detail-img { height: 140px; border-radius: 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 12px; }
.detail-img img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 6px; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { width: 36%; padding: 7px 8px 7px 0; text-align: left; color: var(--muted); font-weight: 600; vertical-align: top; }
.kv td { padding: 7px 0; }
.kv tr + tr { border-top: 1px solid var(--line); }
.hero-menu img { max-width: 100%; max-height: 140px; margin: 0 auto; }

.qr-box { width: min(280px, 100%); margin: 0 auto 12px; padding: 10px; border-radius: 14px; background: #fff; }
.qr-box svg { display: block; width: 100%; height: auto; }

.menu-list { display: flex; flex-direction: column; }
.menu-item { padding: 12px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; font-weight: 700; cursor: pointer; }
.menu-item:hover { background: var(--panel2); }
.menu-item.danger { color: var(--red); }
.menu-list hr { margin: 6px 0; border: 0; border-top: 1px solid var(--line); }

/* ── 옮겨 담기 체크 모드 (F-21) ── */
.checkmode { position: fixed; inset: 0; z-index: 90; overflow-y: auto; padding: 0 16px 40px; background: var(--bg); }
.check-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px;
  padding: 12px 0; background: var(--bg); border-bottom: 1px solid var(--line);
}
.check-head > div { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-prog { font-weight: 900; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.checkmode h3 { margin: 18px 0 10px; font-size: 15px; color: var(--muted); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px 6px; }
.check {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer;
}
.check:hover { background: var(--panel); }
.check-img {
  position: relative; width: 60px; height: 60px; border-radius: 10px; overflow: hidden;
  border: 1.5px solid rgba(0, 0, 0, .45);
}
.check-img img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.check-img.g-hero img { object-position: 50% 15%; }
.check-img b { position: absolute; right: 2px; bottom: 2px; padding: 0 5px; border-radius: 6px; background: rgba(8, 12, 20, .9); font-size: 13px; color: #fff; }
.check-nm { font-weight: 700; font-size: 11.5px; line-height: 1.2; text-align: center; }
.check.done { opacity: .35; }
.check.done::after {
  content: "✓"; position: absolute; left: 0; right: 0; top: 6px; height: 60px; display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 900; color: var(--green); text-shadow: 0 2px 6px #000;
}

/* ── 토스트 ── */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translate(-50%, 20px);
  max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 12px;
  background: #0b101b; color: #eef2f8; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: #1f7a4c; }
.toast.warn { border-color: #8a6a1a; color: #ffe2a0; }

/* 홈 화면 앱 (F-27): 새 버전 알림 줄, 설치 창 */
.update-bar {
  position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 190;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 14px; border-radius: 12px; background: #0b101b; color: #eef2f8;
  border: 1px solid #1f7a4c; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-weight: 700;
}
.pwa-how { margin: 14px 0 6px; font-size: 14px; }
.pwa-steps { margin: 0; padding-left: 18px; }
.pwa-steps li + li { margin-top: 4px; }

.footer { max-width: 1400px; margin: 8px auto 0; padding: 8px 16px 28px; color: var(--muted); font-size: 12px; }
.footer p { margin: 4px 0; }
.footer a { color: var(--blue); }
/* 바닥글: 고지 → 언어 선택(F-30) → 버그·문제 신고(F-32) */
.footer-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.lang-row { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.lang-row select {
  height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-weight: 700;
}
.report-row .btn { gap: 4px; }
.report-note { color: var(--muted); }

/* 신고 창 */
.modal select, .field select {
  width: 100%; height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text);
}
.modal .field { margin-bottom: 10px; }
.check-line { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; font-weight: 600; }
.check-line input { width: 18px; height: 18px; }
.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.report-result { margin: 8px 0 0; font-weight: 700; }
.report-result.warn { color: var(--warn-text); }
.note a, .report-result a { color: var(--blue); }

/* 레벨별 스펙 (F-29) */
.spec-title { margin: 16px 0 8px; font-size: 14px; }
.spec-lv { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.spec-lv select { width: auto; min-width: 130px; height: 32px; }
.spec-lv .btn.sm { width: 32px; padding: 0; font-size: 16px; }
.spec-note { font-size: 12px; color: var(--muted); }
.spec-note.warn { color: var(--warn-text); }
.kv.spec td { font-variant-numeric: tabular-nums; font-weight: 700; }

/* 자동 백업 목록 (F-31) */
.auto-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.auto-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2);
}
.auto-item small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.fab, .sheet-backdrop { display: none; }

/* ── 태블릿·휴대폰: 팔레트를 아래 시트로 (§6.3) ── */
@media (max-width: 999px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .palette {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    height: 62vh; max-height: 62vh; border-radius: 18px 18px 0 0;
    transform: translateY(105%); transition: transform .22s ease; box-shadow: 0 -10px 30px rgba(0, 0, 0, .5);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.sheet-open .palette { transform: none; }
  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
  .sheet-close { display: block; }
  .fab {
    display: block; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30;
    height: 54px; padding: 0 24px; border-radius: 27px; border: 1px solid var(--gold-dark);
    background: linear-gradient(#ffd75e, #e9a920); color: #2b1d00; font-weight: 900; font-size: 16px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .45); cursor: pointer;
  }
  body.sheet-open .fab { display: none; }
  .toast { bottom: 90px; }
  .update-bar { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .footer { padding-bottom: 96px; }
}

@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .preset-box { flex-basis: 0; }
  .preset-btns { display: none; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; padding: 0 8px; }
  .actions .btn.icon { flex: none; }
  #btn-open-game { flex: 1 1 100%; height: 46px; order: -1; font-size: 16px; }
  .capbar { padding: 6px 12px; gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .capbar::-webkit-scrollbar { display: none; }
  .cap { flex: none; font-size: 12px; padding: 4px 8px 9px 5px; gap: 4px; }
  .cap-sep { display: none; }
  .issues { margin: 8px 12px 0; }
  .sec { padding: 10px 10px 12px; }
  .sbtn { width: 30px; font-size: 16px; }   /* 손가락으로 누르기 쉽게 (높이 42px) */
  .hero-list { gap: 6px; }
  .grid { grid-template-columns: repeat(auto-fill, 42px); gap: 7px; }
  .tile { width: 42px; height: 42px; }
  .pal-status { display: none; }
  .modal-wrap { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 88vh; border-radius: 18px 18px 0 0; }
  .modal-foot .btn { flex: 1; }
}

@media (hover: none), (pointer: coarse) {
  .pc-only { display: none !important; }
}
