:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5f6f82;
  --line: #d9e1ea;
  --accent: #00c471;
  --accent-dark: #008f55;
  --ink: #101418;
  --shadow: 0 10px 28px rgba(23, 32, 42, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d23;
  --text: #edf2f7;
  --muted: #a7b4c2;
  --line: #2c3742;
  --accent: #23d18b;
  --accent-dark: #62e6ad;
  --ink: #ffffff;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  transition:
    background-color 220ms ease,
    color 220ms ease;
}

a {
  color: inherit;
}

.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 34px clamp(18px, 4vw, 56px) 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  text-align: center;
  transition:
    background-color 220ms ease,
    border-color 220ms ease;
}

.brand-block {
  width: 100%;
}

.header-actions {
  position: absolute;
  top: 16px;
  right: clamp(18px, 4vw, 56px);
  z-index: 2;
}

.theme-switcher {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: color-mix(in srgb, var(--panel) 86%, var(--bg));
  box-shadow: var(--shadow);
}

.theme-choice {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.theme-choice:hover {
  transform: translateY(-1px);
}

.theme-choice[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

.header-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.header-popularity-row {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.stream-link,
.discord-link,
.popularity-entry {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.popularity-entry {
  min-height: 34px;
  border: 1px solid color-mix(in srgb, var(--accent) 58%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--accent-dark);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.popularity-entry:hover {
  transform: translateY(-1px);
}

.popularity-entry[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.stream-link {
  grid-auto-flow: column;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.stream-link.is-live {
  border-color: #ff8b8b;
  background: #fff7f7;
  color: #c62828;
  box-shadow: 0 0 0 0 rgba(255, 98, 98, 0.44);
  animation: livePulse 1400ms ease-in-out infinite;
}

.live-badge {
  display: inline-grid;
  place-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 0 7px;
  background: #ff4d4f;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.live-badge[hidden] {
  display: none;
}

.discord-link {
  border: 1px solid #5865f2;
  background: #5865f2;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(88, 101, 242, 0.24);
}

.stream-link:hover,
.discord-link:hover,
.popularity-entry:hover {
  text-decoration: underline;
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.category-bar {
  display: none;
}

.category-button,
.copy-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.category-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.status-row p {
  margin: 0;
}

.text-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.clip-browser {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  position: sticky;
  top: 16px;
}

.category-card {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.category-card:hover {
  transform: translateX(4px);
}

.category-card[aria-pressed="true"] {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 196, 113, 0.18);
}

.category-card strong {
  display: block;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: 0;
}

.category-card span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.clips-panel {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  opacity: 0.66;
  transform: translateX(-10px);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.clips-panel.is-open {
  opacity: 1;
  transform: translateX(0);
}

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.clip-grid[hidden] {
  display: none;
}

.clip-card {
  border-radius: 8px;
  animation: slideIn 260ms ease both;
}

.clip-open {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(0, 196, 113, 0.22), rgba(23, 32, 42, 0.12)),
    #e7edf4;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.clip-open:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(23, 32, 42, 0.14);
  transform: translateY(-3px);
}

.clip-open::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(16, 20, 24, 0.72);
  transform: translate(-50%, -50%);
}

.clip-open::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 50% auto auto 50%;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid #ffffff;
  transform: translate(-35%, -50%);
}

.thumb-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.primary-link {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  flex: 1;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.secondary-link {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.copy-button {
  flex: 0 0 auto;
}

.clip-label {
  margin: 7px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  padding: 20px 16px 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes livePulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 98, 98, 0.38);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(255, 98, 98, 0.12);
  }
}

.player-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.player-modal[hidden] {
  display: none;
}

.player-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 20, 24, 0.72);
}

.player-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.player-kicker {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.player-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.close-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.player-frame-wrap {
  aspect-ratio: 16 / 9;
  background: #101418;
}

.player-frame-wrap iframe,
.player-frame-wrap video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #101418;
}

.player-note {
  margin: 14px 16px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.external-player-link {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  margin: 14px 16px 16px;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
}

.empty-state {
  margin-top: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 36px 18px;
  background: var(--panel);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.popularity-panel {
  display: grid;
  gap: 16px;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.popularity-panel[hidden] {
  display: none;
}

.popularity-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: color-mix(in srgb, var(--bg) 54%, var(--panel));
}

.mode-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.mode-tab:hover {
  transform: translateY(-1px);
}

.mode-tab[aria-selected="true"] {
  background: var(--accent);
  color: #ffffff;
}

.popularity-view {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.popularity-view.is-active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: viewIn 220ms ease both;
}

.game-intro,
.ranking-head,
.ranking-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.game-intro h2,
.ranking-head h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 22px;
  letter-spacing: 0;
}

.game-intro p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.primary-action,
.secondary-action {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.primary-action {
  border: 0;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 24%, transparent);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-2px);
}

.tournament-stage {
  display: grid;
  gap: 14px;
  animation: viewIn 220ms ease both;
}

.tournament-stage[hidden] {
  display: none;
}

.game-progress {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    var(--panel);
  color: var(--muted);
  text-align: center;
}

.game-progress strong {
  color: var(--accent-dark);
  font-size: 28px;
  line-height: 1;
}

.game-progress span {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--panel) 82%, var(--bg));
  font-size: 12px;
  font-weight: 900;
}

.match-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.match-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: left;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
  animation: cardIn 240ms ease both;
}

.match-card:hover {
  border-color: var(--accent);
  box-shadow: 0 16px 34px rgba(23, 32, 42, 0.16);
  transform: translateY(-4px);
}

.match-media {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #101418;
}

.match-media video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #101418;
  cursor: pointer;
  object-fit: cover;
}

.match-play {
  position: absolute;
  inset: 50% auto auto 50%;
  min-width: 74px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(16, 20, 24, 0.78);
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition:
    background-color 180ms ease,
    opacity 180ms ease,
    transform 180ms ease;
}

.match-play:hover {
  background: rgba(0, 196, 113, 0.92);
  transform: translate(-50%, -50%) scale(1.04);
}

.match-card.is-playing .match-play {
  opacity: 0.72;
}

.match-card strong {
  display: block;
  margin: 10px 2px 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-select {
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    transform 180ms ease;
}

.match-select:hover {
  transform: translateY(-2px);
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ranking-head h2 {
  margin: 0;
}

.ranking-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 96px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: cardIn 220ms ease both;
}

.ranking-rank {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}

.ranking-thumb {
  width: 96px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #101418;
  object-fit: cover;
}

.ranking-title {
  min-width: 0;
}

.ranking-title strong {
  display: block;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ranking-score {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.ranking-empty {
  color: var(--muted);
  line-height: 1.55;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .app-header {
    padding-top: 28px;
    flex-direction: column;
  }

  .header-actions {
    position: static;
    order: 2;
    margin-top: 14px;
  }

  .clip-browser {
    grid-template-columns: 1fr;
  }

  .category-grid {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-board,
  .popularity-mode-tabs {
    grid-template-columns: 1fr;
  }

  .ranking-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ranking-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .ranking-thumb {
    width: 100%;
    grid-column: 1 / -1;
  }

  .ranking-score {
    grid-column: 2;
  }

  .player-head {
    align-items: stretch;
    flex-direction: column;
  }

  .copy-button {
    width: 100%;
  }
}
