/* ── 폰트 ──────────────────────────────────────────────────────────── */
@import url('https://cdn.jsdelivr.net/gh/spoqa/spoqa-han-sans@latest/css/SpoqaHanSansNeo.css');

/* ── 리셋 ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; border: 0; }

/* ── 기본 ──────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: 'SpoqaHanSansNeo', 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  font-size: 13px;
  background: #3c3431;
  color: #e0d8d0;
  overscroll-behavior: contain;
}

/* ── 래퍼 ──────────────────────────────────────────────────────────── */
#wrapper {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: 1300px;
  height: 100vh;
  background: linear-gradient(180deg, #484442 0%, #3c3431 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════
   헤더
   ══════════════════════════════════════════════════════════════════════ */
#frame_header {
  flex-shrink: 0;
  background: rgba(30, 28, 26, 0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
  z-index: 200;
}
.header-row {
  display: flex;
  align-items: center;
  height: 46px;
  padding: 0 10px;
  gap: 6px;
}
#header-title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: 0.5px;
}
#header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.header-btn {
  background: rgba(255,255,255,0.1);
  color: #e0d8d0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.header-btn:hover { background: rgba(255,255,255,0.18); }
.header-btn.hidden { display: none !important; }
.view-btn { opacity: 0.55; }
.view-btn.active { opacity: 1; background: rgba(62,64,229,0.4); color: #fff; }
.header-select {
  background: rgba(255,255,255,0.1);
  color: #e0d8d0;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.header-select.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════
   화면 전환
   ══════════════════════════════════════════════════════════════════════ */
.screen {
  display: none;
  flex: 1;
  overflow: hidden;
}
.screen.show { display: flex; }

/* ══════════════════════════════════════════════════════════════════════
   SCREEN 1: 메인
   ══════════════════════════════════════════════════════════════════════ */
#screen-main {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
#main-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 32px;
  width: 100%;
  max-width: 700px;
}
.main-title {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 32px;
  letter-spacing: 0.5px;
}

/* ── 메인 타일 ─────────────────────────────────────────────────── */
.main-tiles {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 620px;
  justify-content: center;
}
.main-tile {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  aspect-ratio: 1 / 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
  padding: 28px 16px;
  text-align: center;
}
.main-tile:hover {
  background: rgba(255,255,255,0.13);
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.main-tile-icon {
  font-size: 48px;
  line-height: 1;
}
.main-tile-label {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}
.main-tile-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  line-height: 1.6;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.main-nav-btn {
  background: rgba(255,255,255,0.1);
  color: #e0d8d0;
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-align: center;
}
.main-nav-btn:hover {
  background: rgba(255,255,255,0.18);
  transform: translateY(-1px);
}
.main-nav-btn--primary {
  background: linear-gradient(135deg, #6e4a1e, #a06a2e);
  color: #ffe8b0;
  border: 1px solid rgba(255,210,100,0.25);
  font-size: 16px;
  padding: 16px 28px;
}
.main-nav-btn--primary:hover {
  background: linear-gradient(135deg, #7e5a2e, #b07a3e);
}

/* ── 직업 선택 화면 ─────────────────────────────────────────────── */
#screen-class-select {
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
}
#class-select-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 32px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}
.class-select-title {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
}

/* 직업 선택 그리드 */
#class-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 620px;
}
.class-btn {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  /* 항상 보이는 골드 톤 테두리 — 카드를 명확히 감싸 줌 */
  border: 2px solid rgba(255,210,120,0.55);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5) inset, 0 4px 12px rgba(0,0,0,0.45);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, filter 0.15s;
  background-color: #2a2825;
  background-size: cover;
  background-position: center 20%;
  background-repeat: no-repeat;
  display: flex;
  align-items: flex-end;
  /* 이미지 색감 보정 (어두운 배경에서 바래 보이는 문제 완화) */
  filter: saturate(1.15) contrast(1.08) brightness(1.05);
}
.class-btn:hover {
  transform: translateY(-3px);
  border-color: rgba(255,230,150,0.95);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5) inset, 0 8px 22px rgba(0,0,0,0.6);
  filter: saturate(1.25) contrast(1.12) brightness(1.12);
}
/* 포맷 미선택 시 직업 그리드 비활성화 */
#class-grid.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.6);
}
.class-btn-label {
  width: 100%;
  text-align: center;
  /* 어두운 그라데이션 스트립 제거 — 텍스트가 이미지 위에 직접 올라옴 */
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  padding: 6px 4px 10px;
  pointer-events: none;
  letter-spacing: 0.3px;
  /* 이미지 위에서도 또렷이 보이도록 강한 텍스트 그림자 */
  text-shadow:
    0 2px 4px rgba(0,0,0,0.95),
    0 0 6px rgba(0,0,0,0.85),
    0 0 2px rgba(0,0,0,1);
}

/* ══════════════════════════════════════════════════════════════════════
   SCREEN 2: 카드 목록
   ══════════════════════════════════════════════════════════════════════ */
#screen-cards {
  flex-direction: row;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════
   SCREEN 3: 저장된 덱
   ══════════════════════════════════════════════════════════════════════ */
