/* 배치: 지도가 한 장의 도판이고, 화면 틀은 그 도판의 부속물이다.
   위 가운데 = 날짜 표제, 오른쪽 = 범례(지금 일어나는 일), 아래 = 연표 자(시대 띠와 눈금), 왼쪽 아래 = 축척 자. */
:root {
  /* 색: 먹빛 쪽색 바탕에 금박(시간·선택), 인주(전쟁), 옥색(공사·켜짐) */
  --ink: #131a27;
  --ink-2: #1d2738;
  --paper: #f2ead8;
  --mute: #a0a8b8;
  --gilt: #dcb76a;
  --seal: #d2553d;
  --jade: #86bfa2;
  --line: rgba(220, 183, 106, 0.2);
  --panel: rgba(19, 26, 39, 0.94);
  --shadow: 0 8px 28px rgba(5, 8, 14, 0.45);
  /* 글자: 제목·연도는 명조, 본문은 고딕 */
  --display: 'Noto Serif KR', 'Noto Sans KR', serif;
  --body: 'Noto Sans KR', system-ui, sans-serif;
  /* 예전 이름 (다른 곳에서 아직 쓴다) */
  --bg: #0b0f17; --glass: var(--panel); --text: var(--paper); --muted: var(--mute); --accent: var(--gilt); --gold: var(--gilt); --serif: var(--display);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--paper); font-family: var(--body); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── 지도와 지도 부속물 ── */
#map { position: fixed; inset: 0; background: #cfd6d3; }
.leaflet-top.leaflet-left { top: 84px; }
.leaflet-bottom.leaflet-right { bottom: 92px; right: 352px; } /* 출처 글씨가 오른쪽 목록 창 밑으로 들어가지 않게 */
.leaflet-bottom.leaflet-left { bottom: 92px; left: 6px; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bar a { background: var(--panel); color: var(--gilt); border-color: var(--line) !important; }
.leaflet-bar a:hover { background: var(--ink-2); color: var(--paper); }
.leaflet-control-scale-line { background: rgba(19, 26, 39, 0.78); color: var(--paper); border: 0; border-bottom: 2px solid var(--gilt);
  border-left: 2px solid var(--gilt); border-right: 2px solid var(--gilt); font: 500 11px var(--body); padding: 1px 6px 2px; text-shadow: none; }

/* ── 날짜 표제 ── */
#top { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; display: flex; justify-content: center; padding: 12px 16px; pointer-events: none; }
#clock { text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px 28px 8px;
  box-shadow: var(--shadow); min-width: 250px; }
#year { font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 1.2; letter-spacing: 0.5px; color: #fbf3df;
  font-variant-numeric: tabular-nums; }
#era { font-size: 13px; color: var(--gilt); letter-spacing: 0.3px; }
#panelToggle { display: none; pointer-events: auto; position: absolute; right: 16px; top: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; }

/* ── 범례: 지금 일어나는 일 ── */
#panel { position: fixed; top: 14px; right: 14px; bottom: 96px; width: 330px; z-index: 1000; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; overflow-y: auto; padding: 4px 0; box-shadow: var(--shadow);
  scrollbar-width: thin; scrollbar-color: rgba(220, 183, 106, 0.3) transparent; }
#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb { background: rgba(220, 183, 106, 0.25); border-radius: 4px; }
.sec { padding: 6px 14px 10px; }
.sec h3 { font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--gilt); letter-spacing: 0.6px; margin: 8px 0 6px;
  display: flex; align-items: center; gap: 8px; }
.sec h3::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.row { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: 6px; padding: 6px; font-size: 14px;
  transition: background 0.15s; }
.row:hover { background: rgba(220, 183, 106, 0.1); }
.row .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row .top > span:first-child { min-width: 0; }
.row .sub { color: var(--mute); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* 줄 앞 표식: 전쟁 = 인주 마름모, 전투 = 작은 점, 이동 = 옥색 고리 */
.mk { display: inline-block; width: 7px; height: 7px; margin: 0 9px 1px 2px; vertical-align: middle; }
.mk.war { background: var(--seal); transform: rotate(45deg); }
.mk.battle { width: 5px; height: 5px; margin-left: 3px; margin-right: 10px; border-radius: 50%; background: rgba(210, 85, 61, 0.65); }
.mk.move { border-radius: 50%; border: 2px solid var(--jade); }
/* 상태 딱지 */
.chip { flex: none; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 999px; white-space: nowrap; color: var(--mute);
  border: 1px solid rgba(160, 168, 184, 0.35); }
.chip.live { color: #ffd9cf; border-color: rgba(210, 85, 61, 0.7); background: rgba(210, 85, 61, 0.18); }
.chip.why { color: var(--gilt); border-color: rgba(220, 183, 106, 0.5); }
.bar { height: 4px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--jade); }
.empty { color: var(--mute); font-size: 13px; padding: 4px 6px; }

/* ── 고른 것의 설명 ── */
#detail { padding: 14px; border-bottom: 1px solid var(--line); }
#detail .kind { font-size: 12px; color: var(--mute); }
#detail h2 { margin: 4px 0 2px; font: 900 21px/1.3 var(--display); letter-spacing: 0.3px; text-wrap: balance; }
#detail .when { color: var(--mute); font-size: 13px; margin-bottom: 8px; line-height: 1.5; }
#detail p { margin: 0 0 10px; line-height: 1.65; font-size: 14px; }
#detail h4 { margin: 14px 0 6px; font: 700 13px var(--display); color: var(--gilt); }
#detail .close { float: right; background: none; border: none; color: var(--mute); font-size: 20px; line-height: 1; }
#detail .close:hover { color: var(--paper); }
#detail .stage { display: flex; gap: 8px; font-size: 13px; padding: 3px 0; }
#detail .stage .st { width: 52px; flex: none; color: var(--mute); }
#detail .stage.now .st { color: var(--gilt); font-weight: 700; }
#detail .stage.done .st { color: var(--jade); }
#detail .mat { font-size: 13px; padding: 2px 0; }
#detail .note { font-size: 12px; color: var(--mute); line-height: 1.55; }
#detail .note a { color: var(--gilt); }
/* 그림은 종이 위에 놓인 도판처럼 */
#detail .pic { margin: 8px 0; border-radius: 6px; background: radial-gradient(ellipse at 50% 40%, #f3eedb, #d9cfac); padding: 6px; text-align: center;
  box-shadow: inset 0 0 0 1px rgba(90, 60, 30, 0.25); }
#detail .pic img { width: 100%; height: auto; display: block; }
#detail img.species { display: block; width: 100%; max-width: 300px; border-radius: 6px; margin: 2px 0 10px; }
#detail .arts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
#detail figure.art { margin: 0; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#detail figure.art img { display: block; width: 100%; aspect-ratio: 13 / 10; }
#detail figure.art figcaption { padding: 6px 8px 8px; font-size: 11px; line-height: 1.45; color: var(--mute); }
#detail figure.art figcaption b { display: block; color: var(--paper); font-size: 12px; margin-bottom: 2px; }
#detail ol.why { margin: 0 0 6px; padding-left: 20px; }
#detail ol.why li { font-size: 13px; line-height: 1.55; margin: 3px 0; }
#detail .res { color: var(--jade); font-size: 13px; line-height: 1.5; }
#detail .play { background: rgba(220, 183, 106, 0.14); border: 1px solid rgba(220, 183, 106, 0.55); color: var(--gilt); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; margin: 0 0 6px; }
#detail .play:hover { background: rgba(220, 183, 106, 0.26); }

