/* Apex Tiers — hand-crafted dark editorial theme */

:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-2: #0b1220;
  --panel: #101a2e;
  --panel-2: #142238;
  --line: #1e2d47;
  --line-soft: #16233a;
  --text: #eaf2ff;
  --muted: #8ea2c4;
  --dim: #5a6b8a;
  --accent: #3b82f6;      /* primary blue */
  --accent-2: #60a5fa;
  --gold: #93c5fd;
  --danger: #ef4444;

  --tier-ht1: #1d4ed8;
  --tier-ht2: #3b82f6;
  --tier-ht3: #60a5fa;
  --tier-lt1: #7aa7d9;
  --tier-lt2: #6a7fa0;
  --tier-lt3: #4d5b78;

  --radius: 4px;
  --radius-lg: 6px;
  --shadow: 0 1px 0 0 rgba(255,255,255,0.04) inset, 0 24px 60px -30px rgba(0,0,0,0.9);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background-image:
  radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
  opacity: 0.4;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-2); }
button { font: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.85em; background: var(--panel); padding: 2px 6px; border-radius: 3px; color: var(--accent-2); }

/* ---------------- TOPBAR ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11,12,16,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto;
  padding: 14px 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: 0 0 0 3px rgba(255,106,26,0.08);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 400; font-size: 22px; letter-spacing: 0.2px;
}
.brand-text strong em { color: var(--accent);  }
.brand-text small { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin-top: 2px; }

.nav-primary { display: flex; gap: 4px; justify-content: center; }
.nav-primary a {
  padding: 8px 14px;
  font-size: 13px; font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-radius: 3px;
  transition: color .15s, background .15s;
}
.nav-primary a:hover { color: var(--text); background: var(--panel); }

.nav-tools { display: flex; gap: 10px; align-items: center; }
.ghost-btn {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 12px; font-size: 12px; border-radius: 3px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color .15s, border-color .15s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--dim); }
.cta-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #ffffff;
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  border: none; border-radius: 3px;
  letter-spacing: 0.02em;
  transition: background .15s, transform .1s;
}
.cta-btn:hover { background: var(--accent-2); color: #ffffff; }
.cta-btn:active { transform: translateY(1px); }
.link-btn {
  padding: 10px 4px; font-size: 13px;
  color: var(--muted); border-bottom: 1px solid var(--dim);
  border-radius: 0;
}
.link-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------------- LAYOUT ---------------- */
main { max-width: 1320px; margin: 0 auto; padding: 48px 28px 80px; }
.page { display: block; }
[hidden] { display: none !important; }

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 12px;
}
h1 {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.95; letter-spacing: -0.01em;
  margin: 0;
}
h1 em { color: var(--accent);  }
h2 {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 400; font-size: 28px; margin: 0;
  letter-spacing: -0.005em;
}
p { margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ---------------- HERO ---------------- */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 56px;
  padding: 40px 0 72px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 56px;
}
.hero-copy .lede {
  max-width: 46ch;
  color: var(--muted);
  font-size: 17px; line-height: 1.6;
  margin: 22px 0 28px;
}
.hero-actions { display: flex; align-items: center; gap: 18px; margin-bottom: 44px; }
.hero-stats {
  display: grid; grid-template-columns: repeat(3, auto);
  gap: 40px; margin: 0;
  padding-top: 28px; border-top: 1px solid var(--line-soft);
}
.hero-stats div { display: flex; flex-direction: column; gap: 4px; }
.hero-stats dt { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin: 0; }
.hero-stats dd {
  margin: 0; font-family: "JetBrains Mono", monospace;
  font-size: 28px; font-weight: 700; color: var(--text);
}

.hero-side {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border-radius: var(--radius-lg);
  padding: 20px;
}
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 14px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.side-head .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 12px var(--accent); animation: pulse 2s ease-in-out infinite; }
.side-head h2 { font-family: Inter; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; flex: 1; }
.side-head a { font-size: 12px; color: var(--muted); }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

/* ---------------- SECTIONS ---------------- */
.section { margin-bottom: 64px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 20px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: 34px; display: flex; align-items: baseline; gap: 16px; }
.section-head h2 .num {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px; color: var(--dim);
  letter-spacing: 0.1em;
}
.section-head p { color: var(--muted); font-size: 14px; max-width: 40ch; text-align: right; }

/* ---------------- RESULT FEED ---------------- */
.result-feed { display: flex; flex-direction: column; gap: 2px; }
.result-feed.feed-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 8px;
}
.result-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: background .15s, border-color .15s;
}
.result-row:hover { background: var(--panel); border-color: var(--line); }
.result-left { display: flex; align-items: center; gap: 10px; }
.result-left img { width: 28px; height: 28px; border-radius: 3px; image-rendering: pixelated; }
.result-left strong { font-size: 14px; font-weight: 600; }
.result-right { display: flex; align-items: center; gap: 10px; }
.mode-icon { width: 22px; height: 22px; opacity: 0.9; }
.feed-empty { padding: 20px; font-size: 13px; color: var(--dim); }