#screen-decks {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
}
#decks-inner {
  width: 100%;
  max-width: 700px;
  padding: 20px 16px;
}
#decks-top-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.saved-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: rgba(26,26,34,0.85);
  border-radius: 10px;
  /* 상하 padding 제거 — 행 높이가 우측 crop 이미지(64px) 높이와 정확히 일치 */
  /* 우측 padding도 0: 삭제 버튼이 우측 끝까지 정사각형(64×64)으로 채움 */
  padding: 0 0 0 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: filter 0.15s;
  overflow: hidden;
  position: relative;
  height: 64px;                    /* crop 이미지와 동일한 고정 높이 */
}
.saved-item:hover { filter: brightness(1.12); }
.saved-item-hero {
  width: 48px;
  height: 48px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: transparent;
  flex-shrink: 0;
}
.saved-item-info { flex: 1; }
.saved-item-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
}
.saved-item-meta { font-size: 11px; color: rgba(255,255,255,0.45); }
.saved-item-dust {
  font-size: 11px;
  color: #ffd66a;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.saved-item-dust .dust-icon {
  width: 12px;
  height: 12px;
}
.saved-item-tile {
  width: 240px;
  height: 64px;
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
  border-radius: 6px;
  flex-shrink: 0;
  /* 좌측으로 살짝 페이드 (정보 영역과의 경계를 부드럽게) */
  -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, #000 18%, #000 100%);
          mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, #000 18%, #000 100%);
}
.saved-item-del {
  flex-shrink: 0;
  /* 부모의 gap:10px를 상쇄 → crop 이미지에 딱 붙음 */
  margin-left: -10px;
  /* 행 높이와 동일한 정사각형 — 우측 끝에 딱 붙어 공간이 비지 않음 */
  width: 64px;
  height: 64px;
  align-self: stretch;
  background: rgba(200,60,60,0.18);
  color: #f08080;
  border: none;
  border-radius: 0;                /* 행의 우측 끝 모서리는 .saved-item이 overflow:hidden으로 클리핑 */
  padding: 0;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.saved-item-del:hover { background: rgba(220,70,70,0.55); color: #fff; }
.saved-empty {
  text-align: center;
  color: rgba(255,255,255,0.35);
  padding: 40px 0;
  font-size: 14px;
}

/* ══════════════════════════════════════════════════════════════════════
   SCREEN 4: 덱 제작 (4컬럼: 미리보기 | 카드목록 50% | 덱카드 50% | 스탯)
   ══════════════════════════════════════════════════════════════════════ */
#screen-builder {
  flex-direction: row;
  overflow: hidden;
}

/* ── 공통 미리보기 패널 ──────────────────────────────────────────── */
.preview-panel {
  width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: rgba(0,0,0,0.25);
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}
.preview-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
}
.preview-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.preview-name {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.3;
}
.preview-set {
  margin-top: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

/* ── 카드 패널 (중앙좌, 50%) ───────────────────────────────────── */
#builder-card-panel {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
}
#cards-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── 덱 패널 (중앙우, 50%) ─────────────────────────────────────── */
#deck-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(0,0,0,0.22);
  border-left: 1px solid rgba(255,255,255,0.06);
}

/* ── 스탯 패널 (우측: 마나곡선 + 카드유형) ─────────────────────── */
#stats-panel {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(0,0,0,0.22);
  border-left: 1px solid rgba(255,255,255,0.06);
  padding: 8px 0;
}

/* ══════════════════════════════════════════════════════════════════════
   공통 필터 / 검색
   ══════════════════════════════════════════════════════════════════════ */
.filter-row {
  display: flex;
  align-items: center;
  padding: 4px 6px;
  gap: 4px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.scrollable-tabs { overflow-x: auto; scrollbar-width: none; }
.scrollable-tabs::-webkit-scrollbar { display: none; }
/* 드롭다운 필터 행: 줄바꿈 허용 */
.flt-row-wrap { flex-wrap: wrap; align-items: center; row-gap: 4px; }

.search-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 6px 10px;
  color: #e0d8d0;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: background 0.15s;
}
.search-input:focus { background: rgba(255,255,255,0.12); }
.search-input::placeholder { color: rgba(255,255,255,0.3); }

