:root {
  --bg: #03080b;
  --bg2: #071219;
  --panel: rgba(6, 20, 29, 0.94);
  --panel2: rgba(8, 28, 39, 0.94);
  --line: rgba(103, 137, 153, 0.22);
  --line2: rgba(255, 255, 255, 0.08);
  --gold: #f2a32c;
  --gold2: #ffd36a;
  --blue: #28a7ff;
  --green: #02dc79;
  --red: #ff344d;
  --magic: #7ac8ff;
  --phys: #ff7558;
  --text: #f7fbff;
  --muted: #98aabd;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(3, 8, 11, 0.42), rgba(3, 8, 11, 0.96) 520px),
    radial-gradient(circle at 50% 0, rgba(94, 52, 24, 0.28), transparent 42%),
    #03080b;
}

a { color: var(--gold); text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(26px, calc((100vw - 1220px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(3, 6, 10, 0.88);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 0 32%, rgba(0, 0, 0, .35) 33% 45%, transparent 46%),
    linear-gradient(180deg, #ffd36a, #b76b16);
  box-shadow: 0 0 18px rgba(242, 163, 44, 0.38);
}

.site-nav { display: flex; gap: 26px; align-items: center; }
.site-nav a { position: relative; color: #ccd5de; font-weight: 800; }
.site-nav a:hover { color: #fff; }
.site-nav a:hover:after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 2px;
  background: var(--gold);
}

main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }

.landing-hero {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  min-height: 760px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(3, 6, 10, .38), rgba(3, 6, 10, .78) 70%, #03080b 100%),
    url("/hero-bg.svg");
  background-size: cover;
  background-position: center;
}

.hero-center { max-width: 820px; padding: 0 20px; }
.hero-center h1 {
  margin: 0 0 18px;
  font-size: clamp(54px, 7vw, 104px);
  line-height: .95;
  font-weight: 950;
  letter-spacing: .01em;
  text-shadow: 0 5px 18px rgba(0, 0, 0, .85);
}
.hero-center p {
  max-width: 720px;
  margin: 0 auto;
  color: #dbe5ef;
  font-size: 20px;
  line-height: 1.55;
}

.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 34px; }

.button, button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  padding: 10px 22px;
  color: #fff;
  background: linear-gradient(180deg, #ff9f1c, #e06b10);
  box-shadow: 0 2px 0 rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.25);
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}
.button.secondary, .ghost { background: rgba(15, 32, 43, .95); border: 1px solid rgba(255,255,255,.16); box-shadow: none; }
.full { width: 100%; }

.section-title {
  padding: 54px 0 24px;
  text-align: center;
}
.section-title h2, .leaderboard-page h1 {
  font-size: 42px;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 4px 12px rgba(0,0,0,.65);
}
.section-title span {
  display: block;
  width: 92px;
  height: 3px;
  margin: 14px auto 0;
  background: var(--gold);
}

.feature-stack {
  display: grid;
  gap: 22px;
  margin-bottom: 74px;
}
.feature-row {
  min-height: 260px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  align-items: center;
  gap: 24px;
  padding: 18px;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: rgba(18, 21, 32, .92);
}
.feature-row.flip { grid-template-columns: 1fr 1.05fr; }
.feature-row.flip .feature-image { order: 2; }
.feature-image {
  height: 230px;
  overflow: hidden;
  border-radius: 8px;
  background: #08131b;
}
.feature-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.feature-text { padding: 12px; }
.feature-text h2 { font-size: 26px; margin: 0 0 12px; }
.feature-text p { color: #b8c5d4; line-height: 1.65; font-size: 16px; }

.cta-final {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding: 70px 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(4, 12, 16, .2), rgba(4, 12, 16, .96));
}
.cta-final h2 { margin: 0 0 20px; font-size: 42px; }

.page-head { padding: 50px 0 24px; }
.page-head h1 { margin: 0; font-size: 48px; }
.eyebrow { color: var(--gold); font-size: 12px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }

.table-wrap, .panel, .match-result-screen, .match-topline, .login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0,0,0,.34);
}

