/* Code Dungeon 상세 페이지 전용 — 인라인 SVG 그림, 사진 배치
   색은 site.css 의 변수만 써서 라이트 · 다크 · 인쇄에서 그대로 따라갑니다. */

/* ── 그림 틀 ── */
.dg { margin: 0; display: grid; gap: 8px; }
.dg-frame { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.dg svg { display: block; width: 100%; height: auto; max-width: 100%; }
.dg-sm svg { max-width: 27.5rem; margin-inline: auto; }
.dg .dg-narrow { display: none; }

/* A* 직선화 3단 */
.dg-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dg-steps svg { max-width: 17rem; margin-inline: auto; }

/* ── SVG 안 글자 · 선 ── */
.dg text { font-family: var(--f-body); font-size: 12.5px; fill: var(--ink-2); }
.dg .t-b { fill: var(--ink); font-weight: 700; font-size: 13.5px; }
.dg .t-m { font-family: var(--f-mono); font-size: 12px; letter-spacing: .02em; fill: var(--ink-3); }
.dg .t-c { font-family: var(--f-mono); font-size: 12px; }
.dg .t-s { font-size: 12px; }
.dg .t-p { fill: var(--p); }
.dg .t-mid { text-anchor: middle; }
.dg .t-end { text-anchor: end; }
.dg .bx { fill: var(--paper); stroke: var(--line); stroke-width: 1; }
.dg .bx-p { fill: var(--p-soft); stroke: var(--p); stroke-width: 1.4; }
.dg .grp { fill: none; stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 4 4; }
.dg .ln { fill: none; stroke: var(--ink-3); stroke-width: 1.4; }
.dg .ln-p { fill: none; stroke: var(--p); stroke-width: 1.8; }
.dg .dash { stroke-dasharray: 5 4; }
.dg .hd { fill: var(--ink-3); }
.dg .hd-p { fill: var(--p); }
.dg .lab-bg { fill: var(--surface); }
.dg .tri { fill: var(--surface); stroke: var(--ink-3); stroke-width: .8; }
.dg .tri-on { fill: var(--p); fill-opacity: .28; stroke: var(--p); stroke-width: 1.2; }
.dg .mesh { fill: var(--paper); stroke: var(--line); stroke-width: .8; }
.dg .dot { fill: var(--ink-3); }
.dg .dot-p { fill: var(--p); }
.dg .floor { fill: none; stroke: var(--ink-2); stroke-width: 4; stroke-linecap: round; }
.dg .who { fill: var(--p); }

/* 작은 그림 · 좁은 화면용 그림은 글자를 한 단계 키워 390px에서도 읽히게 */
.dg-sm text, .dg-narrow text { font-size: 13.5px; }
.dg-sm .t-b { font-size: 14.5px; }
.dg-sm .t-s, .dg-narrow .t-s { font-size: 12.5px; }
.dg-sm .t-c { font-size: 12px; }
.dg-narrow .t-b { font-size: 14.5px; }

/* ── 플레이어 사진: 키우지 않고 같은 높이로 나란히 ── */
.shots { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.shots figure { flex: none; max-width: 100%; }
.shots img { height: 240px; width: auto; max-width: 100%; object-fit: contain; }

/* ── 몬스터 상태도 탭: 스크립트가 없으면 탭 줄을 숨기고 네 그림을 모두 보입니다 ── */
.mtabs { display: grid; gap: 14px; }
.mtabs-list { display: none; }
.mtabs.tabs-on .mtabs-list { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.mtabs-list [role="tab"] { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 10px 14px 9px; font: 600 .92rem/1.4 var(--f-body); color: var(--ink-3); cursor: pointer; }
.mtabs-list [role="tab"]:hover { color: var(--ink); }
.mtabs-list [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--p); }
.mtabs-note { font-size: .84rem; color: var(--ink-3) !important; }
.mtabs-panel { display: grid; gap: 14px; min-width: 0; }
.mtabs-panel[hidden] { display: none; }
.mob-png img { background: #fff; }

/* 몬스터 사진 4장 */
.figs-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
@media (max-width: 640px) { .figs-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 코드: -> 와 >= 가 합자로 바뀌지 않게 */
.content pre { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* 한계 표: 첫 열도 줄바꿈 */
#cd-limits td:first-child { white-space: normal; min-width: 7.5em; }

/* 넓은 흐름도는 860px 아래에서 세로판으로 바꿈 (글자가 10px 밑으로 작아지지 않게) */
@media (max-width: 860px) {
  .dg .dg-wide { display: none; }
  .dg .dg-narrow { display: block; max-width: 26rem; margin-inline: auto; }
}

@media (max-width: 640px) {
  .dg-frame { padding: 12px; }
  .dg-steps { grid-template-columns: minmax(0, 1fr); }
  .shots img { height: 200px; }
}

@media print {
  .dg .dg-wide { display: block !important; }
  .dg .dg-narrow { display: none !important; }
  .dg, .dg-frame, .shots { break-inside: avoid; }
  .dg-frame { padding: 10px; }
  .dg-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shots img { height: 52mm; max-height: 52mm; }
  .mtabs-list { display: none !important; }
  .mtabs-panel[hidden] { display: grid !important; }
  .figs-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* 직접 작성한 코드 링크 */
.code-links { margin: 14px 0 0; font-size: .92rem; line-height: 1.9; color: var(--ink-2); }
.code-links b { color: var(--ink); margin-right: 10px; }
@media print { .code-links a::after { content: none; } }

/* 몬스터 썸네일 비율 통일 */
.figs-4 img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
/* 모바일 상단 띠 글자 가독성 */
@media (max-width: 640px) {
  .band-cd::after { background: linear-gradient(to top, rgba(8,9,10,.95) 0%, rgba(8,9,10,.7) 55%, rgba(8,9,10,.25) 100%); }
}

/* content width — same as INSTRUCTION */
.content > section > * { max-width: 52rem; }
.content > section > p, .content > section > ul, .content > section > ol { max-width: 48rem; }
.content > section > .wide, .content > section > figure.wide { max-width: 52rem; }
@media print { .content > section > * { max-width: none; } }
@media print {
  .mtabs { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px 16px; }
  .mtabs > :not(.mtabs-panel) { grid-column: 1 / -1; }
  .mtabs-panel { break-inside: avoid; }
  .mtabs-panel .dg svg { max-height: 120mm; }
  .dg-sm svg { max-width: 22rem; }
}
@media print {
  .mtabs { grid-template-columns: minmax(0, 1fr) !important; }
  .mtabs-panel .dg svg { max-height: 108mm; max-width: 100%; width: auto; }
  .dg-sm svg { max-width: 100%; }
}
