/* 캐릭터 만들기 (chareditor.js). style.css 의 변수/.btn/.panel/.gfx-chip/.stat 을 그대로 사용 */
#char-editor-root { position: fixed; inset: 0; z-index: 15; }
.ce {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 316px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: 'top top top' 'left stage right';
  background: #bfe3ff;
  font-family: var(--font-ui);
  color: var(--ink);
  user-select: none;
  word-break: keep-all; /* 한글 낱말 중간에서 줄 바꾸지 않게 */
  overflow-wrap: break-word;
}
.ce-off { display: none !important; }
.ce kbd { font-size: 11px; padding: 0 5px; }

/* 상단 막대 (노치 화면이면 안전 영역만큼 띄움) */
.ce-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: var(--panel);
  border-bottom: 3px solid #fff;
  box-shadow: 0 4px 18px rgba(0, 30, 80, 0.2);
  z-index: 3;
  overflow-x: auto;
  scrollbar-width: none;
}
.ce-top .btn { min-height: 42px; white-space: nowrap; flex: none; }
.ce-top .ce-ico { min-width: 42px; font-size: 18px; padding: 6px 10px; }
.ce-title { font-family: var(--font-kr); font-weight: 400; font-size: 22px; margin: 0 4px; white-space: nowrap; }
.ce-gap { flex: 1; }
.ce-modes { display: flex; gap: 3px; padding: 3px; background: #e6ebf8; border-radius: 14px; flex: none; }
.ce-mode {
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  border: 0;
  border-radius: 11px;
  padding: 8px 14px;
  background: transparent;
  color: #5b6488;
  cursor: pointer;
  white-space: nowrap;
}
.ce-mode.on { background: #fff; color: var(--blue); box-shadow: 0 2px 6px rgba(0, 30, 80, 0.18); }
.ce-mode[data-mode='paint'].on { color: #d6337a; }
/* 편집 버튼 ~ 「새로 만들기」 묶음 (chareditor.js buildCompact): 넓은 화면은 그대로, 휴대폰은 「⋯」 메뉴 */
.ce-tmore { display: contents; }
.ce-top .ce-morebtn { display: none; }

/* 양쪽 패널 */
.ce-left, .ce-right {
  background: var(--panel);
  overflow-y: auto;
  padding: 2px 14px max(18px, env(safe-area-inset-bottom));
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.ce-left { grid-area: left; border-right: 4px solid #fff; box-shadow: 6px 0 20px rgba(0, 30, 80, 0.14); padding-left: max(14px, env(safe-area-inset-left)); }
.ce-right { grid-area: right; border-left: 4px solid #fff; box-shadow: -6px 0 20px rgba(0, 30, 80, 0.14); padding-right: max(14px, env(safe-area-inset-right)); }
/* 패널 탭 (좁은 화면에서만 보임) */
.ce-tabs { display: none; }
.ce[data-mode='build'] .ce-paint, .ce[data-mode='paint'] .ce-build { display: none; }
.ce-sec { padding: 11px 0; border-bottom: 2px solid #eef1fb; }
.ce-sec:last-child { border-bottom: none; }
.ce-sec h3 { margin: 0 0 8px; font-family: var(--font-kr); font-weight: 400; font-size: 18px; display: flex; align-items: baseline; gap: 6px; }
.ce-sec h3 small { font-family: var(--font-ui); font-size: 12px; color: #8a93b3; font-weight: 800; }
.ce-note { margin: 6px 0 0; font-size: 12px; color: #6a7396; line-height: 1.45; font-weight: 600; }
.ce-wide { width: 100%; }
.ce-sheet { display: none; }

/* 라이브러리 */
.ce-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.ce-card, .ce-tool {
  font: inherit;
  border: 2px solid transparent;
  background: #f1f4fc;
  border-radius: 12px;
  padding: 6px 2px 4px;
  min-height: 52px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--ink);
  transition: transform 0.08s, background 0.15s;
}
.ce-card span, .ce-tool span { font-size: 21px; line-height: 1.15; }
.ce-card small, .ce-tool small { font-size: 10.5px; font-weight: 800; color: #5a6385; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ce-card:hover, .ce-tool:hover { background: #fff; border-color: #9fb3e6; transform: translateY(-1px); }
.ce-card:active, .ce-tool:active { transform: translateY(1px); }
.ce-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; }
.ce-tool.on { background: linear-gradient(180deg, #ff6fb0, #e8357e); border-color: #e8357e; }
.ce-tool.on small { color: #fff; }

/* 슬라이더/체크 */
.ce-slider { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 8px; margin: 5px 0; font-size: 12px; font-weight: 800; color: #5a6385; }
.ce-slider b { font-size: 11px; color: var(--ink); min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.ce-slider input[type='range'], .ce-hue { width: 100%; padding: 0; border: 0; accent-color: var(--blue); background: transparent; height: 24px; }
.ce-check { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: #3a4466; margin: 7px 0; cursor: pointer; }
.ce-check input { width: 18px; height: 18px; padding: 0; accent-color: var(--blue); }
.ce-gloss { display: none; padding-left: 4px; }
.ce.ce-glossy .ce-gloss { display: block; }
.ce .ce-spray-only { display: none; }
.ce[data-tool='spray'] .ce-spray-only { display: grid; }

/* 색 고르기 */
.ce-picker { display: flex; flex-direction: column; gap: 6px; }
.ce-sv { width: 100%; height: 118px; border-radius: 10px; cursor: crosshair; touch-action: none; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.06); }
.ce-hue {
  -webkit-appearance: none;
  appearance: none;
  height: 16px !important;
  border-radius: 8px;
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00) !important;
}
.ce-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.ce-hue::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
.ce-cur { display: flex; align-items: center; gap: 6px; }
.ce-cur i { width: 36px; height: 36px; border-radius: 10px; flex: none; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.12); }
.ce-cur input { flex: 1; min-width: 0; font-family: var(--font-num); letter-spacing: 1px; padding: 7px 9px; font-size: 14px; }
.ce-cur .btn { padding: 7px 11px; }
.ce-pal-title { font-size: 11px; font-weight: 800; color: #6a7396; margin: 9px 0 4px; }
.ce-pal-title small { font-weight: 600; color: #9aa2bd; }
.ce-pal { display: flex; flex-wrap: wrap; gap: 4px; }
.ce-sw {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d5dbef;
  cursor: pointer;
  padding: 0;
  transition: transform 0.08s;
}
.ce-sw:hover { transform: scale(1.12); }
.ce-sw.on { box-shadow: 0 0 0 2px var(--blue); }
.ce-empty { font-size: 11px; color: #9aa2bd; font-weight: 700; }
.ce-kart { align-items: center; }
.ce-kart input[type='color'] { width: 34px; height: 28px; padding: 0 2px; border-radius: 8px; cursor: pointer; }

/* 캐릭터 정보 */
.ce-field { display: flex; flex-direction: column; gap: 5px; font-weight: 800; font-size: 12px; color: #5a6385; margin: 6px 0; }
.ce-field > input { padding: 8px 10px; font-size: 15px; }
.ce-stats { margin-top: 4px; } /* 차량 에디터 능력치 보정 */

/* 선택한 부품 */
.ce-kind { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; font-weight: 800; margin: 4px 0 6px; }
.ce-btns { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.ce-btns .btn { flex: 1 1 auto; }
.ce-btns.ce-acts { display: grid; grid-template-columns: 1fr 1.6fr auto auto; }
.ce-btns.ce-acts .btn { padding: 7px 8px; white-space: nowrap; }
.ce .btn.ce-danger { background: #ffe4e2; color: #c0261e; }
.ce-xyz { display: grid; grid-template-columns: 30px repeat(3, minmax(0, 1fr)) 18px; gap: 4px; align-items: center; margin: 5px 0; }
.ce-xyz-l { font-size: 12px; font-weight: 800; color: #5a6385; }
.ce-xyz > small { font-size: 11px; font-weight: 800; color: #8a93b3; }
.ce-num { display: flex; align-items: center; background: #fff; border: 2px solid #d5dbef; border-radius: 9px; overflow: hidden; }
.ce-num b { font-size: 10px; padding: 0 3px 0 5px; }
.ce-num.axX b { color: #e8352e; }
.ce-num.axY b { color: #22a34a; }
.ce-num.axZ b { color: var(--blue); }
.ce-num input { border: 0; border-radius: 0; padding: 5px 2px; font-size: 13px; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
.ce-colrow { display: flex; gap: 5px; align-items: center; }
.ce-colrow input[type='color'] { width: 46px; height: 34px; padding: 0 2px; border-radius: 9px; cursor: pointer; flex: none; }
.ce-colrow .btn { flex: 1; }
.ce-roles { display: flex; flex-wrap: wrap; gap: 4px; }
.ce-roles .gfx-chip { font-size: 12px; }

/* 부품 목록 */
.ce-list { display: flex; flex-direction: column; gap: 3px; }
.ce-row {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 2px solid transparent;
  background: #f4f6fc;
  border-radius: 10px;
  padding: 5px 8px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.ce-row:hover { background: #fff; }
.ce-row.on { border-color: var(--blue); background: #fff; }
.ce-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.ce-rname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-row small { font-size: 12px; }
.ce-twin { color: var(--blue); font-weight: 900; }

/* 부품 그룹 (접히는 폴더) */
.ce-grp { display: flex; flex-direction: column; gap: 3px; border-radius: 12px; background: #eaf0fd; padding: 3px; }
.ce-grp.on { box-shadow: inset 0 0 0 2px var(--blue); }
.ce-grp.some { box-shadow: inset 0 0 0 2px #9fb3e6; }
.ce-ghead { display: flex; align-items: center; gap: 2px; }
.ce-gtog, .ce-gren {
  font: inherit;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: #5a6385;
  flex: none;
  min-width: 26px;
  min-height: 30px;
  padding: 0 4px;
  font-size: 13px;
}
.ce-gtog:hover, .ce-gren:hover { background: #fff; }
.ce-gren { font-size: 12px; opacity: 0.7; }
.ce-gname {
  font: inherit;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 5px 6px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}
.ce-gname:hover { background: #fff; }
.ce-grp.on .ce-gname { color: var(--blue); }
.ce-gico { flex: none; }
.ce-gcount { flex: none; font-size: 11px; font-weight: 800; color: #6a7396; background: #fff; border-radius: 8px; padding: 1px 7px; }
.ce-ginput { flex: 1; min-width: 0; padding: 5px 8px; font-size: 13px; font-weight: 800; }
.ce-gbody { display: flex; flex-direction: column; gap: 3px; padding-left: 14px; border-left: 2px solid #c9d4f0; margin-left: 12px; }
.ce-row.ce-in { background: #fff; }
.ce-row.ce-in.on { border-color: var(--blue); }
.ce-gsel { align-items: center; }
.ce-gfield { flex: 1 1 140px; display: flex; align-items: center; gap: 6px; font-size: 16px; min-width: 0; }
.ce-gfield input { flex: 1; min-width: 0; padding: 6px 9px; font-size: 14px; font-weight: 800; }
.ce .btn.ce-gchip { display: flex; align-items: center; gap: 2px; min-width: 0; max-width: 100%; background: #eaf0fd; }
.ce-gchip .ce-rname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-gchip small { flex: none; font-size: 11px; color: #5a6385; }

/* 상단 편집 버튼 (복사·붙여넣기·전체 선택·선택 해제): 아이콘 + 작은 글자 */
.ce-tsep { flex: none; width: 2px; align-self: stretch; margin: 6px 2px; border-radius: 1px; background: #e2e7f5; }
.ce-top .btn.ce-ebtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 50px; padding: 3px 7px; font-size: 16px; line-height: 1.05; }
.ce-ebtn small { font-size: 10px; font-weight: 800; color: #5a6385; white-space: nowrap; }

/* 저장 칸 (3D 모델 2개 · 직접 만들기 30개) */
.ce-slots { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 2px 0 6px; }
.ce-slots:empty { display: none; }
.ce-slotlbl { font-size: 11px; font-weight: 800; color: #8a93b3; margin-right: 2px; }
.ce-slot { font-size: 11.5px; font-weight: 800; color: #5a6385; background: #eef1fb; border-radius: 8px; padding: 2px 7px; white-space: nowrap; }
.ce-slot.cur { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px #9fb3e6; }
.ce-slot.full { color: #c0261e; }
.ce-slotwarn { font: inherit; flex: 1 1 100%; border: 0; border-radius: 9px; background: #ffe4e2; color: #c0261e; font-size: 12px; font-weight: 800; padding: 6px 9px; text-align: left; cursor: pointer; }
.ce-newslots { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 4px 0 10px; }
.ce-newslots small { flex: 1 1 100%; font-size: 11px; color: #8a93b3; }
.ce-newslots.full { color: #c0261e; display: block; }

/* 메뉴의 「캐릭터 만들기」 카드: 저장 칸 수 (ui.js) */
.cc-count { font-size: 9.5px; font-weight: 800; color: #6a7396; white-space: nowrap; line-height: 1.2; }
.cc-count.full { color: #c0261e; }

/* 무대 */
.ce-stage { grid-area: stage; position: relative; overflow: hidden; min-width: 0; min-height: 0; container-type: inline-size; }
/* 무대가 좁으면 상태 배지를 보기 버튼 아래로, 도움말은 숨김 */
@container (max-width: 660px) {
  .ce-badge { top: 58px; max-width: calc(100% - 24px); }
  .ce-hint { display: none; }
}
.ce-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.ce[data-mode='paint'] .ce-canvas { cursor: crosshair; }
.ce-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: calc(100% - 300px);
  pointer-events: none;
}
.ce-badge span {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(0, 30, 80, 0.18);
  white-space: nowrap;
}
.ce-badge .ce-ok { color: #168a43; }
.ce-badge .ce-warn { background: #ff8a00; color: #fff; }
.ce-badge .ce-warn.soft { background: #ffc400; color: var(--ink); }
.ce-badge .ce-tri.warn { color: #c0261e; }
.ce-views { position: absolute; right: 12px; top: 12px; display: flex; gap: 4px; }
.ce-gizmo { position: absolute; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 5px; }
.ce[data-mode='paint'] .ce-gizmo { display: none; }
.ce-vbtn {
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  border: 0;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  min-width: 40px;
  min-height: 36px;
  padding: 4px 9px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 30, 80, 0.2), inset 0 -3px 0 rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.ce-vbtn small { font-size: 10px; color: #5a6385; }
.ce-vbtn.on { background: var(--blue); color: #fff; }
.ce-vbtn.on small { color: #dfe9ff; }
.ce-vbtn.off { opacity: 0.5; }
.ce-gizmo .ce-vbtn { font-size: 18px; min-width: 52px; min-height: 48px; }
.ce-touch {
  position: absolute;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 30, 80, 0.25);
  cursor: pointer;
}
.ce-hint {
  position: absolute;
  left: 50%;
  top: 58px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  background: rgba(20, 30, 60, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 10px;
  text-align: center;
  pointer-events: none;
}
.ce-toast {
  position: absolute;
  left: 50%;
  top: 56px;
  transform: translate(-50%, -12px);
  width: max-content;
  max-width: calc(100% - 32px);
  background: rgba(20, 30, 60, 0.92);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 3;
}
.ce-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ce-prev {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 14px;
  padding: 8px 8px 8px 16px;
  box-shadow: 0 6px 20px rgba(0, 30, 80, 0.25);
  white-space: nowrap;
  max-width: calc(100% - 24px);
}
.ce-prev b { font-family: var(--font-kr); font-weight: 400; font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ce-prev .btn { flex: none; }
.ce.ce-previewing .ce-prev { display: flex; }
.ce.ce-previewing .ce-gizmo, .ce.ce-previewing .ce-badge, .ce.ce-previewing .ce-touch { display: none; }
.ce.ce-previewing [data-act='preview'] { background: linear-gradient(180deg, #4f95ff, var(--blue)); color: #fff; }
/* 움직임 보기 탈것 (카트 / 바이크 / 달리기): 미리보기 중에만, 상태 배지 자리에 (캐릭터 에디터만 있음) */
.ce-pveh { position: absolute; left: 12px; top: 12px; display: none; gap: 4px; }
.ce.ce-previewing .ce-pveh { display: flex; }
.ce-pveh .ce-vbtn { min-width: 58px; font-size: 18px; }
@container (max-width: 660px) {
  .ce-pveh { top: 58px; }
}

/* 모달 (창은 화면 안에서만: 넘치면 창 안이 스크롤) */
.ce-modal {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: rgba(10, 20, 50, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.ce-modal .ce-dialog { width: min(560px, 100%); max-height: 100%; overscroll-behavior: contain; touch-action: pan-y; }
.ce-dialog h2 { margin: 0 0 4px; font-family: var(--font-kr); font-weight: 400; font-size: 27px; }
.ce-dialog .sub { white-space: pre-line; }
.ce-foot { justify-content: flex-end; margin-top: 14px; }
.ce-foot .btn { flex: 0 1 auto; }
.ce-spin { margin: 14px auto 4px; border-color: rgba(31, 111, 224, 0.2); border-top-color: var(--blue); }
.ce-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ce-tcard {
  font: inherit;
  border: 3px solid transparent;
  background: #f1f4fc;
  border-radius: 16px;
  padding: 14px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink);
  transition: transform 0.1s;
}
.ce-tcard:hover { transform: translateY(-2px); border-color: var(--blue); background: #fff; }
.ce-tcard span { font-size: 34px; line-height: 1.2; }
.ce-tcard b { font-size: 15px; }
.ce-tcard small { font-size: 12px; color: #6a7396; font-weight: 700; text-align: center; }
.ce-mine { display: flex; flex-direction: column; gap: 6px; max-height: 56vh; overflow-y: auto; touch-action: pan-y; }
.ce-item { display: flex; align-items: center; gap: 8px; background: #f1f4fc; border-radius: 12px; padding: 6px 8px; }
.ce-item .btn { min-height: 40px; flex: none; }
.ce-thumb { width: 56px; height: 56px; border-radius: 12px; flex: none; background: radial-gradient(circle at 50% 40%, #fff, var(--kc)); overflow: hidden; }
.ce-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ce-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ce-item-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-item-txt small { font-size: 11px; color: #6a7396; font-weight: 700; }

/* 중간 폭: 패널을 줄이고 덜 중요한 버튼은 아이콘만 (상단 막대가 넘치지 않게 단계별로) */
@media (max-width: 1600px) {
  .ce-ebtn small { display: none; }
  .ce-top .btn.ce-ebtn { min-width: 42px; padding: 6px 9px; font-size: 18px; }
}
@media (max-width: 1500px) {
  .ce-top .lbl.opt { display: none; }
}
@media (max-width: 1320px) {
  .ce { grid-template-columns: 224px minmax(0, 1fr) 286px; }
  .ce-title { font-size: 19px; }
}
@media (max-width: 1240px) {
  .ce-title { display: none; }
}
@media (max-width: 1100px) {
  .ce-mode span { display: none; }
  .ce-mode { padding: 8px 11px; font-size: 16px; }
}
@media (max-width: 980px) {
  .ce-top { gap: 6px; }
  .ce-tsep { display: none; }
  .ce-top .btn.ce-ebtn { min-width: 38px; padding: 6px 7px; }
  .ce-top [data-act='save'] .lbl { display: none; }
}

/* ------------------------------------------------------------------ 좁은 화면 (휴대폰 · 태블릿 세로 · 가로 휴대폰)
   3D 화면을 크게 두고, 패널은 탭(부품 · 속성 · 목록 · 색칠 · 관절)으로 하나씩: 세로 = 아래 시트, 가로 = 오른쪽 서랍.
   지금 탭을 다시 누르거나 ▾ 를 누르면 접혀서 3D 화면이 넓어져요. 모드(만들기/색칠/관절)는 탭이 바꿈 → 상단의 모드 버튼은 숨김 */
@media (max-width: 860px), (max-height: 520px) and (orientation: landscape) {
  .ce-top { gap: 6px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .ce-top .lbl, .ce-title, .ce-modes, .ce-ebtn small { display: none; }
  .ce-top .btn { min-width: 42px; padding: 6px 10px; font-size: 16px; }
  .ce-top .btn.ce-ebtn { min-width: 42px; padding: 6px 8px; }
  .ce-tsep { display: none; }
  /* 패널: 고른 탭 하나만 */
  .ce-left, .ce-right { grid-area: sheet; display: none; border: 0; box-shadow: none; }
  .ce[data-ptab='parts'] .ce-left, .ce[data-ptab='paint'] .ce-left, .ce[data-ptab='rig'] .ce-left { display: block; }
  .ce[data-ptab='props'] .ce-right, .ce[data-ptab='list'] .ce-right { display: flex; flex-direction: column; }
  .ce-right > * { flex: none; }
  .ce[data-ptab='props'] .ce-listsec, .ce[data-ptab='list'] .ce-right > .ce-sec:not(.ce-listsec) { display: none; }
  .ce[data-ptab='props'] .ce-selsec { order: -1; } /* 고른 부품의 속성을 먼저 */
  .ce-right .ce-sec { border-bottom: 2px solid #eef1fb; }
  .ce.ce-collapsed .ce-left, .ce.ce-collapsed .ce-right { display: none; }
  .ce-sheet { display: none; }
  /* 탭 막대 */
  .ce-tabs {
    grid-area: tabs;
    display: flex;
    gap: 4px;
    padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
    background: var(--panel);
    box-shadow: 0 -6px 18px rgba(0, 30, 80, 0.16);
    z-index: 2;
    scrollbar-width: none;
  }
  .ce-tab {
    font: inherit;
    flex: 1 1 0;
    min-width: 0;
    min-height: 46px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #5b6488;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 3px 2px;
    cursor: pointer;
  }
  .ce-tab span { font-size: 19px; line-height: 1.1; }
  .ce-tab small { font-size: 12px; font-weight: 800; line-height: 1.2; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ce-tab:active { transform: translateY(1px); }
  .ce-tab.on { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(0, 30, 80, 0.16), inset 0 -3px 0 var(--blue); }
  .ce-tab[data-ptab='paint'].on { color: #d6337a; box-shadow: 0 2px 8px rgba(0, 30, 80, 0.16), inset 0 -3px 0 #e8357e; }
  .ce-tab[data-ptab='rig'].on { color: #8a4b12; box-shadow: 0 2px 8px rgba(0, 30, 80, 0.16), inset 0 -3px 0 #c98a3a; }
  .ce.ce-collapsed .ce-tab.on { background: transparent; box-shadow: inset 0 -3px 0 #c9d4f0; }
  .ce-tab.ce-fold { flex: 0 0 52px; background: #eef1fb; color: #5a6385; }
  .ce-tab.ce-fold span { font-size: 16px; }
  /* 무대 위 */
  .ce-badge { max-width: calc(100% - 24px); top: 56px; }
  .ce-hint { display: none; }
  .ce-gizmo, .ce-touch { bottom: 12px; }
  .ce-prev { bottom: 64px; }
  .ce-dialog h2 { font-size: 23px; }
}

/* 세로 (휴대폰 · 태블릿): 3D 화면 / 탭 / 아래 시트 */
@media (max-width: 860px) and (min-height: 521px), (max-width: 860px) and (orientation: portrait) {
  .ce {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: 'top' 'stage' 'tabs' 'sheet';
  }
  .ce-tabs { border-top: 3px solid #fff; border-radius: 18px 18px 0 0; }
  .ce-left, .ce-right { height: clamp(170px, 38vh, 460px); padding-bottom: max(18px, calc(10px + env(safe-area-inset-bottom))); }
  .ce.ce-collapsed .ce-tabs { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .ce-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .ce .ce-shopgrid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .ce-tools { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
}

/* 가로 휴대폰 (낮은 화면): 3D 화면 | 서랍 | 탭 세로 막대. 접으면 서랍이 사라져 3D 화면이 넓어짐 */
@media (max-height: 520px) and (orientation: landscape) {
  .ce {
    grid-template-columns: minmax(0, 1fr) min(272px, 40vw) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: 'top top top' 'stage sheet tabs';
  }
  .ce.ce-collapsed { grid-template-columns: minmax(0, 1fr) 0 auto; }
  .ce-left, .ce-right { border-left: 3px solid #fff; box-shadow: -6px 0 18px rgba(0, 30, 80, 0.14); padding-left: 12px; padding-right: 12px; }
  .ce-tabs {
    flex-direction: column;
    width: calc(64px + env(safe-area-inset-right));
    padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) 6px;
    border-left: 3px solid #fff;
    box-shadow: -4px 0 14px rgba(0, 30, 80, 0.12);
    overflow-y: auto;
  }
  .ce-tab { min-height: 42px; max-height: 64px; }
  .ce-tab.ce-fold { flex: 0 0 42px; }
  .ce-tab.ce-fold span { transform: rotate(-90deg); } /* ▾ → ▸ (접기), ▴ → ◂ (펼치기) */
  /* 노치 / 홈 막대 쪽 여백 */
  .ce-badge, .ce-pveh { left: calc(12px + env(safe-area-inset-left)); }
  .ce-gizmo { left: calc(12px + env(safe-area-inset-left)); bottom: calc(10px + env(safe-area-inset-bottom)); }
  .ce-touch { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .ce-gizmo .ce-vbtn { min-width: 48px; min-height: 44px; }
  .ce-prev { bottom: calc(62px + env(safe-area-inset-bottom)); }
}

/* 휴대폰 폭: 상단 막대는 닫기 · 되돌리기 · 다시 하기 · ⋯ · 저장 · 달리기 만. 나머지는 「⋯ 더보기」 메뉴 */
@media (max-width: 719px) {
  .ce-top { position: relative; overflow: visible; }
  .ce-top .ce-morebtn { display: block; margin-left: auto; font-size: 20px; line-height: 1; }
  .ce.ce-moreopen .ce-top .ce-morebtn { background: var(--blue); color: #fff; }
  .ce-tmore {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: max(8px, env(safe-area-inset-right));
    z-index: 5;
    width: min(320px, calc(100vw - 16px));
    max-height: calc(100vh - 80px);
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    padding: 8px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 34px rgba(0, 30, 80, 0.32);
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .ce.ce-moreopen .ce-tmore { display: grid; }
  .ce-tmore .ce-tsep, .ce-tmore .ce-gap { display: none; }
  .ce-top .ce-tmore .btn, .ce-top .ce-tmore .btn.ce-ebtn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 8px 10px;
    font-size: 19px;
    text-align: left;
  }
  .ce-top .ce-tmore .btn small, .ce-top .ce-tmore .btn .lbl { display: inline; font-size: 14px; font-weight: 800; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ce-top .ce-tmore .btn:disabled small { color: #8a93b3; }
}
/* 가로 휴대폰 · 태블릿 세로: 자리가 남으면 「달리기」 글자도 */
@media (min-width: 600px) and (max-width: 860px), (min-width: 600px) and (max-height: 520px) and (orientation: landscape) {
  .ce-top [data-act='use'] .lbl { display: inline; }
}

/* ------------------------------------------------------------------ 차량 만들기 (vehicleeditor.js — 캐릭터 에디터 화면을 그대로 씀) */
#vehicle-editor-root { position: fixed; inset: 0; z-index: 15; }
.ve-gap { margin-top: 6px; }
.ve-basebtn {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 2px solid #d5dbef;
  background: #fff;
  border-radius: 12px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--ink);
  text-align: left;
}
.ve-basebtn:hover { border-color: var(--blue); }
.ve-basebtn .ve-ico { font-size: 26px; line-height: 1; flex: none; }
.ve-basetxt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ve-basetxt b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ve-basetxt small { font-size: 11px; color: #6a7396; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ve-basebtn em { font-style: normal; font-size: 12px; font-weight: 800; color: var(--blue); flex: none; }
.ve-stat em { font-style: normal; font-size: 11px; font-weight: 900; min-width: 20px; text-align: right; color: #8a93b3; }
.ve-stat em.up { color: #18a058; }
.ve-stat em.down { color: #e8352e; }
.ve-bar { position: relative; }
.ve-bar::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: #b8c2dd; }
.ve-bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.ve-bar i.up { background: linear-gradient(90deg, #8be0ad, #22b35a); }
.ve-bar i.down { background: linear-gradient(90deg, #e8352e, #ffa9a3); }
.ce-sw.ve-none { background: repeating-linear-gradient(45deg, #fff 0 4px, #e6ebf8 4px 8px); font-size: 12px; font-weight: 900; color: #8a93b3; line-height: 1; }

/* 기준 차량 고르기 */
.ce-dialog:has(.ve-picker) { width: min(900px, 100%); }
.ve-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.ve-picker { max-height: 58vh; overflow-y: auto; touch-action: pan-y; padding-right: 4px; }
.ve-cls h4 { margin: 10px 0 6px; font-family: var(--font-kr); font-weight: 400; font-size: 17px; }
.ve-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ve-vcard {
  font: inherit;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  text-align: left;
  border: 2px solid transparent;
  background: #f1f4fc;
  border-radius: 12px;
  padding: 7px 9px 8px;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.08s;
}
.ve-vcard:hover { background: #fff; border-color: #9fb3e6; transform: translateY(-1px); }
.ve-vcard.on { border-color: var(--blue); background: #fff; box-shadow: 0 3px 10px rgba(31, 111, 224, 0.2); }
.ve-vcard b { font-size: 13px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ve-vcard small { font-size: 10.5px; font-weight: 700; color: #6a7396; }
.ve-dots { display: flex; gap: 3px; margin-top: 3px; }
.ve-dots i { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.ve-mini { position: absolute; right: 8px; bottom: 8px; display: flex; align-items: flex-end; gap: 2px; height: 18px; }
.ve-mini i { width: 4px; height: var(--h, 30%); border-radius: 2px; background: #c3cbe2; }
.ve-mini i.up { background: #22b35a; }
.ve-mini i.down { background: #e8352e; }
.ve .ce-card { min-width: 0; }
.ve .ce-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) {
  .ve .ce-grid { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
}

/* ------------------------------------------------------------------ 🦴 관절 지정 (rigedit.js) */
.ce-rig { display: none; }
.ce[data-mode='rig'] .ce-build, .ce[data-mode='rig'] .ce-paint { display: none; }
.ce[data-mode='rig'] .ce-rig { display: block; }
.ce[data-mode='rig'] .ce-gizmo { display: none; }
.ce-mode[data-mode='rig'].on { color: #8a4b12; }
.ce-rmodes .gfx-chip { display: flex; flex-direction: column; align-items: center; line-height: 1.15; padding: 6px 10px; flex: 1; }
.ce-rmodes .gfx-chip small { font-size: 10px; opacity: 0.75; font-weight: 700; }
.ce-rig .ce-btns .btn.on { background: linear-gradient(180deg, #4f95ff, var(--blue)); color: #fff; }
.ce-jlist { display: flex; flex-wrap: wrap; gap: 4px; }
.ce-jchip {
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  border: 2px solid transparent;
  border-radius: 9px;
  padding: 3px 7px;
  cursor: pointer;
  background: #eef1fb;
  color: var(--ink);
}
.ce-jchip.jL { background: #ffe8e6; color: #b3261e; }
.ce-jchip.jR { background: #e3f6ea; color: #13703a; }
.ce-jchip.jC { background: #e6eeff; color: #1f4fb8; }
.ce-jchip.on { border-color: #ffb800; box-shadow: 0 0 0 2px rgba(255, 184, 0, 0.35); }
.ce-jchip.dim { opacity: 0.45; }
.ce-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 2px; font-size: 11px; font-weight: 800; color: #5a6385; }
.ce-legend span { display: inline-flex; align-items: center; gap: 2px; }
.ce-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.ce-legend span i:last-of-type { margin-right: 3px; }

/* ------------------------------------------------------------------ ✨ 꾸미기 상점 (decorparts.js) */
.ce-shop h3 small { margin-left: auto; }
.ce-shopcoins { font-size: 12px; font-weight: 900; color: #a8730a; margin: -2px 0 6px; }
.ce-shopcoins:empty { display: none; }
.ce-shopcats { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.ce-dcat {
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 3px 9px 3px 7px;
  background: #f1f4fc;
  color: #5a6385;
  cursor: pointer;
  white-space: nowrap;
}
.ce-dcat span { font-size: 13px; }
.ce-dcat:hover { background: #fff; border-color: #f2b8d6; }
.ce-dcat.on { background: linear-gradient(180deg, #ff8cc0, #ef4f97); border-color: #ef4f97; color: #fff; }
.ce-shopgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ce-card.ce-dcard { position: relative; min-height: 74px; padding: 4px 2px 5px; background: linear-gradient(180deg, #fff7fb, #f3f1ff); }
.ce-dcard:hover { border-color: #f2a6cb; }
.ce-card.ce-dcard small { white-space: normal; word-break: keep-all; text-align: center; line-height: 1.12; overflow: visible; }
.ce-dthumb { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 28px; line-height: 1; }
.ce-dthumb img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.ce-dcard.locked .ce-dthumb img { filter: saturate(0.75) brightness(1.02); }
.ce-price {
  position: absolute;
  top: 3px;
  right: 3px;
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 8px;
  background: #ffe9a8;
  color: #8a5a00;
  box-shadow: 0 1px 3px rgba(120, 80, 0, 0.18);
  pointer-events: none;
}
.ce-dcard.open .ce-price { background: #d9f5e3; color: #168a43; }
.ce-dcard.cant .ce-price { background: #eceff7; color: #7d86a6; box-shadow: none; }
/* 코인이 모자랄 때 창: 지갑 / 가격 막대 */
.ce-coinbar { height: 12px; border-radius: 6px; background: #eef1fb; overflow: hidden; margin: 8px 0 4px; box-shadow: inset 0 0 0 1px #d5dbef; }
.ce-coinbar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #ffd23f, #ffb020); }

/* 잠긴 장식 창: 캐릭터 미리보기가 보이게 배경은 옅게, 창은 아래쪽에 */
.ce-modal.ce-peek { background: rgba(10, 20, 50, 0.12); align-items: flex-end; padding-bottom: max(28px, calc(12px + env(safe-area-inset-bottom))); }
.ce-modal.ce-peek .ce-dialog { width: min(460px, 100%); box-shadow: 0 10px 40px rgba(0, 30, 80, 0.35); }

/* ------------------------------------------------------------------ 🎯 선택한 부품만 칠하기 */
.ce-ptsec { padding-top: 6px; }
.ce-onlychk { margin-top: 2px; padding: 6px 8px; border-radius: 10px; background: #f1f4fc; }
.ce.ce-only .ce-onlychk { background: #fff0f7; box-shadow: inset 0 0 0 2px #ef4f97; color: #b3195f; }
.ce-ptgt { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 2px; }
.ce-ptgt.dim { opacity: 0.7; }
.ce-ptlbl { font-size: 11px; font-weight: 800; color: #8a93b3; margin-right: 2px; }
.ce-ptmore { font-size: 11px; font-weight: 800; color: #6a7396; }
.ce-ptchip {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 2px solid #f2b8d6;
  background: #fff;
  border-radius: 9px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}
.ce-ptchip:hover { border-color: #ef4f97; }
.ce-ptchip .ce-dot { width: 11px; height: 11px; }
.ce-ptgt.dim .ce-ptchip { border-color: #d5dbef; }
.ce-ptsec .btn.on { background: linear-gradient(180deg, #ff8cc0, #ef4f97); color: #fff; }
.ce-ptbadge {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: none;
  max-width: calc(100% - 24px);
  background: rgba(239, 79, 151, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 14px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(120, 0, 60, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.ce-ptbadge.show { display: block; }
.ce.ce-previewing .ce-ptbadge { display: none; }
.ce[data-mode='paint'] .ce-canvas.ce-choosing { cursor: pointer; }
@media (pointer: coarse) {
  .ce-ptbadge { bottom: 70px; }
}

/* 3D 모델 끌어다 놓기 */
#char-editor-root.ce-dropping::after {
  content: '📦 여기에 놓으면 불러와요 (모델 + 텍스처 함께)';
  position: fixed;
  inset: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px dashed #1f6fe0;
  border-radius: 20px;
  background: rgba(31, 111, 224, 0.12);
  color: #1f6fe0;
  font: 800 22px 'Segoe UI', 'Malgun Gothic', sans-serif;
  pointer-events: none;
}

/* ------------------------------------------------------------------ 터치 · 좁은 화면 공통 (파일 끝: 위의 기본값보다 우선) */
/* 터치: 더 큰 버튼 (손가락으로 누를 것은 40px 안팎 이상) */
@media (pointer: coarse) {
  .ce-card, .ce-tool { min-height: 60px; }
  .ce-sw { width: 40px; height: 40px; border-radius: 10px; }
  .ce-pal { gap: 5px; }
  .ce-vbtn { min-height: 44px; min-width: 46px; }
  .ce-slider input[type='range'] { height: 36px; }
  .ce-hue { height: 28px !important; border-radius: 14px; }
  .ce-hue::-webkit-slider-thumb { width: 28px; height: 28px; }
  .ce-hue::-moz-range-thumb { width: 22px; height: 22px; }
  .ce-check { min-height: 40px; margin: 3px 0; }
  .ce-check input { width: 22px; height: 22px; }
  .ce .ce-btns .btn, .ce .btn.ce-wide, .ce-cur .btn, .ce-item .btn, .ce-prev .btn { min-height: 42px; }
  .ce-cur .btn { min-width: 44px; }
  .ce-cur i { width: 42px; height: 42px; }
  .ce-cur input, .ce-num input, .ce-ginput, .ce-gfield input { min-height: 40px; }
  .ce-kart input[type='color'] { width: 44px; height: 40px; }
  .ce-colrow input[type='color'] { height: 42px; }
  .ce-row { min-height: 44px; }
  .ce-gname { min-height: 42px; }
  .ce-gtog, .ce-gren { min-width: 40px; min-height: 42px; }
  .ce-dcat { min-height: 40px; padding: 6px 12px 6px 9px; }
  .ce-jchip { min-height: 40px; padding: 4px 10px; }
  .ce-ptchip { min-height: 40px; padding: 4px 9px; }
  .ce-roles .gfx-chip { min-height: 40px; }
  .ce-slotwarn { min-height: 40px; }
  .ve-chips .gfx-chip { min-height: 40px; }
}
/* 터치 태블릿 가로 (넓은 화면 배치 그대로): 모드 버튼은 키우고, 좁은 왼쪽 패널의 도형 칸은 3줄로 */
@media (pointer: coarse) and (min-width: 861px) and (min-height: 521px) {
  .ce-mode { min-height: 42px; min-width: 44px; }
  .ce-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 휴대폰 · 태블릿 (좁은 화면이나 터치): 작은 글씨를 12px 이상으로 */
@media (max-width: 860px), (max-height: 520px) and (orientation: landscape), (pointer: coarse) {
  .ce kbd, .ce-card small, .ce-tool small, .ce-slider, .ce-slider b, .ce-pal-title, .ce-pal-title small, .ce-empty, .ce-xyz > small, .ce-num b, .ce-gcount,
  .ce-slotlbl, .ce-slot, .ce-newslots small, .ce-item-txt small, .ce-ptlbl, .ce-ptmore, .ce-legend, .ce-dcat, .ce-jchip, .ce-price, .ce-vbtn small,
  .ce-ebtn small, .ce-rmodes .gfx-chip small, .ce-gchip small, .ve-basetxt small, .ve-stat em, .ve-vcard small, .ce-tcard small {
    font-size: 12px;
  }
  .ce-dcat span { font-size: 14px; }
  .ce-num b { padding: 0 2px 0 6px; }
}

/* 좁거나 낮은 화면의 창: 창 안이 스크롤되고 아래 버튼 줄은 늘 보이게 (sticky) */
@media (max-width: 860px), (max-height: 720px) {
  .ce-modal .ce-dialog { background: #fff; }
  .ce-dialog .ce-foot {
    position: sticky;
    bottom: -22px; /* 창 안쪽 여백만큼 내려서 창 아래 끝에 붙임 */
    z-index: 1;
    margin: 14px -24px -22px;
    padding: 12px 24px 22px;
    background: linear-gradient(rgba(255, 255, 255, 0), #fff 12px);
  }
  .ce-mine, .ve-picker { max-height: none; overflow: visible; }
}
@media (max-width: 600px), (max-height: 520px) {
  .ce-modal { padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .ce-modal .ce-dialog { padding: 16px 16px; border-radius: 18px; }
  .ce-dialog .ce-foot { bottom: -16px; margin: 12px -16px -16px; padding: 12px 16px 16px; flex-wrap: wrap; }
  .ce-dialog .ce-foot .btn { flex: 1 1 auto; }
  .ce-dialog h2 { font-size: 22px; }
  .ce-dialog .sub { margin-bottom: 10px; }
  .ce-tpls { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .ce-tcard { padding: 10px 6px; border-radius: 14px; }
  .ce-tcard span { font-size: 28px; }
  .ce-item { padding: 6px; gap: 6px; }
  .ce-thumb { width: 44px; height: 44px; }
  .ve-cards { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .ce-modal.ce-peek { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
