/* 디자인: 네오 브루탈리즘 = 밝은 원색 + 굵은 검정 테두리 + 번지지 않는 딱딱한 그림자.
   배치: PC 에서는 왼쪽 사이드바 + 오른쪽 본문(블로그와 같은 구조), 휴대폰에서는 한 열. */
:root {
  --bg: #fff4d6;     /* 크림색 바탕 */
  --ink: #111111;    /* 글자와 테두리의 검정 */
  --card: #ffffff;
  --point: #ffd23f;  /* 노랑: 조회 버튼, 선택된 것 */
  --sub: #b8e0ff;    /* 하늘: 사이드바 */
  --ok: #9be8a8;     /* 초록: 재고 있음 */
  --dim: #555555;    /* 회색 글자: 품절, 확인불가 */
  --line: 2px solid var(--ink);
  --shadow: 3px 3px 0 var(--ink); /* 가로 3px, 세로 3px, 번짐 0 = 딱딱한 그림자 */
}

/* grid: 왼쪽 280px 사이드바 + 나머지(1fr) 본문. 본문 아래 줄에 footer */
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr); /* minmax(0, …) = 내용이 길어도 칸이 화면 밖으로 늘어나지 않게 */
  grid-template-rows: 1fr auto;
  font: 14px/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif; /* 글자크기/줄간격 글꼴 */
  background: var(--bg);
  color: var(--ink);
  word-break: keep-all;    /* 한글을 단어 중간에서 끊지 않는다 */
  overflow-wrap: anywhere; /* 그래도 넘치는 긴 주소는 꺾는다 */
}

/* 사이드바: 스크롤해도 화면에 붙어 있다 */
header {
  grid-row: 1 / 3;
  position: sticky;
  top: 0;
  height: 100vh;
  box-sizing: border-box;
  padding: 28px 22px;
  background: var(--sub);
  border-right: var(--line);
  overflow-y: auto; /* 권역이 많아 화면보다 길어지면 사이드바 안에서 스크롤 */
}

h1, h2 { font-weight: 800; line-height: 1.2; }
h1 { font-size: 1.7rem; margin: 0 0 4px; }
/* 제목(왼쪽)과 초기화 버튼(오른쪽)을 한 줄에 */
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tagline { margin: 0 0 20px; font-weight: 700; }

/* 소제목 뒤에 노란 형광펜을 칠한 듯한 효과 */
h2 {
  display: inline-block;
  font-size: 0.95rem;
  margin: 0 0 10px;
  padding: 1px 8px;
  background: var(--point);
  border: var(--line);
}

main { padding: 28px 32px 8px; max-width: 1100px; }
footer { padding: 8px 32px 20px; color: var(--dim); font-size: 12px; max-width: 1100px; }
footer p { margin: 4px 0; }

a { color: var(--ink); font-weight: 700; }

/* 누르는 것은 모두 button */
button {
  font: inherit;
  min-height: 36px;
  padding: 6px 12px;
  border: var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, box-shadow 0.1s;
}

/* 마우스를 올리면 살짝 떠오르고, 누르는 동안에는 그림자 자리로 내려가 "눌린" 것처럼 보인다 */
button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
button:active { transform: translate(3px, 3px); box-shadow: none; }

