:root {
  --bg: #f2f1ee;
  --card-bg: #ffffff;
  --text: #2b2b2b;
  --text-dim: #767676;
  --text-faint: #a9a49f;
  --border: #e7e4df;
  --accent-bar: #6b4040;
  --green: #4f8f6a;
  --red: #c0524a;
  --dark: #34383a;
  --dark-bar: #2f3335;
  --radius: 10px;
  --max-w: 744px;

  --cat-hr: #8a5468;
  --cat-mgmt: #8c7a45;
  --cat-build: #5f7a5a;
  --cat-rnd: #6d5a82;

  --region-west: #c2a878;
  --region-midwest: #b5493e;
  --region-south: #6f8f5c;
  --region-east: #7d5f88;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px 24px 64px;
}

a { color: inherit; text-decoration: none; }

/* ---------- Top bar / header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.brand {
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}

.nav-icons {
  display: flex;
  gap: 18px;
}

.nav-icons button {
  background: none;
  border: none;
  cursor: pointer;
  color: #3a3a3a;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icons button:hover { color: #000; }
.nav-icons svg { width: 20px; height: 20px; }

.back-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}
.back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 6px 6px 0;
  display: flex;
  color: var(--text);
}
.back-btn svg { width: 22px; height: 22px; }

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: #3a3a3a;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: #000; }

/* ---------- 바텀시트 모달 (초기 세팅 / 부서 조직 방법) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}
.modal-sheet {
  width: 100%;
  max-width: var(--max-w);
  max-height: 80vh;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  padding: 18px 20px 28px;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .18);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}
.modal-title svg { width: 18px; height: 18px; }
.modal-close {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px;
  display: flex;
}
.modal-close svg { width: 16px; height: 16px; }

/* ---------- 새로운 시작 (경매식 계산기) ---------- */
.bid-input {
  width: 100%;
  background: #e3e1dc;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 16px;
  color: var(--text);
  text-align: center;
  box-sizing: border-box;
}
.bid-input:focus { outline: 2px solid var(--dark); outline-offset: 1px; }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.choice-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
}
.choice-card .val { font-weight: 700; font-size: 15px; }
.choice-card .cost { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.choice-card .cost.income { color: var(--green); }
.choice-card.selected {
  border-color: var(--accent-bar);
  background: #f3e9ea;
}

.summary-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  margin-bottom: 14px;
}
.summary-header {
  background: #e7e4df;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 14px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 13.5px;
  border-top: 1px solid var(--border);
}
.newstart-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  font-weight: 600;
  padding: 12px 4px 0;
}

h1.page-title {
  font-size: 30px;
  font-weight: 700;
  margin: 4px 0 6px;
}

.page-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 18px;
}

/* ---------- Segmented control (기본판 / 확장 포함) ---------- */

.segmented {
  display: inline-flex;
  background: #eae7e1;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 10px;
}
.segmented button {
  border: none;
  background: transparent;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.segmented button.active {
  background: var(--dark);
  color: #fff;
}

.hint-text {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 18px;
}

/* ---------- Home cards ---------- */

.setup-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  cursor: pointer;
  transition: background .12s ease;
}
.setup-card:hover { background: #f7f6f3; }

.setup-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.setup-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
}
.setup-card-title .people-icon { color: #3a3a3a; }
.setup-card-title .badge-exp {
  color: var(--text-dim);
  display: inline-flex;
}
.setup-card-top svg.arrow { width: 20px; height: 20px; color: #555; }

.setup-card-body { margin-top: 10px; }
.setup-line-exclude {
  color: var(--red);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.setup-line-dim {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- Tabs (detail page) ---------- */

.tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tabs button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 2px 12px;
  font-size: 14px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button svg { width: 16px; height: 16px; }
.tabs button.active {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--accent-bar);
}

.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.detail-title-row h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 26px;
  margin: 0;
}
.detail-title-row h1 svg { width: 20px; height: 20px; flex: none; color: var(--text-dim); }
.setup-card-title svg { flex: none; }
.setup-card-title .badge-exp svg { width: 18px; height: 18px; }

/* toggle (요약/상세) reuses .segmented but smaller */
.toggle-sm button { padding: 7px 16px; font-size: 13.5px; }

/* ---------- Stat cards ---------- */

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-top: 3px solid var(--green);
}
.stat-card.exclude { border-top-color: var(--red); }
.stat-card .stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.stat-card .stat-label svg { width: 14px; height: 14px; }
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
}
.stat-card.use .stat-value { color: var(--green); }
.stat-card.exclude .stat-value { color: var(--red); }

