:root {
  --bg: #0c0c0d;
  --surface: #141416;
  --surface-2: #1b1b1e;
  --line: #2a2a2e;
  --text: #ededee;
  --muted: #a1a1a8;
  --win: #00bb00;
  --win-ink: #ffffff;
  --loss: #b70f0f;
  --loss-ink: #ffffff;
  --draw: #808080;
  --draw-ink: #ffffff;
  --check: #f6c744;
  --check-ink: #2b2005;
  --focus: #ededee;
  --select-bg: #3a3a40;
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #efefec;
  --line: #dcdcd7;
  --text: #121214;
  --muted: #5a5a61;
  --focus: #121214;
  --select-bg: #c9c9c3;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f5f3;
    --surface: #ffffff;
    --surface-2: #efefec;
    --line: #dcdcd7;
    --text: #121214;
    --muted: #5a5a61;
    --focus: #121214;
    --select-bg: #c9c9c3;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--select-bg); color: var(--text); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px; border-right: 1px solid var(--line); background: var(--bg);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 54px; flex: none;
  background: #111113; border: 1px solid var(--line); border-radius: 8px;
}
.brand-mark img { width: 30px; height: auto; display: block; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; line-height: 1.25; }
.brand-sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 700; }

.members { min-height: 0; overflow-y: auto; }
.members summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 12px 6px; list-style: none; display: flex; justify-content: space-between; }
.members summary::-webkit-details-marker { display: none; }
.members ul { list-style: none; margin: 0; padding: 4px 0 0; display: flex; flex-direction: column; gap: 6px; }
.mem { display: flex; align-items: center; gap: 12px; padding: 6px 12px; border-radius: 8px; text-decoration: none; font-size: 14px; }
a.mem:hover { background: var(--surface-2); }
.mem-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.mem-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-state { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.mem-state.on { color: var(--text); }

.avatar { position: relative; flex: none; width: 40px; height: 40px; border-radius: 999px; padding: 2px; }
.avatar.is-live { box-shadow: 0 0 0 2px #e11919; padding: 2px; background: var(--bg); }
.avatar-img { display: block; width: 100%; height: 100%; border-radius: 999px; overflow: hidden; background: #f1f1f1; position: relative; }
.avatar-img img { position: absolute; width: 190%; max-width: none; height: auto; left: -45%; top: -24%; }
.avatar:not(.is-live) .avatar-img { filter: grayscale(1); opacity: 0.55; }
.live-badge {
  position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  background: #e11919; color: #fff; font-size: 9px; font-weight: 800; letter-spacing: 0.04em;
  line-height: 1; padding: 3px 5px; border-radius: 4px; border: 2px solid var(--bg);
}
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }

.btn {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; text-align: left;
}
.btn:hover { background: var(--surface-2); }

.main { padding: 28px clamp(16px, 3vw, 40px) 64px; max-width: 1240px; width: 100%; }

.notice {
  margin: 0 0 24px; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 13px;
}

h1 { font-size: clamp(1.4rem, 2.4vw, 1.9rem); line-height: 1.2; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h2 { font-size: 1rem; letter-spacing: -0.01em; margin: 40px 0 12px; }
.sub { color: var(--muted); margin: 6px 0 0; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 20px; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
select, .seg button {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
select { padding: 8px 32px 8px 12px; min-height: 40px; }

/* ---------- result strip ---------- */
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: 0 0 28px; padding: 0; list-style: none; }
.strip a {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  min-height: 76px; padding: 10px 12px; border-radius: 8px; text-decoration: none;
}
.strip .res { font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.strip .nm { font-weight: 600; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.strip a:hover { filter: brightness(1.06); }
.r-win { background: var(--win); color: var(--win-ink); }
.r-loss { background: var(--loss); color: var(--loss-ink); }
.r-draw { background: var(--draw); color: var(--draw-ink); }
.r-review { background: var(--check); color: var(--check-ink); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
caption { text-align: left; padding: 0; }
th, td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
thead th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.row-flag td:first-child { box-shadow: inset 2px 0 0 var(--check); }
tr:target, tr.hl { background: var(--surface-2); }

th button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; gap: 4px; align-items: center; font-weight: 600;
}
th button:hover { color: var(--text); }
th[aria-sort="ascending"] button::after { content: "▲"; font-size: 9px; }
th[aria-sort="descending"] button::after { content: "▼"; font-size: 9px; }

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.tag { display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--check); white-space: nowrap; }
:root[data-theme="light"] .tag { color: #8a6500; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .tag { color: #8a6500; } }

.heroes { color: var(--muted); font-size: 13px; line-height: 1.45; }
.mode { color: var(--muted); }
.mapname { font-weight: 600; }

.bar { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 10px; min-width: 150px; }
.bar i { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); position: relative; overflow: hidden; }
.bar i b { position: absolute; inset: 0 auto 0 0; background: var(--win); border-radius: 4px; }
.bar span { text-align: right; font-weight: 600; }

/* ---------- segmented ---------- */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 700; }
.controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin-bottom: 16px; }

.recent td a { text-decoration: none; font-weight: 600; }
.recent td a:hover { text-decoration: underline; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 14px; height: 14px; border-radius: 3px; display: block; }

.empty { padding: 28px; color: var(--muted); text-align: center; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 12px 16px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand-sub { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .rail-foot { margin: 0 0 0 auto; }
  .members { order: 4; width: 100%; }
  .main { padding-top: 20px; }
  .strip { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip a { min-height: 64px; }
}

@media (prefers-reduced-motion: no-preference) {
  .strip a, .btn, tbody tr { transition: filter 0.18s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.18s cubic-bezier(0.22, 1, 0.36, 1); }
  .strip li { animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
  .strip li:nth-child(2) { animation-delay: 0.05s; }
  .strip li:nth-child(3) { animation-delay: 0.1s; }
  .strip li:nth-child(4) { animation-delay: 0.15s; }
  .strip li:nth-child(5) { animation-delay: 0.2s; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}

/* ---------- hero portraits & replay code ---------- */
.hero-row { display: inline-flex; gap: 4px; }
.hero { width: 36px; height: 36px; border-radius: 6px; background: var(--surface-2); object-fit: cover; display: block; flex: none; }
.hero-missing { display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); }
td:has(.hero-row) { white-space: nowrap; }

.rp { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.rp-mask { letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.rp-copy { padding: 4px 10px; font-size: 13px; text-align: center; min-width: 64px; }
.rp-wait { display: inline-block; padding: 2px 10px; border: 1px dashed var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- day view: time-slot columns ---------- */
.daynav { display: flex; align-items: flex-end; gap: 8px; }
.daynav .btn { min-height: 40px; text-align: center; }
.head-cal { align-items: flex-start; }
.head-main { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.head-main .daynav { margin-top: 20px; }
.cal { width: 288px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; flex: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .btn { min-width: 36px; text-align: center; padding: 6px 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wk { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-day {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 34px; font: inherit; font-size: 13px; color: var(--text); background: transparent; border: 1px solid transparent;
  border-radius: 8px; cursor: pointer;
}
.cal-day:hover { background: var(--surface-2); }
.cal-day.has { font-weight: 700; }
.cal-day.is-today { border-color: var(--muted); }
.cal-day.is-sel { background: var(--text); color: var(--bg); }
.cal-dots { display: inline-flex; gap: 2px; height: 5px; }
.cal-dots i { width: 5px; height: 5px; border-radius: 999px; display: block; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.cal-foot .btn { padding: 6px 12px; }
.cal-legend { font-size: 12px; color: var(--muted); }
.daynav .btn:disabled { opacity: 0.4; cursor: default; }

.day { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.slot { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.slot header { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.slot h2 { margin: 0; font-size: 1.05rem; }
.slot-meta { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.slot-empty { background: transparent; border-style: dashed; padding: 14px 16px; }
.slot-empty p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.maps { list-style: none; margin: 0; padding: 0; }
.maps li + li { border-top: 1px solid var(--line); }
.maps summary {
  display: grid; grid-template-columns: minmax(0, 1fr) 76px; grid-template-rows: auto auto;
  align-items: center; column-gap: 10px; row-gap: 2px;
  min-height: 64px; padding: 10px 16px; cursor: pointer; list-style: none;
  --row-bg: var(--surface); background-color: var(--row-bg);
}
.maps summary.has-bg {
  background-image:
    linear-gradient(90deg, var(--row-bg) 0%, var(--row-bg) 34%, color-mix(in srgb, var(--row-bg) 45%, transparent) 100%),
    var(--map-img);
  background-size: 100% 100%, cover;
  background-position: 0 0, right center;
  background-repeat: no-repeat;
}
.maps summary::-webkit-details-marker { display: none; }
.maps summary:hover { --row-bg: var(--surface-2); }
.maps summary .mapname { grid-column: 1; grid-row: 1; line-height: 1.3; overflow-wrap: anywhere; }
.maps summary .res-cell { grid-column: 2; grid-row: 1 / span 2; display: flex; justify-content: center; }
.maps summary .res-cell .chip { min-width: 64px; text-align: center; padding: 3px 8px; }
.maps summary .score { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 13px; }
.maps details[open] > summary { --row-bg: var(--surface-2); }

.detail { padding: 4px 16px 14px; background: var(--surface-2); display: grid; gap: 10px; }
.d-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13px; }
.d-label { color: var(--muted); }
.detail .hero-row { flex-wrap: wrap; }

@media (max-width: 1100px) {
  .cal { width: 100%; max-width: 340px; }
  .day { grid-template-columns: minmax(0, 1fr); }
  .daynav { flex-wrap: wrap; }
}

/* ---------- live video box ---------- */
.player { aspect-ratio: 16 / 9; background: #0a0a0b; border-bottom: 1px solid var(--line); }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.player-btn {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 13px; color: #ededee; background: #0a0a0b; border: 0; cursor: pointer;
}
.player-btn:hover { background: #151517; }
.player-btn svg { background: #ededee; color: #0a0a0b; border-radius: 999px; padding: 10px; width: 48px; height: 48px; box-sizing: border-box; }
.player-note { margin: 0; padding: 16px; font-size: 13px; line-height: 1.5; color: #a1a1a8; display: grid; place-items: center; height: 100%; text-align: center; }

/* ---------- 달력: 작게 (스크림 결과를 밀어내지 않도록) ---------- */
.cal { width: 204px; padding: 8px; border-radius: 10px; }
.cal-head { gap: 4px; margin-bottom: 4px; }
.cal-head strong { font-size: 13px; margin-right: auto; margin-left: 4px; }
.cal-head .btn { min-width: 0; padding: 2px 8px; font-size: 12px; line-height: 20px; border-radius: 6px; }
.cal-head .cal-today { padding: 2px 6px; }
.cal-grid { gap: 1px; }
.cal-wk { font-size: 10px; padding: 2px 0; }
.cal-day { height: 24px; font-size: 11px; border-radius: 6px; gap: 0; }
.cal-dots { position: absolute; left: 0; right: 0; bottom: 1px; justify-content: center; gap: 1px; height: 3px; }
.cal-dots i { width: 3px; height: 3px; }
.head-main .daynav { margin-top: 12px; }

/* ---------- 달력: 더 작게, 이전 날 · 날짜 · 다음 날 바로 왼쪽에 붙임 ---------- */
.head { align-items: flex-end; }
.head-right { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.cal { width: 176px; padding: 6px; border-radius: 8px; }
.cal-head { margin-bottom: 2px; }
.cal-head strong { font-size: 12px; }
.cal-head .btn { padding: 0 6px; font-size: 11px; line-height: 18px; min-height: 0; }
.cal-wk { font-size: 9px; padding: 1px 0; }
.cal-day { height: 20px; font-size: 10px; border-radius: 5px; }
.cal-dots { bottom: 0; }
@media (max-width: 1100px) {
  .head-right { justify-content: flex-start; }
  .cal { width: 176px; max-width: none; }
}

/* ---------- 달력 칸이 상자 밖으로 튀어나오지 않게 ---------- */
.cal { box-sizing: border-box; overflow: hidden; }
.cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-grid > * { min-width: 0; }
.cal-day { padding: 0; min-width: 0; width: 100%; }
.cal-wk { min-width: 0; text-align: center; }
.cal-head { display: flex; align-items: center; gap: 4px; min-width: 0; }
.cal-head strong { min-width: 0; white-space: nowrap; }
.cal-head .btn { flex: none; }

/* ---------- 영상 모음 ---------- */
.vgroup + .vgroup { margin-top: 8px; }
.vgroup h2 { margin: 28px 0 12px; font-size: 1rem; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.vcard .player { border-bottom: 0; background-size: cover; background-position: center; position: relative; }
.vcard .player-btn { background: transparent; }
.vcard .player-btn:hover { background: rgba(0, 0, 0, 0.25); }
.vtitle { margin: 0; padding: 10px 14px 12px; font-size: 13px; font-weight: 600; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mem-state { transition: color 0.15s; }
a.mem:hover .mem-name { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 화면 잠금 ---------- */
html.cr-cover body > .shell { visibility: hidden; }
#cr-lock { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--bg); }
#cr-lock[hidden] { display: none; }
.lock-box { width: min(320px, calc(100vw - 32px)); display: grid; gap: 12px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.lock-title { margin: 0; font-weight: 700; font-size: 1.05rem; }
.lock-field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.lock-field input { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.lock-msg { margin: 0; min-height: 1.4em; font-size: 13px; color: var(--loss); }
.lock-btn { text-align: center; min-height: 40px; }

.lock-msg { color: #ff7b72; }
:root[data-theme="light"] .lock-msg { color: #b00020; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .lock-msg { color: #b00020; } }

.lock-title { text-align: center; font-size: 1.15rem; }
.lock-time { margin: 0; text-align: center; font-size: 14px; line-height: 1.6; color: var(--muted); }
.lock-time strong { color: var(--text); font-size: 18px; letter-spacing: 0.02em; }
.lock-now { font-variant-numeric: tabular-nums; }

/* ---------- 팀 로고 (상대 이름 왼쪽, 아주 작게) ---------- */
.tl { width: 16px; height: 16px; object-fit: contain; vertical-align: -3px; margin-right: 6px; border-radius: 3px; }
.tl-light { display: none; }
:root[data-theme="light"] .tl-light { display: inline; }
:root[data-theme="light"] .tl-dark { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .tl-light { display: inline; }
  :root:not([data-theme="dark"]) .tl-dark { display: none; }
}

/* ---------- 수정 폼 (수정 권한이 있는 사람만) ---------- */
.edit-open { padding: 4px 12px; font-size: 13px; }
.edit-form { display: grid; gap: 10px; padding: 12px; margin-top: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.edit-form[hidden] { display: none; }
.ef { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.ef input, .ef select { font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%; }
.edit-actions { display: flex; gap: 8px; }
.edit-actions .btn { padding: 6px 14px; text-align: center; }
.edit-msg { margin: 0; min-height: 1.3em; font-size: 12px; color: #ff7b72; }
:root[data-theme="light"] .edit-msg { color: #b00020; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .edit-msg { color: #b00020; } }

.d-edit .edit-open { justify-self: start; width: auto; padding: 3px 12px; }
.rail-note { margin: 0; font-size: 12px; font-weight: 600; line-height: 1.4; }
.rail-note span { font-weight: 400; color: var(--muted); }