/* ── "왜 일어났나" 이야기 카드 ── */
#story { position: fixed; top: 96px; left: calc((100% - 344px) / 2); transform: translateX(-50%); width: min(540px, calc(100% - 380px));
  z-index: 1001; background: var(--panel); border: 1px solid rgba(220, 183, 106, 0.55); border-radius: 12px; padding: 12px 16px;
  box-shadow: var(--shadow); max-height: calc(100% - 300px); overflow-y: auto; }
#story[hidden] { display: none; }
#story .kind { font-size: 12px; color: var(--gilt); }
#story h3 { margin: 2px 0 8px; font: 900 18px/1.3 var(--display); }
#story h3 span { font: 400 13px var(--body); color: var(--mute); margin-left: 8px; }
#story ol { margin: 0; padding-left: 22px; }
#story li { font-size: 14px; line-height: 1.6; margin: 4px 0; }
#story li.wait { display: none; }
#story li.done { color: var(--mute); }
#story li.on { color: #ffe3a3; animation: slidein 0.35s ease; }
#story .res { margin: 8px 0 0; color: var(--jade); font-size: 14px; line-height: 1.5; animation: slidein 0.35s ease; }
#story .close { float: right; background: none; border: none; color: var(--mute); font-size: 20px; line-height: 1; }

/* ── 전투 장면 보기 ── */
#watch { position: fixed; bottom: 98px; left: calc((100% - 344px) / 2); transform: translateX(-50%); width: min(480px, calc(100% - 380px));
  z-index: 1001; background: rgba(44, 16, 12, 0.94); border: 1px solid rgba(210, 85, 61, 0.7); border-radius: 12px; padding: 8px 16px 10px;
  box-shadow: var(--shadow); text-align: center; }
#watch[hidden] { display: none; }
#watch .kind { font-size: 11px; color: #ffb0a0; }
#watch h3 { margin: 0 0 2px; font: 900 17px/1.3 var(--display); }
#watch .sides { font-size: 12px; color: var(--mute); }
#watch .sides .a { color: #ffc4b8; font-weight: 700; }
#watch .sides .b { color: #c4d4ff; font-weight: 700; }
#watch .ph { margin: 6px 0 5px; font-size: 15px; color: #ffe3a3; animation: slidein 0.35s ease; }
#watch .bar i { background: var(--seal); transition: width 0.2s linear; }
#watch .again { position: absolute; left: 10px; top: 8px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 11px; }
#watch .close { position: absolute; right: 10px; top: 6px; background: none; border: none; color: var(--mute); font-size: 20px; line-height: 1; }
body.watching #feed { display: none; }

/* ── 새 소식 ── */
#feed { position: fixed; left: 14px; bottom: 126px; width: 290px; z-index: 1000; display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none; }
.news { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px 8px; font-size: 13px;
  line-height: 1.45; cursor: pointer; animation: slidein 0.35s ease; box-shadow: 0 4px 14px rgba(5, 8, 14, 0.35); }
.news .y { color: var(--gilt); font-size: 11px; font-variant-numeric: tabular-nums; }
.news.war { border-color: rgba(210, 85, 61, 0.6); }
.news.war .y { color: #f0917c; }
@keyframes slidein { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

/* ── 아래 조작판: 재생 · 연표 자 · 빠르기 · 표시 ── */
#controls { position: fixed; left: 14px; right: 14px; bottom: 14px; z-index: 1000; display: flex; align-items: center; gap: 14px;
  padding: 8px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
#transport { flex: none; display: flex; align-items: center; gap: 8px; }
#play { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--gilt); color: #241703; font-size: 18px; flex: none;
  box-shadow: 0 2px 8px rgba(220, 183, 106, 0.4); }
#play:hover { background: #ecc97c; }
.step { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 14px; line-height: 1; }
.step:hover { background: rgba(220, 183, 106, 0.25); }
/* 연표 자 */
#sliderWrap { position: relative; flex: 1; min-width: 0; height: 54px; border-radius: 4px; }
#sliderWrap:focus-within { outline: 2px solid var(--gilt); outline-offset: 3px; }
#chron { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#chronHead { position: absolute; top: -3px; bottom: 12px; left: 0; width: 2px; margin-left: -1px; background: var(--gilt); pointer-events: none;
  box-shadow: 0 0 6px rgba(220, 183, 106, 0.8); }
#chronHead::before { content: ''; position: absolute; left: -3px; top: -4px; width: 8px; height: 8px; background: var(--gilt); transform: rotate(45deg); }
#chronTip { position: absolute; bottom: calc(100% + 10px); left: 0; transform: translateX(-50%); background: var(--ink); border: 1px solid rgba(220, 183, 106, 0.5);
  border-radius: 6px; padding: 4px 9px; font-size: 12px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
#slider { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; -webkit-appearance: none; appearance: none; outline: none; }
#slider::-webkit-slider-thumb { -webkit-appearance: none; width: 1px; height: 54px; }
#slider::-moz-range-thumb { width: 1px; height: 54px; border: 0; }
/* 빠르기 */
#rate { flex: none; text-align: center; }
#rateText { font-size: 12px; color: var(--mute); margin-bottom: 5px; font-variant-numeric: tabular-nums; }
#speeds { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#speeds button { background: none; border: 0; border-left: 1px solid var(--line); padding: 5px 9px; font-size: 12px; white-space: nowrap; transition: background 0.15s; }
#speeds button:first-child { border-left: 0; }
#speeds button:hover { background: rgba(220, 183, 106, 0.16); }
#speeds button.on { background: var(--gilt); color: #241703; font-weight: 700; }
/* 묶음 틀이 바깥 테두리를 잘라 내므로 초점 고리는 안쪽에 그린다 */
#speeds button:focus-visible, #layers button:focus-visible { outline-offset: -3px; }
#speeds button.on:focus-visible, #layers button.on:focus-visible { outline-color: #241703; }
/* 자동 카메라 */
#tourBtn { flex: none; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px 8px 26px; font-size: 12px; position: relative;
  color: var(--mute); transition: border-color 0.15s; }