.tab-bar {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
}
.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.55);
  border-radius: 6px;
  padding: 6px 13px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.tab-btn:hover { background: rgba(255,255,255,0.09); color: #fff; }
.tab-btn.active { background: rgba(62,64,229,0.38); color: #c0c8ff; font-weight: 700; }
.tab-btn.hidden { display: none !important; }

/* 포맷 탭 (정규/야생) — 카드 목록 전용 */
.format-tabs { gap: 5px; }
.format-tabs .tab-btn {
  font-size: 13px;
  padding: 6px 20px;
}
.format-tabs .tab-btn.active {
  background: rgba(44, 160, 80, 0.45);
  color: #a0ffb8;
}

/* ── 인라인 필터 바 (비용·유형 등) ─────────────────────────────── */
.inline-filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.inline-filter-bar::-webkit-scrollbar { display: none; }
.inline-label {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  margin-right: 2px;
  flex-shrink: 0;
}
.icost-btn, .itype-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.6);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  min-width: 34px;
  text-align: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.icost-btn:hover, .itype-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.icost-btn.active, .itype-btn.active {
  background: rgba(62,64,229,0.45);
  color: #c0c8ff;
  font-weight: 700;
}

/* 드롭다운 버튼 */
.flt-wrap { position: relative; }
.flt-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.65);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
.flt-btn:hover { background: rgba(255,255,255,0.14); }
.flt-btn.filtered { background: rgba(62,64,229,0.3); color: #c0c8ff; }
.flt-arrow { font-size: 9px; }
.flt-reset {
  background: transparent;
  color: rgba(255,255,255,0.35);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
  margin-left: auto;
}
.flt-reset:hover { color: #fff; }

.count-info {
  flex-shrink: 0;
  padding: 3px 8px;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ══════════════════════════════════════════════════════════════════════
   카드 목록
   ══════════════════════════════════════════════════════════════════════ */
.card-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.card-list::-webkit-scrollbar { width: 4px; }
.card-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ── 목록형 카드 (crop) — Simplestone 구조 그대로 ─────────────── */
.card {
  position: relative;
  overflow: hidden;
  margin-bottom: 2px;
  width: 100%;
  height: 40px;
  background-color: #2a2a35;
  background-repeat: no-repeat;
  background-position: right 8px top 0px; /* 우측 끝에서 8px 여백 */
  background-size: auto 40px;
  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.card:hover {
  box-shadow: 0 0 1px #fff, 0 0 2px #fff, 0 0 4px #228DFF,
              0 0 7px #228DFF, 0 0 10px #228DFF;
  outline-color: #228DFF;
}

/* 카드 코스트 — float:left (Simplestone 방식) */
.card_cost {
  float: left;
  width: 30px;
  height: 40px;
  color: #fff;
  text-shadow: 0 -1px #000, 1px -1px #000, 1px 0 #000, 1px 1px #000,
               0 1px #000, -1px 1px #000, -1px 0 #000, -1px -1px #000;
  font-size: 20px;
  line-height: 40px;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

/* 카드 이름 — display:table (Simplestone 방식) */
.card_name {
  display: table;
  overflow: hidden;
  margin-top: -1px;
  padding-left: 5px;
  width: calc(100% - 50px);
  height: 42px;
  background: linear-gradient(
    to right,
    rgba(50,50,60,1) 0%,
    rgba(50,50,60,1) calc(100% - 100px),
    rgba(50,50,60,0) 100%
  );
  box-sizing: border-box;
  color: #fff;
  text-shadow: 0 -1px #000, 1px -1px #000, 1px 0 #000, 1px 1px #000,
               0 1px #000, -1px 1px #000, -1px 0 #000, -1px -1px #000;
  font-size: 13px;
  line-height: 20px;
  letter-spacing: -0.5px;
  pointer-events: none;
  user-select: none;
}
.card_name p {
  display: table-cell;
  height: 100%;
  font-size: 13px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 장수 표시 — 우측 고정 (Simplestone 방식) */
.card_quantity {
  position: absolute;
  right: 0; top: 0;
  width: 30px;
  height: 40px;
  background-color: #000;
  color: gold;
  font-size: 16px;
  line-height: 40px;
  text-align: center;
  pointer-events: none;
  user-select: none;
}
.card_quantity.hidden { display: none; }
.card_quantity--legend {
  color: #f5c842;
  font-size: 16px;
  line-height: 40px;
  background: #000;
}

/* 라이브러리에서 꽉 찬 카드(unusable 없음) → cursor만 변경, 색은 유지 */
#builder-card-list .card:not(.unusable):not(.tourist-blocked) { cursor: default; }

/* DK 룬 비용 표시 (카드 좌측 하단) */
.card_rune_cost {
  position: absolute;
  left: 2px;
  bottom: 2px;
  display: flex;
  gap: 1px;
  pointer-events: none;
  z-index: 3;
}
.mini-rune {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.4);
}
.mini-rune-blood  { background: #c44; }
.mini-rune-frost  { background: #46c; }
.mini-rune-unholy { background: #4a8; }

/* 룬 차단 카드 (왼쪽 패널) — 크림슨 */
#builder-card-list .card.rune-blocked .card_cost { background-color: #7a1a1a !important; }
#builder-card-list .card.rune-blocked .card_name {
  background: linear-gradient(
    to right,
    rgba(120,20,20,0.95) 0%,
    rgba(120,20,20,0.95) calc(100% - 80px),
    rgba(120,20,20,0) 100%
  ) !important;
}
#builder-card-list .card.rune-blocked { cursor: not-allowed; }

/* 덱 패널: 룬 충돌 카드 크림슨 표시 */
#deck-list .card.rune-conflict .card_cost { background-color: #7a1a1a !important; }
#deck-list .card.rune-conflict .card_name {
  background: linear-gradient(
    to right,
    rgba(120,20,20,0.95) 0%,
    rgba(120,20,20,0.95) calc(100% - 80px),
    rgba(120,20,20,0) 100%
  ) !important;
}
#deck-list .card.rune-conflict { cursor: pointer; }

/* 덱 패널: 정규 포맷 사용 불가 카드 크림슨 표시 */
#deck-list .card.format-illegal .card_cost { background-color: #7a1a1a !important; }
#deck-list .card.format-illegal .card_name {
  background: linear-gradient(
    to right,
    rgba(120,20,20,0.95) 0%,
    rgba(120,20,20,0.95) calc(100% - 80px),
    rgba(120,20,20,0) 100%
  ) !important;
}
#deck-list .card.format-illegal { cursor: pointer; }

/* 관광객 차단 카드 */
.card.tourist-blocked .card_cost { background-color: #7a1a1a !important; }
.card.tourist-blocked .card_name {
  background: linear-gradient(
    to right,
    rgba(80,10,10,0.95) 0%,
    rgba(80,10,10,0.95) calc(100% - 100px),
    rgba(80,10,10,0) 100%
  ) !important;
}
.card.tourist-blocked { cursor: not-allowed; }

/* 카드 제거 버튼 (질리악스/ETC 전용) */
.card-remove-btn {
  position: absolute;
  right: 22px; top: 50%;
  transform: translateY(-50%);
  background: rgba(180,30,30,0.7);
  color: #fff;
  border-radius: 3px;
  width: 18px; height: 18px;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.12s;
}
.card:hover .card-remove-btn { opacity: 1; }

/* ── 일러스트형 카드 (illust) ────────────────────────────────────── */
.card-list.illust-view {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0;
  padding: 4px;
  background: #1a1a1a;
}
.card-list.illust-view .card-illust {
  width: calc(25% - 1px);
  aspect-ratio: 170 / 247;
  flex-shrink: 0;
  overflow: hidden;
  background-color: #1a1a1a;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.card-list.illust-view .card-illust:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.7);
  z-index: 2;
}

/* illust 카드: 꽉 찬 카드 → 어둡게 */
#builder-card-list .card-illust:not(.unusable):not(.tourist-blocked) { filter: brightness(0.45); cursor: default; }
#builder-card-list .card-illust:not(.unusable):not(.tourist-blocked):hover { filter: brightness(0.5); }
.card-illust.tourist-blocked { filter: brightness(0.45) sepia(60%) hue-rotate(-20deg) !important; cursor: not-allowed; }

/* ── 덱 패널 카드 그룹 ──────────────────────────────────────────── */
.card-group { overflow: hidden; }
.card-group--sig .card { opacity: 0.95; }
.sub-card-wrap { padding-left: 12px; background: rgba(0,0,0,0.2); }
.sub-card-wrap .card { height: 32px; margin-bottom: 0; }
.sub-card-wrap .card_cost { width: 24px; height: 32px; font-size: 13px; line-height: 32px; }
.sub-card-wrap .card_name { height: 33px; font-size: 11px; }

/* ══════════════════════════════════════════════════════════════════════
   덱 패널 스타일
   ══════════════════════════════════════════════════════════════════════ */
#deck-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
#deck-hero-img {
  width: 52px;
  height: 52px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: transparent;
  flex-shrink: 0;
  z-index: 1;
  cursor: pointer;
  transition: filter 0.15s;
}
#deck-hero-img:hover { filter: brightness(1.2); }
.deck-fmt-label-text {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-left: 2px;
}
#deck-header-info { flex: 1; min-width: 0; z-index: 1; }
/* 우측 영웅 크롭 이미지 */
#deck-hero-crop {
  flex-shrink: 0;
  width: 220px;
  height: 66px;
  background-size: auto 100%;
  background-position: center center;
  background-repeat: no-repeat;
  border-radius: 4px;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.6) 30%, #000 100%);
  mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.6) 30%, #000 100%);
  z-index: 1;
}
/* 덱 이름 행 */
#deck-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-bottom: 2px;
}
#deck-name-display {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  cursor: default;
}
#deck-name-edit-btn {
  flex-shrink: 0;
  background: none;
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s;
}
#deck-name-edit-btn:hover { color: rgba(255,255,255,0.8); }
#deck-name-input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  outline: none;
}
#deck-name-input:focus { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.14); }

