:root {
  --bg: #07060c;
  --ink: #f2eefc;
  --muted: #9b93b0;
  --line: rgba(167, 139, 250, 0.18);
  --violet: #a78bfa;
  --magenta: #d946ef;
  --navy: #1e1b4b;
  --win: #34d399;
  --lose: #f87171;
  --draw: #fbbf24;
  --soon: #7dd3fc;
  --panel: rgba(16, 12, 28, 0.72);
  --font-display: "Oxanium", sans-serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--bg);
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(124, 58, 237, 0.38), transparent 60%),
    radial-gradient(700px 480px at 92% 8%, rgba(217, 70, 239, 0.18), transparent 55%),
    radial-gradient(800px 600px at 70% 100%, rgba(30, 27, 75, 0.55), transparent 50%),
    linear-gradient(180deg, #0b0914 0%, #07060c 100%);
}

.fog {
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  animation: drift 18s ease-in-out infinite alternate;
}
.fog-a {
  top: -18%;
  left: -10%;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.55), transparent 70%);
}
.fog-b {
  right: -12%;
  bottom: 10%;
  background: radial-gradient(circle, rgba(217, 70, 239, 0.28), transparent 70%);
  animation-delay: -7s;
  animation-duration: 22s;
}

.grid {
  position: absolute;
  inset: 0;
  opacity: 0.14;
  background-image:
    linear-gradient(rgba(167, 139, 250, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(167, 139, 250, 0.12) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 20%, #000 20%, transparent 75%);
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(4%, 3%, 0) scale(1.08); }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(16px, 3vw, 28px) 64px;
}

.hero {
  display: grid;
  gap: clamp(28px, 4vw, 40px);
  margin-bottom: clamp(36px, 6vw, 56px);
  animation: rise 0.7s ease-out both;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 28px);
  flex-wrap: wrap;
}

.crest {
  width: clamp(112px, 16vw, 168px);
  height: auto;
  filter: drop-shadow(0 0 28px rgba(167, 139, 250, 0.35));
  animation: pulseGlow 4.5s ease-in-out infinite;
}

.hero-copy { min-width: min(100%, 280px); }

.hero-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 0.95;
  background: linear-gradient(120deg, #fff 10%, #c4b5fd 45%, #e879f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 500;
  max-width: 28ch;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px 18px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  animation: rise 0.85s ease-out 0.12s both;
}

.stat {
  padding: 4px 0 2px;
}
.stat .k {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.stat .v {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.stat.winrate .v {
  color: var(--violet);
  text-shadow: 0 0 24px rgba(167, 139, 250, 0.35);
}

.board {
  animation: rise 0.9s ease-out 0.2s both;
}

.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.board-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.board-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 24px 60px rgba(0, 0, 0, 0.35);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.1);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.28);
}

tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.2s ease; }
tbody tr:hover td { background: rgba(167, 139, 250, 0.08); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:focus-visible td { background: rgba(167, 139, 250, 0.14); outline: none; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.ctr { text-align: center; }

tr.win td:first-child { box-shadow: inset 3px 0 0 var(--win); }
tr.lose td:first-child { box-shadow: inset 3px 0 0 var(--lose); }
tr.draw td:first-child { box-shadow: inset 3px 0 0 var(--draw); }
tr.upcoming td:first-child { box-shadow: inset 3px 0 0 var(--soon); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 10px currentColor;
}
.dot.win { background: var(--win); color: var(--win); }
.dot.lose { background: var(--lose); color: var(--lose); }
.dot.draw { background: var(--draw); color: var(--draw); }
.dot.upcoming { background: var(--soon); color: var(--soon); }

.note {
  margin: 18px 4px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
  max-width: 70ch;
}

body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 10, 0.72);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  max-height: min(86vh, 820px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(14, 11, 24, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: rise 0.28s ease-out both;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}
.modal-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}
.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
}
.modal-close:hover { color: var(--ink); }

.modal-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px 0;
}
.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.tab.active {
  color: var(--ink);
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(167, 139, 250, 0.14);
}

.modal-body {
  padding: 14px 20px 20px;
  overflow: auto;
}
.modal-empty, .modal-loading {
  margin: 12px 0;
  color: var(--muted);
  line-height: 1.55;
}
.players-scroll { overflow-x: auto; }
.players-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: fixed;
}
.players-table th,
.players-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.1);
  vertical-align: middle;
}
.players-table th {
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  background: rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}
.players-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.players-table th.sortable:hover { color: var(--ink); }
.players-table th:nth-child(2),
.players-table td:nth-child(2) {
  text-align: left;
  width: 34%;
}
.players-table th.ctr,
.players-table td.ctr {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.players-table td.record {
  color: #f5d76e;
  font-weight: 700;
  font-size: 1.05em;
}
.players-table td.record.anti {
  color: #f07178;
}
.nick-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.nick-name { font-weight: 600; }
.mvp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.mvp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 4px;
  border-radius: 999px;
  border: 1px solid rgba(245, 215, 110, 0.45);
  background: rgba(245, 215, 110, 0.12);
  color: #f5d76e;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.mvp-badge img {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}
.mvp-badge.anti {
  color: #f07178;
  border-color: rgba(240, 113, 120, 0.45);
  background: rgba(240, 113, 120, 0.12);
}
.players-table tfoot td {
  border-top: 1px solid rgba(167, 139, 250, 0.28);
  border-bottom: none;
  font-weight: 600;
  color: var(--ink);
  background: rgba(167, 139, 250, 0.08);
  text-align: center;
}
.players-table tfoot td:nth-child(2) { text-align: left; }

.match-summary {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
}
.match-summary-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}
.match-summary-hint {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
}
.match-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 12px;
}
.match-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.match-summary-item .k {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-display);
}
.match-summary-item .v {
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 22px rgba(167, 139, 250, 0.28)); }
  50% { filter: drop-shadow(0 0 36px rgba(217, 70, 239, 0.4)); }
}

@media (max-width: 900px) {
  .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  th, td { padding: 11px 12px; font-size: 0.84rem; }
  .crest { width: 96px; }
}