#tourBtn::before { content: ''; position: absolute; left: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: rgba(160, 168, 184, 0.5); }
#tourBtn.on { color: var(--paper); border-color: rgba(134, 191, 162, 0.6); }
#tourBtn.on::before { background: var(--jade); box-shadow: 0 0 6px rgba(134, 191, 162, 0.8); }
#tourBtn:hover { border-color: var(--gilt); }
/* 지도에 표시 */
#viewWrap { flex: none; position: relative; }
#viewBtn { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: 12px; transition: border-color 0.15s; }
#viewBtn:hover, #viewBtn[aria-expanded="true"] { border-color: var(--gilt); color: var(--gilt); }
#viewMenu { position: absolute; right: 0; bottom: calc(100% + 16px); width: 230px; background: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 12px 14px; box-shadow: var(--shadow); }
#viewMenu[hidden] { display: none; }
.vm-label { font: 700 12px var(--display); color: var(--gilt); letter-spacing: 0.4px; margin: 0 0 6px; }
#layers + .vm-label { margin-top: 14px; }
#layers { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#layers button { flex: 1; background: none; border: 0; padding: 6px 8px; font-size: 12px; }
#layers button + button { border-left: 1px solid var(--line); }
#layers button.on { background: var(--gilt); color: #241703; font-weight: 700; }
#layers2 { display: flex; flex-direction: column; gap: 2px; }
#layers2 button { display: flex; align-items: center; gap: 9px; background: none; border: 0; border-radius: 6px; padding: 6px 6px; font-size: 13px; text-align: left; color: var(--mute); }
#layers2 button:hover { background: rgba(220, 183, 106, 0.1); }
/* 켜고 끄는 단추: 왼쪽의 작은 스위치가 상태를 보여 준다 */
#layers2 button::before { content: ''; flex: none; width: 26px; height: 14px; border-radius: 999px; background: rgba(160, 168, 184, 0.3);
  background-image: radial-gradient(circle at 7px 7px, #cfd4de 4.5px, transparent 5px); transition: background-color 0.15s; }
#layers2 button.on { color: var(--paper); }
#layers2 button.on::before { background-color: rgba(134, 191, 162, 0.75); background-image: radial-gradient(circle at 19px 7px, #fff 4.5px, transparent 5px); }

/* ── 민족 따라가기 ── */
#peopleBtn { pointer-events: auto; position: absolute; left: 70px; top: 16px; background: var(--panel); color: var(--gilt); border: 1px solid rgba(220, 183, 106, 0.55);
  border-radius: 6px; padding: 8px 14px; font: 700 13px var(--display); box-shadow: var(--shadow); transition: background 0.15s; }
#peopleBtn:hover { background: var(--ink-2); }
#peopleBtn.on { background: var(--gilt); color: #241703; }
#peoplePick { position: fixed; inset: 0; z-index: 3000; background: rgba(5, 8, 14, 0.72); display: flex; align-items: center; justify-content: center; }
#peoplePick[hidden] { display: none; }
#peoplePick .box { width: min(760px, calc(100% - 32px)); max-height: calc(100% - 80px); overflow-y: auto; background: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); }
#peoplePick h2 { margin: 0 0 4px; font: 900 20px/1.3 var(--display); }
#peoplePick p.sub { margin: 0 0 14px; color: var(--mute); font-size: 13px; }
#peoplePick .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
#peoplePick .pp { text-align: left; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; color: var(--paper); cursor: pointer; }
#peoplePick .pp:hover { border-color: var(--gilt); background: rgba(220, 183, 106, 0.1); }
#peoplePick .pp b { display: block; font: 700 15px var(--display); margin-bottom: 3px; }
#peoplePick .pp span { display: block; font-size: 12px; color: var(--mute); line-height: 1.45; }
#peoplePick .x { float: right; background: none; border: none; color: var(--mute); font-size: 22px; cursor: pointer; }
#peopleCard { position: fixed; top: 70px; left: 58px; width: 300px; max-height: calc(100% - 190px); overflow-y: auto; z-index: 1001;
  background: var(--panel); border: 1px solid rgba(220, 183, 106, 0.5); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
#peopleCard[hidden] { display: none; }
#peopleCard .kind { font-size: 12px; color: var(--gilt); }
#peopleCard h3 { margin: 2px 0 2px; font: 900 18px/1.3 var(--display); }
#peopleCard .now { margin: 8px 0 6px; padding: 8px 10px; border-radius: 6px; background: rgba(220, 183, 106, 0.12); border: 1px solid rgba(220, 183, 106, 0.35); animation: slidein 0.35s ease; }
#peopleCard .now b { font: 700 16px var(--display); color: #ffe3a3; }
#peopleCard .now .yr { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
#peopleCard .now p { margin: 6px 0 0; font-size: 13px; line-height: 1.6; }
/* 단계 목록은 실제로 시간 순서라 왼쪽 줄로 잇는다 */
#peopleCard .tl { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
#peopleCard .tl button { text-align: left; background: none; border: none; border-left: 3px solid var(--line); padding: 3px 8px; color: var(--mute); font-size: 12px; cursor: pointer; }
#peopleCard .tl button.done { color: #c9cfdb; border-left-color: rgba(220, 183, 106, 0.45); }
#peopleCard .tl button.cur { color: #ffe3a3; font-weight: 700; border-left-color: var(--gilt); background: rgba(220, 183, 106, 0.08); }
#peopleCard .tl button i { font-style: normal; color: var(--mute); font-weight: 400; margin-left: 6px; }
#peopleCard .close { float: right; background: none; border: none; color: var(--mute); font-size: 20px; line-height: 1; cursor: pointer; }
body.people #feed { display: none; } /* 민족 따라가기 중에는 카드에 바뀐 나라가 나온다 */

/* ── 좁은 화면 (휴대폰) ── */
@media (max-width: 900px) {
  #tourBtn { padding: 8px 8px 8px 22px; font-size: 0; }
  #tourBtn::after { content: '카메라'; font-size: 12px; }
}
/* 휴대폰: 아래에서부터 조작판(3줄) → 출처 줄 → 축척 줄을 쌓고, 목록·설명은 그 위에 뜬다.
   높이는 모두 아래 변수 하나로 맞물린다 (조작판을 바꾸면 --dock-h만 고친다). */
