:root {
  --bg: #090b0f;
  --panel: #10131a;
  --panel-hover: #171b24;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f2f0eb;
  --muted: #8f96a3;
  --red: #e2474e;
  --max-width: 1480px;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.5;
}
button, a { color: inherit; font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.site-header, main, footer {
  width: min(calc(100% - 40px), var(--max-width));
  margin-inline: auto;
}

.site-header {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  color: #fff;
  font-size: 19px;
  font-weight: 850;
  letter-spacing: -0.04em;
  text-decoration: none;
}
.header-section {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.header-links { display: flex; gap: 14px; align-items: center; }
.discord-link {
  padding: 6px 10px;
  border: 1px solid rgba(88, 101, 242, 0.55);
  border-radius: 5px;
  color: #dfe2ff;
  background: rgba(88, 101, 242, 0.16);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}
.discord-link:hover { border-color: #7884ff; background: rgba(88, 101, 242, 0.28); }

.toolbar {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto auto auto;
  gap: 22px;
  align-items: center;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
}
.toolbar h1 { margin: 0; font-size: 22px; letter-spacing: -0.025em; }
.archive-stats { display: flex; gap: 0; margin: 0; }
.archive-stats div { display: flex; gap: 8px; padding: 0 16px; border-left: 1px solid var(--line); }
.archive-stats dt { color: var(--muted); font-size: 11px; }
.archive-stats dd { margin: 0; font-size: 12px; font-weight: 700; }
.filters, .sort-modes {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.filter, .sort-mode {
  padding: 7px 12px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}
.filter:hover, .filter.is-active,
.sort-mode:hover, .sort-mode.is-active { color: #fff; background: rgba(255, 255, 255, 0.09); }
.archive-controls { display: flex; gap: 7px; align-items: center; }
.player-search { display: flex; min-height: 34px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--panel); }
.player-search input { width: 126px; padding: 0 9px; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 11px; }
.player-search button { padding: 0 8px; border: 0; border-left: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.025); font-size: 10px; }
.player-search:focus-within { border-color: rgba(226, 71, 78, 0.55); }
.date-search {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
}
.date-search input {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  color-scheme: dark;
  background: var(--panel);
  font-size: 11px;
}
.all-dates {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--panel);
  font-size: 10px;
  white-space: nowrap;
}
.all-dates:hover, .all-dates.is-active { color: #fff; border-color: rgba(226, 71, 78, 0.55); }
.view-modes {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.view-mode {
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
}
.view-mode:hover, .view-mode.is-active { color: #fff; background: rgba(255, 255, 255, 0.09); }

.library-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 22px;
  align-items: start;
  padding: 22px 0 48px;
}
.featured, .archive {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.featured { min-width: 0; overflow: hidden; }
.featured__stage { background: #030405; }
.video-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #030405;
}
.video-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-frame__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}
.video-frame__empty strong { color: #d7d4ce; font-size: 14px; }
.video-frame__empty small { margin-top: 5px; font-size: 11px; }
.featured__bar {
  display: flex;
  min-height: 52px;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.featured__actions { display: flex; gap: 7px; }
.action-button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #d8d9dc;
  background: transparent;
  font-size: 11px;
  text-decoration: none;
}
.action-button:hover:not(:disabled) { border-color: rgba(226, 71, 78, 0.65); color: #fff; }
.action-button:disabled { cursor: default; opacity: 0.45; }
.featured__details {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 18px 28px;
  padding: 20px;
  border-top: 1px solid var(--line);
}
.featured__title h2 { margin: 0; font-size: 21px; line-height: 1.25; }
.featured__summary { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.encounter-data { display: flex; gap: 0; margin: 0; }
.encounter-data div { min-width: 78px; padding: 0 14px; border-left: 1px solid var(--line); }
.encounter-data dt { color: var(--muted); font-size: 10px; }
.encounter-data dd { margin: 3px 0 0; font-size: 13px; font-weight: 650; }
.featured__tags { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 1 / -1; }
.featured__rosters { display: grid; gap: 4px; grid-column: 1 / -1; }
.featured__rosters p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.tag {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: #aeb3bc;
  font-size: 9px;
  letter-spacing: 0.05em;
}

.archive { overflow: hidden; }
.archive__heading { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.archive__heading h2 { margin: 0; font-size: 15px; }
.replay-grid { display: grid; }
.replay-card { border-bottom: 1px solid var(--line); background: transparent; }
.replay-card:last-child { border-bottom: 0; }
body[data-view="theater"] .replay-card.is-selected { background: rgba(226, 71, 78, 0.08); box-shadow: inset 3px 0 var(--red); }
.replay-card__button {
  display: grid;
  width: 100%;
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 12px;
  padding: 11px;
  border: 0;
  color: inherit;
  background: none;
  text-align: left;
}
.replay-card__button:hover { background: rgba(255, 255, 255, 0.035); }
.replay-card__visual {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 4px;
  background: #07090d;
}
.replay-card__visual video { width: 100%; height: 100%; object-fit: contain; opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
.replay-card__visual video.is-ready { opacity: 0.82; }
.replay-card__visual img { display: block; width: 100%; height: 100%; object-fit: contain; opacity: .88; }
.replay-card__play {
  position: absolute;
  top: 7px;
  left: 8px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  text-shadow: 0 1px 4px #000;
}
.replay-card__duration {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 9px;
}
.replay-card__views {
  position: absolute;
  left: 6px;
  bottom: 5px;
  padding: 2px 4px;
  border-radius: 2px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.72);
  font-size: 9px;
}
.replay-card__content { min-width: 0; align-self: center; }
.replay-card__meta { display: flex; gap: 8px; color: var(--muted); font-size: 9px; }
.replay-card__meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-card__meta span:last-child { margin-left: auto; white-space: nowrap; }
.replay-card h3 { margin: 5px 0 3px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.replay-card p { margin: 0; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.archive-state { display: grid; min-height: 180px; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.archive-state p { margin: 10px 0 0; font-size: 12px; }
.empty-action { margin-top: 12px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; color: #d9dbe0; background: rgba(255,255,255,.03); font-size: 11px; }
.loader { width: 22px; height: 22px; border: 2px solid rgba(255,255,255,.12); border-top-color: var(--red); border-radius: 50%; animation: spin 800ms linear infinite; }
.load-more { display: block; width: calc(100% - 24px); margin: 12px; padding: 9px; border: 1px solid var(--line); border-radius: 5px; color: #d9dbe0; background: rgba(255,255,255,.03); font-size: 11px; }

body[data-view="cards"] .library-layout,
body[data-view="board"] .library-layout { grid-template-columns: 1fr; }
body[data-view="cards"] .featured,
body[data-view="board"] .featured { display: none; }
body[data-view="cards"] .replay-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}
body[data-view="cards"] .replay-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}
body[data-view="cards"] .replay-card__button { display: block; padding: 0; }
body[data-view="cards"] .replay-card__visual { border-radius: 0; }
body[data-view="cards"] .replay-card__content { padding: 13px; }
body[data-view="board"] .replay-grid { grid-template-columns: 1fr; }
body[data-view="board"] .replay-card__button {
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 112px;
  padding: 14px;
}
.replay-dialog {
  width: min(960px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
}
.replay-dialog::backdrop { background: rgba(0, 0, 0, 0.82); }
.replay-dialog__header,
.replay-dialog__footer {
  display: flex;
  gap: 16px;
  min-height: 52px;
  padding: 10px 14px;
  align-items: center;
  justify-content: space-between;
}
.replay-dialog__header { border-bottom: 1px solid var(--line); }
.replay-dialog__footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.dialog-controls,
.dialog-actions,
.session-nav { display: flex; gap: 7px; align-items: center; }
.dialog-controls { margin-left: auto; }
.session-nav { padding-right: 7px; border-right: 1px solid var(--line); }
.session-nav button { padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; color: #d9dbe0; background: rgba(255,255,255,.03); font-size: 10px; }
.session-nav button:disabled { opacity: .35; }
.session-nav span { min-width: 78px; text-align: center; }
.replay-dialog video { display: block; width: 100%; max-height: calc(100vh - 138px); background: #000; }
.dialog-close { padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: transparent; font-size: 11px; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 24px 0 36px;
  border-top: 1px solid var(--line);
  color: #676e7b;
  font-size: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .library-layout { grid-template-columns: 1fr; }
  .replay-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .replay-card:nth-child(odd) { border-right: 1px solid var(--line); }
  body[data-view="cards"] .replay-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-view="board"] .replay-grid { grid-template-columns: 1fr; }
  body[data-view="board"] .replay-card:nth-child(odd) { border-right: 0; }
}
@media (max-width: 1250px) and (min-width: 761px) {
  .toolbar { grid-template-columns: minmax(100px, 1fr) auto auto; padding-block: 12px; }
  .archive-controls { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 680px) {
  .replay-dialog__footer { align-items: flex-start; flex-direction: column; }
  .dialog-controls { width: 100%; margin-left: 0; justify-content: space-between; }
}
@media (max-width: 760px) {
  .site-header, main, footer { width: min(calc(100% - 24px), var(--max-width)); }
  .toolbar { grid-template-columns: 1fr; gap: 12px; padding: 15px 0; }
  .filters, .sort-modes { width: 100%; overflow-x: auto; }
  .archive-controls { width: 100%; flex-wrap: wrap; }
  .player-search { flex: 1 1 100%; }
  .player-search input { flex: 1; width: auto; }
  .date-search { flex: 1; }
  .date-search input { flex: 1; }
  .filter { flex: 1 0 auto; }
  .featured__details { grid-template-columns: 1fr; }
  .encounter-data { flex-wrap: wrap; }
  .encounter-data div:first-child { padding-left: 0; border-left: 0; }
  .replay-grid { grid-template-columns: 1fr; }
  body[data-view="cards"] .replay-grid { grid-template-columns: 1fr; }
  body[data-view="board"] .replay-card__button { grid-template-columns: 112px minmax(0, 1fr); min-height: 0; }
  .replay-card:nth-child(odd) { border-right: 0; }
  footer { display: grid; gap: 6px; }
}
@media (max-width: 430px) {
  .featured__bar { align-items: flex-start; flex-direction: column; gap: 10px; padding-block: 12px; }
  .replay-card__button { grid-template-columns: 112px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
