:root {
  --bg: #0b1016;
  --bg-grad: radial-gradient(1100px 560px at 50% -12%, #16243a 0%, #0b1016 62%);
  --surface: #131b25;
  --surface-2: #1a2530;
  --line: rgba(255, 255, 255, .09);
  --line-soft: rgba(255, 255, 255, .05);
  --text: #e6edf5;
  --muted: #8ea0b3;
  --dim: #62748a;
  --steam: #66c0f4;
  --steam-soft: rgba(102, 192, 244, .14);
  --gold: #f0b544;
  --gold-soft: rgba(240, 181, 68, .14);
  --green: #63d297;
  --rose: #f2707a;
  --violet: #a58bf5;
  --radius: 14px;
  --tabh: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  background-image: var(--bg-grad);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom, 0px) + 28px);
}

a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }

/* ---------- 상단 ---------- */
.topbar {
  padding: 18px 16px 11px;
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner { max-width: 720px; margin: 0 auto; }
.brand {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark { color: var(--steam); font-size: 18px; }
.brand-sub {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: -.01em;
}

/* ---------- 탭 ---------- */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(11, 16, 22, .93);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  height: var(--tabh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: -.02em;
  transition: color .15s;
}
.tab-ico svg {
  width: 21px; height: 21px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab-label { display: block; }
.tab[aria-current="page"] { color: var(--steam); }

/* ---------- 레이아웃 ---------- */
main { max-width: 720px; margin: 0 auto; padding: 14px 14px 0; }
.view { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.loading { padding: 70px 0; text-align: center; color: var(--muted); }
.spinner {
  width: 26px; height: 26px;
  margin: 0 auto 14px;
  border: 2px solid var(--line);
  border-top-color: var(--steam);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sec-head {
  margin: 22px 0 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.sec-head:first-child { margin-top: 4px; }
.sec-title { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -.02em; }
.sec-note { font-size: 11.5px; color: var(--dim); }

.lead {
  margin: 2px 0 14px;
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: -.01em;
}
.lead strong { color: var(--text); font-weight: 600; }

/* 오해를 막는 주석 배너 — 연대기 화면의 핵심 장치 */
.caveat {
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  margin: 0 0 16px;
  background: var(--gold-soft);
  border: 1px solid rgba(240, 181, 68, .28);
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #f4dcae;
  letter-spacing: -.01em;
}
.caveat b { color: var(--gold); font-weight: 700; }
.caveat-ico { flex: none; color: var(--gold); font-size: 13px; line-height: 1.5; }

/* ---------- 통계 카드 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-bottom: 6px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 13px;
}
.stat-val {
  display: block;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.stat-val .u { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.stat-key { display: block; margin-top: 2px; font-size: 11.5px; color: var(--dim); letter-spacing: -.01em; }
.stat.wide { grid-column: 1 / -1; }
.stat.accent .stat-val { color: var(--gold); }
.stat.steam .stat-val { color: var(--steam); }

/* ---------- 순위 막대 ---------- */
.rank-list { display: flex; flex-direction: column; gap: 7px; }
.rank-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px 12px 11px;
}
.rank-row.crown { border-color: rgba(240, 181, 68, .3); background: linear-gradient(180deg, rgba(240,181,68,.07), var(--surface) 60%); }
.rank-no {
  display: block;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.rank-row.crown .rank-no { color: var(--gold); }
.rank-body { display: block; min-width: 0; }
.rank-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--dim);
}
.rank-hours { color: var(--steam); font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-row.crown .rank-hours { color: var(--gold); }
.bar {
  display: block;
  height: 6px;
  margin-top: 7px;
  background: rgba(255, 255, 255, .06);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3d8fc4, var(--steam));
  border-radius: 3px;
}
.rank-row.crown .bar-fill { background: linear-gradient(90deg, #c58f2c, var(--gold)); }

.hundred-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 12px 2px;
  font-size: 11.5px;
  color: var(--dim);
}
.hundred-line::before, .hundred-line::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- 연대기 ---------- */
.year-list { display: flex; flex-direction: column; }
.year {
  border-left: 2px solid var(--line);
  padding: 0 0 14px 15px;
  margin-left: 7px;
  position: relative;
}
.year:last-child { padding-bottom: 4px; }
.year::before {
  content: "";
  position: absolute;
  left: -6px; top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--dim);
}
.year.hot::before { background: var(--steam); border-color: var(--steam); box-shadow: 0 0 0 4px var(--steam-soft); }
.year.empty::before { background: var(--bg); border-color: var(--line); }
.year-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: none;
  border: 0;
  padding: 0 0 4px;
  text-align: left;
  cursor: pointer;
}
.year-no { font-size: 15px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.year.empty .year-no { color: var(--dim); font-weight: 600; }
.year-count { font-size: 12px; color: var(--muted); }
.year-caret { margin-left: auto; font-size: 10px; color: var(--dim); transition: transform .18s; }
.year.open .year-caret { transform: rotate(90deg); }
.year-track {
  display: block;
  height: 7px;
  background: rgba(255, 255, 255, .06);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 2px;
}
.year-track-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3d8fc4, var(--steam));
  border-radius: 4px;
}
.year.empty .year-track-fill { background: var(--line); }
.year-games {
  display: none;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
  flex-direction: column;
  gap: 5px;
}
.year.open .year-games { display: flex; }
.ygame {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
}
.ygame-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.02em;
}
.ygame-side { display: block; text-align: right; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.ygame-side b { display: block; color: var(--muted); font-weight: 600; }

/* ---------- 지분 (도넛 + 곡선) ---------- */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
}
.donut { width: 190px; height: 190px; display: block; }
.donut-hole-val { font-size: 30px; font-weight: 700; fill: var(--gold); letter-spacing: -.04em; }
.donut-hole-key { font-size: 10.5px; fill: var(--muted); }
.donut-cap {
  margin: 6px 0 0;
  font-size: 13px;
  text-align: center;
  letter-spacing: -.01em;
  color: var(--muted);
}
.donut-cap b { color: var(--text); }

.legend { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; width: 100%; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center; font-size: 12.5px; }
.legend-dot { display: block; width: 10px; height: 10px; border-radius: 3px; }
.legend-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.02em; }
.legend-val { display: block; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }

.curve-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 15px 14px 12px;
}
/* 비율을 강제로 늘리면 축 글자가 찌그러진다. height 는 viewBox 가 정하게 둔다. */
.curve { width: 100%; height: auto; display: block; }
.curve-axis { font-size: 9.5px; fill: var(--dim); }
.curve-marks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.mark {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: -.01em;
}
.mark b { color: var(--steam); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 무덤 ---------- */
.grave-list { display: flex; flex-direction: column; gap: 6px; }
.grave {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 9px 12px;
}
.grave-main { display: block; min-width: 0; }
.grave-name {
  display: block;
  font-size: 13.5px;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grave-sub { display: block; margin-top: 1px; font-size: 11px; color: var(--dim); }
.grave-min {
  display: block;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--rose);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.grave-min .u { font-size: 10.5px; font-weight: 500; color: var(--dim); margin-left: 1px; }
.grave.zero .grave-min { color: var(--dim); }

/* ---------- 전체 목록 ---------- */
.controls { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.search-wrap { position: relative; }
.search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 34px 10px 12px;
  font-size: 14px;
  outline: none;
}
.search:focus { border-color: var(--steam); }
.search::placeholder { color: var(--dim); }
.search-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 17px;
  padding: 4px 8px;
  cursor: pointer;
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -.01em;
}
.chip[aria-pressed="true"] { background: var(--steam-soft); border-color: rgba(102, 192, 244, .45); color: var(--steam); font-weight: 600; }

.list { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px 12px;
  transition: border-color .15s;
}
.item:active { border-color: var(--steam); }
.item-main { display: block; min-width: 0; }
.item-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-name.unknown { color: var(--muted); font-weight: 500; font-style: italic; }
.item-sub {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-side { display: block; text-align: right; }
.item-hours {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--steam);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.item-hours .u { font-size: 10.5px; font-weight: 500; color: var(--dim); margin-left: 1px; }
.item-last { display: block; font-size: 10.5px; color: var(--dim); font-variant-numeric: tabular-nums; }

.empty-msg { padding: 34px 0; text-align: center; color: var(--dim); font-size: 13.5px; }
.more-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- 푸터 ---------- */
.foot {
  max-width: 720px;
  margin: 26px auto 0;
  padding: 14px 16px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.65;
  letter-spacing: -.01em;
}

@media (min-width: 560px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat.wide { grid-column: span 2; }
  .donut { width: 220px; height: 220px; }
}
