:root {
  --bg: #f5f5f5;
  --fg: #000000;
  --muted: #525252;
  --card: #ffffff;
  --border: #e5e5e5;
  --brand: #D02915;
  --brand-dark: #7A180D;
  --brand-grad: linear-gradient(135deg, #7A180D 0%, #D02915 100%);
  --black: #000000;
  --white: #ffffff;
  --danger: #991b1b;
  --warn: #b45309;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body, input, button, select, textarea, table, th, td {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif !important;
}
body {
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
.page { min-height: 100vh; display: flex; flex-direction: column; }
.wrap { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 1rem; }
.main { flex: 1; padding: 1.5rem 1rem 2.5rem; }

/* Header — MLP style: black bar, bold uppercase */
.site-header {
  background: var(--black);
  color: var(--white);
  border-bottom: 3px solid var(--brand);
  position: sticky; top: 0; z-index: 40;
}
.header-inner {
  display: flex; flex-direction: column; gap: .75rem;
  align-items: stretch; justify-content: space-between;
  padding: .85rem 1rem;
}
@media (min-width: 600px) {
  .header-inner { flex-direction: row; align-items: center; }
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-size: 1rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.brand span { color: var(--brand); }
.nav { 
  display: flex; gap: .2rem; align-items: center; 
  flex-wrap: wrap; justify-content: center;
  scrollbar-width: none; -ms-overflow-style: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-link, .nav-user, .btn { flex-shrink: 0; }
.nav-link {
  border-radius: 0; padding: .45rem .75rem; font-size: .75rem;
  font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.nav-link:hover { color: var(--brand); }
.nav-link.active {
  background: var(--brand-grad);
  color: var(--white);
}
.nav-user { font-size: .7rem; opacity: .8; margin: 0 .35rem 0 .5rem; text-transform: uppercase; letter-spacing: .04em; }

.site-footer {
  background: var(--black); color: rgba(255,255,255,.7);
  border-top: 3px solid var(--brand);
  padding: 1.25rem 1rem; text-align: center; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .08em;
}

/* Hero */
.hero {
  border-radius: 0;
  background: var(--brand-grad);
  color: var(--white);
  padding: 2.25rem 1.5rem;
  box-shadow: 0 16px 40px rgba(122, 24, 13, .28);
  position: relative; overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; right: -40px; top: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.hero .eyebrow {
  font-size: .7rem; letter-spacing: .22em; text-transform: uppercase;
  color: rgba(255,255,255,.85); margin: 0; font-weight: 800;
}
.hero h1 {
  margin: .45rem 0 0; font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 900; letter-spacing: -.02em; text-transform: uppercase;
}
.hero p { margin: .85rem 0 0; max-width: 42rem; color: rgba(255,255,255,.92); }

.hero-banner {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 2.5rem;
}
.hero-banner .hero-actions {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  width: 100%;
}
@media (max-width: 768px) {
  .hero-banner {
    background-size: contain;
    background-position: top center;
    min-height: auto;
    padding-top: 58vw; /* Leaves space for the backdrop image to display without crop */
    padding-bottom: 1.5rem;
    background-color: var(--black); /* Blend with the image if it doesn't cover all */
  }
}

.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.35rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 0; padding: .6rem 1.05rem;
  font-size: .75rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; cursor: pointer;
}
.btn-sm { padding: .35rem .75rem; font-size: .7rem; }
.btn-accent { background: var(--brand); color: var(--white); }
.btn-light { background: var(--white); color: var(--black); }
.btn-ghost { background: transparent; color: var(--white); box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.btn-dark { background: var(--black); color: var(--white); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-primary { background: var(--brand-grad); color: var(--white); }

.grid-3 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-top: 1.25rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 0;
  padding: 1rem; box-shadow: 0 1px 0 rgba(0,0,0,.04);
  border-top: 3px solid var(--brand);
}
.card .label {
  margin: 0; font-size: .65rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); font-weight: 800;
}
.card .value { margin: .3rem 0 0; font-size: 1.6rem; font-weight: 900; }

.section { margin-top: 1.75rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.section h2 {
  margin: 0; font-size: 1.15rem; font-weight: 900;
  text-transform: uppercase; letter-spacing: .04em;
}
.link { color: var(--brand); font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }

.table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: 0; background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: .75rem; }
@media (min-width: 600px) { table { font-size: .875rem; } }
th, td { padding: .5rem .5rem; text-align: left; border-top: 1px solid var(--border); white-space: nowrap; }
@media (min-width: 600px) { th, td { padding: .7rem .75rem; } }
thead th {
  background: var(--black); color: var(--white); border-top: 0;
  font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 800;
}
tr.top { background: #fff1f0; }
.team-code { font-weight: 900; color: var(--brand); }

/* Bảng hiển thị dọc cho Mobile */
@media (max-width: 768px) {
  .table-wrap:has(.responsive-table) { border: none; background: transparent; padding: 0; margin-left: -.5rem; margin-right: -.5rem; width: auto; }
  .responsive-table, .responsive-table thead, .responsive-table tbody, .responsive-table th, .responsive-table td, .responsive-table tr {
    display: block; width: 100%;
  }
  .responsive-table thead tr {
    position: absolute; top: -9999px; left: -9999px;
  }
  .responsive-table tr {
    background: var(--card); border: 1px solid var(--border) !important; border-radius: 6px;
    margin-bottom: .75rem; padding: .25rem 0; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }
  .responsive-table td {
    border: none; border-bottom: 1px solid var(--border);
    position: relative; padding: .5rem .75rem .5rem 45% !important; 
    text-align: right; min-height: 2.2rem; display: flex; align-items: center; justify-content: flex-end;
    white-space: normal;
  }
  .responsive-table td:last-child { border-bottom: 0; }
  .responsive-table td::before {
    position: absolute; left: .75rem; width: 40%; padding-right: 10px;
    white-space: nowrap; text-align: left; font-weight: 800; font-size: .65rem; text-transform: uppercase; color: var(--muted);
    content: attr(data-label);
  }
}

.flash { margin-bottom: 1rem; padding: .75rem 1rem; border-radius: 0; font-size: .9rem; border-left: 4px solid; }
.flash-success { background: #fff1f0; color: #7A180D; border-color: #D02915; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: var(--brand); }
.flash-info { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }

.form { display: grid; gap: .75rem; max-width: 28rem; }
.form-row { display: grid; gap: .35rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
input, select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 0;
  padding: .55rem .7rem; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand);
}

.admin-nav { 
  display: flex; gap: .35rem; margin-bottom: 1.25rem;
  overflow-x: auto; white-space: nowrap;
  scrollbar-width: none; -ms-overflow-style: none;
}
.admin-nav::-webkit-scrollbar { display: none; }
.admin-link { flex-shrink: 0; }
.admin-link {
  border-radius: 0; padding: .45rem .75rem; font-size: .7rem;
  background: #fff; border: 1px solid var(--border);
  font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.admin-link.active, .admin-link:hover {
  background: var(--brand-grad); color: #fff; border-color: var(--brand);
}

.stack { display: grid; gap: 1rem; }
.muted { color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; border-radius: 0; padding: .15rem .5rem; font-size: .65rem; background: #e5e5e5; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-wait { background: #e5e5e5; color: #404040; }
.score-grid { display: grid; gap: .75rem; }
.score-item { display: grid; gap: .65rem; grid-template-columns: 1fr; }
@media (min-width: 800px) {
  .score-item { grid-template-columns: 2fr 1fr auto; align-items: center; }
}
.pair-grid { display: grid; gap: .75rem; }
.pair-card { display: grid; gap: .5rem; }
@media (min-width: 900px) {
  .pair-card { grid-template-columns: 80px 1fr 1fr auto; align-items: end; }
}
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.filters a {
  border-radius: 0; padding: .4rem .75rem; border: 1px solid var(--border);
  background: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.filters a.active { background: var(--brand-grad); color: #fff; border-color: var(--brand); }
.danger-box { border: 1px solid #fecaca; background: #fef2f2; color: #7f1d1d; border-radius: 0; padding: 1rem; border-left: 4px solid var(--brand); }

/* Tower */
.tower { display: grid; gap: 1.25rem; }
.tower-tier {
  border: 1px solid var(--border); border-radius: 0;
  background: #fff; overflow: hidden;
  box-shadow: 0 10px 28px rgba(0,0,0,.06);
}
.tower-tier-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1rem; background: var(--brand-grad); color: #fff;
}
.tower-tier-head h3 { margin: .1rem 0 0; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .04em; }
.tower-tier-label { font-size: .65rem; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.85); font-weight: 800; }
.tower-slots { display: grid; gap: 1rem; padding: 1rem; }
.tower-slot {
  border: 1px solid #e5e5e5; border-radius: 0; padding: .75rem; background: #fafafa;
}
.tower-slot-title { font-size: .75rem; font-weight: 800; color: var(--black); margin-bottom: .65rem; text-transform: uppercase; letter-spacing: .06em; }
.tower-matches {
  display: grid; gap: .65rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.match-card {
  border: 1px solid var(--border); border-radius: 0; background: #fff;
  padding: .45rem .6rem; display: grid; gap: .25rem;
}
.match-card.is-done { border-color: #fca5a5; box-shadow: inset 3px 0 0 var(--brand); }
.match-card.is-wait { border-color: #e5e5e5; }
.match-meta { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin-bottom: .15rem; }
.match-side {
  display: grid; grid-template-columns: auto 1fr auto; gap: .35rem;
  align-items: center; font-size: .8rem;
}
.match-side strong { min-width: 2rem; color: var(--brand); font-weight: 900; }
.match-side span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-side em { font-style: normal; font-weight: 800; min-width: 1.2rem; text-align: right; }
.match-side.winner { background: #fff1f0; padding: .15rem .35rem; margin: 0 -.1rem; }
.match-vs { text-align: center; font-size: .65rem; color: var(--muted); font-weight: 800; text-transform: uppercase; }

@media (max-width: 768px) {
  .match-card { padding: .4rem .4rem; gap: .25rem; }
  .match-side { gap: .25rem; font-size: .75rem; }
  .match-side strong { min-width: 1.8rem; font-size: .75rem; }
  .match-side span { font-size: .65rem; letter-spacing: -0.02em; }
}

@media (min-width: 960px) {
  .tower-tier:nth-child(odd) { margin-left: 0; margin-right: 4%; }
  .tower-tier:nth-child(even) { margin-left: 4%; margin-right: 0; }
}

.team-cards {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.team-card {
  position: relative; background: #fff; border: 1px solid var(--border);
  border-radius: 0; padding: 1rem; overflow: hidden;
}
.team-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--team, var(--brand));
}
.team-card.rank-1 { border-color: #fca5a5; background: linear-gradient(180deg, #fff1f0 0%, #fff 60%); }
.team-card.rank-2 { border-color: #d4d4d4; }
.team-card.rank-3 { border-color: #fdba74; }
.team-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.team-rank { font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.team-badge {
  width: 2.4rem; height: 2.4rem; border-radius: 0;
  display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 1.1rem;
  background: var(--brand-grad);
}
.team-name { margin: .7rem 0 .35rem; font-size: 1.05rem; text-transform: uppercase; font-weight: 900; }
.team-points { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .85rem; }
.team-points .num { font-size: 2.2rem; font-weight: 900; line-height: 1; color: var(--black); }
.team-points .lbl { color: var(--muted); font-size: .8rem; text-transform: uppercase; }
.team-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.team-stats > div {
  background: #fafafa; border: 1px solid #eee; border-radius: 0;
  padding: .45rem .55rem; display: flex; align-items: center; justify-content: space-between;
}
.team-stats .span-2 { grid-column: 1 / -1; }
.team-stats .lbl { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.team-stats strong { font-size: .95rem; }

/* Group Standings */
.champions-table-wrap {
  border: 2px solid var(--brand);
  box-shadow: 0 4px 16px rgba(208, 41, 21, .12);
}
.champions-table-wrap thead th {
  background: var(--brand-grad);
}
tr.champion-best {
  background: linear-gradient(90deg, #fff7ed 0%, #fff1f0 50%, #fff7ed 100%) !important;
  box-shadow: inset 4px 0 0 #D02915;
}
tr.champion-best td {
  font-weight: 700;
}
.group-badge {
  display: inline-block;
  background: var(--brand-grad);
  color: #fff;
  padding: .15rem .55rem;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-radius: 0;
}
.group-detail-section {
  margin-top: 1.25rem;
}
.group-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .65rem;
  padding: .6rem .85rem;
  background: var(--black);
  color: var(--white);
  border-left: 4px solid var(--brand);
}
.group-detail-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.group-champ-label {
  font-size: .8rem;
  font-weight: 800;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ===== Leaderboard ===== */
.leaderboard {
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(145deg, #1a0a2e 0%, #2d1150 40%, #3a1560 100%);
  box-shadow: 0 20px 60px rgba(26, 10, 46, .5), 0 0 0 1px rgba(255,255,255,.08);
  position: relative;
}
.leaderboard::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(208, 41, 21, .25) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(180, 40, 120, .2) 0%, transparent 60%);
  pointer-events: none;
}
.leaderboard-header {
  position: relative;
  text-align: center;
  padding: 1.25rem 1rem 1rem;
}
.leaderboard-header h2 {
  display: inline-block;
  margin: 0;
  padding: .6rem 2rem;
  background: linear-gradient(135deg, #D02915 0%, #e84393 100%);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(208, 41, 21, .4);
}
.leaderboard-body {
  position: relative;
  padding: .75rem 1rem 1rem;
  display: grid;
  gap: .6rem;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .85rem;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  transition: transform .15s, box-shadow .15s;
}
.lb-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
/* Gold */
.lb-row.lb-gold {
  background: linear-gradient(135deg, rgba(255,215,0,.18) 0%, rgba(255,180,0,.08) 100%);
  border-color: rgba(255,215,0,.35);
  box-shadow: 0 0 20px rgba(255,215,0,.1);
}
/* Silver */
.lb-row.lb-silver {
  background: linear-gradient(135deg, rgba(192,192,192,.15) 0%, rgba(160,160,160,.06) 100%);
  border-color: rgba(192,192,192,.3);
}
/* Bronze */
.lb-row.lb-bronze {
  background: linear-gradient(135deg, rgba(205,127,50,.15) 0%, rgba(180,100,30,.06) 100%);
  border-color: rgba(205,127,50,.3);
}

.lb-rank {
  min-width: 2.2rem;
  text-align: center;
  flex-shrink: 0;
}
.lb-medal {
  font-size: 1.6rem;
  line-height: 1;
}
.lb-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.6);
  font-size: .85rem;
  font-weight: 800;
}
.lb-badge {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
  background: var(--brand-grad);
  box-shadow: 0 3px 12px rgba(208, 41, 21, .4);
  flex-shrink: 0;
}
.lb-info {
  flex: 1;
  min-width: 0;
}
.lb-name {
  color: #fff;
  font-size: .95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-stats-sub {
  color: rgba(255,255,255,.5);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: .1rem;
}
.lb-score-block {
  text-align: center;
  flex-shrink: 0;
  min-width: 3.5rem;
}
.lb-points {
  color: #fff;
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
}
.lb-pts-label {
  color: rgba(255,255,255,.45);
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

@media (max-width: 480px) {
  .leaderboard-body { padding: .5rem .6rem .75rem; gap: .5rem; }
  .lb-row { padding: .55rem .65rem; gap: .5rem; }
  .lb-medal { font-size: 1.3rem; }
  .lb-badge { width: 2.2rem; height: 2.2rem; font-size: .95rem; }
  .lb-name { font-size: .85rem; }
  .lb-points { font-size: 1.3rem; }
}