/* 직업명 + 구분자 */
#deck-class-name {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}
.deck-info-sep {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
}
#deck-count-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
#deck-count {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}
.deck-fmt-trig {
  font-size: 11px;
  padding: 3px 8px;
  color: rgba(255,255,255,0.6);
  border-color: rgba(255,255,255,0.12);
}
.deck-fmt-trig:hover { color: rgba(255,255,255,0.9); }
.flt-popup--deck-fmt { min-width: 90px; }

/* 가루 표시 */
#deck-dust-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  font-size: 11px;
}
.dust-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
  user-select: none;
}
#deck-dust-real { color: #ffd66a; font-weight: 700; }
.dust-loaner {
  color: rgba(255,214,106,0.55);
  font-size: 10px;
}
.dust-loaner.hidden { display: none !important; }

/* ── DK 룬 선택기 ──────────────────────────────────────────────── */
#dk-rune-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
#dk-rune-row.hidden { display: none !important; }
.dk-rune-label {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  flex-shrink: 0;
}
#dk-rune-pips {
  display: flex;
  gap: 4px;
}
.rune-pip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  padding: 0;
  background-color: transparent;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.1s, border-color 0.15s;
}
.rune-pip:hover {
  transform: scale(1.15);
  border-color: rgba(255,255,255,0.7);
}
/* 'none' 슬롯 — 원본 이미지(144×144) 없음. 동일 크기 자리만 비워둠. */
.rune-pip-empty {
  background-color: rgba(255,255,255,0.04);
  border-style: dashed;
  border-color: rgba(255,255,255,0.2);
}
/* 룬 호환 불가 카드 */
.card.rune-blocked { opacity: 1; }