@media (max-width: 760px) {
  :root {
    --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
    --edge: 8px;                                   /* 조작판·목록이 화면 가장자리에서 떨어진 거리 */
    --dock-h: 166px;                               /* 조작판 상자 높이 (테두리 포함) */
    --dock-b: calc(var(--edge) + var(--safe-b));   /* 조작판 아래 끝 */
    --dock-clear: calc(var(--dock-b) + var(--dock-h));
    --lane-gap: 4px; --attr-h: 46px; --scale-h: 20px; /* 출처(세 줄)·축척 자리 */
    --chrome-clear: calc(var(--dock-clear) + var(--lane-gap) + var(--attr-h) + var(--lane-gap) + var(--scale-h));
    --sheet-b: calc(var(--chrome-clear) + 8px);    /* 목록·설명·메뉴의 아래 끝 */
  }
  /* 위: 날짜 표제 · 목록 · 민족 따라가기 */
  #top { z-index: 1001; padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l)); }
  #year { font-size: 22px; }
  #clock { min-width: 0; padding: 6px 18px 7px; }
  #panelToggle { display: block; top: calc(16px + var(--safe-t)); right: calc(12px + var(--safe-r)); min-width: 44px; min-height: 44px;
    padding: 0 14px; border-radius: 8px; box-shadow: var(--shadow); transition: border-color 0.15s, color 0.15s; }
  #panelToggle[aria-expanded="true"] { border-color: var(--gilt); color: var(--gilt); }
  #peopleBtn { left: calc(12px + var(--safe-l)); top: calc(84px + var(--safe-t)); min-height: 44px; padding: 0 14px; border-radius: 8px; }
  #peopleCard { top: calc(136px + var(--safe-t)); left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r)); width: auto; max-height: 34%; }
  #story { top: calc(80px + var(--safe-t)); left: 50%; width: calc(100% - 32px - var(--safe-l) - var(--safe-r)); max-height: 40%; }
  #story li { font-size: 13px; }
  #feed { display: none; }

  /* 지도 확대 단추: 민족 따라가기 아래, 손가락 크기 */
  .leaflet-top.leaflet-left { top: calc(128px + var(--safe-t)); left: var(--safe-l); }
  .leaflet-top.leaflet-left .leaflet-control-zoom { margin: 8px 0 0 12px; }
  .leaflet-touch .leaflet-bar a, .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; font-size: 22px; }
  .leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out { font-size: 22px; }
  /* 출처 줄 (조작판 바로 위, 화면 폭 전체) 과 축척 줄 (그 위) — 서로 덮지 않는다 */
  .leaflet-bottom .leaflet-control { margin: 0; }
  .leaflet-bottom.leaflet-right { bottom: calc(var(--dock-clear) + var(--lane-gap)); left: calc(var(--edge) + var(--safe-l)); right: calc(var(--edge) + var(--safe-r)); }
  .leaflet-bottom.leaflet-right .leaflet-control-attribution { float: none; display: block; }
  .leaflet-container .leaflet-control-attribution { background: rgba(19, 26, 39, 0.86); color: #c3cad6; font-size: 9.5px; line-height: 1.35;
    padding: 3px 8px; border-radius: 6px; }
  .leaflet-container .leaflet-control-attribution a { color: var(--gilt); }
  .leaflet-bottom.leaflet-left { bottom: calc(var(--dock-clear) + var(--lane-gap) * 2 + var(--attr-h)); left: calc(var(--edge) + var(--safe-l)); }

  /* 목록 창: 닫힘(아무 표시 없음) · 설명만 낮게(.open) · 목록 전체(.open.expanded) */
  #panel { display: none; top: calc(80px + var(--safe-t)); bottom: var(--sheet-b); left: calc(var(--edge) + var(--safe-l)); right: calc(var(--edge) + var(--safe-r));
    width: auto; border-radius: 14px; overscroll-behavior: contain; }
  #panel.open { display: block; }
  #panel.open:not(.expanded) { top: auto; padding: 0; max-height: 36vh;
    max-height: min(36dvh, max(96px, calc(100dvh - var(--chrome-clear) - var(--safe-t) - 88px))); }
  #panel.open:not(.expanded) > .sec { display: none; }
  #panel.open:not(.expanded) > #detail { border-bottom: 0; }
  #panel.open.expanded { padding-top: 52px; background: rgba(19, 26, 39, 0.985); } /* 위 왼쪽의 민족 따라가기 단추 자리; 아래 지도 단추가 비치지 않게 */
  #panel :focus-visible { outline-offset: -2px; }
  .row { min-height: 44px; padding-top: 11px; padding-bottom: 11px; }
  #detail .close { min-width: 44px; min-height: 44px; margin: -12px -12px -6px 6px; font-size: 22px; }
  #detail .play { min-height: 44px; padding: 8px 14px; }

  /* 아래 조작판: ① 연표 자 ② 빠르기 ③ 재생·소리·카메라·표시 — 세 줄, 166px */
  #controls { flex-wrap: wrap; align-content: space-between; left: calc(var(--edge) + var(--safe-l)); right: calc(var(--edge) + var(--safe-r));
    bottom: var(--dock-b); height: var(--dock-h); column-gap: 6px; row-gap: 0; padding: 4px 10px; border-radius: 14px; }
  #sliderWrap { order: -2; flex: 0 0 100%; height: 48px; }
  #sliderWrap:focus-within { outline-offset: 0; }
  #slider::-webkit-slider-thumb { height: 48px; }
  #slider::-moz-range-thumb { height: 48px; }
  #chronHead { top: 2px; }
  #rate { order: -1; flex: 0 0 100%; display: flex; flex-direction: column; gap: 2px; text-align: left; }
  #rateText { margin: 0; padding: 0 2px; height: 12px; font-size: 11px; line-height: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #speeds { border: 0; box-shadow: inset 0 0 0 1px var(--line); border-radius: 8px; }
  #speeds button { flex: 1 1 0; min-width: 44px; height: 44px; padding: 0 2px; font-size: 13px; }
  #transport { flex: none; gap: 4px; }
  /* 앞뒤 단추: 누르는 자리는 44px, 보이는 동그라미는 34px */
  .step { width: 44px; height: 44px; border: 5px solid transparent; background-clip: padding-box; box-shadow: inset 0 0 0 1px var(--line); }
  /* 글자 길이에 맞춘 시작 폭 (390px에서 셋 다 한 줄) — 좁아지면 44px까지 줄며 단추 안에서 줄바꿈 */
  /* 셋 다 44px에서 시작해 남는 폭을 글자 길이 비율로 나눈다 → 390px에서 모두 한 줄, 320px까지 넷째 줄 없음 */
  #controls > #soundBtn { flex: 1 1 44px; min-width: 44px; } /* #soundBtn 기본 규칙이 파일 뒤쪽에 있어 한 단계 더 구체적으로 */
  #tourBtn { flex: 1 1 44px; min-width: 44px; }
  #viewWrap { flex: 1.8 1 44px; min-width: 44px; }
  #controls > #soundBtn, #tourBtn, #viewBtn { height: 44px; padding: 2px 6px; line-height: 1.2; white-space: normal; word-break: keep-all; border-radius: 8px; }
  #controls > #soundBtn, #viewBtn { font-size: 11px; } /* #tourBtn은 글자 크기 0 (긴 이름을 숨기고 ::after로 '카메라') */
  #tourBtn { padding-left: 19px; }
  #tourBtn::before { left: 7px; }
  #tourBtn::after { font-size: 11px; }
  #viewBtn { width: 100%; }
  #viewMenu { position: fixed; left: calc(var(--edge) + var(--safe-l)); right: calc(var(--edge) + var(--safe-r)); width: auto; bottom: var(--sheet-b); }
  #layers button, #layers2 button { min-height: 44px; }
  #watch { bottom: var(--sheet-b); left: 50%; width: calc(100% - 32px - var(--safe-l) - var(--safe-r)); }
}
/* 좁은 휴대폰(360px 무렵): 카메라 단추의 켜짐 점을 글자 위로 올려 글자가 단추 밖으로 나가지 않게 */
@media (max-width: 380px) {
  #tourBtn { padding: 15px 4px 2px; }
  #tourBtn::before { top: 7px; left: 50%; margin: 0 0 0 -4px; }
}
/* 아주 좁은 화면(320px 무렵): 셋째 줄이 넘치지 않게 틈만 줄인다 (줄 수는 그대로) */
@media (max-width: 340px) {
  #year { font-size: 19px; }
  #clock { padding: 5px 12px 6px; }
  #panelToggle { padding: 0 10px; }
  :root { --attr-h: 58px; } /* 출처가 네 줄이 된다 */
  #controls { column-gap: 4px; padding-left: 8px; padding-right: 8px; }
  #transport { gap: 2px; }
}
/* 넓은 휴대폰·눕힌 휴대폰: 출처는 두 줄이면 된다 */
@media (max-width: 760px) and (min-width: 560px) {
  :root { --attr-h: 32px; }
}
/* 눕힌 휴대폰: 민족 따라가기와 확대 단추를 표제 왼쪽 한 줄에 놓아 아래 출처·축척 줄과 겹치지 않게 */
@media (max-width: 760px) and (max-height: 500px) and (min-width: 640px) {
  #peopleBtn { top: calc(16px + var(--safe-t)); }
  .leaflet-top.leaflet-left { top: calc(14px + var(--safe-t)); left: calc(128px + var(--safe-l)); }
  .leaflet-top.leaflet-left .leaflet-control-zoom { display: flex; margin: 0; }
  .leaflet-touch .leaflet-control-zoom a { border-bottom: 0; border-radius: 0; }
  .leaflet-touch .leaflet-control-zoom a:first-child { border-right: 1px solid var(--line); border-radius: 6px 0 0 6px; }
  .leaflet-touch .leaflet-control-zoom a:last-child { border-radius: 0 6px 6px 0; }
  .leaflet-bottom.leaflet-left { left: auto; right: calc(var(--edge) + var(--safe-r)); }

  /* 목록·설명은 오른쪽 세로 창: 위 날짜·목록 단추 아래에서 화면 아래까지 (가로가 짧아 아래 창은 몇 줄도 안 보인다).
     창을 연 동안(body.sheet)에는 출처가 창 바로 아래로 가고, 조작판·축척은 창 왼쪽으로 비킨다.
     --side-attr-h 는 오른쪽 칸에서 출처가 차지하는 높이 (app.js 가 잰 값으로 고친다) */
  :root { --side-w: min(300px, 44vw); --side-x: calc(var(--edge) * 2 + var(--side-w) + var(--safe-r)); --side-attr-h: 72px;
    --side-t: calc(80px + var(--safe-t)); --side-b: calc(var(--edge) + var(--safe-b) + var(--side-attr-h) + var(--lane-gap)); }
  #panel { top: var(--side-t); bottom: var(--side-b); left: auto; right: calc(var(--edge) + var(--safe-r)); width: var(--side-w); }
  #panel.open:not(.expanded) { top: var(--side-t); bottom: auto; max-height: calc(100vh - var(--side-t) - var(--side-b));
    max-height: calc(100dvh - var(--side-t) - var(--side-b)); }
  #panel.open.expanded { padding-top: 0; } /* 위 왼쪽 단추들과 겹치지 않으니 빈 자리가 필요 없다 */
  #panel.open ~ #controls { right: var(--side-x); }
  body.sheet .leaflet-bottom.leaflet-right { left: auto; right: calc(var(--edge) + var(--safe-r)); width: var(--side-w); bottom: calc(var(--edge) + var(--safe-b)); }
  body.sheet .leaflet-bottom.leaflet-left { right: var(--side-x); bottom: calc(var(--dock-clear) + var(--lane-gap)); }
  body.sheet #viewMenu { right: var(--side-x); }
}