/* ---------------- NEWS ---------------- */
.news-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
}
.news-card {
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 240px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: var(--panel);
  transition: transform .2s, border-color .2s;
}
.news-card:hover { transform: translateY(-2px); border-color: var(--dim); }
.news-card.news-card-large { grid-row: span 1; min-height: 320px; }
.news-card.has-image::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,12,16,0.1) 0%, rgba(11,12,16,0.95) 100%);
  z-index: 1;
}
.news-card-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  z-index: 0; opacity: 0.55;
  transition: transform .4s;
}
.news-card:hover .news-card-bg { transform: scale(1.04); opacity: 0.7; }
.news-card > span, .news-card > h3, .news-card > p { position: relative; z-index: 2; }
.news-card > span {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.news-card > h3 {
  font-family: Inter, sans-serif;
  font-weight: 400; font-size: 26px; line-height: 1.15;
  margin: 0 0 10px; color: var(--text);
}
.news-card > p { font-size: 13px; color: var(--muted); line-height: 1.5; }

@media (max-width: 900px) {
  .news-grid { grid-template-columns: 1fr; }
}

/* ---------------- PAGE HEAD ---------------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding-bottom: 24px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.page-head h1 { font-size: clamp(40px, 5vw, 64px); }

.search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 3px;
  padding: 0 12px;
  min-width: 260px;
}
.search span { color: var(--dim); font-size: 16px; }
.search input {
  background: transparent; border: none; outline: none; color: var(--text);
  padding: 10px 0; font: inherit; font-size: 14px; width: 100%;
}
.search input::placeholder { color: var(--dim); }

/* ---------------- MODE TABS ---------------- */
.mode-tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 20px;
}
.mode-tabs button, .mode-tabs a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: transparent; border: none;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  border-radius: 3px;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.mode-tabs button:hover, .mode-tabs a:hover { color: var(--text); background: var(--panel-2); }
.mode-tabs button.active, .mode-tabs a.active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--line);
}
.mode-tabs img { width: 18px; height: 18px; image-rendering: pixelated; }

.ranking-counts {
  display: flex; gap: 20px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 16px;
}

/* ---------------- RANKINGS TABLE ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.rankings-table {
  width: 100%; border-collapse: collapse;
  background: var(--panel);
}
.rankings-table thead th {
  padding: 14px 12px;
  text-align: left;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  white-space: nowrap;
}
.rankings-table tbody tr {
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .15s;
}
.rankings-table tbody tr:hover { background: var(--panel-2); }
.rankings-table td {
  padding: 12px;
  vertical-align: middle;
  font-size: 14px;
}
.rankings-table td:first-child {
  font-family: "JetBrains Mono", monospace;
  color: var(--dim); font-weight: 700; width: 60px;
}
.table-player { display: flex; align-items: center; gap: 12px; }
.table-player img { width: 34px; height: 34px; border-radius: 3px; image-rendering: pixelated; }
.table-player strong { display: block; font-size: 14px; font-weight: 600; }
.table-player span { font-size: 11px; color: var(--dim); font-family: "JetBrains Mono", monospace; }
.mode-head { display: inline-flex; align-items: center; gap: 6px; }
.mode-head img { width: 16px; height: 16px; }
.no-tier { color: var(--dim); }

/* Tier badges */
.tier-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 4px 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  border-radius: 3px;
  border: 1px solid transparent;
}
.tier-badge.high {
  color: var(--tier-ht1);
  background: rgba(255,90,42,0.08);
  border-color: rgba(255,90,42,0.35);
}
.tier-badge.low {
  color: var(--tier-lt1);
  background: rgba(127,169,201,0.08);
  border-color: rgba(127,169,201,0.3);
}

/* ---------------- MODE COLUMNS ---------------- */
.tier-columns {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.mode-tier-column {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
}
.mode-tier-column header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.mode-tier-column header h2 {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
}
.mode-tier-column header span {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; color: var(--dim);
}
.mode-tier-column.tier-1 header h2 { color: var(--tier-ht1); }
.mode-tier-column.tier-2 header h2 { color: var(--tier-ht2); }
.mode-tier-column.tier-3 header h2 { color: var(--tier-ht3); }
.mode-tier-column.tier-4 header h2 { color: var(--tier-lt1); }
.mode-tier-column.tier-5 header h2 { color: var(--tier-lt2); }
.mode-tier-list { display: flex; flex-direction: column; padding: 6px; }
.mode-tier-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 3px;
  transition: background .15s;
}
.mode-tier-row:hover { background: var(--panel-2); }
.mode-tier-row img { width: 26px; height: 26px; border-radius: 2px; image-rendering: pixelated; }
.mode-tier-row strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
  .tier-columns { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .tier-columns { grid-template-columns: 1fr; }
}