table { width: 100%; border-collapse: collapse; }
th {
  padding: 14px 16px;
  color: #dfeeff;
  background: rgba(25, 57, 72, .78);
  text-align: left;
  font-size: 14px;
  text-transform: uppercase;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(124, 163, 181, .14);
  color: #eef7ff;
}
tr.click-row { cursor: pointer; }
tr:hover td { background: rgba(36, 71, 88, .35); }

.avatar-stack { display: flex; }
.avatar-stack img {
  width: 36px;
  height: 36px;
  margin-left: -8px;
  border: 2px solid #06141c;
  border-radius: 50%;
  object-fit: cover;
}
.avatar-stack img:first-child { margin-left: 0; }

.result { font-weight: 900; }
.result.win, .result.victory { color: var(--green); }
.result.lose, .result.loss, .result.defeat { color: var(--red); }

.match-topline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 34px 0 18px;
}
.match-topline div { padding: 18px 20px; }
.match-topline span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.match-topline b { display: block; margin-top: 8px; }

.match-result-screen {
  padding: 24px;
  margin-bottom: 34px;
}
.match-title {
  color: var(--gold2);
  font-size: 48px;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(242,163,44,.35);
}
.match-title.lose, .match-title.loss, .match-title.defeat { color: var(--red); }
.match-meta {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 8px 0 24px;
  color: #63ffd2;
  font-size: 20px;
  font-weight: 900;
}
.match-header, .match-row {
  display: grid;
  grid-template-columns: 58px 220px 86px 230px 230px minmax(170px, 1fr) 120px 120px;
  gap: 10px;
  align-items: center;
}
.match-header {
  padding: 12px 14px;
  background: linear-gradient(90deg, rgba(137, 83, 28, .98), rgba(101, 55, 22, .9));
  color: #fff8dc;
  font-weight: 900;
}
.match-row {
  min-height: 86px;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(124, 163, 181, .16);
  background: rgba(8, 21, 30, .72);
}
.match-row.is-mvp { box-shadow: 0 0 16px rgba(242,163,44,.72), inset 0 0 0 1px rgba(242,163,44,.4); }
.place { color: #fff; text-align: center; font-weight: 900; }
.match-player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.match-player img { width: 52px; height: 52px; object-fit: cover; }
.match-player b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvp { padding: 4px 6px; border: 1px solid var(--gold); color: var(--gold); font-size: 11px; font-weight: 900; }
.resources { display: flex; gap: 8px; flex-wrap: wrap; color: #d7eaff; font-size: 13px; }
.damage-total { margin-bottom: 6px; color: #dff7ff; font-weight: 900; }
.split-bar { height: 14px; display: flex; overflow: hidden; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); }
.split-bar i { display: block; height: 100%; }
.split-bar .phys { background: linear-gradient(90deg, #ff4032, var(--phys)); }
.split-bar .magic { background: linear-gradient(90deg, #3aa7ff, var(--magic)); }
.split-labels { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-size: 12px; }
.reward-list, .icon-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.item-icon, .card-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: inline-flex;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.28);
}
.item-icon img, .card-icon img { width: 100%; height: 100%; object-fit: cover; }
.item-icon b {
  position: absolute;
  right: 2px;
  bottom: 0;
  padding: 0 3px;
  background: rgba(0,0,0,.76);
  font-size: 11px;
}
.rarity-common { box-shadow: inset 0 0 0 1px #6b7280; }
.rarity-rare { box-shadow: inset 0 0 0 1px #3aa7ff; }
.rarity-mythical { box-shadow: inset 0 0 0 1px #b65cff; }
.rarity-legendary { box-shadow: inset 0 0 0 1px #ffd35a; }
.rarity-immortal { box-shadow: inset 0 0 0 1px #ff4159; }
.rarity-super, .rarity-unique { box-shadow: inset 0 0 0 1px #ff8a00, 0 0 10px rgba(255,138,0,.45); }
.cards-details summary { cursor: pointer; color: var(--gold); font-size: 13px; font-weight: 900; }
.cards-details[open] { grid-column: span 2; }
.ability-list { display: grid; gap: 5px; margin-top: 8px; }
.ability-list span, .ability-admin-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  color: #dbe9f4;
  font-size: 12px;
}
.ability-list img, .tiny-icon, .ability-admin-row img { width: 28px; height: 28px; object-fit: cover; }

.leaderboard-page {
  min-height: calc(100vh - 70px);
  padding: 46px 0 90px;
  background: radial-gradient(circle at 50% 0, rgba(242,163,44,.18), transparent 38%);
}
.leaderboard-page h1, .leaderboard-page h2 { text-align: center; }
.leaderboard-page h2 { color: var(--gold); margin: 10px 0 44px; }
.leader-player { display: flex; gap: 10px; align-items: center; font-weight: 900; }
.leader-player img { width: 34px; height: 34px; object-fit: cover; }

.is-admin main { width: 100%; margin: 0; }
.is-admin .topbar { display: none; }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(4, 13, 18, .98);
}
.admin-brand { margin-bottom: 24px; }
.admin-sidebar a:not(.brand) {
  display: block;
  margin-bottom: 6px;
  padding: 12px 14px;
  color: #b9c8d5;
  font-weight: 900;
}
.admin-sidebar a.active, .admin-sidebar a:hover { color: #fff; background: rgba(31, 73, 92, .72); }
.admin-content { padding: 30px; }
.admin-hero { padding: 28px; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); }
.admin-hero h1, .admin-head h1 { margin: 0; font-size: 38px; }
.admin-hero p { color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { min-height: 120px; padding: 18px; background: var(--panel); border: 1px solid var(--line); }
.stat-card span { color: var(--muted); text-transform: uppercase; font-size: 12px; }
.stat-card b { display: block; margin-top: 10px; color: var(--gold); font-size: 38px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(360px, .75fr); align-items: start; }
.panel { padding: 20px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 14px; color: #fff; }
.bar-line { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.inline-search { display: flex; gap: 8px; align-items: center; }
input, textarea, select {
  width: 100%;
  min-height: 42px;
  margin: 7px 0;
  padding: 10px 12px;
  border: 1px solid rgba(128, 160, 177, .24);
  color: var(--text);
  background: rgba(0, 0, 0, .34);
  font: inherit;
}
textarea { font-family: Consolas, "Courier New", monospace; }
label span, label small { display: block; }
label span { color: var(--gold); font-weight: 900; }
label small { color: var(--muted); }
.quick-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.quick-form .button { grid-column: 1 / -1; }
.player-title { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.player-title img { width: 74px; height: 74px; object-fit: cover; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; max-height: 440px; overflow: auto; }
.catalog-grid span { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px; background: rgba(255,255,255,.04); font-size: 12px; }
.catalog-grid img { width: 32px; height: 32px; object-fit: cover; }
.table-bar { position: relative; height: 28px; min-width: 180px; background: rgba(255,255,255,.06); }
.table-bar i { display: block; height: 100%; background: linear-gradient(90deg, #0bb0ff, #ff9f1c); }
.table-bar b { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 10px; }
.login-panel { width: min(430px, calc(100% - 32px)); margin: 14vh auto; padding: 30px; }
.ability-admin-grid { display: grid; gap: 8px; }
.ability-admin-row { grid-template-columns: 32px 150px 1fr auto; min-height: 38px; padding: 6px 8px; background: rgba(255,255,255,.04); }
.admin-player-snapshot { margin-top: 10px; }
pre { max-height: 620px; overflow: auto; padding: 14px; background: #02070a; border: 1px solid var(--line); color: #d7e4ee; }
.error { color: var(--red); }
.muted { color: var(--muted); }

@media (max-width: 1180px) {
  .match-header, .match-row { grid-template-columns: 50px 1fr 80px; }
  .match-header span:nth-child(n+4), .match-row > div:nth-child(n+4), .match-row > details { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .feature-row, .feature-row.flip { grid-template-columns: 1fr; }
  .feature-row.flip .feature-image { order: 0; }
}

@media (max-width: 760px) {
  main { width: min(100% - 22px, 1240px); }
  .topbar { height: auto; padding: 14px 16px; flex-direction: column; gap: 10px; }
  .site-nav { flex-wrap: wrap; justify-content: center; }
  .landing-hero { min-height: 620px; }
  .match-topline, .grid.two, .stat-grid, .quick-form, .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
  .admin-content { padding: 18px; }
}