/* 덱 목록 스크롤 영역 */
#deck-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
#deck-list::-webkit-scrollbar { width: 3px; }
#deck-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }

/* ── 마나 곡선 ──────────────────────────────────────────────────── */
#mana-curve-wrap {
  flex-shrink: 0;
  padding: 8px 10px 6px;
}
.panel-label {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  font-weight: 700;
}
#mana-curve {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.curve-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 54px;
}
.curve-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  gap: 2px;
}
.curve-bar-count {
  font-size: 9px;
  color: rgba(255,255,255,0.5);
  line-height: 1;
}
.curve-bar {
  width: 100%;
  background: linear-gradient(180deg, #5a7ee8 0%, #3e40e5 100%);
  border-radius: 3px 3px 0 0;
  min-height: 0;
  transition: height 0.2s;
}
.curve-bar.empty { background: rgba(255,255,255,0.1); height: 3px !important; }
.curve-labels {
  display: flex;
  gap: 3px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 3px;
}
.curve-labels span {
  flex: 1;
  text-align: center;
  font-size: 9px;
  color: rgba(255,255,255,0.35);
}

/* ── 카드 유형 분포 ─────────────────────────────────────────────── */
#type-dist-wrap {
  flex-shrink: 0;
  padding: 6px 10px 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 4px;
}
#type-dist { display: flex; flex-direction: column; gap: 4px; }
.type-item {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 14px;
}
.type-label {
  width: 36px;
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  flex-shrink: 0;
  text-align: right;
}
.type-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  overflow: hidden;
}
.type-bar {
  height: 100%;
  border-radius: 3px;
  background: rgba(90,126,232,0.7);
  width: 0%;
  transition: width 0.25s;
  display: block;
}
.type-count {
  width: 18px;
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  text-align: right;
  flex-shrink: 0;
}

/* 덱 코드 영역 */
#deck-code-wrap { flex-shrink: 0; padding: 6px; }
#deck-code-area {
  width: 100%;
  height: 64px;
  background: rgba(0,0,0,0.3);
  color: #e0d8d0;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 10px;
  font-family: monospace;
  resize: none;
  outline: none;
}