/* ---------- Panel (종류 고르기 / 타일 제외 / 기부 차트 / 도시 건설 부지) ---------- */

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-bar);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.panel-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.panel-title svg { width: 16px; height: 16px; }
.panel-sub {
  color: var(--text-dim);
  font-size: 12.5px;
}
.shuffle-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.shuffle-btn svg { width: 17px; height: 17px; }
.shuffle-btn:hover { background: #f3f2ef; }

/* number-picker groups inside 종류 고르기 */
.type-groups { margin-top: 14px; }
.type-group-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.type-group-row:first-child { border-top: none; }
.type-group-label { font-weight: 700; font-size: 14px; }
.type-chip-row { display: flex; gap: 10px; flex-wrap: wrap; }
.type-chip {
  width: 42px;
  height: 34px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}
.type-chip.excluded {
  background: #eeece8;
  color: var(--text-faint);
}

/* ---------- Tile cards (타일 제외 grid, 부서 도감) ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}
@media (max-width: 560px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
}

.tile-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.tile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px 4px;
}
.tile-card-num {
  font-weight: 800;
  font-size: 14px;
}
.tile-card-title { padding: 0 9px; }
.tile-card-title .kr { font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.tile-card-title .en {
  font-size: 9px;
  letter-spacing: .04em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.tile-card-art {
  margin: 8px 9px;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background: #eee9df;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b7ae9d;
  font-size: 11px;
  text-align: center;
  overflow: hidden;
}
.tile-card-art img { width: 100%; height: 100%; object-fit: cover; }
.tile-card-effect {
  margin-top: auto;
  background: var(--dark-bar);
  color: #fff;
  font-size: 11px;
  padding: 8px 9px;
  line-height: 1.4;
}
.tile-card-status {
  min-width: 20px;
  height: 20px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 5px;
  flex: none;
}
.tile-card-status svg { width: 12px; height: 12px; flex: none; }
.tile-card-status .status-count { font-size: 10px; font-weight: 800; line-height: 1; }
.tile-card-status.status-kept { background: #eeece8; color: var(--text-faint); padding: 0; width: 20px; }
.tile-card-status.status-out-red { background: var(--red); color: #fff; }
.tile-card-status.status-out-yellow { background: #d8a13a; color: #fff; }

/* full-width tile row for 상세 view / 부서 도감 */
.tile-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 14px;
  overflow: hidden;
}
.tile-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 8px;
}
.tile-row-num {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
  flex: none;
}
.tile-row-title .kr { font-size: 17px; font-weight: 700; }
.tile-row-title .en { font-size: 11px; color: var(--text-faint); letter-spacing: .04em; text-transform: uppercase; }
.tile-row-art {
  margin: 8px 16px;
  height: 130px;
  border-radius: 6px;
  background: #eee9df;
  display: flex; align-items: center; justify-content: center;
  color: #b7ae9d; font-size: 12px;
  overflow: hidden;
}
.tile-row-art img { width: auto; max-width: 100%; height: 100%; object-fit: contain; }
.tile-row-effect {
  background: var(--dark-bar);
  color: #fff;
  padding: 12px 16px;
  font-size: 13px;
  text-align: center;
}

.cat-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  margin: 22px 0 14px;
}
.cat-banner .en { font-weight: 400; opacity: .85; font-size: 12.5px; }
.cat-banner img, .cat-banner svg { width: 18px; height: 18px; }

/* ---------- Neutral disc lists ---------- */

.donation-list {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 230px;
  overflow-y: auto;
}
.donation-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.donation-row:first-child { border-top: none; }
.donation-code {
  border: 1px solid var(--text-faint);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 6px;
  color: var(--text-dim);
  flex: none;
}

.region-band {
  color: #fff;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 6px;
  margin: 14px 0 0;
  font-size: 13.5px;
}
.city-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-top: none;
  background: #fff;
}
.city-row:first-of-type { border-top: none; }
.city-count {
  background: #eeece8;
  color: var(--text-dim);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Simple numbered step list (룰 요약 / 1인 도우미) ---------- */

.step-list { margin-top: 12px; }
.step-row {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.step-row:first-child { border-top: none; }
.step-num {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: #eeece8;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px;
}
.step-title { font-weight: 700; font-size: 14.5px; margin-bottom: 3px; }
.step-desc { font-size: 13px; color: var(--text-dim); line-height: 1.55; }

.bullet-list { margin-top: 12px; }
.bullet-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.55;
}
.bullet-row:first-child { border-top: none; }
.bullet-row .bullet-icon {
  flex: none;
  width: 20px; height: 20px;
  color: var(--text-dim);
}

/* ---------- Icon legend page ---------- */

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
}
@media (max-width: 560px) {
  .legend-grid { grid-template-columns: 1fr; }
}
.legend-col-title {
  text-align: center;
  font-weight: 700;
  font-size: 14.5px;
  padding-bottom: 12px;
  border-bottom: 2px solid #8a6f5a;
  margin-bottom: 18px;
}
.legend-item {
  text-align: center;
  margin-bottom: 26px;
}
.legend-icon {
  width: 56px; height: 56px;
  margin: 0 auto 8px;
  background: #eee9df;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #b7ae9d;
  overflow: hidden;
}
.legend-icon img { width: 100%; height: 100%; object-fit: contain; }
.legend-label { font-size: 12.5px; color: var(--text-dim); line-height: 1.4; }

.rules-title {
  color: #8a6f5a;
}