:root {
  --bg: #0c0c0c;
  --bg-scene-1: #121212;
  --bg-scene-2: #090909;
  --panel: #1a1a1a;
  --panel-alt: #202020;
  --border: #3c3c3c;
  --border-soft: #2a2a2a;
  --text: #e6e6e6;
  --text-dim: #9c9c9c;
  --text-faint: #6a6a6a;
  --accent: #d4d4d4;
  --accent-strong: #f5f5f5;
  --positive: #f0f0f0;
  --negative: #565656;
  --radius: 10px;
  --font-display: "Cinzel", serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

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

.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 40% at 50% -10%, rgba(255, 255, 255, 0.06), transparent 60%),
    radial-gradient(ellipse 80% 60% at 15% 110%, rgba(255, 255, 255, 0.04), transparent 60%),
    linear-gradient(180deg, var(--bg-scene-1) 0%, var(--bg-scene-2) 100%);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

.title-block {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin: 0 0 10px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: 0.02em;
  margin: 0 0 10px;
  color: var(--accent-strong);
  position: relative;
  display: inline-block;
}

h1::after {
  content: "";
  display: block;
  width: 64px;
  height: 2px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: flicker 4s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 auto;
  max-width: 460px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
}

select {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rank-card {
  background: linear-gradient(160deg, var(--panel-alt), var(--panel));
  border-color: var(--border);
}

.stat-label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--accent-strong);
}

.stat-value.mono {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--text);
}

.table-wrap {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-head {
  display: grid;
  grid-template-columns: 48px 1fr 118px 90px 110px;
  padding: 12px 16px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel-alt);
}

.table-body {
  display: flex;
  flex-direction: column;
}

.row {
  display: grid;
  grid-template-columns: 48px 1fr 118px 90px 110px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: 13.5px;
}

.row:last-child { border-bottom: none; }
.row:nth-child(odd) { background: rgba(255, 255, 255, 0.012); }

.rank-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
}

.row:nth-child(1) .rank-badge { border-color: var(--accent); color: var(--accent-strong); }

.col-name-cell {
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

.wph-value {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.wph-value.positive { color: var(--positive); }
.wph-value.negative { color: var(--negative); }
.wph-value.neutral { color: var(--text-faint); }

.season-rank { color: var(--positive); white-space: nowrap; }
.guild-cell { color: var(--text-dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 6px; }

.empty-state, .error-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.6;
}

.error-state { color: var(--negative); }

@media (max-width: 480px) {
  .table-head {
    grid-template-columns: 34px minmax(100px, 1fr) 82px 66px 82px;
    padding: 10px 12px;
  }

  .row {
    grid-template-columns: 34px minmax(100px, 1fr) 82px 66px 82px;
    padding: 10px 12px;
    column-gap: 6px;
  }

  .col-name-cell { font-size: 12.5px; }
  .season-rank { font-size: 11.5px; white-space: nowrap; }
  .wph-value { font-size: 12.5px; text-align: right; white-space: nowrap; }

  .stat-row { grid-template-columns: 1fr 1fr; }
}


/* Guild is shown only in the 전체 view. */
.stat-row.hidden-for-all { display: none !important; }
.table-head:not(.all-mode),
.table-body:not(.all-mode) { }
.table-head:not(.all-mode) {
  grid-template-columns: 48px 1fr 90px 110px;
}
.table-body:not(.all-mode) .row {
  grid-template-columns: 48px 1fr 90px 110px;
}
.table-head:not(.all-mode) .col-guild,
.table-body:not(.all-mode) .guild-cell { display: none; }

/* Keep Season Wave visually identical to WPH. */
.wph-value { 
  font-family: var(--font-mono) !important;
  font-size: 13.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

@media (max-width: 480px) {
  .table-head:not(.all-mode) {
    grid-template-columns: 34px minmax(100px, 1fr) 66px 82px;
  }
  .table-body:not(.all-mode) .row {
    grid-template-columns: 34px minmax(100px, 1fr) 66px 82px;
  }
}


/* Season Wave: color-only override. Typography remains inherited from .wph-value. */
.season-wave-value { color: var(--positive) !important; }


/* 전체 탭: 시즌 등수 300등 이내 / 300등 초과 구분선 */
.all-rank-300-divider {
  border-top: 2px solid #d4af37 !important;
}


/* 모바일 전체 탭: 좁은 화면에서도 시즌웨이브가 반드시 보이도록 최적화 */
@media (max-width: 480px) {
  .table-head.all-mode {
    grid-template-columns: 28px minmax(56px, 1fr) 40px 56px 64px;
    padding: 9px 10px;
    column-gap: 3px;
    min-width: 0;
    font-size: 8.5px;
    letter-spacing: 0.01em;
  }
  .table-body.all-mode .row {
    grid-template-columns: 28px minmax(56px, 1fr) 40px 56px 64px;
    padding: 9px 10px;
    column-gap: 3px;
    min-width: 0;
  }
  .table-head.all-mode .col-guild,
  .table-body.all-mode .guild-cell { display: block; }
  .table-body.all-mode .col-name-cell { font-size: 11px; }
  .table-body.all-mode .guild-cell { font-size: 9px; padding-right: 2px; }
  .table-body.all-mode .season-rank { font-size: 9.5px; }
  .table-body.all-mode .wph-value { font-size: 11px; }
}
