:root {
  --bg: #12110e;
  --panel: #1b1914;
  --panel-2: #24211b;
  --line: #3a3429;
  --text: #ece4d4;
  --muted: #9a8f7c;
  --gold: #e6b85c;
  --gold-dark: #b98c34;
  --red: #e05a4f;
  --blue: #5b9bd5;
  --green: #5fbf7f;
  --sea: #c9c1aa;
  --land: #efe8d6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--red); }
.ok { color: var(--green); }
.accent { color: var(--gold); }

/* ── 버튼·입력 ────────────────────── */
.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: bold;
}
.btn:hover { border-color: var(--gold-dark); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.icon { width: 34px; height: 34px; padding: 0; font-size: 16px; }
.btn.block { width: 100%; margin-top: 12px; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.btn.primary:hover { background: #f0c66e; }
.btn.danger { background: #7a2620; border-color: #9a352d; }
.btn.danger:hover { background: #923029; }
.btn:disabled { opacity: 0.4; cursor: default; }

select, input[type=text], input[type=number], input[type=time], input[type=date], input:not([type]), input[type=password] {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  outline: none;
}
select:focus, input:focus { border-color: var(--gold-dark); }

.link { background: none; border: none; color: var(--muted); text-decoration: underline; font-size: 12px; }
.link:hover { color: var(--text); }
.link.warn { color: var(--red); }

/* ── 상단 ─────────────────────────── */
.topbar {
  display: flex;
  align-items: stretch;
  gap: 16px;
  padding: 0 24px;
  background: #0d0c0a;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1100;
  min-height: 64px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  color: var(--gold);
  font-size: 18px;
}
.brand b { display: block; letter-spacing: 1px; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }

.tabs { display: flex; margin: 0 auto; }
.tab {
  background: none;
  border: none;
  padding: 0 16px;
  color: var(--muted);
  font-weight: bold;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); background: rgba(230, 184, 92, 0.06); }

.top-right { display: flex; align-items: center; gap: 12px; }
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  min-width: 150px;
}
.status-pill b { display: block; font-size: 12px; }
.status-pill small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.dot.locked { background: var(--gold); }
.me-label { display: flex; align-items: center; gap: 6px; font-weight: bold; }

.daybar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  background: #0f1513;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.progress { flex: 1; max-width: 420px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--gold); transition: width 1s linear; }

/* ── 레이아웃 ─────────────────────── */
main { max-width: 1680px; margin: 0 auto; padding: 24px 24px 60px; }
.page { display: none; }
.page.active { display: block; }

.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.page-head h1 { font-size: 22px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.panel h2 { font-size: 16px; }
.panel h3 { font-size: 14px; margin-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.panel-head small { color: var(--muted); font-size: 12px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 16px;
}
.tile { padding: 14px 18px; border-right: 1px solid var(--line); }
.tile:last-child { border-right: none; }
.tile small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tile b { font-size: 24px; margin-right: 4px; }
.tile span { color: var(--muted); font-size: 12px; }

.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }

/* ── 지도 ─────────────────────────── */
.map-tools { display: flex; gap: 8px; }
.map-wrap { position: relative; }
.map {
  height: 680px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--sea);
}
.map.tall { height: 760px; }

.map-search { position: absolute; top: 10px; left: 10px; z-index: 900; width: 240px; }
.map-search input { width: 100%; background: rgba(18, 17, 14, 0.92); }
.search-results { list-style: none; margin-top: 4px; background: rgba(18, 17, 14, 0.95); border-radius: 6px; overflow: hidden; }
.search-results li { padding: 7px 10px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-results li:hover { background: var(--panel-2); }
.search-results li small { color: var(--muted); margin-left: 6px; }

.map-badge {
  position: absolute;
  top: 52px;
  left: 10px;
  z-index: 800;
  background: rgba(18, 17, 14, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: bold;
}

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.lg.neutral { background: var(--land); }
.lg.new { background: var(--land); border: 2px solid #fff3a8; }
.lg.line { height: 0; width: 22px; border-radius: 0; border-top: 2px solid; }
.lg.line.attack { border-color: var(--red); border-top-style: dashed; }
.lg.line.attack-order { border-color: var(--red); border-top-width: 3px; }
.lg.line.defend { border-color: var(--blue); border-top-width: 3px; }
.lg.line.mine { border-color: #2e4d2e; }
.lg-icon { font-style: normal; display: inline-grid; place-items: center; }
.lg-icon.capital { color: var(--gold); }
.lg-icon.heritage { color: var(--gold); }
.lg-icon.station { width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid #333; }
.lg-icon.port { width: 9px; height: 9px; border-radius: 50%; background: #5b7f9e; border: 2px solid #fff; }
.lg-icon.vs { font-size: 9px; font-weight: bold; background: #111; color: #fff; padding: 1px 3px; border-radius: 3px; }

/* 지도 위 아이콘 */
.mk { background: none; border: none; }
/* 아이콘 크기가 0이라 폭을 내용에 맞춰야 이름표 배경이 글자를 감쌈 */
.mk span { display: block; width: max-content; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none; text-align: center; }
.mk-capital span { color: #ffd15c; font-size: 16px; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.mk-vs span {
  background: #111;
  color: #fff;
  font-size: 9px;
  font-weight: bold;
  padding: 1px 3px;
  border-radius: 3px;
  border: 1px solid #fff;
}

/* ── 리플레이 ─────────────────────── */
.replay { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.replay-label { min-width: 90px; }
.replay-label small { display: block; color: var(--muted); font-size: 11px; }
#replay-slider { flex: 1; accent-color: var(--gold); }

/* ── 순위 ─────────────────────────── */
.rank-panel { max-height: 760px; display: flex; flex-direction: column; }
.rank-panel > p { margin-bottom: 8px; }
.rank-list { list-style: none; overflow-y: auto; }
.rank-list li {
  display: grid;
  grid-template-columns: 26px 4px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 4px;
}
.rank-list li:hover, .rank-list li.focused { background: var(--panel-2); }
.rank-list .no { color: var(--muted); font-size: 12px; }
.rank-list .bar { width: 4px; height: 28px; border-radius: 2px; }
.rank-list .nm b { display: block; }
.rank-list .nm small { color: var(--muted); font-size: 11px; }
.rank-list .score { font-size: 18px; font-weight: bold; }
.rank-list .score small { font-size: 11px; color: var(--muted); margin-left: 2px; }

.sw {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ── 뉴스 ─────────────────────────── */
.news-panel { margin-top: 16px; }
#news-list { max-height: 520px; overflow-y: auto; }
.news-day h4 { color: var(--gold); font-size: 13px; margin: 14px 0 6px; }
.news-day:first-child h4 { margin-top: 0; }
.news-day ul { list-style: none; }
.news-day li { padding: 7px 0; border-bottom: 1px solid var(--line); line-height: 1.5; }

/* ── 작전실 ───────────────────────── */
.guest { text-align: center; padding: 60px 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.ops-side { display: flex; flex-direction: column; gap: 12px; }
.summary-lines div { margin-top: 4px; }

.commands { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.commands small { display: block; color: var(--muted); font-size: 12px; }
.commands b { font-size: 28px; color: var(--gold); }
#ops-submit-state { text-align: right; font-size: 12px; }
#ops-submit-state .btn { margin-top: 4px; }

#ops-selected h3 { margin-bottom: 4px; }
#ops-selected > div { margin-top: 4px; }
#ops-selected > .btn, #ops-selected > p { margin-top: 12px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 11px; padding: 2px 6px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); }

.order-row { display: flex; gap: 8px; margin-top: 12px; }
.order-row input { width: 70px; }

.orders { list-style: none; }
.orders li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.orders .nm { flex: 1; font-size: 13px; }
.tag { font-size: 11px; color: #fff; padding: 2px 6px; border-radius: 3px; }
.tag.attack { background: #a8362d; }
.tag.defend { background: #2e6aa8; }
.tag.admin { background: #555; margin-left: 4px; }

.diplo li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.diplo { list-style: none; margin-bottom: 10px; }
.diplo .nm { flex: 1; }
.diplo .state { font-size: 11px; color: var(--muted); }
.diplo-new { display: flex; gap: 8px; }
.diplo-new select { flex: 1; min-width: 0; }

/* 작전실 통계·모드·대기열 */
.ops-tiles { grid-template-columns: repeat(6, 1fr); }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.mode-tabs button { background: var(--panel-2); border: none; border-right: 1px solid var(--line); padding: 10px; font-weight: bold; color: var(--muted); }
.mode-tabs button:last-child { border-right: none; }
.mode-tabs button:hover { color: var(--text); }
.mode-tabs button.active { background: var(--gold); color: #1a1408; }
.queue-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.queue-head h3 { margin-bottom: 0; }
.tag.chain { background: #b96a17; }
.plans { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.plans-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.plan-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; font-size: 12px; }
.plan-row .slot { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); font-weight: bold; }
.plan-row .slot.saved { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.plan-row .info { flex: 1; color: var(--muted); }
.conn-list { margin-top: 8px; font-size: 12px; line-height: 1.7; }
.conn-list b { color: var(--gold); font-weight: normal; }
.lg.line.isolated { border-color: #8a8a8a; border-top-style: dotted; }
.lg.line.chain { border-color: #e08a2a; border-top-style: dashed; }

/* 지도 위 이름표 */
.map-label { background: none; border: none; }
.map-label span {
  display: block;
  transform: translate(-50%, 7px);
  white-space: nowrap;
  font-size: 11px;
  font-weight: bold;
  color: #1a1408;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff;
  pointer-events: none;
}
.map-label.heritage span { color: #6b4500; }
.map-label.port span { color: #1d4a6e; }
.mk-capital span em {
  display: block;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  background: rgba(18, 17, 14, 0.85);
  border-radius: 3px;
  padding: 0 4px;
  margin-top: -2px;
  text-shadow: none;
  text-align: center;
}

/* 서신함 */
.badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.letter-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.letter-form select { grid-column: 1 / -1; }
.letter-form textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
  font: inherit;
  color: var(--text);
}
.letter-form button { align-self: end; }
.letter-filter select { width: 100%; }
.letters { list-style: none; max-height: 420px; overflow-y: auto; }
.letters li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.letters li.in { border-left: 3px solid var(--gold); }
.letters li.out { border-left: 3px solid var(--blue); background: rgba(91, 155, 213, 0.05); }
.letters li.unread { background: rgba(230, 184, 92, 0.08); }
.letters .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.letters .meta b { color: var(--text); }
.letters .body { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }

.letter-form select[name=kind] { grid-column: 1 / -1; }
.letter-form p { grid-column: 1 / -1; }
.letter-tabs { display: flex; gap: 6px; }
.letter-tabs .btn.active { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.letter-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.letters li.open .body { padding: 8px 0; border-top: 1px solid var(--line); margin-top: 6px; }
.read-mark { font-size: 11px; color: var(--muted); }
.read-mark.unread { color: var(--red); }
.read-mark.new { color: var(--gold); font-weight: bold; }
.tag.strategy { background: #555; }
.tag.ally { background: #3a7a4f; }
.tag.break { background: #7a2620; }

/* ── 출석판 ───────────────────────── */
.page-head #letters-btn { align-self: center; }
.attendance-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.attendance-strip .att-title { font-weight: bold; margin-right: 6px; }
.att-cell {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.1;
  position: relative;
}
.att-cell i { font-style: normal; font-size: 13px; color: var(--red); }
.att-cell.on { border: 2px solid var(--red); color: var(--text); background: rgba(224, 90, 79, 0.08); }
.att-cell.today { box-shadow: 0 0 0 2px var(--gold-dark); }
.attendance-strip.big { justify-content: center; border: none; background: none; padding: 4px 0; }
.attendance-strip.big .att-cell { width: 54px; height: 54px; font-size: 14px; }
.attendance-strip.big .att-cell i { font-size: 18px; }

/* ── 작전실 하단 명령권 식 ─────────── */
.cmd-formula {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 14px;
}
.cmd-formula .label { font-weight: bold; }
.cmd-formula .op { color: var(--muted); }
.cmd-formula .term { padding: 3px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); cursor: help; }
.cmd-formula .term b, .cmd-formula .total b { color: var(--gold); }
.cmd-formula .total { font-weight: bold; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--gold-dark); }
.cmd-formula > .small { margin-left: auto; }

/* ── 명령·스킬 ────────────────────── */
.order-row { flex-wrap: wrap; }
.tag.strong { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); }
.tag.skill { background: #6a45a8; }
.tag.cat-attack { background: #a8362d; }
.tag.cat-defend { background: #2e6aa8; }
.tag.cat-ops { background: #8a6a1f; }
.tag.cat-intel { background: #4f5b66; }
.lg.line.skill { border-color: #8e5bd6; border-top-style: dashed; border-top-width: 3px; }
.orders li b { font-size: 12px; white-space: nowrap; }

.skills { list-style: none; }
.skill { padding: 8px 0; border-bottom: 1px solid var(--line); }
.skill:last-child { border-bottom: none; }
.skill-head { display: flex; align-items: center; gap: 6px; }
.skill-head .cd { margin-left: auto; font-size: 11px; color: var(--muted); }
.skill-desc { font-size: 12px; color: var(--muted); margin: 4px 0 6px; line-height: 1.5; }
.skill-form { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 6px; background: var(--panel-2); }
.skill-form input { width: 100%; }
/* 스킬 대상 찾기: 지역 찾기처럼 목록을 띄우고, 가능·불가능을 함께 표시 */
.skill-pick { position: relative; }
.skill-pick .search-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin-top: 2px; max-height: 300px; overflow-y: auto; }
.skill-pick .search-results li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.skill-pick .search-results li.no { color: var(--muted); }
.skill-pick .pick-badge { flex-basis: 100%; font-size: 11px; }
.skill-pick li.ok .pick-badge { color: var(--green); }
.skill-pick li.no .pick-badge { color: var(--red); }
.skill-pick .pick-state { margin-top: 3px; min-height: 0; }
.skill-form .order-row { margin-top: 4px; }
.skill-today { padding: 8px 10px; margin-bottom: 8px; border: 1px solid #6a45a8; border-radius: 6px; background: rgba(142, 91, 214, 0.08); font-size: 13px; }
.skill-today .link { margin-top: 4px; }
.skill-result { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); line-height: 1.6; }
.offer-btn { margin: 0 0 10px; }
.offer-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.offer-card {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.offer-card:hover { border-color: var(--gold); background: rgba(230, 184, 92, 0.08); }
.offer-card .tag { align-self: flex-start; }
.offer-card b { font-size: 16px; }
.offer-card span:not(.tag) { font-size: 12px; line-height: 1.5; }
.offer-card small { color: var(--muted); font-size: 11px; margin-top: auto; }
.skill-chips { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

/* ── 관리자: 명령권 지급 ───────────── */
.admin-grants { margin-bottom: 16px; }
.grant-players-head { display: flex; justify-content: space-between; align-items: center; }
.grant-players { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.form label.grant-player { flex-direction: row; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; }
.grant-player .nm { flex: 1; }
.grant-player .nm small { display: block; color: var(--muted); font-size: 11px; }
.grant-player .cmd { font-size: 12px; color: var(--muted); white-space: nowrap; }
.grant-player .cmd b { color: var(--gold); }
.grant-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grant-row input[name=count] { width: 70px; }
.grant-row input[name=reason] { flex: 1; min-width: 120px; }
.grant-log { list-style: none; max-height: 320px; overflow-y: auto; }
.grant-log li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.grant-log li .nm { flex: 1; }
.grant-log li.canceled { opacity: 0.5; }
#capital-warnings .sum-warn { margin-bottom: 12px; }

/* ── 관리자: 서신 열람 ─────────────── */
.admin-letters { margin-bottom: 16px; }
.admin-letter-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.admin-letter-filter input[name=day] { width: 80px; }
.admin-letter-filter input[name=text] { flex: 1; min-width: 160px; }
.admin-letter-table td { vertical-align: top; font-size: 13px; }
.admin-letter-table td.nowrap { white-space: nowrap; }
.admin-letter-table td.letter-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; min-width: 240px; }

/* ── 관리자: 게임 운영 ─────────────── */
.game-control { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 16px; }
.game-state { display: flex; align-items: center; gap: 10px; }
.game-state .dot { width: 12px; height: 12px; }
.game-buttons { display: flex; gap: 8px; margin-left: auto; }
.game-help { flex-basis: 100%; line-height: 1.6; }
.game-help b { color: var(--text); }

/* ── 시즌 ─────────────────────────── */
.season-pill { margin-left: auto; padding: 2px 10px; border: 1px solid var(--gold-dark); border-radius: 10px; color: var(--gold); font-weight: bold; }
.season-banner { margin-bottom: 16px; border-color: var(--gold); background: linear-gradient(180deg, rgba(230, 184, 92, 0.12), var(--panel)); }
.season-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.season-head .trophy { font-size: 34px; }
.season-head h2 { font-size: 18px; }
.season-rank { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.season-rank li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.season-rank li.r1 { border-color: #ffd15c; }
.season-rank .medal { width: 34px; text-align: center; font-weight: bold; }
.season-rank .pts { margin-left: auto; color: var(--gold); font-weight: bold; font-size: 16px; }

/* ── 리더보드 ─────────────────────── */
.board { width: 100%; border-collapse: collapse; }
.board th, .board td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
.board th { color: var(--muted); font-weight: normal; font-size: 12px; }
.board td .sw { margin-right: 6px; }
.board tr.me { background: rgba(230, 184, 92, 0.08); }
.board td.actions { text-align: right; white-space: nowrap; }
.board td.actions .link { margin-left: 8px; }

/* 부문별 1위 카드 */
.award-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.award {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.award:hover { border-color: var(--gold-dark); }
.award.active { border-color: var(--gold); background: rgba(230, 184, 92, 0.08); }
.award .award-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.award .award-label i { font-style: normal; }
.award .award-who { font-weight: bold; font-size: 15px; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.award .award-value { color: var(--gold); font-size: 20px; font-weight: bold; }
.award .award-value small { font-size: 12px; color: var(--muted); margin-left: 2px; font-weight: normal; }
.award .award-none { color: var(--muted); font-size: 13px; }

.board-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.board-tabs .btn.active { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.board th.metric-col, .board td.metric-col { color: var(--gold); font-weight: bold; }
.board td.metric-col { font-size: 16px; }
.board .rank-1 td:first-child { color: #ffd15c; font-weight: bold; }
.board .rank-2 td:first-child { color: #d9d9d9; font-weight: bold; }
.board .rank-3 td:first-child { color: #d69a5a; font-weight: bold; }
.board .up { color: var(--green); }
.board .down { color: var(--red); }

/* ── 튜토리얼: tutorial.css ───────── */

/* ── 관리자 ───────────────────────── */
.ops-side .panel p { margin-bottom: 4px; line-height: 1.5; }

/* ── 역·항구·문화재 표시 ──────────── */
/* 바깥 div(.site-icon)는 Leaflet 이 위치를 잡고, 안쪽 .site 가 그림. 축소하면 --site-scale 만큼 작아짐 */
.site-icon { background: none; border: none; }
.site-icon .site {
  position: absolute;
  left: -6px;
  top: -6px;
  width: 12px;
  height: 12px;
  transform: scale(var(--site-scale, 1));
  transition: transform 0.15s;
}
.site-icon .site-heritage { left: -8px; top: -8px; width: 16px; height: 16px; }
.site { display: block; font-style: normal; border-radius: 50%; box-sizing: border-box; }
.site-station { background: #fff; border: 2px solid #222; }
.site-port { background: #2f6690; border: 2px solid #fff; }
.site-heritage {
  border-radius: 0;
  color: #ffd15c;
  font-size: 15px;
  line-height: 16px;
  text-align: center;
  text-shadow: 0 0 2px #000, 0 0 2px #000, 0 0 2px #000;
}
.site.picked { box-shadow: 0 0 0 3px #ffd54a, 0 0 8px 3px rgba(255, 213, 74, 0.8); }
.site-heritage.picked { box-shadow: none; color: #fff; }

/* 선로·바닷길 층: 빈 곳은 클릭이 아래 지역으로 지나가게 */
.leaflet-feat-pane svg { pointer-events: none; }
.zoom-far .ln-rail:not(.leaflet-interactive) { stroke-width: 1.5px; }
.zoom-far .ln-rail-dash { display: none; }
.zoom-far .ln-sea:not(.leaflet-interactive) { stroke-width: 1.2px; }

/* ── 지도 편집 ────────────────────── */
.editor { margin-bottom: 16px; }
.editor-save { display: flex; align-items: center; gap: 8px; }
.editor-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.editor-tools .btn { display: flex; align-items: center; gap: 6px; }
.editor-tools .btn.active { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.site-dot { display: inline-block; width: 11px; height: 11px; font-style: normal; }
.site-dot.site-heritage { width: auto; height: auto; font-size: 13px; line-height: 1; }
.ed-hint {
  margin: 10px 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  min-height: 36px;
}
.ed-hint b { color: var(--gold); }
.ed-list { max-height: 640px; overflow-y: auto; font-size: 13px; }
.ed-list h4 { color: var(--gold); font-size: 12px; margin: 12px 0 4px; display: flex; justify-content: space-between; }
.ed-list h4:first-child { margin-top: 0; }
.ed-list ul { list-style: none; }
.ed-list li { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.ed-list li .nm { flex: 1; cursor: pointer; }
.ed-list li .nm:hover { color: var(--gold); }
.ed-list li small { color: var(--muted); }
.admin-accounts { margin-top: 0; }

/* ── 지도 툴팁·컨트롤 ─────────────── */
.leaflet-tooltip.region-tooltip {
  background: rgba(18, 17, 14, 0.94);
  border: 1px solid var(--gold-dark);
  color: var(--text);
  font-family: inherit;
  padding: 6px 10px;
  box-shadow: none;
}
.leaflet-tooltip.region-tooltip::before { display: none; }
/* 지역 툴팁: 점령된 땅이면 나라 색 배경 (안쪽 상자가 바깥 여백까지 채움) */
.leaflet-tooltip.region-tooltip:has(.tt-box.owned) { padding: 0; }
.tt-box.owned { padding: 6px 10px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55); }
.tt-box.owned.light { color: #12110e; text-shadow: none; }
.tt-box.owned .tt-owner, .tt-box.owned .tt-tags { color: inherit; opacity: 0.85; }
.tt-name { font-weight: bold; font-size: 13px; }
.tt-owner { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tt-tags { font-size: 11px; color: var(--gold); margin-top: 2px; }

.leaflet-bar a { background: var(--panel); color: var(--text); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--panel-2); color: var(--gold); }
.leaflet-container { font-family: inherit; }

/* ── 모달 ─────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  width: 360px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-box.wide { width: 560px; }
.modal-box h4 { font-size: 13px; color: var(--gold); margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form h3 { margin-bottom: 0; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input { color: var(--text); }
.form input[type=color] { height: 38px; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; }

.sum-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sum-table th, .sum-table td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sum-table th { color: var(--muted); font-weight: normal; font-size: 12px; }
.sum-table .note { display: block; font-size: 11px; margin-top: 2px; }
.sum-total { display: flex; justify-content: space-between; font-weight: bold; padding: 8px 0; }
.sum-warn { background: rgba(224, 90, 79, 0.1); border: 1px solid rgba(224, 90, 79, 0.4); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.sum-info { color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ── 토스트 ───────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--gold-dark);
  padding: 10px 18px;
  border-radius: 6px;
  z-index: 2100;
  max-width: calc(100% - 32px);
}
.toast.error { border-color: var(--red); color: #ffb3ad; }

/* ── 반응형 ───────────────────────── */
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; margin: 0; }
  .tab { padding: 10px 12px; white-space: nowrap; }
  .grid-main { grid-template-columns: 1fr; }
  .rank-panel { max-height: 480px; }
  .award-grid { grid-template-columns: repeat(2, 1fr); }
  .ops-tiles { grid-template-columns: repeat(3, 1fr); }
  .ops-tiles .tile:nth-child(3) { border-right: none; }
  .ops-tiles .tile:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .offer-cards { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .brand small, .me-label, .status-pill { display: none; }
  .daybar { padding: 8px 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile:nth-child(2) { border-right: none; }
  .tile:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .map, .map.tall { height: 420px; }
  .map-search { width: calc(100% - 60px); }
  .panel-head { flex-direction: column; }
  .replay { flex-wrap: wrap; }
  #replay-slider { order: 5; width: 100%; flex-basis: 100%; }
  #tab-board .board th:nth-child(n+4), #tab-board .board td:nth-child(n+4) { display: none; }
}
