:root {
  --bg: #f6f7fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #1b2130;
  --muted: #5d6679;
  --border: #dde2ea;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --gold: #b07d00;
  --ok: #1f9d55;
  --bad: #d64545;
  --code-bg: #eef1f6;
  --header-bg: #1d2433;
  --header-text: #e9edf5;
  --shadow: 0 1px 2px rgba(20, 28, 45, .06), 0 4px 16px rgba(20, 28, 45, .05);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f;
    --surface: #1a202c;
    --surface-2: #222a38;
    --text: #e6eaf2;
    --muted: #9aa4b8;
    --border: #2c3546;
    --accent: #7c9cff;
    --accent-text: #0f1420;
    --gold: #ffd34d;
    --ok: #4ade80;
    --bad: #f87171;
    --code-bg: #222a38;
    --header-bg: #0c0f16;
    --header-text: #e6eaf2;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f;
  --surface: #1a202c;
  --surface-2: #222a38;
  --text: #e6eaf2;
  --muted: #9aa4b8;
  --border: #2c3546;
  --accent: #7c9cff;
  --accent-text: #0f1420;
  --gold: #ffd34d;
  --ok: #4ade80;
  --bad: #f87171;
  --code-bg: #222a38;
  --header-bg: #0c0f16;
  --header-text: #e6eaf2;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-underline-offset: 2px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
pre code { background: none; padding: 0; }
img.ico { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: -4px; margin-right: 5px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 6px 10px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* 머리 */
.site-header { background: var(--header-bg); color: var(--header-text); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a { color: inherit; text-decoration: none; padding: 6px 10px; border-radius: 6px; opacity: .85; }
.site-nav a:hover { background: rgba(255, 255, 255, .08); opacity: 1; }
.site-nav a[aria-current="page"] { background: rgba(255, 255, 255, .14); opacity: 1; }
.site-nav a.nav-download { background: var(--gold); color: #1d2433; opacity: 1; font-weight: 700; margin-left: 4px; }
.site-nav a.nav-download:hover { background: color-mix(in srgb, var(--gold) 85%, #fff); }
.theme-toggle { background: none; border: 1px solid rgba(255, 255, 255, .25); color: inherit; border-radius: 6px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; }

/* 배치 */
.layout { padding-top: 24px; padding-bottom: 48px; }
.layout.has-aside { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 32px; align-items: start; }
.side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; font-size: .9rem; }
.toc { margin-bottom: 20px; }
.toc-title { font-weight: 700; margin: 0 0 6px; color: var(--muted); font-size: .8rem; letter-spacing: .04em; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.toc li a { display: block; padding: 3px 0 3px 12px; color: var(--text); text-decoration: none; }
.toc li a:hover { color: var(--accent); }
.toc .toc-d3 a { padding-left: 24px; color: var(--muted); font-size: .85rem; }

/* 문서 */
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); margin-bottom: 20px; }
.doc h1 { font-size: 1.75rem; line-height: 1.3; margin: 0 0 12px; }
.doc h2 { font-size: 1.35rem; margin: 32px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.doc h2:first-child { margin-top: 0; }
.doc h3 { font-size: 1.12rem; margin: 26px 0 10px; }
.doc h4 { font-size: 1rem; margin: 22px 0 8px; }
.doc h2 .anchor, .doc h3 .anchor, .doc h4 .anchor { margin-left: 6px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
.doc :is(h2, h3, h4):hover .anchor { opacity: .7; }
.doc blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--gold); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.doc blockquote p { margin: 0; }
.lede { font-size: 1.05rem; color: var(--muted); margin-top: 0; }
.meta { color: var(--muted); font-size: .9rem; margin-top: -4px; }
.badge { display: inline-block; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 8px; font-size: .78rem; font-weight: 600; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 6px; opacity: .6; }

/* 표 */
.table-wrap { overflow-x: auto; margin: 12px 0 18px; border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:target { background: color-mix(in srgb, var(--gold) 18%, transparent); }
td strong { white-space: nowrap; }

/* 카드 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 16px 0; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card span { color: var(--muted); font-size: .88rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; color: var(--text); background: var(--surface-2); }
.chip:hover { border-color: var(--accent); }

/* 검색 */
.search { position: relative; margin: 16px 0; }
.search input { width: 100%; padding: 12px 14px; font-size: 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-results { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); max-height: 420px; overflow-y: auto; }
.search-results li a { display: block; padding: 8px 12px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); }
.search-results li:last-child a { border-bottom: 0; }
.search-results li a:hover, .search-results li a:focus { background: var(--surface-2); }
.search-results .c { color: var(--muted); font-size: .8rem; margin-left: 6px; }
.search-results .d { display: block; color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .empty { padding: 10px 12px; color: var(--muted); }

/* 홈 */
.hero { text-align: center; padding: 28px 0 20px; }
.hero h1 { font-size: clamp(2.2rem, 7vw, 3.4rem); margin: 0; letter-spacing: -.02em; }
.eyebrow { color: var(--muted); margin: 0 0 4px; font-size: .9rem; }
.address { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }
.address code { font-size: 1.15rem; padding: 8px 14px; border: 1px solid var(--border); background: var(--surface); }
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.status-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); margin: 0 auto 20px; max-width: 760px; }
.status-head { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.off { background: var(--bad); }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0 6px; }
.status-grid div { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; }
.status-grid dt { color: var(--muted); font-size: .8rem; }
.status-grid dd { margin: 0; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.players-list { margin: 8px 0 0; }
.players-list span { display: inline-block; background: var(--surface-2); border-radius: 999px; padding: 1px 10px; margin: 2px 4px 2px 0; font-size: .9rem; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.recent li:last-child { border-bottom: 0; }
.recent a { text-decoration: none; }

/* 업데이트 */
.updates { list-style: none; padding: 0; margin: 0; }
.update { padding: 16px 0; border-bottom: 1px solid var(--border); }
.update:last-child { border-bottom: 0; }
.update-link { text-decoration: none; color: var(--text); }
.update-link h2 { border: 0; margin: 0 0 4px; padding: 0; font-size: 1.2rem; }
.update-link:hover h2 { color: var(--accent); }
.update-summary { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; }

.site-footer { border-top: 1px solid var(--border); padding: 20px 0 32px; color: var(--muted); font-size: .875rem; }
.site-footer p { margin: 4px 0; }

@media (max-width: 960px) {
  .layout.has-aside { display: block; }
  .side { position: static; max-height: none; margin-top: 8px; }
  .side .toc:first-child:not(:last-child) { display: none; }
  .home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .doc { padding: 18px 16px; border-radius: 8px; }
  .doc h1 { font-size: 1.45rem; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .site-nav { gap: 2px; }
  .site-nav a { padding: 6px 7px; font-size: .92rem; }
  .header-inner { gap: 8px; }
  .brand span { display: none; }
  /* 좁은 화면: 표 행을 카드로 */
  .table-wrap { border: 0; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; padding: 6px 0; background: var(--surface); }
  .table-wrap td { border: 0; padding: 4px 12px; display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; }
  .table-wrap td:empty { display: none; }
  td strong { white-space: normal; }
}