/* 키보드로 선택했을 때 어디에 있는지 보이게 한다 */
:focus-visible { outline: 3px solid #1a4fff; outline-offset: 2px; }

/* 상품 입력칸 */
header label.field { display: block; padding: 0; margin-bottom: 4px; font-weight: 800; cursor: default; }
#keyword { width: 100%; height: 40px; margin: 0 0 10px; padding: 0 10px; box-sizing: border-box; font: inherit; border: var(--line); border-radius: 6px; background: var(--card); color: var(--ink); }

/* 재고 조회와 카드 조회를 반반씩 나란히 (1fr 1fr = 같은 폭 두 칸) */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions button { text-align: center; font-size: 1rem; font-weight: 800; padding: 10px 4px; }
#load-btn { background: var(--point); }

button:disabled { cursor: wait; background: var(--card); color: var(--dim); transform: none; box-shadow: none; }

/* 진행 막대: 브라우저 기본 모양을 지우고(appearance: none) 테두리와 노란 채움으로 다시 그린다 */
#bar { appearance: none; display: block; width: 100%; height: 18px; margin-top: 14px; border: var(--line); border-radius: 6px; background: var(--card); overflow: hidden; box-sizing: border-box; }
#bar[hidden] { display: none; }
#bar::-webkit-progress-bar { background: var(--card); }
#bar::-webkit-progress-value { background: var(--point); border-right: var(--line); transition: width 0.3s; } /* 크롬·사파리 */
#bar::-moz-progress-bar { background: var(--point); }                                                         /* 파이어폭스 */

/* 초기화 버튼: 제목 오른쪽에 작고 조용하게 */
/* 제목 오른쪽에 초기화와 일괄 조회를 위아래로. 두 버튼은 크기와 글자 크기가 같다 */
.title-buttons { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; margin-top: 4px; }
#reset-btn, #batch-btn { min-height: 30px; padding: 2px 10px; font-size: 12px; font-weight: 700; text-align: center; box-shadow: 2px 2px 0 var(--ink); }
#batch-btn { background: var(--point); }

/* 잠긴(disabled) 체크박스와 그 이름표는 흐리게 */
header label:has(input:disabled), legend .all:disabled { opacity: 0.4; cursor: not-allowed; }
fieldset:has(input:disabled) { background: transparent; }

/* 주변 판매처 지도 */
#map { height: 420px; margin: 10px 0 14px; border: var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 0; }
#map[hidden] { display: none; }
#places-note { margin: 0 0 6px; color: var(--dim); font-size: 12px; }
#places-list { list-style: none; padding: 0; margin: 0; }
#places-list li { margin-bottom: 10px; }
#places-list a { display: inline-block; padding: 6px 0 0; font-size: 12px; }

#status { margin: 8px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; } /* tabular-nums = 숫자 폭을 같게 해 글자가 흔들리지 않게 */
#status:empty, #fetched-at:empty { display: none; } /* :empty = 내용이 없을 때는 자리도 차지하지 않게 */
#fetched-at { display: inline-block; margin: 12px 0 0; padding: 2px 8px; background: var(--ink); color: var(--card); font-weight: 700; font-size: 12px; }
.notice { margin: 16px 0 0; font-size: 12px; }

/* "조회할 상품" 이름표와 [선택하기]를 한 줄의 양 끝에 */
.field-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.field-row label.field { margin: 0; }
header label.pick { padding: 0; font-size: 12px; font-weight: 700; }
#keyword:disabled { opacity: 0.4; cursor: not-allowed; }
/* 팩 목록: 길어지면 이 상자 안에서 스크롤 */
#packs { max-height: 190px; overflow-y: auto; margin: -4px 0 10px; }
#packs[hidden] { display: none; }

/* 카드 조회 버튼 */
#cards-btn { background: var(--ok); }

/* ---------- 힛카드 화면 ---------- */
#cards-note { margin: 0 0 14px; color: var(--dim); font-size: 12px; }
.pack { margin-bottom: 28px; padding: 14px 16px 16px; border: var(--line); border-radius: 8px; background: var(--card); box-shadow: var(--shadow); }
.pack h3 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.pack-meta { margin: 2px 0 0; color: var(--dim); font-size: 12px; }

/* 팩 목록: 이름과 설명을 한 줄로. 이름이 길면 말줄임표 */
#packs label span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#packs label small { white-space: nowrap; }

/* 무대: 닫힌 팩 또는 펼쳐진 카드가 가운데에 놓인다. 뒤 배경은 팩의 색(--c)을 옅게 깐 빗금 무늬 */
.stage {
  display: flex; justify-content: center; align-items: center; min-height: 270px; margin-top: 10px; padding: 16px 0 96px; overflow: hidden;
  border: 1px solid var(--ink); border-radius: 8px;
  background-color: color-mix(in srgb, var(--c, var(--point)) 45%, var(--card)); /* 팩 색과 흰색을 섞는다 */
  background-image: repeating-linear-gradient(45deg, transparent 0 16px, rgb(255 255 255 / 0.4) 16px 32px);
} /* 아래 여백: 기울어진 카드의 끝이 잘리지 않게 */

/* 팩 뒤의 박스 모양(직접 그린 것): 팩보다 크고 살짝 기울어 뒤에 놓인다 */
.stage { position: relative; }
.box-art {
  position: absolute; left: 50%; top: 22px; width: 210px; height: 230px; box-sizing: border-box;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; padding: 12px 14px;
  transform: translateX(-34%) rotate(6deg);
  border: var(--line); border-radius: 6px; box-shadow: 5px 5px 0 var(--ink);
  background: color-mix(in srgb, var(--c, var(--point)) 70%, var(--ink)); /* 팩 색을 조금 어둡게 */
  color: var(--card); font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
}
.box-art::before { content: ''; position: absolute; left: 0; right: 0; top: 34px; border-top: 2px dashed rgb(255 255 255 / 0.7); } /* 뚜껑 절취선 */
.box-art strong { font-size: 1.05rem; letter-spacing: 0; text-align: right; }
.box-art[hidden] { display: none; }
.stage.still { padding-bottom: 24px; } /* 펼칠 카드가 없는 팩: 아래 여백이 필요 없다 */
.pack-cover { position: relative; z-index: 1; margin-right: 70px; } /* 박스 앞, 약간 왼쪽에 */

/* 닫힌 팩: 세로로 긴 봉지 모양 버튼 */
.pack-cover { display: flex; flex-direction: column; justify-content: space-between; align-items: center; width: 130px; height: 210px; padding: 14px 10px; text-align: center; background: var(--c, var(--point)); border-radius: 10px; font-size: 12px; }
button.pack-cover[aria-expanded], button.pack-cover:hover { background: var(--c, var(--point)); }
.pack-cover[hidden], .fan[hidden], .again[hidden] { display: none; }
.pack-cover strong { font-size: 1.05rem; font-weight: 800; line-height: 1.25; }
.pack-cover .open { padding: 2px 10px; background: var(--ink); color: var(--card); font-weight: 800; }

/* 실제 팩 그림(정사각형 그림 가운데에 팩이 있다). 다 불러오면 script.js 가 has-img 를 붙인다 */
.pack-img { display: none; }
.has-img > .pack-img { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* 팩 표지: 그림이 팩 모양을 대신하고, 직접 그린 글자는 숨긴다. [팩 열기] 표시는 그림 아래쪽에 */
button.pack-cover.has-img, button.pack-cover.has-img:hover { padding: 0; background: transparent; border-color: transparent; box-shadow: none; }
.pack-cover.has-img > .pack-img { filter: drop-shadow(3px 3px 0 var(--ink)); }
.pack-cover.has-img > span:not(.open), .pack-cover.has-img > strong { visibility: hidden; }
.pack-cover.has-img .open { position: absolute; bottom: -10px; z-index: 1; }
/* 박스 앞면: 팩 그림을 크게 확대해 그림 부분으로 채우고, 글자는 어두운 띠 위에 */
.box-art { overflow: hidden; }
.box-art::before { z-index: 1; }
.box-art.has-img > .pack-img { transform: scale(1.8); }
.box-art > span, .box-art > strong { position: relative; z-index: 1; }
.box-art.has-img > span, .box-art.has-img > strong { padding: 0 6px; background: rgb(0 0 0 / 0.7); }

/* 펼쳐진 카드: 가운데를 기준으로 부채꼴. --i = 몇 번째 카드, --n = 카드 수, --w = 카드 폭 */
.fan { --w: 125px; display: flex; justify-content: center; flex: 1; min-width: 0; padding: 20px 34px 0; box-sizing: border-box; }
/* 카드 한 자리(slot): 부채꼴의 기울기·겹침을 맡고, 마우스를 올려도 움직이지 않는다 */
.slot {
  /* 가운데에서 멀수록 더 기울인다. 카드가 많으면 한 장당 기울기를 줄여 전체 각도가 너무 커지지 않게 한다 */
  --turn: calc((var(--i) - (var(--n) - 1) / 2) * min(5deg, 44deg / var(--n)));
  flex: 0 0 var(--w); height: calc(var(--w) * 1.44);
  transform: rotate(var(--turn)) translateY(calc(var(--turn) / 1deg * var(--turn) / 1deg * 0.18px)); /* 끝으로 갈수록 살짝 내려 부채꼴로 */
  transform-origin: 50% 120%;
  animation: deal 0.45s backwards; animation-delay: calc(var(--i) * 70ms); /* 한 장씩 차례로 나타난다 */
}
/* 둘째 카드부터는 앞 카드와 겹친다. 카드가 많을수록 더 많이 겹쳐서 전체가 화면 폭 안에 들어오게 한다
   (여기서 100% 는 .fan 의 폭) */
.slot + .slot { margin-left: calc(min(var(--w) - 28px, (100% - var(--w)) / (var(--n) - 1)) - var(--w)); }
@keyframes deal { from { opacity: 0; transform: translateY(40px) rotate(0); } }
/* 자리 안의 카드: 마우스를 올린 자리의 카드만 똑바로 세워 앞으로 띄운다 */
.tcg {
  display: flex; flex-direction: column; justify-content: space-between;
  width: 100%; height: 100%; padding: 8px; box-sizing: border-box;
  border: var(--line); border-radius: 8px; background: var(--card); box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.15s;
  font-size: 12px;
}
.slot:hover { z-index: 1; }
.slot:hover > .tcg { transform: rotate(calc(-1 * var(--turn))) translateY(-10px) scale(1.06); }
.tcg strong { font-size: 13px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.tcg .rarity { align-self: flex-start; padding: 0 6px; border: 1px solid var(--ink); background: var(--card); font-weight: 800; }
.tcg .no { color: var(--dim); }
/* 그림 카드: 여백 없이 그림으로 꽉 채운다 */
.tcg.art { padding: 0; overflow: hidden; }
.tcg.art img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* 그림이 있는 카드 목록: 격자로 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 12px 10px; margin: 0; padding: 6px 0 10px; list-style: none; }
.gallery img { display: block; width: 100%; height: auto; border: var(--line); border-radius: 6px; box-shadow: 2px 2px 0 var(--ink); }
.gallery strong { display: block; margin-top: 4px; font-size: 12px; font-weight: 800; overflow-wrap: anywhere; }
.gallery span { color: var(--dim); font-size: 11px; }
/* 누르면 카드 창이 열리는 칸: 버튼 모양은 지우고 그림만 */
button.card-pick { display: block; width: 100%; min-height: 0; padding: 0; border: none; background: none; box-shadow: none; }
button.card-pick:hover { transform: translateY(-2px); box-shadow: none; }
button.chip-pick { min-height: 0; padding: 0; border: none; background: none; box-shadow: none; text-align: left; }
.chips li:has(.chip-pick) { cursor: pointer; }
/* 펼친 카드도 버튼이지만 버튼의 기본 움직임은 쓰지 않는다(자리의 마우스 반응이 맡는다) */
button.tcg, button.tcg:hover, button.tcg:active { min-height: 0; text-align: left; }
button.tcg:active { box-shadow: 3px 3px 0 var(--ink); }

/* 카드 창: 큰 그림 + 시세 */
.card-dialog { width: min(640px, calc(100vw - 32px)); box-sizing: border-box; padding: 18px; border: var(--line); border-radius: 10px; background: var(--card); color: var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.card-dialog[open] { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 16px; align-items: start; }
.card-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.card-dialog > img, .card-dialog > .blank { width: 100%; aspect-ratio: 245 / 337; height: auto; border: var(--line); border-radius: 8px; }
.card-dialog > .blank { display: grid; place-items: center; background: var(--bg); color: var(--dim); }
.dialog-close { position: absolute; top: 8px; right: 8px; min-height: 30px; padding: 2px 10px; font-weight: 800; }
.card-info h3 { margin: 0 64px 2px 0; font-size: 1.2rem; font-weight: 800; }
.card-info .price { display: flex; flex-direction: column; gap: 2px; margin: 12px 0; padding: 10px 12px; border: var(--line); border-radius: 8px; background: var(--bg); }
.card-info .price small { color: var(--dim); font-size: 11px; }
.price-big { font-size: 1.8rem; font-weight: 900; line-height: 1.1; }
/* 그림이 없는 카드: 카드 모양의 빈 칸 */
.gallery .blank { display: grid; place-items: center; aspect-ratio: 245 / 337; border: 2px dashed var(--dim); border-radius: 6px; background: var(--bg); color: var(--dim); font-size: 11px; }

/* 등급별 카드 색: 색만으로 구분하지 않고 등급 글자를 함께 적는다 */
.r-SAR { background: var(--point); }
.r-UR, .r-MUR { background: #ffb3b3; }
.r-BWR { background: #e6e6e6; }
.r-SSR { background: var(--sub); }

.again { display: block; margin: 12px auto; min-height: 30px; padding: 2px 16px; font-weight: 700; border-radius: 999px; box-shadow: 2px 2px 0 var(--ink); }

/* 카드 목록: 가로로 넘기는 칸들. wrap 이 붙으면 여러 줄로 */
.chips { display: flex; gap: 8px; margin: 0; padding: 4px 2px 10px; list-style: none; overflow-x: auto; }
.chips.wrap { flex-wrap: wrap; overflow-x: visible; }
.chips li { flex: 0 0 auto; min-width: 120px; padding: 6px 10px; border: 1px solid var(--ink); border-radius: 6px; background: var(--bg); }
.chips strong { display: block; font-size: 13px; font-weight: 800; }
.chips span { color: var(--dim); font-size: 12px; }
.pack summary { margin-top: 6px; cursor: pointer; font-weight: 700; font-size: 12px; }
.all-cards { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--ink); }
.all-cards > summary { font-size: 13px; }
/* 움직임을 줄이도록 설정한 사람에게는 등장 효과를 끈다 */
@media (prefers-reduced-motion: reduce) { .slot { animation: none; } .tcg { transition: none; } }

/* 편의점 연결 상태 박스 4개 */
#health-wrap { margin-bottom: 24px; }
#health { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; } /* 편의점 4곳을 항상 한 줄에 */
.health-box { padding: 10px 12px; border: var(--line); border-radius: 6px; background: var(--card); box-shadow: var(--shadow); }
.health-box strong { display: block; font-size: 1.05rem; font-weight: 800; }
.health-box small { display: block; margin-top: 4px; color: var(--dim); font-size: 12px; }
/* 상태 꼬리표: 색만으로 구분하지 않고 "정상 / 오류 / 확인 중" 글자를 함께 적는다 */
.state { display: inline-block; margin-top: 4px; padding: 0 8px; border: 1px solid var(--ink); font-weight: 800; font-size: 12px; }
.state.ok { background: var(--ok); }
.state.bad { background: #ffb3b3; }
#health-note { margin: 8px 0 0; color: var(--dim); font-size: 12px; }

/* 첫 화면: 왼쪽에 안내 글, 오른쪽에 카드 그림 부채꼴 */
.hero {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: center; /* 자리가 좁으면 글과 카드가 위아래로 쌓인다 */
  padding: 26px 28px; border: var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
  background-color: var(--point);
  background-image: radial-gradient(rgb(255 255 255 / 0.55) 2px, transparent 2.5px); background-size: 18px 18px; /* 물방울 무늬 */
}
.hero[hidden] { display: none; }
.hero-kicker { display: inline-block; margin: 0; padding: 1px 8px; background: var(--ink); color: var(--card); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }
.hero-title { margin: 10px 0 8px; font-size: 1.75rem; font-weight: 800; line-height: 1.25; }
/* 속성 색 동그라미: 불 · 물 · 풀 · 전기 · 에스퍼 */
.energy { display: flex; gap: 6px; margin: 0 0 12px; }
.energy i { width: 16px; height: 16px; border: var(--line); border-radius: 50%; }
.energy i:nth-child(1) { background: #ff6b4a; }
.energy i:nth-child(2) { background: #4aa8ff; }
.energy i:nth-child(3) { background: #5fcf6a; }
.energy i:nth-child(4) { background: #ffe14a; }
.energy i:nth-child(5) { background: #c07bff; }
.hero-steps { margin: 0; padding: 12px 14px 12px 34px; border: var(--line); border-radius: 8px; background: var(--card); }
.hero-steps li { margin: 4px 0; }
.hero-steps strong { display: block; font-weight: 800; }
.hero-cards { min-height: 230px; display: flex; align-items: center; padding-bottom: 40px; }
.hero-cards .fan { --w: 112px; padding: 10px 26px 0; }

/* 요약 카드: 모두 같은 크기. auto-fill = 카드 수와 상관없이 칸 너비가 일정하다(좁으면 자동으로 줄바꿈) */
#summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px 10px; width: 100%; height: 220px; padding: 10px 12px; overflow: hidden; }
/* 조회 중: 오른쪽은 힛카드(머리줄 아래부터 카드 바닥까지). 안쪽 너비의 50% = 박스 전체 너비의 약 45% */
.card.busy { grid-template-columns: minmax(0, 1fr) 50%; }
.card-head { grid-column: 1 / -1; }
.card small { display: block; color: var(--dim); font-size: 12px; }
/* 머리줄: 편의점 이름 왼쪽, 상태 표시 오른쪽 */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head strong { font-size: 1.1rem; font-weight: 800; }
.pill { padding: 0 8px; border: 1px solid var(--ink); border-radius: 999px; background: var(--card); font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill.run { background: var(--point); }
.pill.ok { background: var(--ok); }
.pill.bad { background: #ffb3b3; }
.pill.wait { color: var(--dim); }
.card-main { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 0; }
.card-wait { color: var(--dim); font-weight: 700; }
.big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 4px; }
.big b { font-size: 2.2rem; font-weight: 900; line-height: 1; }
.big span { font-weight: 700; white-space: nowrap; }
.has-stock .big b { padding: 2px 6px; border: var(--line); background: var(--ok); }
/* 작은 숫자 3칸: 품절 · 미확인 · 전체 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--card); }
.stats > span { display: flex; flex-direction: column; align-items: center; padding: 2px 0; }
.stats > span + span { border-left: 1px solid var(--ink); }
.stats b { font-weight: 800; line-height: 1.3; }
.stats small { font-size: 10px; white-space: nowrap; }
/* 맨 아래 줄: 두 줄까지만 보이고 넘치면 말줄임표 */
.card .card-foot { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; line-height: 1.4; }

/* aria-expanded / aria-pressed 가 true 인 버튼 = 지금 펼쳐졌거나 선택된 것 → 노랗게 */
button[aria-expanded="true"], button[aria-pressed="true"] { background: var(--point); }


/* 편의점의 첫 결과를 기다리는 동안 힛카드가 한 장씩 넘어가는 자리 (넘기는 움직임은 script.js 의 deal) */
/* container-type: size = 안쪽에서 이 자리의 너비(cqw)·높이(cqh)를 잴 수 있게 한다. 카드는 자리에 들어가는 가장 큰 크기로 */
.deal { grid-column: 2; grid-row: 2 / -1; container-type: size; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.deal img { width: min(100cqw - 4px, (100cqh - 20px) * 245 / 337); aspect-ratio: 245 / 337; border: var(--line); border-radius: 6px; background: var(--bg); box-shadow: 2px 2px 0 var(--ink); }
.deal small { width: 100%; text-align: center; color: var(--ink); font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#panel { margin-top: 28px; }
/* 목록 제목은 왼쪽, 점포 검색창은 오른쪽 끝에 */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
#store-search { width: 260px; max-width: 100%; height: 36px; padding: 0 10px; box-sizing: border-box; font: inherit; border: var(--line); border-radius: 6px; background: var(--card); color: var(--ink); }
/* 화면에는 안 보이지만 화면 읽기 프로그램은 읽는 글자(입력칸의 이름표) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#panel-note, #scope { margin: 0 0 10px; color: var(--dim); font-size: 12px; }

/* 권역 체크박스 (사이드바) */
header h2 { display: block; width: fit-content; margin: 20px 0 8px; background: var(--card); } /* block = 앞의 조회 시각과 같은 줄에 붙지 않게 */
fieldset { margin: 0 0 8px; padding: 6px 10px 8px; border: var(--line); border-radius: 6px; background: var(--card); }
legend { padding: 0 4px; font-weight: 800; }
legend .all { min-height: 22px; margin-left: 6px; padding: 0 8px; font-size: 12px; font-weight: 700; box-shadow: none; }
.checks { padding: 6px 10px; border: var(--line); border-radius: 6px; background: var(--card); } /* 편의점 체크박스 상자 */
/* 체크박스 | 이름 | 점포 수(오른쪽 끝) 를 한 줄에 */
header label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }
header label small { margin-left: auto; color: var(--dim); font-size: 11px; }
/* 조회할 편의점·권역: 점포 수를 이름 뒤 같은 자리에서 왼쪽 정렬(이름 칸 너비를 6em 으로 맞춘다) */
#chains label, #regions label { display: grid; grid-template-columns: auto 6em 1fr; }
#chains label small, #regions label small { margin-left: 0; }
.checks .hint { display: block; margin-top: 4px; color: var(--dim); font-size: 11px; } /* 체크박스 아래의 짧은 안내 */
header input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); } /* accent-color = 체크 표시의 색 */
#estimate { margin: 8px 0 0; font-weight: 700; font-size: 12px; }

#store-list { list-style: none; padding: 0; margin: 0; }
#store-list li { margin-bottom: 8px; }
/* 일괄 조회 목록의 편의점별 제목 줄 */
#store-list li.group { margin: 18px 0 8px; padding: 2px 10px; width: fit-content; background: var(--ink); color: var(--card); font-weight: 800; }
#store-list li.group:first-child { margin-top: 0; }

/* 점포 한 줄을 3칸으로: 점포명 | 주소 | 거리. 그 아래 줄 전체에 상품별 재고 */
.store {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 2.2fr) auto;
  gap: 2px 16px;
  align-items: baseline;
  width: 100%;
  padding: 8px 12px;
  box-shadow: 2px 2px 0 var(--ink);
}
.store strong { font-weight: 800; }
.store .where { color: var(--dim); font-size: 12px; }
.store .stocks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }

/* 재고 상태 칩: 색만으로 구분하지 않고 "재고 N / 품절 / 확인불가" 글자를 함께 적는다 */
.stock { padding: 0 8px; border: 1px solid var(--ink); border-radius: 999px; font-size: 12px; background: var(--card); }
.stock.in { background: var(--ok); font-weight: 800; }
.stock.out { color: var(--dim); border-color: var(--dim); }
.stock.unknown { color: var(--dim); border: 1px dashed var(--dim); }

.map { padding: 8px 0 4px; }
.map iframe { display: block; width: 100%; height: 240px; border: var(--line); border-radius: 6px; box-sizing: border-box; }
.map a { display: inline-block; padding: 8px 0; }

/* 화면 폭 700px 이하(휴대폰): 사이드바를 위로 올려 한 열로, 누르는 요소는 손가락에 맞게 44px 이상 */
@media (max-width: 700px) {
  body { display: block; }
  header { position: static; height: auto; border-right: none; border-bottom: var(--line); padding: 20px 16px; overflow-y: visible; }
  h1 br { display: none; }
  main { padding: 20px 16px 8px; }
  footer { padding: 8px 16px 20px; }
  button, legend .all { min-height: 44px; }
  header label { padding: 10px 0; }
  .map a { padding: 12px 0; }
  #health { gap: 6px; }
  .health-box { padding: 6px; }
  .health-box strong { font-size: 12px; }
  .health-box .state { padding: 0 4px; font-size: 11px; }
  .health-box small { font-size: 10px; }
  .card-dialog[open] { grid-template-columns: 1fr; } .card-dialog > img, .card-dialog > .blank { max-width: 220px; justify-self: center; }
  #summary { grid-template-columns: 1fr; } /* 요약 카드는 숫자와 힛카드가 함께 들어가야 해서 한 줄에 하나 */
  .card { height: 260px; } /* 폭이 넓어진 만큼 높이도 늘려 힛카드를 크게 */
  .hero { padding: 20px 16px; }
  .hero-title { font-size: 1.4rem; }
  .hero-cards .fan { --w: 84px; }
  #reset-btn, #batch-btn { min-height: 44px; }
  .fan { --w: 101px; padding: 16px 26px 0; }
  .store { grid-template-columns: 1fr; }
}
