:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1c2330; --muted: #6b7686; --line: #dfe3ea;
  --accent: #2f6fdd; --good: #1f8a4c; --bad: #c0392b; --warn: #b7791f; --zero: #fdecea;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161d; --panel: #1b212b; --text: #e6eaf0; --muted: #93a0b2; --line: #2c3442;
    --accent: #6ea2ff; --good: #4cc27f; --bad: #ff7b6b; --warn: #e0b354; --zero: #3a2224; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; font: 15px/1.5 -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
header { padding: 16px 16px 0; max-width: 1280px; margin: 0 auto; }
h1 { margin: 0; font-size: 20px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
main { padding: 8px 16px 48px; max-width: 1280px; margin: 0 auto; }
.muted { color: var(--muted); margin: 2px 0 0; }
nav { display: flex; gap: 2px; margin-top: 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
nav::-webkit-scrollbar { display: none; }
nav button { border: 0; background: none; color: var(--muted); padding: 12px 14px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; flex: 0 0 auto; }
nav button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.card .big { font-size: 22px; font-weight: 700; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
tr.gone td { color: var(--muted); }
td.zero { background: var(--zero); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.badge { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 9px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
select, input, textarea, button.act { min-height: 40px; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
button.act { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); }
button.act.sub { background: var(--panel); color: var(--text); border-color: var(--line); }
textarea { width: 100%; min-height: 90px; font-family: ui-monospace, monospace; }
.note { color: var(--muted); font-size: 12px; margin: 6px 0; }
.detail td { background: color-mix(in srgb, var(--accent) 5%, var(--panel)); text-align: left; white-space: normal; }
label { display: inline-flex; gap: 6px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.form-grid label { flex-direction: column; align-items: stretch; }
details.fold { padding: 0; }
details.fold > summary { padding: 10px 14px; cursor: pointer; list-style-position: inside; }
details.fold[open] > summary { border-bottom: 1px solid var(--line); }
details.fold > .scroll { padding: 4px 14px 10px; }
details.fold th:first-child, details.fold td:first-child { position: static; }

/* 멤버 칸: 순위 + 초상화 + 닉네임. 줄 높이는 초상화(36px)에 맞춘다. */
.who { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; }
.who img { width: 36px; height: 36px; border-radius: 8px; background: color-mix(in srgb, var(--muted) 18%, var(--panel)); flex: 0 0 auto; object-fit: cover; }
.who .rk { min-width: 22px; text-align: right; color: var(--muted); font-size: 13px; }
.who .nm { font-weight: 600; }
input[type="checkbox"] { min-height: 0; }
.scroll { -webkit-overflow-scrolling: touch; }
td:first-child { box-shadow: 1px 0 0 var(--line); }

/* 휴대폰: 여백을 줄이고, 닉네임 칸 너비를 제한해 점수 칸이 더 많이 보이게 한다. */
@media (max-width: 640px) {
  header { padding: 12px 12px 0; }
  main { padding: 4px 12px 40px; }
  h1 { font-size: 18px; }
  .panel { padding: 8px 10px; margin: 10px 0; border-radius: 10px; }
  th, td { padding: 8px 10px; }
  .who { gap: 8px; }
  .who .nm { max-width: 108px; overflow: hidden; text-overflow: ellipsis; }
  .who .rk { min-width: 18px; }
  .controls { gap: 8px; }
  .controls select { max-width: 100%; }
  .note { font-size: 12.5px; }
}
.detail .day { display: inline-block; margin: 2px 14px 2px 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.detail .sub { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.detail .sub > b { margin-right: 10px; }

/* 펼친 세부: 제목 + 숫자 상자 묶음 */
.detail td { padding: 10px 12px 12px; }
.sgroup + .sgroup { margin-top: 10px; }
.sgroup .st { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.02em; -webkit-user-select: none; user-select: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; text-align: center; min-width: 0; }
.stat .lb { font-size: 11px; color: var(--muted); white-space: nowrap; }
.stat .vl { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.zero { background: var(--zero); }
.stat.zero .vl { color: var(--muted); font-weight: 600; }
.stat.sum { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.stat.sum .vl { color: var(--accent); }
tr.clickable td:last-child::after { content: "›"; display: inline-block; margin-left: 8px; color: var(--muted); }
.mhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mhead .who img { width: 48px; height: 48px; }
.mhead .who .nm { font-size: 17px; max-width: none; }
.panel.missed { border-style: dashed; }
h2 .muted { font-size: 13px; font-weight: 500; margin-left: 8px; }
#clan-sub:empty { display: none; }
.sgroup .st { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.sgroup .st > span { padding: 4px 8px 4px 0; }
button.act.mini { min-height: 28px; padding: 2px 10px; font-size: 12px; font-weight: 600; border-radius: 14px; white-space: nowrap; }
.medals { font-size: 22px; line-height: 1.3; letter-spacing: 1px; }
.medals .medal { margin-right: 10px; white-space: nowrap; }
.medals .muted { font-size: 13px; letter-spacing: 0; }
.medals { letter-spacing: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.medals .medal { margin-right: 0; display: inline-flex; align-items: center; gap: 2px; }
.medals .mdl { display: block; }
.medals .mx { font-size: 14px; font-weight: 700; margin-left: 2px; }
tr.mine td { font-weight: 700; background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }

/* 1~3위 구분: 순위 숫자를 색 동그라미로, 초상화에 같은 색 테두리 */
:root { --gold: #e0a91f; --silver: #8f9aa8; --bronze: #c2733c; }
.who.top1, .who.top2, .who.top3 { --c: var(--gold); }
.who.top2 { --c: var(--silver); }
.who.top3 { --c: var(--bronze); }
.who[class*="top"] .rk { min-width: 22px; height: 22px; line-height: 22px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; text-align: center; font-size: 12px; }
.who[class*="top"] img { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4.5px var(--c); }
.who[class*="top"] .nm { font-weight: 800; }
@media (max-width: 640px) { .who[class*="top"] .rk { min-width: 20px; height: 20px; line-height: 20px; } }

/* 역대 기록 */
.wl { display: inline-block; min-width: 26px; padding: 1px 6px; border-radius: 6px; font-size: 12px; font-weight: 800; text-align: center; color: #fff; }
.wl.w { background: var(--good); }
.wl.l { background: var(--bad); }
.hsum { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hsum .big { font-size: 22px; font-weight: 800; }
.hsum .flow { display: flex; gap: 4px; flex-wrap: wrap; }
.hcard { border-left: 4px solid var(--line); }
.hcard.win { border-left-color: var(--good); }
.hcard.lose { border-left-color: var(--bad); }
.hcard > summary { list-style: none; }
.hcard > summary::-webkit-details-marker { display: none; }
.hrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hrow .opp { font-weight: 600; }
.vs { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.vs .n { min-width: 64px; font-weight: 700; color: var(--muted); }
.vs .n.own { text-align: right; color: var(--text); }
.vs .bar { flex: 1; height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--bad) 55%, var(--panel)); overflow: hidden; }
.vs .bar i { display: block; height: 100%; background: var(--accent); border-right: 2px solid var(--panel); }
table.cmp th, table.cmp td { text-align: right; }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; color: var(--muted); }
table.cmp td.lead { font-weight: 800; color: var(--text); }
table.cmp td:not(.lead):not(:first-child) { color: var(--muted); }