/* ── 첫 화면: 지도를 가리지 않게 옅게만 덮고, 가운데에서 볼 곳을 고른다 ── */
#intro { position: fixed; inset: 0; z-index: 2500; display: flex; align-items: center; justify-content: center; background: rgba(8, 12, 20, 0.45); padding: 16px; }
#intro[hidden] { display: none; }
.intro-card { width: min(470px, 100%); max-height: 100%; overflow-y: auto; background: var(--ink); border: 1px solid rgba(220, 183, 106, 0.45); border-radius: 12px;
  padding: 26px 28px 20px; box-shadow: var(--shadow); }
.intro-card h1 { margin: 0 0 10px; font: 900 30px/1.25 var(--display); letter-spacing: 0.5px; color: #fbf3df; }
.intro-card p { margin: 0; font-size: 14px; line-height: 1.75; color: #d6d0c2; }
.intro-card h2 { margin: 22px 0 4px; font: 700 13px var(--display); color: var(--gilt); letter-spacing: 0.5px; }
.intro-list { display: flex; flex-direction: column; }
.intro-list button { display: flex; flex-direction: column; gap: 2px; text-align: left; background: none; border: 0; border-top: 1px solid var(--line);
  padding: 11px 4px 12px; transition: background 0.15s, padding-left 0.15s; }
.intro-list button:first-child { border-top: 0; }
.intro-list button:hover, .intro-list button:focus-visible { background: rgba(220, 183, 106, 0.1); padding-left: 10px; }
.intro-list b { font: 700 16px var(--display); color: var(--paper); }
.intro-list button:hover b { color: var(--gilt); }
.intro-list span { font-size: 12.5px; color: var(--mute); }
.intro-card p.hint { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--mute); line-height: 1.6; }

/* ── 전투 장면 보기 (영화처럼): 목록·조작판을 치우고 전장만 남긴다 ── */
body.watching #panel, body.watching #feed, body.watching #controls, body.watching #top, body.watching #peopleCard,
body.watching .leaflet-control-container, body.watching .zoom-stage-list { display: none; }
/* 위아래 어둠: 전황판과 자막이 지도에 묻히지 않게 */
body.watching::before, body.watching::after { content: ''; position: fixed; left: 0; right: 0; height: 150px; z-index: 900; pointer-events: none; }
body.watching::before { top: 0; background: linear-gradient(rgba(8, 11, 18, 0.85), rgba(8, 11, 18, 0)); }
body.watching::after { bottom: 0; height: 210px; background: linear-gradient(rgba(8, 11, 18, 0), rgba(8, 11, 18, 0.9)); }
/* 전황판: 왼쪽 군대(인주) · 전투 이름 · 오른쪽 군대(쪽빛) */
#cineHud { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); width: min(1040px, calc(100% - 32px)); z-index: 1002;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 22px; align-items: center; }
#cineHud[hidden] { display: none; }
.army { min-width: 0; }
.army .nm { font: 900 19px/1.25 var(--display); color: #ffd9cf; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.army .cm { font-size: 12.5px; color: var(--mute); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.army .num { font: 700 15px var(--body); font-variant-numeric: tabular-nums; color: var(--paper); margin-top: 4px; min-height: 20px; }
.army .hp { height: 7px; background: rgba(255, 255, 255, 0.13); border-radius: 4px; overflow: hidden; margin-top: 4px; display: flex; }
.army .hp i { display: block; height: 100%; background: var(--seal); border-radius: 4px; transition: width 0.4s linear; }
.army.b { text-align: right; }
.army.b .nm { color: #cfdcff; }
.army.b .hp { justify-content: flex-end; }
.army.b .hp i { background: #6f8fe0; }
.cine-mid { text-align: center; padding: 0 6px; }
.cine-mid b { display: block; font: 900 24px/1.2 var(--display); color: #fbf3df; letter-spacing: 0.5px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); }
.cine-mid span { font-size: 13px; color: var(--gilt); font-variant-numeric: tabular-nums; }
.cine-mid span.scl { display: block; margin-top: 3px; font-size: 11.5px; line-height: 1.4; color: rgba(242, 234, 216, 0.78); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); text-wrap: balance; }
.cine-mid span.scl:empty { display: none; }
@media (max-width: 760px) { /* 휴대폰: 가운데 글(곳·때·축척)이 길어도 양쪽 군대 칸이 눌려 한 글자씩 꺾이지 않게 */
  #cineHud { grid-template-columns: minmax(76px, 1fr) minmax(0, 2fr) minmax(76px, 1fr); }
  .army .num { font-size: 12.5px; white-space: nowrap; } .cine-mid span { font-size: 11.5px; } .cine-mid span.scl { font-size: 10.5px; } }
/* 자막: 지금 벌어지는 단계 */
body.watching #watch { left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); width: min(760px, calc(100% - 32px)); background: none; border: 0; box-shadow: none; padding: 0; text-align: center; }
#watch .bt { display: flex; align-items: baseline; justify-content: center; gap: 10px; animation: beatin 0.5s ease; }
#watch .bt b { font: 900 30px/1.2 var(--display); color: #ffe3a3; letter-spacing: 1px; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85); }
#watch .bt span { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid; }
#watch .bt span.a { color: #ffd9cf; border-color: rgba(210, 85, 61, 0.7); }
#watch .bt span.b { color: #cfdcff; border-color: rgba(111, 143, 224, 0.7); }
body.watching #watch .ph { margin: 4px 0 12px; font-size: 16px; line-height: 1.5; color: var(--paper); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9); animation: none; text-wrap: balance; }
/* 진행 줄: 점은 단계가 바뀌는 곳 */
#watch .tl { position: relative; height: 4px; background: rgba(255, 255, 255, 0.16); border-radius: 2px; margin: 0 auto 10px; max-width: 520px; }
#watch .tl i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gilt); border-radius: 2px; }
#watch .tl s { position: absolute; top: -3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: #3a4356; border: 2px solid rgba(255, 255, 255, 0.35); text-decoration: none; }
#watch .tl s.on { background: var(--gilt); border-color: #fff3d6; }
#watch .acts, #cineEnd .acts { display: flex; gap: 8px; justify-content: center; }
#watch .acts button, #cineEnd .acts button { position: static; background: rgba(19, 26, 39, 0.8); border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px;
  font-size: 12px; color: var(--paper); line-height: 1.4; }
#watch .acts button:hover, #cineEnd .acts button:hover { border-color: var(--gilt); color: var(--gilt); }
@keyframes beatin { from { opacity: 0; transform: translateY(8px) scale(1.06); } to { opacity: 1; transform: none; } }
/* 결과 */
#cineEnd { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100% - 32px)); z-index: 1003; background: var(--ink);
  border: 1px solid rgba(220, 183, 106, 0.55); border-radius: 12px; padding: 22px 26px 18px; box-shadow: var(--shadow); text-align: center; animation: beatin 0.5s ease; }
#cineEnd[hidden] { display: none; }
#cineEnd .res { font: 700 20px/1.3 var(--display); color: var(--paper); margin-bottom: 12px; }
#cineEnd .res b { font-weight: 900; font-size: 28px; color: #ffe3a3; }
#cineEnd .loss { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; margin-bottom: 12px; font-size: 13px; line-height: 1.5; }
#cineEnd .loss > div { border-top: 2px solid var(--seal); padding-top: 6px; }
#cineEnd .loss > div + div { border-top-color: #6f8fe0; }
#cineEnd .loss span { display: block; font: 700 13px var(--display); color: var(--gilt); margin-bottom: 2px; }
#cineEnd p { margin: 0 0 12px; font-size: 14px; line-height: 1.65; text-align: left; }
#cineEnd p.src { font-size: 11px; color: var(--mute); }
#cineEnd { max-height: calc(100% - 32px); overflow-y: auto; }
/* 장면 속 진형과 그 근거 등급 (기록 / 일부 기록 / 학설 갈림 / 후대 전승 / 시대 일반형 / 공통 배치) */
#watch .fm { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin: -6px auto 10px; max-width: 640px; font-size: 12px; line-height: 1.5; color: rgba(242, 234, 216, 0.82); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }
#watch .fm b { font-weight: 700; margin-right: 2px; } #watch .fm b.a { color: #ffc4b8; } #watch .fm b.b { color: #c4d4ff; }
.fc { font-style: normal; font-size: 10.5px; font-weight: 600; padding: 0 6px; margin-left: 3px; border-radius: 8px; border: 1px solid rgba(242, 234, 216, 0.4); white-space: nowrap; color: rgba(242, 234, 216, 0.85); }
.fc-recorded, .fc-partial { border-color: rgba(220, 183, 106, 0.85); color: #f0d48f; }
.fc-disputed, .fc-tradition { border-color: rgba(230, 150, 110, 0.8); color: #f2b99b; border-style: dashed; }
.fc-generic, .fc-none { opacity: 0.75; border-style: dotted; }
#cineEnd .fm-end { text-align: left; margin: 0 0 12px; padding-top: 8px; border-top: 1px solid var(--line); }
#cineEnd .fm-end > b { display: block; font: 700 13px var(--display); color: var(--gilt); margin-bottom: 4px; }
#cineEnd .fm-end p { font-size: 12.5px; line-height: 1.55; margin: 0 0 8px; }
#cineEnd .fm-end span { font-weight: 700; } #cineEnd .fm-end span.a { color: #ffc4b8; } #cineEnd .fm-end span.b { color: #c4d4ff; }
#cineEnd .fm-end i { display: block; font-style: normal; font-size: 11px; color: var(--mute); }
/* 소리 단추 */
#soundBtn { flex: none; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 12px; color: var(--mute); }
#soundBtn.on { color: var(--paper); border-color: rgba(134, 191, 162, 0.6); }
#soundBtn:hover { border-color: var(--gilt); }
#soundBtn[hidden] { display: none; }
@media (max-width: 760px) {
  #cineHud { gap: 8px; top: calc(10px + env(safe-area-inset-top, 0px)); }
  #watch .acts button, #cineEnd .acts button { min-width: 44px; min-height: 44px; padding: 6px 14px; font-size: 13px; border-radius: 8px; }
  .army .nm { font-size: 14px; } .cine-mid b { font-size: 16px; } #watch .bt b { font-size: 22px; } body.watching #watch .ph { font-size: 14px; }
}

/* ── 확대 단계 (app.js 의 STAGES): +/− 아래 지금 단계 이름과 "5/6", 누르면 6단계 목록 ── */
.leaflet-bar .zoom-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 100%; min-width: 30px; padding: 4px 0 3px; border: 0; border-radius: 0 0 4px 4px; background: var(--panel); color: var(--paper); line-height: 1.1; }
.leaflet-bar .zoom-stage b { font: 700 11px var(--body); letter-spacing: -0.02em; }
.leaflet-bar .zoom-stage span { font: 500 9.5px var(--body); color: var(--gilt); }
.leaflet-bar .zoom-stage:hover, .leaflet-bar .zoom-stage[aria-expanded="true"] { background: var(--ink-2); }
.leaflet-bar a.leaflet-control-zoom-out { border-radius: 0; border-bottom: 1px solid var(--line); }
.zoom-stage-list { position: fixed; z-index: 1300; left: 0; top: 0; display: flex; flex-direction: column; min-width: 92px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.zoom-stage-list[hidden] { display: none; }
.zoom-stage-list button { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 10px 0 6px; border: 0; border-radius: 4px;
  background: transparent; color: var(--paper); font: 500 13px var(--body); text-align: left; white-space: nowrap; }
.zoom-stage-list button:hover { background: var(--ink-2); }
.zoom-stage-list button .n { display: inline-block; width: 18px; text-align: center; color: var(--mute); font-size: 11px; }
.zoom-stage-list button.on { color: var(--gilt); background: rgba(220, 183, 106, 0.12); }
.zoom-stage-list button.on .n { color: var(--gilt); }
@media (max-width: 760px) {
  .leaflet-bar .zoom-stage { min-width: 44px; min-height: 40px; }
  .leaflet-bar .zoom-stage b { font-size: 12px; }
  .zoom-stage-list button { min-height: 44px; font-size: 14px; }
}
/* 눕힌 휴대폰: 단추가 가로 한 줄이라 단계 칸도 그 오른쪽 끝에 */
@media (max-width: 760px) and (max-height: 500px) and (min-width: 640px) {
  .leaflet-bar .zoom-stage { width: auto; min-height: 44px; padding: 0 6px; border-left: 1px solid var(--line); border-radius: 0 6px 6px 0; }
  .leaflet-touch .leaflet-control-zoom a.leaflet-control-zoom-out { border-radius: 0; border-bottom: 0; }
}
/* ── 주의사항·건의사항으로 가는 글자 단추 (목록 창 맨 아래, 첫 화면 카드 아래) ── */
.sec.site-links { display: flex; gap: 8px; padding: 12px 14px 16px; border-top: 1px solid var(--line); margin-top: 6px; }
.sec.site-links a { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--mute); text-decoration: none; font-size: 13px; }
.sec.site-links a:hover { color: var(--gilt); border-color: var(--gilt); }
.intro-card p.site-links { margin-top: 10px; font-size: 12px; text-align: center; color: var(--mute); }
.intro-card p.site-links a { color: var(--mute); display: inline-block; padding: 10px 6px; }
.intro-card p.site-links a:hover { color: var(--gilt); }

/* ── 광고 칸 (ads.js에 애드센스 번호를 넣었을 때만 보인다) ── */
.sec.ad-slot { padding: 10px 14px; border-top: 1px solid var(--line); min-height: 120px; }
.ad-slot .ad-label { font-size: 10px; color: var(--mute); letter-spacing: 1px; margin-bottom: 4px; }

/* ── 내 기록 (mine.js): 내 장면 · 내 연표 · 도감 · 오늘의 퀴즈 ── */
#mineBtn { pointer-events: auto; position: absolute; left: 190px; top: 16px; background: var(--panel); color: var(--paper); border: 1px solid rgba(220, 183, 106, 0.55);
  border-radius: 6px; padding: 0 14px; font-size: 13px; min-height: 36px; cursor: pointer; }
#mineBtn:hover { background: var(--ink-2); }
#mineBtn.on { background: var(--gilt); color: #241703; }
#minePanel { position: fixed; z-index: 1500; left: 70px; top: 66px; width: 390px; max-height: calc(100% - 180px); display: flex; flex-direction: column;
  background: rgba(19, 26, 39, 0.98); border: 1px solid rgba(220, 183, 106, 0.45); border-radius: 12px; box-shadow: var(--shadow); color: var(--paper); }
#minePanel[hidden] { display: none; }
.mp-head { display: flex; align-items: center; padding: 10px 8px 4px 16px; }
.mp-head h2 { flex: 1; margin: 0; font: 900 18px var(--display); color: #fbf3df; }
.mp-x { background: none; border: 0; color: var(--mute); font-size: 22px; min-width: 40px; min-height: 40px; }
.mp-tabs { display: flex; gap: 4px; padding: 4px 12px 8px; border-bottom: 1px solid var(--line); }
.mp-tabs button { flex: 1; min-height: 38px; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--mute); font-size: 13px; white-space: nowrap; }
.mp-tabs button.on { color: var(--gilt); border-color: rgba(220, 183, 106, 0.5); background: rgba(220, 183, 106, 0.08); font-weight: 700; }
.mp-body { overflow-y: auto; padding: 10px 16px 14px; overscroll-behavior: contain; }
.mp-body h3 { font: 700 13px var(--display); color: var(--gilt); margin: 16px 0 8px; }
.mp-body h3 small { color: var(--mute); font: 400 12px var(--body); margin-left: 6px; }
.mp-lead { font-size: 12.5px; line-height: 1.65; color: #c9c3b6; margin: 0 0 10px; }
.mp-empty { font-size: 13px; color: var(--mute); text-align: center; padding: 18px 6px; line-height: 1.7; }
.mp-main { background: var(--gilt); color: #1a1408; border: 0; border-radius: 8px; min-height: 40px; padding: 0 14px; font-weight: 700; font-size: 13px; }
.mp-wide { width: 100%; margin: 4px 0 8px; }
.mp-new { display: flex; gap: 6px; margin-bottom: 8px; }
.mp-new input { flex: 1; min-width: 0; }
#minePanel input, #minePanel select { font: inherit; font-size: 13px; color: var(--paper); background: var(--ink); border: 1px solid rgba(220, 183, 106, 0.3); border-radius: 8px;
  min-height: 40px; padding: 0 10px; width: 100%; }
#minePanel input:focus, #minePanel select:focus { outline: none; border-color: var(--gilt); }
.mp-list { list-style: none; margin: 8px 0 0; padding: 0; }
.mp-list li { display: flex; gap: 8px; align-items: center; padding: 9px 0; border-top: 1px solid rgba(220, 183, 106, 0.12); }
.mp-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mp-t b { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-t span { font-size: 12px; color: var(--mute); }
.mp-t em { font-style: normal; font-size: 12px; color: #d9cfae; margin-top: 2px; }
.mp-a { display: flex; gap: 4px; flex: none; }
.mp-a button, .mp-place button, .mp-foot button, .qz-stop { background: none; border: 1px solid var(--line); border-radius: 7px; color: var(--paper); font-size: 12px; min-height: 34px; padding: 0 10px; }
.mp-a button:hover, .mp-place button:hover, .mp-foot button:hover { border-color: var(--gilt); color: var(--gilt); }
.mp-form { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 4px; }
.mp-form label { display: grid; gap: 3px; font-size: 12px; color: var(--mute); }
.mp-row { display: grid; grid-template-columns: 1.6fr 1.1fr 0.8fr 0.8fr; gap: 6px; }
.mp-place { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--mute); }
.mp-place b { color: var(--paper); font-weight: 500; }
.mp-err { color: #f0a08f; font-size: 12px; margin: 0; }
.mp-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.mp-cats div { background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.mp-cats b { font: 900 20px var(--display); color: #fbf3df; }
.mp-cats span { font-size: 11.5px; color: var(--mute); }
.mp-eras { display: flex; flex-wrap: wrap; gap: 4px; }
.mp-eras button { font-size: 11px; padding: 4px 8px; border-radius: 12px; border: 1px dashed rgba(160, 168, 184, 0.35); background: none; color: var(--mute); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-eras button.on { border-style: solid; border-color: rgba(220, 183, 106, 0.6); color: #ffe3a3; background: rgba(220, 183, 106, 0.1); }
.mp-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.mp-badges div { display: grid; grid-template-columns: 26px 1fr; column-gap: 6px; align-items: center; padding: 6px 8px; border-radius: 8px; border: 1px solid rgba(160, 168, 184, 0.18); opacity: 0.55; }
.mp-badges div.on { opacity: 1; border-color: rgba(220, 183, 106, 0.55); background: rgba(220, 183, 106, 0.07); }
.mp-badges i { grid-row: span 2; font-style: normal; font-size: 18px; text-align: center; }
.mp-badges b { font-size: 12.5px; font-weight: 700; }
.mp-badges span { font-size: 11px; color: var(--mute); }
.mp-foot { border-top: 1px solid var(--line); padding: 8px 16px 10px; font-size: 11.5px; color: var(--mute); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mp-foot button { min-height: 30px; font-size: 11.5px; }
/* 퀴즈 */
.qz-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--mute); }
.qz-q { font-size: 15px; margin: 8px 0; }
.qz-card { border: 1px solid rgba(220, 183, 106, 0.45); border-radius: 10px; padding: 10px 12px; background: rgba(220, 183, 106, 0.06); }
.qz-card b { display: block; font: 900 17px var(--display); color: #fbf3df; }
.qz-card span { font-size: 12px; color: var(--mute); }
.qz-card p { font-size: 12.5px; line-height: 1.65; margin: 8px 0 0; color: #d6d0c2; }
.qz-ch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.qz-ch button { min-height: 46px; border-radius: 8px; border: 1px solid rgba(220, 183, 106, 0.4); background: var(--ink); color: var(--paper); font: 700 15px var(--display); }
.qz-ch button:hover:not(:disabled) { border-color: var(--gilt); background: rgba(220, 183, 106, 0.1); }
.qz-ch button.right { background: rgba(134, 191, 162, 0.25); border-color: var(--jade); color: #d8f5e6; }
.qz-ch button.wrong { background: rgba(210, 85, 61, 0.22); border-color: var(--seal); color: #ffd6cc; }
.qz-ch button:disabled:not(.right):not(.wrong) { opacity: 0.5; }
.qz-res { font-weight: 700; font-size: 14px; margin: 4px 0; }
.qz-done { font-size: 14px; text-align: center; margin: 12px 0 6px; }
.qz-stop { margin-top: 6px; }
.mp-days { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.mp-days li { display: flex; justify-content: space-between; padding: 4px 0; color: var(--mute); }
.mp-days b { color: var(--gilt); letter-spacing: 2px; font-weight: 400; }
/* 퀴즈 중에는 연도가 드러나는 곳을 가린다 */
body.quizzing #clock, body.quizzing #chronHead, body.quizzing #chronTip, body.quizzing #panel, body.quizzing #feed, body.quizzing #rateText,
body.quizzing #panelToggle, body.quizzing #story, body.quizzing #cineHud, body.quizzing #chron { visibility: hidden !important; }
/* 지도 위 내 연표 핀 */
#minePins { position: absolute; inset: 0; z-index: 460; pointer-events: none; overflow: hidden; }
#minePins.zooming { opacity: 0; }
.mine-pin { position: absolute; left: 0; top: 0; pointer-events: auto; background: none; border: 0; padding: 0; cursor: pointer; }
.mine-pin[hidden] { display: none; }
/* 핀 끝이 그 자리를 가리키게: 동그란 머리는 위, 이름표는 오른쪽 */
.mine-pin i { position: absolute; left: -15px; top: -38px; font-style: normal; width: 30px; height: 30px; display: grid; place-items: center; background: #fbf0d4;
  border: 2px solid var(--gilt); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45); font-size: 15px; line-height: 1; }
.mine-pin i::before { content: ''; }
.mine-pin span { position: absolute; left: 18px; top: -34px; white-space: nowrap; font: 700 12px var(--body); color: #3a2a08; background: rgba(251, 240, 212, 0.96);
  border: 1px solid var(--gilt); border-radius: 10px; padding: 2px 9px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.mine-pin.hot i { animation: minePulse 1.4s ease-in-out infinite; }
@keyframes minePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 183, 106, 0.8); } 50% { box-shadow: 0 0 0 10px rgba(220, 183, 106, 0); } }
body.watching .mine-pin, body.watching #mineBtn, body.watching #minePanel, body.watching #mineTicks { display: none !important; }
/* 연표 자 위 금빛 표시 */
#mineTicks { position: absolute; inset: 0; pointer-events: none; }
#mineTicks span { position: absolute; top: -3px; width: 8px; height: 8px; margin-left: -4px; background: #ffe3a3; border: 1px solid #7a5a1a; transform: rotate(45deg); }
/* 지도에서 자리 고르기 */
#minePick[hidden] { display: none; }
#minePick .cross { position: fixed; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; z-index: 1600; pointer-events: none;
  background: linear-gradient(var(--seal), var(--seal)) center/2px 100% no-repeat, linear-gradient(var(--seal), var(--seal)) center/100% 2px no-repeat; filter: drop-shadow(0 0 2px #fff); }
#minePick .bar { position: fixed; z-index: 1600; left: 50%; transform: translateX(-50%); top: 84px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: var(--panel); border: 1px solid var(--gilt); border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); width: max-content; max-width: calc(100% - 24px); }
#minePick .bar button:not(.mp-main) { background: none; border: 1px solid var(--line); color: var(--paper); border-radius: 8px; min-height: 40px; padding: 0 14px; }
/* 알림 */
#mineToast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 112px; z-index: 1700; display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; width: max-content; max-width: min(460px, calc(100% - 32px)); }
#mineToast .mt { background: rgba(19, 26, 39, 0.96); border: 1px solid rgba(220, 183, 106, 0.5); color: var(--paper); font-size: 13px; padding: 8px 12px; border-radius: 8px;
  box-shadow: var(--shadow); animation: slidein 0.3s ease; transition: opacity 0.4s; }
#mineToast .mt.big { border-color: var(--gilt); color: #ffe3a3; font-weight: 700; }
#mineToast .mt.out { opacity: 0; }
@media (max-width: 760px) {
  #mineBtn { min-height: 44px; border-radius: 8px; }
  #minePanel { left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r)); width: auto; top: calc(136px + var(--safe-t)); bottom: calc(var(--dock-clear) + 8px); max-height: none; }
  .mp-foot { padding: 6px 12px 8px; }
  .mp-tabs button { min-height: 44px; font-size: 12.5px; }
  .mp-a button { min-height: 40px; }
  #mineToast { bottom: calc(var(--dock-clear) + 12px); max-width: calc(100% - 24px); }
  #minePick .bar { top: calc(136px + var(--safe-t)); }
}
@media (max-width: 760px) and (max-height: 500px) and (min-width: 640px) {
  #minePanel { top: calc(66px + var(--safe-t)); }
}

/* ── 첫 화면 이름: 그때 그곳 ── */
.intro-card .intro-logo { display: block; width: 64px; height: 64px; margin: 0 0 10px; border-radius: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.intro-card h1 + .intro-sub { margin: -6px 0 12px; font: 700 15px var(--display); color: var(--gilt); letter-spacing: 1px; }