/* ---------------- PLAYER ---------------- */
.back-link {
  display: inline-block; margin-bottom: 24px;
  font-size: 13px; color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.08em;
}
.back-link:hover { color: var(--accent); }
.player-profile {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
}
.profile-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px; align-items: center;
  padding: 32px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.profile-header > img {
  width: 96px; height: 96px; border-radius: 4px;
  image-rendering: pixelated;
  border: 1px solid var(--line);
}
.profile-header h1 { font-size: 48px; margin-top: 4px; }
.profile-score { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.profile-score > span { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); font-family: "JetBrains Mono", monospace; }
.profile-score strong { font-family: "JetBrains Mono", monospace; font-size: 14px; color: var(--muted); }

.profile-modes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px; padding: 20px;
  border-bottom: 1px solid var(--line);
}
.mode-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border: 1px solid var(--line-soft);
  border-radius: 4px; background: var(--bg-2);
  overflow: hidden;
  min-width: 0;
}
.mode-card img { width: 22px; height: 22px; flex-shrink: 0; }
.mode-card span { flex: 1; font-size: 13px; min-width: 0; }
.empty-tier { color: var(--dim); font-family: "JetBrains Mono", monospace; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; flex-shrink: 0; }

.history-panel { padding: 24px 32px 32px; }
.history-panel h2 { font-family: Inter; font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin-bottom: 16px; }
.history-panel ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.history-panel li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 10px 12px;
  border-radius: 3px;
  background: var(--bg-2);
}
.history-panel li img { width: 20px; height: 20px; }
.history-panel li span { font-size: 12px; color: var(--dim); font-family: "JetBrains Mono", monospace; }

/* ---------------- ADMIN ---------------- */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  display: flex; flex-direction: column; gap: 14px;
}
.admin-card h2 {
  font-family: Inter; font-size: 13px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  padding-bottom: 12px; border-bottom: 1px solid var(--line-soft);
}
.admin-card label { display: flex; flex-direction: column; gap: 6px; }
.admin-card label > span {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--dim); font-weight: 500;
}
.admin-card input, .admin-card select, .admin-card textarea {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--text); padding: 10px 12px;
  border-radius: 3px; font: inherit; font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.admin-card input:focus, .admin-card select:focus, .admin-card textarea:focus { border-color: var(--accent); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.admin-card button {
  padding: 10px 14px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px; font-size: 13px; font-weight: 500;
}
.admin-card button:hover { border-color: var(--dim); }
.admin-card button.cta-btn { background: var(--accent); color: #ffffff; border-color: var(--accent); }
.admin-card button.danger { color: var(--danger); border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.05); }
.admin-card button.danger:hover { background: rgba(239,68,68,0.1); }
.admin-note { font-size: 12px; color: var(--dim); }
.admin-hint { font-size: 12px; color: var(--muted); max-width: 44ch; }

.news-editor { display: flex; flex-direction: column; gap: 14px; }
.news-editor fieldset {
  border: 1px solid var(--line-soft); border-radius: 4px;
  padding: 14px; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-2);
}
.news-editor legend {
  padding: 0 8px;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); font-family: "JetBrains Mono", monospace;
}
.image-row { display: flex; gap: 8px; align-items: center; }
.image-row input[type="file"] { padding: 6px; font-size: 12px; }
.image-preview { max-width: 100%; margin-top: 8px; border-radius: 3px; border: 1px solid var(--line); max-height: 140px; object-fit: cover; }

/* ---------------- STATUS / FOOTER ---------------- */
.status { padding: 12px 16px; font-size: 13px; color: var(--muted); }
.status-inline { padding: 0; }
.site-foot {
  max-width: 1320px; margin: 40px auto 0;
  padding: 28px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  color: var(--dim); font-size: 12px; gap: 16px; flex-wrap: wrap;
}
.site-foot strong { color: var(--muted); font-family: Inter, sans-serif; font-weight: 400; font-size: 16px; margin-right: 10px; }
.site-foot a { margin-left: 16px; color: var(--muted); }
.site-foot a:hover { color: var(--accent); }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 960px) {
  .topbar-inner { grid-template-columns: 1fr auto; gap: 16px; }
  .nav-primary { display: none; }
  .hero { grid-template-columns: 1fr; gap: 32px; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .hero-stats dd { font-size: 22px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .section-head p { text-align: left; }
  .profile-header { grid-template-columns: 1fr; text-align: center; }
  .profile-score { align-items: center; text-align: center; }
}
@media (max-width: 560px) {
  main { padding: 32px 16px 60px; }
  .topbar-inner { padding: 12px 16px; }
  .nav-tools .ghost-btn { display: none; }
  .brand-text small { display: none; }
  .search { min-width: 0; width: 100%; }
  .page-head { flex-direction: column; align-items: stretch; }
}