/* 덱 액션 버튼 */
#deck-actions {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  flex-shrink: 0;
}
.btn-save {
  background: rgba(62,64,229,0.35);
  color: #c0c8ff;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-save:hover { background: rgba(62,64,229,0.55); }

/* ── 공통 버튼 ──────────────────────────────────────────────────── */
.btn-primary {
  flex: 1;
  background: rgba(62,64,229,0.35);
  color: #c0c8ff;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: rgba(62,64,229,0.55); }
.btn-primary:disabled { opacity: 0.35; cursor: default; }
.btn-secondary {
  flex: 1;
  background: rgba(255,255,255,0.1);
  color: #e0d8d0;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.18); }
.btn-secondary:disabled { opacity: 0.35; cursor: default; }
.btn-danger {
  flex: 1;
  background: rgba(200,60,60,0.25);
  color: #f08080;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(200,60,60,0.45); }

/* ══════════════════════════════════════════════════════════════════════
   드롭다운 팝업
   ══════════════════════════════════════════════════════════════════════ */
.flt-popup {
  display: none;
  position: fixed;
  z-index: 500;
  background: #2e2c29;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  min-width: 120px;
  max-width: 220px;
}
.flt-popup.open { display: block; }
.flt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
}
.flt-chip {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  min-width: 32px;
  text-align: center;
}
.flt-chip:hover { background: rgba(255,255,255,0.15); color: #fff; }
.flt-chip.active { background: rgba(62,64,229,0.45); color: #c0c8ff; font-weight: 700; }
.flt-list { display: flex; flex-direction: column; padding: 4px; max-height: 260px; overflow-y: auto; }
.flt-list::-webkit-scrollbar { width: 3px; }
.flt-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.flt-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  width: 100%;
}
.flt-option:hover { background: rgba(255,255,255,0.08); color: #fff; }
.flt-option.active { background: rgba(62,64,229,0.35); color: #c0c8ff; font-weight: 600; }

/* — 초기화 옵션 */
.flt-clear {
  color: rgba(255,255,255,0.28) !important;
  font-size: 13px;
  letter-spacing: 2px;
  justify-content: center;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 3px;
  padding-bottom: 5px !important;
}
.flt-clear:hover { color: rgba(255,255,255,0.6) !important; background: rgba(255,255,255,0.05) !important; }

/* 정렬 팝업 */
.flt-popup--sort { min-width: 160px; }
/* 직업별 체크박스 토글 */
.sort-class-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; font-size: 12px;
  color: rgba(255,255,255,0.55);
  background: transparent; border: none; border-radius: 5px;
  cursor: pointer; white-space: nowrap; width: 100%;
}
.sort-class-toggle::before { content: '☐'; width: 14px; flex-shrink: 0; font-size: 13px; }
.sort-class-toggle.active { color: #a0ffb8; }
.sort-class-toggle.active::before { content: '☑'; color: #a0ffb8; }
.sort-class-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }
/* 구분선 */
.sort-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 3px 6px; }
/* 정렬 기준 옵션 (라디오 스타일) */
.sort-option {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; font-size: 12px;
  color: rgba(255,255,255,0.7);
  background: transparent; border: none; border-radius: 5px;
  cursor: pointer; white-space: nowrap; width: 100%;
}
.sort-option::before { content: ''; width: 12px; flex-shrink: 0; }
.sort-option.active::before { content: '✓'; color: #a0ffb8; }
.sort-option:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sort-option.active { color: #a0ffb8; }

/* 카운트+정렬 행 */
.count-sort-row { justify-content: space-between; padding: 2px 6px; }
.count-sort-row .count-info { padding: 0; }
.sort-trig { font-size: 11px; padding: 4px 8px; color: rgba(255,255,255,0.5); }
.sort-trig:hover { color: rgba(255,255,255,0.9); }

/* 희귀도 점 */
.rarity-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rarity_FREE, .rarity_COMMON  { background-color: #5a5a5a; }
.rarity_RARE                   { background-color: #1a4f82; }
.rarity_EPIC                   { background-color: #6a3a9a; }
.rarity_LEGENDARY              { background-color: #c8880a; }

/* ══════════════════════════════════════════════════════════════════════
   모달
   ══════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: #2a2825;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  width: min(400px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.7);
}
.modal-wide { width: min(640px, 96vw); }
.modal-class { width: min(480px, 96vw); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.modal-close {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
  border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.18); color: #fff; }
.modal textarea {
  flex: 1;
  background: rgba(0,0,0,0.2);
  color: #e0d8d0;
  padding: 12px;
  font-size: 12px;
  font-family: monospace;
  resize: none;
  min-height: 90px;
  outline: none;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  gap: 8px;
}
.modal-footer button {
  background: rgba(62,64,229,0.4);
  color: #c0c8ff;
  border-radius: 7px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.modal-footer button:hover:not(:disabled) { background: rgba(62,64,229,0.65); }
.modal-footer button:disabled { opacity: 0.35; cursor: default; }
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

/* 이미지 저장 프리뷰 모달 — 덱 이미지 너비(300px)에 맞게 */
.modal-export-preview {
  width: min(300px, 92vw);
}
.export-preview-body {
  padding: 0;
  overflow-y: auto;
  max-height: 70vh;
}
.export-preview-body img {
  display: block;
  width: 100%;
  height: auto;
}

.modal-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 10px;
}
.modal-search {
  width: 100%;
  background: rgba(255,255,255,0.07);
  color: #e0d8d0;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  margin-bottom: 8px;
  display: block;
}
.modal-search:focus { background: rgba(255,255,255,0.12); }

/* "새 덱 만들기" — 포맷 선택 영역 (screen-class-select 상단) */
.format-select-section {
  width: 100%;
  max-width: 460px;
  margin: 0 auto 18px;
}
.format-select-label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}
.class-select-step-label {
  margin-top: 4px;
}
.format-select-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.format-select-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  background: rgba(255,255,255,0.05);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.format-select-btn img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  pointer-events: none;
}
.format-select-btn span {
  font-size: 12px;
  font-weight: 700;
  color: #e0d8d0;
}
.format-select-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}
.format-select-btn.active {
  background: rgba(62,64,229,0.25);
  border-color: rgba(120,140,255,0.7);
}

/* 직업 그리드 비활성화 상태 (포맷 미선택) */
.modal-class-grid.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.6);
}

/* 모달 내 직업 그리드 */
.modal-class-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.modal-class-btn {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  aspect-ratio: 3 / 4;
  cursor: pointer;
  background-size: 260%;
  background-position: center 15%;
  background-color: #2a2825;
  border: 2px solid transparent;
  transition: border-color 0.12s, transform 0.12s;
  display: flex;
  align-items: flex-end;
}
.modal-class-btn:hover {
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-2px);
}
.modal-class-btn .class-btn-label {
  width: 100%;
  text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,0.82));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 12px 2px 5px;
}

/* 질리악스 모듈 그리드 */
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.module-card {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  border: 2px solid transparent;
  transition: border-color 0.12s, background 0.12s;
}
.module-card:hover { background: rgba(255,255,255,0.1); }
.module-card.selected { border-color: #5a7ee8; background: rgba(62,64,229,0.2); }
.module-card.disabled { opacity: 0.4; cursor: default; }
.module-card img { width: 100%; border-radius: 4px; margin-bottom: 6px; display: block; }
.module-name { font-size: 13px; color: #fff; font-weight: 600; }

/* ETC 카드 목록 */
.modal-card-list { display: flex; flex-direction: column; gap: 2px; }
.modal-card-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.modal-card-entry:hover { background: rgba(255,255,255,0.08); }
.modal-card-entry.selected { background: rgba(62,64,229,0.2); }
.modal-card-entry.dimmed { opacity: 0.4; cursor: default; }
.modal-card-cost {
  width: 28px; height: 28px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.modal-card-name { flex: 1; font-size: 12px; color: #e0d8d0; }
.modal-card-check {
  width: 18px;
  font-size: 13px;
  color: #5a7ee8;
  text-align: center;
  flex-shrink: 0;
}
.modal-more-hint {
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  padding: 8px 0;
}

/* ══════════════════════════════════════════════════════════════════════
   인라인 편집 패널 (질리악스 스킨/모듈) — 카드 패널과 교체
   ══════════════════════════════════════════════════════════════════════ */
#inline-editor-panel {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 10px 12px;
  gap: 8px;
}
#inline-editor-panel.hidden { display: none; }
/* 인라인 편집(질리악스) 진입 시 카드 목록 패널을 완전히 숨김 */
#builder-card-panel.hidden { display: none !important; }

.ied-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ied-back {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
}
.ied-back:hover { background: rgba(255,255,255,0.15); }
.ied-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.ied-steps {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}
.ied-step {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  transition: all 0.12s;
}
.ied-step.active {
  color: #fff;
  background: rgba(90,126,232,0.25);
  font-weight: 700;
}
.ied-step-sep { color: rgba(255,255,255,0.25); }

.ied-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.ied-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.ied-body > .hidden { display: none; }

/* 스킨 그리드 — 2~3열, 풀 카드 일러스트 */
.ied-skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  padding: 4px 2px;
}
.ied-skin-card {
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ied-skin-card:hover {
  background: rgba(255,255,255,0.08);
  transform: translateY(-2px);
}
.ied-skin-card.selected {
  border-color: #5a7ee8;
  background: rgba(62,64,229,0.22);
}
.ied-skin-card img {
  width: 100%;
  border-radius: 6px;
  display: block;
}
.ied-skin-card .skin-tag {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  font-weight: 600;
}
.ied-skin-card.default .skin-tag { color: #f5c74e; }

/* ── 질리악스 스킨/모듈 — 목록형 행 (카드 리스트 `.card` 와 동일 구조) ─ */
.ied-list-row {
  position: relative;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  margin-bottom: 2px;
  width: 100%;
  height: 40px;
  background-color: #2a2a35;
  background-repeat: no-repeat;
  background-position: right 0%;
  background-size: auto 40px;
  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.ied-list-row:hover {
  box-shadow: 0 0 1px #fff, 0 0 2px #fff, 0 0 4px #228DFF,
              0 0 7px #228DFF, 0 0 10px #228DFF;
  outline-color: #228DFF;
}
.ied-list-row.selected {
  outline: 2px solid #5a7ee8;
  outline-offset: -2px;
}
.ied-list-row.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* 비용 박스 (좌측) — `.card_cost` 와 동일 수치 */
.ied-list-cost {
  flex-shrink: 0;
  width: 30px;
  height: 40px;
  color: #fff;
  text-shadow: 0 -1px #000, 1px -1px #000, 1px 0 #000, 1px 1px #000,
               0 1px #000, -1px 1px #000, -1px 0 #000, -1px -1px #000;
  font-size: 20px;
  line-height: 40px;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

/* 이름 (가운데) — `.card_name` 과 동일 그라디언트·패딩 */
.ied-list-name {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding-left: 5px;
  height: 40px;
  background: linear-gradient(
    to right,
    rgba(50,50,60,1) 0%,
    rgba(50,50,60,1) calc(100% - 100px),
    rgba(50,50,60,0) 100%
  );
  box-sizing: border-box;
  color: #fff;
  text-shadow: 0 -1px #000, 1px -1px #000, 1px 0 #000, 1px 1px #000,
               0 1px #000, -1px 1px #000, -1px 0 #000, -1px -1px #000;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
  user-select: none;
}

/* 뱃지 (우측) — "기본" 또는 선택 순번 1/2, `.card_quantity` 위치에 맞춤 */
.ied-list-badge {
  position: absolute;
  right: 0; top: 0;
  width: 30px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #f5c74e;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  z-index: 2;
}
.ied-list-badge--sel {
  color: #fff;
  background: #3e40e5;
  font-size: 16px;
}

/* 리스트 컨테이너 — 세로 목록 (기존 grid 오버라이드) */
#inline-editor-panel .ied-skin-grid,
#inline-editor-panel .module-grid {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  gap: 0;
}
/* `.hidden` 우선 적용 (higher specificity 필요) */
#inline-editor-panel .ied-skin-grid.hidden,
#inline-editor-panel .module-grid.hidden {
  display: none !important;
}

.ied-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.ied-footer button { min-width: 76px; }
.ied-footer .hidden { display: none; }

/* ── ETC 편집 하단 바 ─────────────────────────────────────────────── */
.etc-edit-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(62,64,229,0.15);
  border-top: 1px solid rgba(90,126,232,0.35);
  flex-shrink: 0;
}
.etc-edit-bar.hidden { display: none !important; }
.etc-edit-label {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.etc-edit-count {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  margin-right: auto;
}
.etc-edit-bar button {
  min-width: 64px;
  padding: 6px 10px;
  font-size: 12px;
}

/* ETC 편집 중 — 카드 상태 시각 표시
   ─ etc-banned  : 고정 금지 (ETC 자체/질리악스/개전/관광객/갈라크론드/레나탈 등)
                   → 빨간 "금지" 라벨 + 크림슨 톤
   ─ etc-rune    : DK 룬 비호환 → 크림슨 톤만 (라벨 없음)
   ─ etc-maxed   : 덱+ETC 합산 최대치 도달 → 일반 "꽉 찬 카드" 시각과 동일 (라벨 없음)
   ─ etc-pending : 선택된 카드 → 파란 아웃라인 */
#builder-card-panel.etc-edit-mode .card.etc-banned,
#builder-card-panel.etc-edit-mode .card-illust.etc-banned,
#builder-card-panel.etc-edit-mode .card.etc-rune,
#builder-card-panel.etc-edit-mode .card-illust.etc-rune {
  cursor: not-allowed;
  position: relative;
}
#builder-card-panel.etc-edit-mode .card.etc-banned .card_cost,
#builder-card-panel.etc-edit-mode .card-illust.etc-banned .card_cost,
#builder-card-panel.etc-edit-mode .card.etc-rune .card_cost,
#builder-card-panel.etc-edit-mode .card-illust.etc-rune .card_cost {
  background-color: #7a1a1a !important;
}
#builder-card-panel.etc-edit-mode .card.etc-banned .card_name,
#builder-card-panel.etc-edit-mode .card-illust.etc-banned .card_name,
#builder-card-panel.etc-edit-mode .card.etc-rune .card_name,
#builder-card-panel.etc-edit-mode .card-illust.etc-rune .card_name {
  background: linear-gradient(
    to right,
    rgba(120,20,20,0.95) 0%,
    rgba(120,20,20,0.95) calc(100% - 80px),
    rgba(120,20,20,0) 100%
  ) !important;
}
/* "금지" 라벨은 고정 금지(ETC_BANNED_IDS)에만 표시 */
#builder-card-panel.etc-edit-mode .card.etc-banned::after,
#builder-card-panel.etc-edit-mode .card-illust.etc-banned::after {
  content: '금지';
  position: absolute;
  top: 4px; right: 4px;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(120,20,20,0.95);
  color: #fff;
  border-radius: 3px;
  z-index: 2;
}
#builder-card-panel.etc-edit-mode .card.etc-pending,
#builder-card-panel.etc-edit-mode .card-illust.etc-pending {
  outline: 2px solid #5a7ee8;
  outline-offset: -2px;
}
/* ETC 편집 중에는 기존 unusable/최대도달 반투명 덮기 해제
   (단, etc-banned / etc-rune / etc-maxed 는 시각 유지) */
#builder-card-panel.etc-edit-mode .card:not(.etc-banned):not(.etc-rune):not(.etc-maxed),
#builder-card-panel.etc-edit-mode .card-illust:not(.etc-banned):not(.etc-rune):not(.etc-maxed) {
  opacity: 1;
  filter: none;
  cursor: pointer;
}
/* etc-maxed: 일반 꽉 찬 카드 시각과 동일 — illust 뷰 디밍 유지 */
#builder-card-panel.etc-edit-mode .card-illust.etc-maxed {
  filter: brightness(0.45);
  cursor: not-allowed;
}
#builder-card-panel.etc-edit-mode .card.etc-maxed {
  cursor: not-allowed;
}

/* ══════════════════════════════════════════════════════════════════════
   모바일 미리보기 오버레이
   ══════════════════════════════════════════════════════════════════════ */
#mobile-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mobile-preview-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  max-width: 300px;
  width: 100%;
}
#mobile-preview-img {
  max-width: 240px;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}
#mobile-preview-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-align: center;
}
#mobile-preview-set {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}
#mobile-preview-close {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 20px;
  padding: 8px 24px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════════════
   토스트
   ══════════════════════════════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,28,26,0.92);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(-50%) translateY(8px); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════════════
   반응형 — 모바일에서 미리보기 패널 숨김
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .preview-panel { display: none !important; }
  #stats-panel { width: 130px; }
  #class-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  #screen-builder { flex-direction: column; }
  #deck-panel {
    flex: none;
    width: 100%;
    height: 260px;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.06);
    overflow-y: auto;
  }
  #stats-panel { display: none; }
  #class-grid { grid-template-columns: repeat(3, 1fr); }
  .modal-class-grid { grid-template-columns: repeat(3, 1fr); }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .card-list.illust-view .card-illust { width: calc(50% - 1px); }
}
